1
$\begingroup$

My task is to count the mutations occurred in several proteins after a treatment. The sequences are all present in the two files in the same order. I opened both files with the FASTA parser (SeqIO.parse) in Biopython and I got all the proteins listed (separated before and after the treatment).

How can I zip the parsers together to count the mutations?

How can I count the mutations that occured after the treatment?

from Bio import SeqIO
for normal_samples in SeqIO.parse("/data/statistic/normal_samples", "fasta"):
    print(normal_samples.id)
    print(repr(normal_samples.seq))
    print(len(normal_samples))

for treated_samples in SeqIO.parse("/data/statistic/with_treatment", "fasta"):
    print(normal_samples.id)
    print(repr(normal_samples.seq))
    print(len(normal_samples))

dict_n_t = dict(zip(normal_samples & treated_samples))
$\endgroup$

1 Answer 1

3
$\begingroup$
from Bio import SeqIO
for normal, treated in zip(SeqIO.parse("/data/statistic/normal_samples", "fasta"),
                           SeqIO.parse("/data/statistic/with_treatment", "fasta")):
    ... do stuff...

That's generally how you zip iterators together in python.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.