Answers.Body: <p>A very basic solution in python:</p>
  <pre class="lang-py prettyprint-override"><code>from Bio import SeqIO
  seq_dict = {i : rec.seq for i,rec in enumerate(SeqIO.parse(&quot;your_msa.aln&quot;, &quot;fasta&quot;))}
  for pos in range(len(seq_dict[0])):
      pos_bases = ([seqio[i] for seqio in [*seq_dict.values()]])
      # If position contains more than one unique base
      if len([*set(pos_bases)])&gt;1:
          print(pos, pos_bases)        # prints the position and alternative bases there
  </code></pre>
  <p>If you need something more useful, just leave a comment here and I'll develop this further.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-10-20T14:47:36.877Z
Answers.LastActivityDate: 2021-10-20T18:03:39.557Z
Answers.LastEditDate: 2021-10-20T18:03:39.557Z
Answers.UserDisplayName: Ricardo Guerreiro
Body: <p>I have an MSA from MAFFT (as a FASTA file; there are several sequences in the MSA), and I would like to quantify the &quot;variants&quot; between these sequences.</p>
  <p>What is the standard tool to do something like this?</p>
  <p>I would prefer to know the non-consensus variants in the the entire MSA, but that may be too tricky, so I would like to figure out the non-consensus variants between those select sequences.</p>
  <p>I'm familiar with calculating an MSA, and then visualizing it---but I would like an output file with all of the different bases.</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-10-20T14:00:41.857Z
Comments.Text: This is surprisingly not done or requested in the community, I'm also struggling.
Comments.UserDisplayName: Ricardo Guerreiro
Tags: <phylogenetics>
Title: Given a multiple sequence alignment, how do I output all of the non-consensus characters by location?
ThreadText: # Given a multiple sequence alignment, how do I output all of the non-consensus characters by location?
  
  (Asked by: username_0 on 2020-03-04)
  
  I have an MSA from MAFFT (as a FASTA file; there are several sequences in the MSA), and I would like to quantify the "variants" between these sequences.
  
  What is the standard tool to do something like this?
  
  I would prefer to know the non-consensus variants in the the entire MSA, but that may be too tricky, so I would like to figure out the non-consensus variants between those select sequences.
  
  I'm familiar with calculating an MSA, and then visualizing it---but I would like an output file with all of the different bases.
  
  **Tags:** phylogenetics
  
  > **Comments:**
  > **username_1**: This is surprisingly not done or requested in the community, I'm also struggling.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2021-10-20. Score: 2
  
  A very basic solution in python:
  
  ```py
  from Bio import SeqIO
  seq_dict = {i : rec.seq for i,rec in enumerate(SeqIO.parse("your_msa.aln", "fasta"))}
  for pos in range(len(seq_dict[0])):
      pos_bases = ([seqio[i] for seqio in [*seq_dict.values()]])
      # If position contains more than one unique base
      if len([*set(pos_bases)])>1:
          print(pos, pos_bases)        # prints the position and alternative bases there
  
  ```
  
  If you need something more useful, just leave a comment here and I'll develop this further.
  
  
  ---
  
  