Created
November 4, 2015 20:37
-
-
Save lennax/9925c08804a57bb5ef72 to your computer and use it in GitHub Desktop.
Describe alignment
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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