Answers.Body: <p>You can use <a href="https://github.com/biologyguy/BuddySuite/wiki/AlignBuddy" rel="nofollow noreferrer">AlignBuddy</a> to process alignments in GenBank format, which allows you to keep the metadata. From the command line:</p>
  
  <pre><code>$: alignbuddy input.gb --generate_alignment mafft | \
     alignbuddy --extract_feature_sequences 'PROT_FEAT_1' | \
     alignbuddy --percent_id
  </code></pre>
  
  <p>If you want to do a large one-to-many comparison and loop through a bunch of features, I'd recommend importing AlignBuddy into a custom python script and calling the relevant functions directly. You can then collect the relevant data and build a histogram with <a href="https://matplotlib.org/devdocs/api/_as_gen/matplotlib.pyplot.hist.html" rel="nofollow noreferrer">matplotlib</a>.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-12-31T14:16:03.513Z
Answers.LastActivityDate: 2017-12-31T14:16:03.513Z
Answers.UserDisplayName: Steve Bond
Answers.Body: <p>In answer to the comments, you can do multiple pair wise alignments and then concatenate them to visualise, if MSA is not the way to go. I have a script you can find <a href="https://github.com/jrjhealey/bioinfo-tools/blob/master/Shannon.py" rel="nofollow noreferrer">here</a> which will draw a graph of the Shannon entropy (uncertainty) in a column. If you create a gapped FASTA alignment for each of your pairs, and concatenate it in to a multifasta, the script should still work with it. Though it may be noisy - best just to try it.</p>
  
  <p>JalView might be an option for a one-stop GUI tool, but I’m not sure if it’ll require an MSA instead of multiple pair wise.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-10-30T20:16:36.967Z
Answers.LastActivityDate: 2017-11-30T08:45:07.573Z
Answers.LastEditDate: 2017-11-30T08:45:07.573Z
Answers.UserDisplayName: Joe Healey
Body: <p>I have a reference sequence of amino acids that I compare other sequences to using <code>Bio.pairwise2.align.globalmx</code> of Biopython package (one to many compare - one by one [is there a better way?])</p>
  
  <p>It's works fine but only returns strings of the alignment with very little metadata.</p>
  
  <p>Now I want to extract the indices of the amino acids that are different than the reference sequence and plot it in some kind of histogram according to protein features:</p>
  
  <p>For example:</p>
  
  <ul>
  <li>pos 1-36: 3 mutations.</li>
  <li>pos 37-202: 4 mutations.</li>
  <li>pos 203: 1 mutation</li>
  <li>pos 204-660: 0 mutations</li>
  </ul>
  
  <p>Is there any builtin package to do so?</p>
  
  <p>How can I get the data of diff between 2 sequences in python? I mean which AA changed to which AA and at each position. <code>Bio.pairwise2.align.globalmx</code> returns some data structures of strings (see below) that can be printed but does not contain the locations in a convenient way. </p>
  
  <pre><code>LLGHKVNPFKALYNRIDMK-QVEALVEASKEE 
  |||||||||||||||||||||||||||||||| 
  LLGHKVNPFKALYNRIDM-RQVEALVEASKEE
  </code></pre>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-10-27T14:36:02.413Z
