Skip to content

Instantly share code, notes, and snippets.

@lennax
Created November 4, 2015 20:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lennax/9925c08804a57bb5ef72 to your computer and use it in GitHub Desktop.
Save lennax/9925c08804a57bb5ef72 to your computer and use it in GitHub Desktop.
Describe alignment
sbjct_aln = "C-GGLK-GAPFLAC"
query_aln = "CHG--KTGASFLQC"
gap = "-"
sbjct_idx = -1
query_idx = -1
for sbjct_resn, query_resn in zip(sbjct_aln, query_aln):
# Check for gaps
sbjct_gap = bool(sbjct_resn == gap)
query_gap = bool(query_resn == gap)
if not query_gap:
# Always increment count
query_idx += 1
if not sbjct_gap:
# Always increment count
sbjct_idx += 1
if query_gap:
end_clause = "not aligned"
else:
# Adding to change from 0 to 1 based indexing
end_clause = "aligned to position %s in query" % query_idx + 1
# Adding to change from 0 to 1 based indexing
print("Position %s in subject is %s" % (sbjct_idx + 1, end_clause))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment