how to write Fasta file for extracting multiple Sequences in python -
i want fasta file output this
>fragment 1 | description .... mvppppsr >fragment 2 | description ... ggaakpgqlgr >fragment 3 | description .. slgplllllrpeepedgdr >fragment 4 | description . eicsesk but output show : assertionerror
python script
from bio import seqio bio.seq import seq bio.seqrecord import seqrecord bio.alphabet import iupac example = 'mvppppsrggaakpgqlgrslgplllllrpeepedgdreicsesk' def trypsin(bases): sub = '' while bases: k, r = bases.find('k'), bases.find('r') cut = min(k, r)+1 if k > 0 , r > 0 else max(k, r)+1 sub += bases[:cut] bases = bases[cut:] if not bases or bases[0] != 'p': yield sub sub = '' seq = (list(trypsin(example))) y = '\n'.join(seq) print(y) my_seqs = seqrecord(seq(y,iupac.protein), id = "fragment_%i (i+1)",description="....") print (my_seqs) open("try.fasta", "w") handle: seqio.write(my_seqs, handle, "fasta") i don't know what's wrong in script python. confuse please me thanks
Comments
Post a Comment