Comments.Text: Can you post a [minimal, working, and complete example](https://stackoverflow.com/help/mcve) of what you have gotten to work so far?
Comments.UserDisplayName: winni2k
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-10-27T15:31:22.730Z
Comments.Text: Lets start with more basic question:
  How can I get the data of diff between 2 sequences in python? I mean which AA changed to which AA and at each position.
  Bio.pairwise2.align.globalmx returns some data structures of strings (see below) that can be printed but does not contain the locations in a convenient way.
  
  LLGHKVNPFKALYNRIDMK-QVEALVEASKEE
  ||||||||||||||||||||||||||||||||
  LLGHKVNPFKALYNRIDM-RQVEALVEASKEE
Comments.UserDisplayName: Kobi T
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-10-27T21:09:47.260Z
Comments.Text: The comments section is not a good place to discuss other questions. Probably best to open a new post.
Comments.UserDisplayName: winni2k
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-10-27T22:43:47.653Z
Comments.Text: Do you just want a graphical representation of the diverse regions of a multiple sequence alignment?
Comments.UserDisplayName: Joe Healey
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-10-28T07:26:12.333Z
Comments.Text: I'm not sure if multiple sequence alignment is what I need because I have one reference sequence that I compare all the others to. I need one-to-many comparison (which now I do by many one-to-one comparisons). Correct me if I'm wrong.
Comments.UserDisplayName: Kobi T
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-10-29T16:49:03.287Z
Comments.Text: @JoeHealey, what if I wanted to do a graphical representation of the diverse regions of a multiple sequence alignment in python. Is there a package for that?
Comments.UserDisplayName: Kobi T
Tags: <phylogenetics><python><sequence-analysis>
Title: Mutations in sequences relative to reference (histogram)
ThreadText: # Mutations in sequences relative to reference (histogram)
  
  (Asked by: username_0 on 2017-10-27)
  
  I have a reference sequence of amino acids that I compare other sequences to using `Bio.pairwise2.align.globalmx` of Biopython package (one to many compare - one by one [is there a better way?])
  
  It's works fine but only returns strings of the alignment with very little metadata.
  
  Now I want to extract the indices of the amino acids that are different than the reference sequence and plot it in some kind of histogram according to protein features:
  
  For example:
  
  * pos 1-36: 3 mutations.
  * pos 37-202: 4 mutations.
  * pos 203: 1 mutation
  * pos 204-660: 0 mutations
  
  Is there any builtin package to do so?
  
  How can I get the data of diff between 2 sequences in python? I mean which AA changed to which AA and at each position. `Bio.pairwise2.align.globalmx` returns some data structures of strings (see below) that can be printed but does not contain the locations in a convenient way.
  
  ```
  LLGHKVNPFKALYNRIDMK-QVEALVEASKEE 
  |||||||||||||||||||||||||||||||| 
  LLGHKVNPFKALYNRIDM-RQVEALVEASKEE
  
  ```
  
  **Tags:** phylogenetics, python, sequence-analysis
  
  > **Comments:**
  > **username_1**: Can you post a [minimal, working, and complete example](https://stackoverflow.com/help/mcve) of what you have gotten to work so far?  
  > **username_0**: Lets start with more basic question: How can I get the data of diff between 2 sequences in python? I mean which AA changed to which AA and at each position. Bio.pairwise2.align.globalmx returns some data structures of strings (see below) that can be printed but does not contain the locations in a convenient way.  LLGHKVNPFKALYNRIDMK-QVEALVEASKEE |||||||||||||||||||||||||||||||| LLGHKVNPFKALYNRIDM-RQVEALVEASKEE  
  > **username_1**: The comments section is not a good place to discuss other questions. Probably best to open a new post.  
  > **username_2**: Do you just want a graphical representation of the diverse regions of a multiple sequence alignment?  
  > **username_0**: I'm not sure if multiple sequence alignment is what I need because I have one reference sequence that I compare all the others to. I need one-to-many comparison (which now I do by many one-to-one comparisons). Correct me if I'm wrong.  
  > **username_0**: @username_2, what if I wanted to do a graphical representation of the diverse regions of a multiple sequence alignment in python. Is there a package for that?  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_3 on 2017-12-31. Score: 2
  
  You can use [AlignBuddy](https://github.com/biologyguy/BuddySuite/wiki/AlignBuddy) to process alignments in GenBank format, which allows you to keep the metadata. From the command line:
  
  ```
  $: alignbuddy input.gb --generate_alignment mafft | \
     alignbuddy --extract_feature_sequences 'PROT_FEAT_1' | \
     alignbuddy --percent_id
  
  ```
  
  If you want to do a large one-to-many comparison and loop through a bunch of features, I'd recommend importing AlignBuddy into a custom python script and calling the relevant functions directly. You can then collect the relevant data and build a histogram with [matplotlib](https://matplotlib.org/devdocs/api/_as_gen/matplotlib.pyplot.hist.html).
  
  
  ---
  
  ### Answer by username_2 on 2017-10-30. Score: 1
  
  In answer to the comments, you can do multiple pair wise alignments and then concatenate them to visualise, if MSA is not the way to go. I have a script you can find [here](https://github.com/jrjhealey/bioinfo-tools/blob/master/Shannon.py) which will draw a graph of the Shannon entropy (uncertainty) in a column. If you create a gapped FASTA alignment for each of your pairs, and concatenate it in to a multifasta, the script should still work with it. Though it may be noisy - best just to try it.
  
  JalView might be an option for a one-stop GUI tool, but I’m not sure if it’ll require an MSA instead of multiple pair wise.
  
  
  ---
  
  