Forum |  HardWare.fr | News | Articles | PC | S'identifier | S'inscrire | Shop Recherche
674 connectés 

  FORUM HardWare.fr
  Programmation
  Python

  Problème de script

 


 Mot :   Pseudo :  
 
Bas de page
Auteur Sujet :

Problème de script

n°2262039
fety
Posté le 07-07-2015 à 19:04:31  profilanswer
 

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,

mood
Publicité
Posté le 07-07-2015 à 19:04:31  profilanswer
 

n°2262427
masklinn
í dag viðrar vel til loftárása
Posté le 14-07-2015 à 12:28:42  profilanswer
 

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

---------------
Stick a parrot in a Call of Duty lobby, and you're gonna get a racist parrot. — Cody

Aller à :
Ajouter une réponse
  FORUM HardWare.fr
  Programmation
  Python

  Problème de script

 

Sujets relatifs
Problème script enregistrement / tranfertProblème copier/coller script Greasemonkey
[POWER SHELL] Problème d'import de module Active DirectoryProblème Script sql developer Oracle
probleme de lancement du script[Résolu] Probleme execution de script php avec cron
problème avec script phpProblème de script de compte à rebours + affichage lien
problème script PHPProblème entre Doctype et un script
Plus de sujets relatifs à : Problème de script


Copyright © 1997-2022 Hardware.fr SARL (Signaler un contenu illicite / Données personnelles) / Groupe LDLC / Shop HFR