Skip to content
Snippets Groups Projects
Verified Commit fb6ecdb9 authored by Etienne MORICE's avatar Etienne MORICE
Browse files

Closes #5

parent 67748c07
No related branches found
No related tags found
No related merge requests found
...@@ -6,11 +6,11 @@ cache: ...@@ -6,11 +6,11 @@ cache:
- balibase/ - balibase/
test: test:
script: script:
- python3 -m unittest alignementseq_tests test_alignementseq_multiple - python3 -m unittest alignementseq_tests test_alignementseq_multiple -v
test_performance: test_performance:
script: script:
- python3 -m unittest alignementseq_tests.PerformanceTestCase - python3 -m unittest alignementseq_tests.PerformanceTestCase -v
artifacts: artifacts:
paths: paths:
- timings.png - timings.png
...@@ -164,20 +164,23 @@ def vec_align(seq1, seq2, mat=dict_to_weight(Bio.SubsMat.MatrixInfo.blosum62), g ...@@ -164,20 +164,23 @@ def vec_align(seq1, seq2, mat=dict_to_weight(Bio.SubsMat.MatrixInfo.blosum62), g
S[0][0] = 0 S[0][0] = 0
S[1][0] = gap S[1][0] = gap
S[1][1] = gap S[1][1] = gap
x *= 26
for s in range(2,n+m+1): for s in range(2,n+m+1):
# First/last cell must be treated differently when first line/col of M # First/last cell must be treated differently when first line/col of M
if(s <= m): if(s <= m):
S[s][0] = S[s-1][0] + gap S[s][0] = S[s-1][0] + gap
if(s <= n): if(s <= n):
S[s][s-max(0,s-m)] = S[s-1][s-1-max(0,s-1-m)] + gap S[s][s-max(0,s-m)] = S[s-1][s-1-max(0,s-1-m)] + gap
# The offsets in the formula become begin/end of slices. # The offsets in the formula become begin/end of slices.
gapped = S[s-1] + gap
S[s][int(s<=m):len(S[s])-int(s<=n)] = np.maximum(np.maximum( S[s][int(s<=m):len(S[s])-int(s<=n)] = np.maximum(np.maximum(
S[s-1][1:] + gap, gapped[1:],
S[s-1][:-1] + gap), gapped[:-1]),
S[s-2][int(s>m+1):len(S[s-2])-int(s>n+1)] S[s-2][int(s>m+1):len(S[s-2])-int(s>n+1)]
+mat[ +mat[
x[max(0,s-m-1):min(n,s-1)] * 26 + x[max(0,s-m-1):min(n,s-1)] + y[max(0,s-n-1):min(m,s-1)][::-1]
y[max(0,s-n-1):min(m,s-1)][::-1]
] ]
) )
......
...@@ -19,11 +19,10 @@ import Bio.Entrez ...@@ -19,11 +19,10 @@ import Bio.Entrez
from Bio.SeqRecord import SeqRecord from Bio.SeqRecord import SeqRecord
from Bio.SubsMat.MatrixInfo import blosum62 from Bio.SubsMat.MatrixInfo import blosum62
class AlignmentSeqTestCase(unittest.TestCase): class BalibaseTestCase(unittest.TestCase):
"""Base class to inherit by all test cases that need access to the balibase.
"""
def setUp(self): def setUp(self):
self.unit_timeout = int(os.environ.get("UNIT_TIMEOUT") or 60)
balibase_zippath = "balibase.zip" balibase_zippath = "balibase.zip"
self.balibase_path = "balibase" self.balibase_path = "balibase"
testfile_path = os.path.join( testfile_path = os.path.join(
...@@ -53,6 +52,8 @@ class AlignmentSeqTestCase(unittest.TestCase): ...@@ -53,6 +52,8 @@ class AlignmentSeqTestCase(unittest.TestCase):
seq1 = next(records) seq1 = next(records)
seq2 = next(records) seq2 = next(records)
yield seq1, seq2, filename yield seq1, seq2, filename
class AlignmentSeqTestCase(BalibaseTestCase):
def get_dataset_records(self): def get_dataset_records(self):
"""Generator function to iterate over the record generator of each """Generator function to iterate over the record generator of each
...@@ -212,7 +213,7 @@ class AlignmentSeqTestCase(unittest.TestCase): ...@@ -212,7 +213,7 @@ class AlignmentSeqTestCase(unittest.TestCase):
Bio.SeqIO.write((r1, r2), fd, "fasta") Bio.SeqIO.write((r1, r2), fd, "fasta")
class PerformanceTestCase(AlignmentSeqTestCase): class PerformanceTestCase(BalibaseTestCase):
"""Performance tests, slow. """Performance tests, slow.
Excluded from default test suite, run it with Excluded from default test suite, run it with
...@@ -224,6 +225,8 @@ class PerformanceTestCase(AlignmentSeqTestCase): ...@@ -224,6 +225,8 @@ class PerformanceTestCase(AlignmentSeqTestCase):
""" """
super().setUp() super().setUp()
self.unit_timeout = int(os.environ.get("UNIT_TIMEOUT") or 60)
with warnings.catch_warnings(): with warnings.catch_warnings():
warnings.simplefilter("ignore") warnings.simplefilter("ignore")
self.titin_human, self.titin_mouse = Bio.SeqIO.parse( self.titin_human, self.titin_mouse = Bio.SeqIO.parse(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment