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

Refactor to use unittest and gitlab-ci (1)

parent cab18201
No related branches found
No related tags found
No related merge requests found
*.swp
balibase/
__pycache__/
balibase.zip
before_script:
- python3 -m pip install -r requirements.txt
cache:
paths:
- balibase/
test:
script:
- python3 -m unittest alignementseq_tests.py
......@@ -38,7 +38,7 @@ def score(a, b, gap=-8, id=1, mut=-1):
# else:
# return mut
def align(seq1, seq2):
def align(seq1, seq2, score=score):
x = seq1.seq
y = seq2.seq
n=len(x)
......@@ -246,4 +246,3 @@ def test():
print(s)
print(x)
print(y)
test()
import unittest
import urllib.request
import os
import zipfile
from Bio.SeqRecord import SeqRecord
class AlignmentSeqTestCase(unittest.TestCase):
def setUp(self):
balibase_zippath = "balibase.zip"
balibase_path = "balibase"
testfile_path = os.path.join(
balibase_path,
"RV11.unaligned", "BBS11001.fasta")
if not os.path.isdir(balibase_path):
os.mkdir(balibase_path)
if not os.path.isfile(testfile_path):
if not os.path.isfile(balibase_zippath):
print("Fetching balibase archive from moodle...")
urllib.request.urlretrieve(
"https://moodle.polytechnique.fr/mod/resource/view.php?id=38570",
balibase_zippath)
with zipfile.ZipFile(balibase_zippath) as balibase_zip:
balibase_zip.extractall()
def test_simple_align(self):
from alignementseq import align
score_fn = lambda a,b : -2 if a == '' or b == '' else -1 if a != b else 1
cases = [
("CHAT", "CAT", 1, "CHAT", "C-AT"),
("CHAT", "CGAT", 2, "CHAT", "CGAT"),
("CHAT", "AT", -2, "CHAT", "--AT")
]
for s1, s2, exp_score, exp_r1, exp_r2 in cases:
score, r1, r2 = align(SeqRecord(s1), SeqRecord(s2), score_fn)
self.assertEqual(score, exp_score)
self.assertEqual(r1.seq, exp_r1)
self.assertEqual(r2.seq, exp_r2)
if __name__ == '__main__':
unittest.main()
biopython==1.73
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