aboutsummaryrefslogtreecommitdiff
path: root/src/filter_max_consecutive_binding.py
diff options
context:
space:
mode:
authorCalvin Morrison <mutantturkey@gmail.com>2014-01-29 17:05:21 -0500
committerCalvin Morrison <mutantturkey@gmail.com>2014-01-29 17:05:21 -0500
commitf844b88723aebf515b344bfa375f981af16f334f (patch)
treefcf60d87ec554b4528c6f6bc0c99ab5887ca62ab /src/filter_max_consecutive_binding.py
parent94d04a1e503121a98b403f882c18a4f0799267d7 (diff)
fix corner case
Diffstat (limited to 'src/filter_max_consecutive_binding.py')
-rwxr-xr-xsrc/filter_max_consecutive_binding.py9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/filter_max_consecutive_binding.py b/src/filter_max_consecutive_binding.py
index daebee4..9054dac 100755
--- a/src/filter_max_consecutive_binding.py
+++ b/src/filter_max_consecutive_binding.py
@@ -8,17 +8,19 @@ def max_consecutive_binding(mer1, mer2):
if len(mer2) > len(mer1):
mer1, mer2 = mer2, mer1
+ # save the len because it'll change when we do a ljust
+ mer1_len = len(mer1)
# reverse mer2,
mer2 = mer2[::-1]
# pad mer one to avoid errors
- mer1 = mer1.ljust(len(mer1) + len(mer1), "_")
+ mer1 = mer1.ljust(mer1_len + len(mer2), "_")
max_bind = 0;
- for offset in range(len(mer2)):
+ for offset in range(mer1_len):
consecutive = 0
for x in range(len(mer2)):
if binding[mer1[offset+x]] == mer2[x]:
- consecutive = consecutive + 1
+ consecutive = consecutive + 1
else:
consecutive = 0
@@ -39,6 +41,7 @@ def test():
("ACG", "CGT", 3),
("CACC", "GGTGT", 4),
("GGTGT", "CACC", 4),
+ ("CCCCCCCCATATAT", "TATA", 4),
]
print 'pass\tmer1\tmer2\tres\tcorr'