[Biopython-dev] Multiple alignment - Clustalw etc...

Laura Padioleu lplp90 at gmail.com
Wed Feb 3 11:35:49 UTC 2010


On Mon, Mar 30, 2009 at 12:42 PM, Cymon Cox <cy at cymon.org
<http://lists.open-bio.org/mailman/listinfo/biopython-dev>> wrote:
>*
*>* Hi Folks,
*>*
*>* this is a demo that i use to create then align my fasta sequences
using clustalw. Hope it helps.
here's the code
*
>def clustal(list_struc):
>
>
>	hash_table={}
>	for i in range (len(list_struc)):
>		for j in range (i+1,len(list_struc)):
>			pair=(list_struc[i],list_struc[j])
>			hash_table
>[pair]=0
>
>
>	for pair in hash_table
>.keys():
>		fasta_fic=open("fasta.fasta",'w')
>		for ID in pair:
>			fasta_fic.write(">"+ID.get_id()+'\n')
>
>			# recuperation des sequences des acides amines
>			for chain in ID.get_chains():
>       			ppb = PPBuilder()
>
>        			pp = ppb.build_peptides(chain)
>				# l'ajout des sequences aux fichiers fasta
>				fasta_fic.write(pp[0].get_sequence().tostring())
>			fasta_fic.write('\n')
>		fasta_fic.close()
>		cline = ClustalwCommandline(cmd="clustalw", infile="file.fasta")
>		return_code = subprocess.call(str(cline), shell=(sys.platform!="win32"))
>		
>		alignment = AlignIO.read(open("file"+str(nb)+".aln"),"clustal")
>
>		
>		j=0
>		i=0
>		for record in alignment:
>   			for amino_acid in record.seq:
>       			if amino_acid == '-':
>          				pass
>        			else:
>            				if amino_acid == alignment[0].seq[j]:
>                				i += 1
>        			j += 1
>    			j = 0
>    			
>seq = str(record.seq)
>    			gap_strip = seq.replace('-', '')
>    			percent = 100.0*i/len(seq)
>    			
>    			i=0
>			hash_table[pair]=str(percent)+"\t"+str(percent2)
>
>		
>	return hash_table
>
>def csv_writer(list_struc):
>	hash_table=clustal(list_struc)
>	csv_fic=open("file.csv",'a')
>	for couple in hash_table.keys():
>		csv_fic.write(pari[0].get_id()+"\t"+str(hash_table[pair])+'\n')
>	csv_fic.close()*






Hello,

im using python version 2.5 but i can't compile this code correctly
what version of python and biopython you are using ?
Thanks



More information about the Biopython-dev mailing list