#!/usr/bin/env python # -*-coding:Utf-8 -* import urllib.request import sys TermesRecherches = [] if len(sys.argv) == 1: # Aucun argument entre => il n'y a que le nom du programme (!) print ("Identifiants - Exemple : EF-hand_1 ou Histone ou 14-3-3 ou Na_K-ATPase ou 7tm_1") TermesRecherches.append(input()) reponse = urllib.request.urlopen('http://pfam.xfam.org/families?output=text') ListeDesPages = [] for ligne in reponse: ligne = bytes.decode(ligne,encoding="utf-8", errors="strict") if '#' not in ligne and 'PF' in ligne: ListeDesPages.append(ligne.rstrip().split('\t')) reponse.close() listePagefiltree = [entree for entree in ListeDesPages if entree[1] in TermesRecherches] if listePagefiltree: for entree in listePagefiltree: numeroPFAM = entree[0] URLfichierHMM = urllib.request.urlopen("http://pfam.xfam.org/family/"+numeroPFAM+"/hmm") fichierDeSortie = open(numeroPFAM+'.hmm','wb') fichierDeSortie.write(URLfichierHMM.read()) fichierDeSortie.close() URLfichierHMM.close() else: print ("Essayez un autre identifiant.")