Answers.Body: <p>As suggested in the comments, the built-in BioPython pairwise aligner should work for this. You can find a short sequence match in a longer sequence using a global alignment with the right score parameters (<code>query_end_... = 0</code>). The other scoring parameters are values that I've found to be good for aligning similar sequences.</p>
  <p>Example code:</p>
  <pre><code>from Bio import Align
  
  aligner = Align.PairwiseAligner()
  aligner = Align.PairwiseAligner()
  aligner.match_score = 5
  aligner.mismatch_score = -9
  aligner.mode = 'global'
  aligner.target_internal_open_gap_score = -12
  aligner.target_internal_extend_gap_score = -3
  aligner.target_end_open_gap_score = -12
  aligner.target_end_extend_gap_score = -3
  aligner.query_internal_open_gap_score = -12
  aligner.query_internal_extend_gap_score = -3
  
  # Set the query_end penalties to zero to effectively implement a 'glocal' alignment as described in the question
  # These are the default values, so you could skip the next two lines, 
  #    but this is relevant to the question, so I'm including them in the example.
  aligner.query_end_open_gap_score = 0
  aligner.query_end_extend_gap_score = 0
      
  alignments = aligner.align(&quot;GAACTCGCATCGATGATCCGTGCGCTGAGATCCGCTGACATGATC&quot;, &quot;GATCCG&quot;)
  
  for a in alignments:
      print(a)
  print()
  print()
  
  alignments = aligner.align(&quot;GAACTCGCATCGATGATCCGTGCGCTGAGATCCGCTGACATGATC&quot;, &quot;GATACG&quot;)
  
  for a in alignments:
      print(a)
  print()
  print()
  
  alignments = aligner.align(&quot;GAACTCGCATCGATGATCCGTGCGCTGAGATCCGCTGACATGATC&quot;, &quot;GATACCG&quot;)
  
  for a in alignments:
      print(a)
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-05-14T14:11:13.477Z
Answers.LastActivityDate: 2021-05-14T14:11:13.477Z
Answers.UserDisplayName: David Ross
Body: <p>I was looking for a simple way to do a <a href="https://en.wikipedia.org/wiki/Sequence_alignment#Global_and_local_alignments" rel="nofollow noreferrer">glocal alignment</a>.
  The case I have is I have a small sequence which should be find in a bigger one, thus typically a glocal alignment.
  Also I can not Install anything on the target machine (Python 3.6 with Biopython is already installed), all I can do is pip install.</p>
  
  <p>My question is : are there any glocal alignment implementation out there ?</p>
  
  <p>I was unable to found one and I don't feel proficient enough with Python yet to implement it myself.</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2018-08-15T11:22:01.580Z
Comments.Text: @winni2k there is also a newer pairwise aligner in `Bio.Align` http://biopython.org/DIST/docs/tutorial/Tutorial.html#htoc87
Comments.UserDisplayName: Chris_Rands
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2018-08-15T11:34:38.523Z
Comments.Text: @ckin, is there any particular reason why you need to perform a glocal alignment?
Comments.UserDisplayName: winni2k
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2018-08-16T12:19:04.817Z
Comments.Text: @winni2k like I said I have a typically case where you want to do a glocal alignement: I have to align a small sequence against a bigger sequence, and my small should be found within the bigger one.
Comments.UserDisplayName: Ckln
Tags: <phylogenetics><python>
Title: Glocal\semi-local\Hybride Globale-Local alignment with Python
ThreadText: # Glocal\semi-local\Hybride Globale-Local alignment with Python
  
  (Asked by: username_0 on 2018-08-14)
  
  I was looking for a simple way to do a [glocal alignment](https://en.wikipedia.org/wiki/Sequence_alignment#Global_and_local_alignments).
  The case I have is I have a small sequence which should be find in a bigger one, thus typically a glocal alignment.
  Also I can not Install anything on the target machine (Python 3.6 with Biopython is already installed), all I can do is pip install.
  
  My question is : are there any glocal alignment implementation out there ?
  
  I was unable to found one and I don't feel proficient enough with Python yet to implement it myself.
  
  **Tags:** phylogenetics, python
  
  > **Comments:**
  > **username_1**: @username_2 there is also a newer pairwise aligner in `Bio.Align` http://biopython.org/DIST/docs/tutorial/Tutorial.html#htoc87  
  > **username_2**: @ckin, is there any particular reason why you need to perform a glocal alignment?  
  > **username_0**: @username_2 like I said I have a typically case where you want to do a glocal alignement: I have to align a small sequence against a bigger sequence, and my small should be found within the bigger one.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_3 on 2021-05-14. Score: 1 | Accepted answer
  
  As suggested in the comments, the built-in BioPython pairwise aligner should work for this. You can find a short sequence match in a longer sequence using a global alignment with the right score parameters (`query_end_... = 0`). The other scoring parameters are values that I've found to be good for aligning similar sequences.
  
  Example code:
  
  ```
  from Bio import Align
  
  aligner = Align.PairwiseAligner()
  aligner = Align.PairwiseAligner()
  aligner.match_score = 5
  aligner.mismatch_score = -9
  aligner.mode = 'global'
  aligner.target_internal_open_gap_score = -12
  aligner.target_internal_extend_gap_score = -3
  aligner.target_end_open_gap_score = -12
  aligner.target_end_extend_gap_score = -3
  aligner.query_internal_open_gap_score = -12
  aligner.query_internal_extend_gap_score = -3
  
  # Set the query_end penalties to zero to effectively implement a 'glocal' alignment as described in the question
  # These are the default values, so you could skip the next two lines, 
  #    but this is relevant to the question, so I'm including them in the example.
  aligner.query_end_open_gap_score = 0
  aligner.query_end_extend_gap_score = 0
      
  alignments = aligner.align("GAACTCGCATCGATGATCCGTGCGCTGAGATCCGCTGACATGATC", "GATCCG")
  
  for a in alignments:
      print(a)
  print()
  print()
  
  alignments = aligner.align("GAACTCGCATCGATGATCCGTGCGCTGAGATCCGCTGACATGATC", "GATACG")
  
  for a in alignments:
      print(a)
  print()
  print()
  
  alignments = aligner.align("GAACTCGCATCGATGATCCGTGCGCTGAGATCCGCTGACATGATC", "GATACCG")
  
  for a in alignments:
      print(a)
  
  ```
  
  
  ---
  
  