Answers.Body: <pre><code>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...
  </code></pre>
  
  <p>That's generally how you <code>zip</code> iterators together in python.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-01-31T20:42:09.413Z
Answers.LastActivityDate: 2018-01-31T20:42:09.413Z
Answers.UserDisplayName: Devon Ryan
Body: <p>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 (<code>SeqIO.parse</code>) in Biopython and I got all the proteins listed (separated before and after the treatment).</p>
  
  <p>How can I zip the parsers together to count the mutations?</p>
  
  <p>How can I count the mutations that occured after the treatment?</p>
  
  <pre><code>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 &amp; treated_samples))
  </code></pre>
  
Tags: <python><fasta><proteins><r><mutations>
Title: Comparing two multi-fasta files of the same set of proteins with parser - to find and count mutations after treatment
ThreadText: # Comparing two multi-fasta files of the same set of proteins with parser - to find and count mutations after treatment
  
  (Asked by: username_0 on 2018-01-31)
  
  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))
  
  ```
  
  **Tags:** python, fasta, proteins, r, mutations
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2018-01-31. Score: 3 | Accepted answer
  
  ```
  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.
  
  
  ---
  
  