Problème de script

Problème de script - Python - Programmation

Marsh Posté le 07-07-2015 à 19:04:31    

Bonjour à tous,  
 
Je suis un novice en programmation, et un ami m'a donné ce script:  
#!/usr/bin/env python2.7.6  
import argparse  
 
parser = argparse.ArgumentParser(description='Process the JSpecies output file to MEGA.')  
parser.add_argument(dest='JSfile', metavar='', help='JSpecies file', type=str)  
args = parser.parse_args()  
 
M=[]  
 
with open(args.JSfile, 'r') as JSinput:  
    for line in JSinput:  
        line = line.split()  
        M.append(line)  
 
analyseType = str(M[0][0])  
title = '!Title '+analyseType+' results from '+args.JSfile+';'  
 
if analyseType == 'ANIm':  
    description = '!Description ANIm is the Average Nucleotide Identity using MUMmer algorithm calculated by the JSpecies software;'  
elif analyseType == 'ANIb':  
    description = '!Description ANIb is the Average Nucleotide Identity using BLAST algorithm calculated by the JSpecies software;'  
elif analyseType == 'Tetra':  
    description = '!Description Tetra is the Tetranucleotide Signature Frequency Correlation Coefficient calculated by the JSpecies software;'  
else:  
    description = ''  
 
format = '!Format DataType=Distance DataFormat=LowerLeft NTaxa='+str(len(M[1]))+';'  
 
 
print('#mega', title, description, format, sep='\n')  
print()  
 
for i in M[1]:  
    print('#', i, sep='')  
print()  
for i in M[3:]:  
    stop = i.index('---')  
    for j in range(len(i[:stop-1])):  
        if analyseType != 'Tetra':  
            i[j+1] = i[j+1].replace('NaN','50')  
            i[j+1] = '{0:f}'.format(100-float(i[j+1]))  
        else:  
            i[j+1] = i[j+1].replace('NaN','50')  
            i[j+1] = '{0:f}'.format(1-float(i[j+1]))  
    print(' '.join(i[1:stop]))  
 
 
Cependant à chaque fois je reçois un message d'erreur en exécutant la commande python ./jspecies2mega.py :  
File "./jspecies2mega.py", line 30  
 
    print('mega', title, description, format, sep='\n')  
 
                                                             ^  
 
Tout aide serait le bienvenue :)
 
Merci par avance,
 
Fety,

Reply

Marsh Posté le 07-07-2015 à 19:04:31   

Reply

Marsh Posté le 14-07-2015 à 12:28:42    

Le script demande Python 2(.7.6), mais la fonction print est dans Python 3 (ou doit être activée explicitement avec from __future__ import print_function)

 

Lancer le script avec Python 3 me semble être le plus simple.


Message édité par masklinn le 14-07-2015 à 12:29:31

---------------
I mean, true, a cancer will probably destroy its host organism. But what about the cells whose mutations allow them to think outside the box, and replicate and expand beyond their wildest dreams by throwing away the limits imposed by overbearing genetic r
Reply

Sujets relatifs:

Leave a Replay

Make sure you enter the(*)required information where indicate.HTML code is not allowed