Answers.Body: <p>Python3 via the <code>difflib</code> library/package. <code>AlignIO</code> can be leveraged (Biopython) to construct the <code>align</code> list. To be honest if your coding isn't strong you could just cut and paste the alignment into this code. Nucleotides not amino acids ... same idea just easier to type. It will work for aa and gaps. &quot;Ref&quot; (output) refers to the first alignment position only.</p>
  <pre><code>import difflib
  
  align=['AGCTAGATGATATGA', 'AGCTAGATGATATGA', 'AGCTAGGTGATATGA', 'AGCTAGATGATATGA', 'AGCTAGATGATATGA', 'AGCTAGAAGATATGA', 'AGCTAGAGGATATGA', 'AGCTAGATCATATGT'] 
  ref= 'AGCTAGATGATATGA'
  for query in align:
      print('{} (ref) =&gt; {} (query)'.format(ref,query))  
      for loc,pos in enumerate(difflib.ndiff(ref, query)):
          if pos[0]==' ': 
              continue
          elif pos[0]=='-':
              print(u'Ref &quot;{}&quot;'.format(pos[-1]))
          elif pos[0]=='+':
              print(u'Query has &quot;{}&quot; at position {}'.format(pos[-1],loc))    
      print ('')
  </code></pre>
  <p>Output,</p>
  <pre><code>AGCTAGATGATATGA (ref) =&gt; AGCTAGATGATATGA (query)
  
  AGCTAGATGATATGA (ref) =&gt; AGCTAGATGATATGA (query)
  
  AGCTAGATGATATGA (ref) =&gt; AGCTAGGTGATATGA (query)
  Ref &quot;A&quot;
  Query has &quot;G&quot; at position 7
  
  AGCTAGATGATATGA (ref) =&gt; AGCTAGATGATATGA (query)
  
  AGCTAGATGATATGA (ref) =&gt; AGCTAGATGATATGA (query)
  
  AGCTAGATGATATGA (ref) =&gt; AGCTAGAAGATATGA (query)
  Ref &quot;T&quot;
  Query has &quot;A&quot; at position 8
  
  AGCTAGATGATATGA (ref) =&gt; AGCTAGAGGATATGA (query)
  Ref &quot;T&quot;
  Query has &quot;G&quot; at position 8
  
  AGCTAGATGATATGA (ref) =&gt; AGCTAGATCATATGA (query)
  Ref &quot;G&quot;
  Query has &quot;C&quot; at position 9
  Query has &quot;T&quot; at position 16
  </code></pre>
  <p>Sequences must be aligned, i.e. ref sequence within the global alignment and separated. Hope that makes sense. It will work with multiple mutations between ref and query as the last example points out (two mutations per example query was just too much to type).</p>
  <p>A reproducible example in future please.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-11-18T03:18:22.520Z
Answers.LastActivityDate: 2022-11-18T18:35:44.813Z
Answers.LastEditDate: 2022-11-18T18:35:44.813Z
Answers.UserDisplayName: M__
Body: <p>I have a fasta file with multiple sequences comprising 38 sequences. The length of the sequences are around 11000 bp.</p>
  <p>How can i get changes in the genomes based in a reference genome? (aa subtitutions or deletions)</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2022-11-18T15:22:03.710Z
Comments.Text: Is this a 10700 genome by any chance?
Comments.UserDisplayName: M__
Tags: <phylogenetics><genome><phylogeny><reference-genome><mutations>
Title: How to identify mutations in a viral genome
ThreadText: # How to identify mutations in a viral genome
  
  (Asked by: username_0 on 2022-11-17)
  
  I have a fasta file with multiple sequences comprising 38 sequences. The length of the sequences are around 11000 bp.
  
  How can i get changes in the genomes based in a reference genome? (aa subtitutions or deletions)
  
  **Tags:** phylogenetics, genome, phylogeny, reference-genome, mutations
  
  > **Comments:**
  > **username_1**: Is this a 10700 genome by any chance?  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2022-11-18. Score: 1 | Accepted answer
  
  Python3 via the `difflib` library/package. `AlignIO` can be leveraged (Biopython) to construct the `align` list. To be honest if your coding isn't strong you could just cut and paste the alignment into this code. Nucleotides not amino acids ... same idea just easier to type. It will work for aa and gaps. "Ref" (output) refers to the first alignment position only.
  
  ```
  import difflib
  
  align=['AGCTAGATGATATGA', 'AGCTAGATGATATGA', 'AGCTAGGTGATATGA', 'AGCTAGATGATATGA', 'AGCTAGATGATATGA', 'AGCTAGAAGATATGA', 'AGCTAGAGGATATGA', 'AGCTAGATCATATGT'] 
  ref= 'AGCTAGATGATATGA'
  for query in align:
      print('{} (ref) => {} (query)'.format(ref,query))  
      for loc,pos in enumerate(difflib.ndiff(ref, query)):
          if pos[0]==' ': 
              continue
          elif pos[0]=='-':
              print(u'Ref "{}"'.format(pos[-1]))
          elif pos[0]=='+':
              print(u'Query has "{}" at position {}'.format(pos[-1],loc))    
      print ('')
  
  ```
  
  Output,
  
  ```
  AGCTAGATGATATGA (ref) => AGCTAGATGATATGA (query)
  
  AGCTAGATGATATGA (ref) => AGCTAGATGATATGA (query)
  
  AGCTAGATGATATGA (ref) => AGCTAGGTGATATGA (query)
  Ref "A"
  Query has "G" at position 7
  
  AGCTAGATGATATGA (ref) => AGCTAGATGATATGA (query)
  
  AGCTAGATGATATGA (ref) => AGCTAGATGATATGA (query)
  
  AGCTAGATGATATGA (ref) => AGCTAGAAGATATGA (query)
  Ref "T"
  Query has "A" at position 8
  
  AGCTAGATGATATGA (ref) => AGCTAGAGGATATGA (query)
  Ref "T"
  Query has "G" at position 8
  
  AGCTAGATGATATGA (ref) => AGCTAGATCATATGA (query)
  Ref "G"
  Query has "C" at position 9
  Query has "T" at position 16
  
  ```
  
  Sequences must be aligned, i.e. ref sequence within the global alignment and separated. Hope that makes sense. It will work with multiple mutations between ref and query as the last example points out (two mutations per example query was just too much to type).
  
  A reproducible example in future please.
  
  
  ---
  
  