diff --git a/conkit/core/tests/test_Contact.py b/conkit/core/tests/test_Contact.py index fb603244..82cc0340 100644 --- a/conkit/core/tests/test_Contact.py +++ b/conkit/core/tests/test_Contact.py @@ -10,20 +10,18 @@ class Test(unittest.TestCase): - def test_distance_bound(self): - # ====================================================== - # Test Case 1 + def test_distance_bound_1(self): contact = Contact(1, 2, 1.0) contact.distance_bound = (0, 8) self.assertEqual((0, 8), contact.distance_bound) - # ====================================================== - # Test Case 2 + + def test_distance_bound_2(self): contact = Contact(1, 2, 1.0) contact.distance_bound = (0, 8) self.assertEqual((0, 8), contact.distance_bound) self.assertTrue(isinstance(contact.distance_bound, tuple)) - # ====================================================== - # Test Case 3 + + def test_distance_bound_3(self): contact = Contact(1, 2, 1.0) try: contact.distance_bound = (1, 100) @@ -34,44 +32,38 @@ def test_distance_bound(self): with self.assertRaises(TypeError): contact.distance_bound = 'test' - def test_is_false_positive(self): - # ====================================================== - # Test Case 1 + def test_is_false_positive_1(self): contact = Contact(1, 2, 1.0) contact.define_false_positive() self.assertTrue(contact.is_false_positive) self.assertFalse(contact.is_true_positive) - def test_is_true_positive(self): - # ====================================================== - # Test Case 1 + def test_is_true_positive_1(self): contact = Contact(1, 2, 1.0) contact.define_true_positive() self.assertTrue(contact.is_true_positive) self.assertFalse(contact.is_false_positive) - def test_lower_bound(self): - # ====================================================== - # Test Case 1 + def test_lower_bound_1(self): contact = Contact(1, 2, 1.0) self.assertEqual(0, contact.lower_bound) - # ====================================================== - # Test Case 2 + + def test_lower_bound_2(self): contact = Contact(1, 2, 1.0) with self.assertRaises(ValueError): contact.lower_bound = -1 - # ====================================================== - # Test Case 3 + + def test_lower_bound_3(self): contact = Contact(1, 2, 1.0) contact.lower_bound = 1 self.assertEqual(1, contact.lower_bound) - # ====================================================== - # Test Case 4 + + def test_lower_bound_4(self): contact = Contact(1, 2, 1.0) contact.lower_bound = 7 self.assertEqual(7, contact.lower_bound) - # ====================================================== - # Test Case 5 + + def test_lower_bound_5(self): contact = Contact(1, 2, 1.0) contact.lower_bound = 1 contact.upper_bound = 8 @@ -82,28 +74,26 @@ def test_lower_bound(self): contact.lower_bound = 10 self.assertEqual(1, contact.lower_bound) - def test_upper_bound(self): - # ====================================================== - # Test Case 1 + def test_upper_bound_1(self): contact = Contact(1, 2, 1.0) self.assertEqual(8, contact.upper_bound) - # ====================================================== - # Test Case 2 + + def test_upper_bound_2(self): contact = Contact(1, 2, 1.0) with self.assertRaises(ValueError): contact.upper_bound = -1 - # ====================================================== - # Test Case 3 + + def test_upper_bound_3(self): contact = Contact(1, 2, 1.0) contact.upper_bound = 10 self.assertEqual(10, contact.upper_bound) - # ====================================================== - # Test Case 4 + + def test_upper_bound_4(self): contact = Contact(1, 2, 1.0) contact.upper_bound = 7 self.assertEqual(7, contact.upper_bound) - # ====================================================== - # Test Case 5 + + def test_upper_bound_5(self): contact = Contact(1, 2, 1.0) contact.lower_bound = 4 contact.upper_bound = 8 @@ -114,9 +104,7 @@ def test_upper_bound(self): contact.upper_bound = 3 self.assertEqual(8, contact.upper_bound) - def test_raw_score(self): - # ====================================================== - # Test Case 1 + def test_raw_score_1(self): contact = Contact(1, 2, 1.0) self.assertEqual(1.0, contact.raw_score) contact.raw_score = 0.3 @@ -126,43 +114,37 @@ def test_raw_score(self): contact.raw_score = 1.0 self.assertEqual(1.0, contact.raw_score) - def test_res1(self): - # ====================================================== - # Test Case 1 + def test_res1_1(self): contact = Contact(1, 2, 1.0) contact.res1 = 'Ala' self.assertEqual('A', contact.res1) - # ====================================================== - # Test Case 2 + + def test_res1_2(self): contact = Contact(1, 2, 1.0) contact.res1 = 'T' self.assertEqual('T', contact.res1) - # ====================================================== - # Test Case 3 + + def test_res1_3(self): contact = Contact(1, 2, 1.0) with self.assertRaises(ValueError): contact.res1 = '8' - def test_res2(self): - # ====================================================== - # Test Case 1 + def test_res2_1(self): contact = Contact(1, 2, 1.0) contact.res2 = 'Met' self.assertEqual('M', contact.res2) - # ====================================================== - # Test Case 2 + + def test_res2_2(self): contact = Contact(1, 2, 1.0) contact.res2 = 'P' self.assertEqual('P', contact.res2) - # ====================================================== - # Test Case 3 + + def test_res2_3(self): contact = Contact(1, 2, 1.0) with self.assertRaises(ValueError): contact.res2 = '?' - def test_res1_chain(self): - # ====================================================== - # Test Case 1 + def test_res1_chain_1(self): contact = Contact(1, 2, 1.0) self.assertEqual('', contact.res1_chain) contact.res1_chain = 'A' @@ -170,9 +152,7 @@ def test_res1_chain(self): contact.res1_chain = 'd' self.assertEqual('d', contact.res1_chain) - def test_res2_chain(self): - # ====================================================== - # Test Case 1 + def test_res2_chain_1(self): contact = Contact(1, 2, 1.0) self.assertEqual('', contact.res2_chain) contact.res2_chain = 'b' @@ -180,9 +160,7 @@ def test_res2_chain(self): contact.res2_chain = 'X' self.assertEqual('X', contact.res2_chain) - def test_res1_seq(self): - # ====================================================== - # Test Case 1 + def test_res1_seq_1(self): contact = Contact(1, 2, 1.0) self.assertEqual(1, contact.res1_seq) contact.res1_seq = 2 @@ -192,9 +170,7 @@ def test_res1_seq(self): contact.res1_seq = 1 self.assertEqual(1, contact.res1_seq) - def test_res2_seq(self): - # ====================================================== - # Test Case 1 + def test_res2_seq_1(self): contact = Contact(1, 2000000, 1.0) self.assertEqual(2000000, contact.res2_seq) contact.res2_seq = 1 @@ -212,29 +188,23 @@ def test_res1_altseq(self): self.assertEqual(1000, contact.res1_altseq) self.assertNotEqual(10, contact.res2_altseq) - def test_res2_altseq(self): - # ====================================================== - # Test Case 1 + def test_res2_altseq_1(self): contact = Contact(1, 2000000, 1.0) contact.res2_altseq = 10 self.assertEqual(10, contact.res2_altseq) self.assertNotEqual(5, contact.res2_altseq) - def test_scalar_score(self): - # ====================================================== - # Test Case 1 + def test_scalar_score_1(self): contact = Contact(1, 2000000, 1.0) contact.scalar_score = 5.432 self.assertEqual(5.432, contact.scalar_score) - # ====================================================== - # Test Case 2 + + def test_scalar_score_2(self): contact = Contact(1, 2000000, 1.0) contact.scalar_score = 3 self.assertNotEqual(3, contact.res2_altseq) - def test_status(self): - # ====================================================== - # Test Case 1 + def test_status_1(self): contact = Contact(1, 2000000, 1.0) self.assertEqual(0, contact.status) contact.define_false_positive() @@ -242,33 +212,25 @@ def test_status(self): contact.define_true_positive() self.assertEqual(1, contact.status) - def test_weight(self): - # ====================================================== - # Test Case 1 + def test_weight_1(self): contact = Contact(1, 2000000, 1.0) self.assertEqual(1.0, contact.weight) contact.weight = 2.5 self.assertEqual(2.5, contact.weight) - def test_define_false_positive(self): - # ====================================================== - # Test Case 1 + def test_define_false_positive_1(self): contact = Contact(1, 2, 1.0) contact.define_false_positive() self.assertTrue(contact.is_false_positive) self.assertFalse(contact.is_true_positive) - def test_define_true_positive(self): - # ====================================================== - # Test Case 1 + def test_define_true_positive_1(self): contact = Contact(1, 2, 1.0) contact.define_true_positive() self.assertTrue(contact.is_true_positive) self.assertFalse(contact.is_false_positive) - def test__to_dict(self): - # ====================================================== - # Test Case 1 + def test__to_dict_1(self): contact = Contact(1, 2, 1.0) dict = { 'id': (1, 2), 'is_false_positive': False, 'is_true_positive': False, 'distance_bound': (0, 8), @@ -277,8 +239,8 @@ def test__to_dict(self): 'status': 0, 'weight': 1.0, } self.assertEqual(dict, contact._to_dict()) - # ====================================================== - # Test Case 2 + + def test__to_dict_2(self): contact = Contact(1, 2, 1.0) contact.define_true_positive() contact.lower_bound = 4 @@ -290,7 +252,7 @@ def test__to_dict(self): } self.assertEqual(dict, contact._to_dict()) - def test__set_residue(self): + def test__set_residue_1(self): self.assertEqual("A", Contact._set_residue("ALA")) self.assertEqual("A", Contact._set_residue("Ala")) self.assertEqual("A", Contact._set_residue("ala")) diff --git a/conkit/core/tests/test_ContactFile.py b/conkit/core/tests/test_ContactFile.py index a140faeb..dff45b94 100644 --- a/conkit/core/tests/test_ContactFile.py +++ b/conkit/core/tests/test_ContactFile.py @@ -11,109 +11,99 @@ class Test(unittest.TestCase): - def test_author(self): - # ====================================================== - # Test Case 1 + def test_author_1(self): contact_file = ContactFile('test') contact_file.author = "John Doe" self.assertEqual("John Doe", contact_file.author) - # ====================================================== - # Test Case 2 + + def test_author_2(self): contact_file = ContactFile('test') contact_file.author = "John Doe" contact_file.author = "Jane Roe" self.assertEqual("Jane Roe", contact_file.author) - def test_method(self): - # ====================================================== - # Test Case 1 + def test_method_1(self): contact_file = ContactFile('test') contact_file.method = 'Hello' self.assertEqual(['Hello'], contact_file.method) - # ====================================================== - # Test Case 2 + + def test_method_2(self): contact_file = ContactFile('test') contact_file.method = 'Hello' contact_file.method = 'World' self.assertEqual(['Hello', 'World'], contact_file.method) - # ====================================================== - # Test Case 3 + + def test_method_3(self): contact_file = ContactFile('test') contact_file.method = 'Hello' contact_file.method = '5' contact_file.method = 'World' contact_file.method = '!' self.assertEqual(['Hello', '5', 'World', '!'], contact_file.method) - # ====================================================== - # Test Case 4 + + def test_method_4(self): contact_file = ContactFile('test') self.assertEqual([], contact_file.method) - # ====================================================== - # Test Case 5 + + def test_method_5(self): contact_file = ContactFile('test') contact_file.method = 'hello' contact_map = ContactMap('foo') contact_file.add(contact_map) self.assertEqual(['hello'], contact_file.method) - def test_remark(self): - # ====================================================== - # Test Case 1 + def test_remark_1(self): contact_file = ContactFile('test') contact_file.remark = 'Hello' self.assertEqual(['Hello'], contact_file.remark) - # ====================================================== - # Test Case 2 + + def test_remark_2(self): contact_file = ContactFile('test') contact_file.remark = 'Hello' contact_file.remark = 'World' self.assertEqual(['Hello', 'World'], contact_file.remark) - # ====================================================== - # Test Case 3 + + def test_remark_3(self): contact_file = ContactFile('test') contact_file.remark = 'Hello' contact_file.remark = '5' contact_file.remark = 'World' contact_file.remark = '!' self.assertEqual(['Hello', '5', 'World', '!'], contact_file.remark) - # ====================================================== - # Test Case 4 + + def test_remark_4(self): contact_file = ContactFile('test') self.assertEqual([], contact_file.remark) - # ====================================================== - # Test Case 5 + + def test_remark_5(self): contact_file = ContactFile('test') contact_file.remark = 'hello' contact_map = ContactMap('foo') contact_file.add(contact_map) self.assertEqual(['hello'], contact_file.remark) - def test_target(self): - # ====================================================== - # Test Case 1 + def test_target_1(self): contact_file = ContactFile('test') contact_file.target = "John Doe" self.assertEqual("John Doe", contact_file.target) - # ====================================================== - # Test Case 2 + + def test_target_2(self): contact_file = ContactFile('test') contact_file.target = "John Doe" contact_file.target = "Jane Roe" self.assertEqual("Jane Roe", contact_file.target) - def test_top_map(self): - # ====================================================== - # Test Case 1 + def test_top_map_1(self): contact_file = ContactFile('test') self.assertEqual(None, contact_file.top_map) - # ====================================================== - # Test Case 2 + + def test_top_map_2(self): contact_file = ContactFile('test') contact_map = ContactMap('foo') contact_file.add(contact_map) self.assertEqual(contact_map, contact_file.top_map) - # ====================================================== - # Test Case 3 + + def test_top_map_3(self): contact_file = ContactFile('test') contact_map1 = ContactMap('foo') contact_map2 = ContactMap('bar') @@ -121,33 +111,31 @@ def test_top_map(self): contact_file.add(contact_map2) self.assertEqual(contact_map1, contact_file.top_map) - def test_sort(self): - # ====================================================== - # Test Case 1 + def test_sort_1(self): contact_file = ContactFile('test') for map in [ContactMap('foo'), ContactMap('bar'), ContactMap('doe')]: contact_file.add(map) contact_file_sorted = contact_file.sort('id', reverse=False, inplace=False) self.assertEqual(['bar', 'doe', 'foo'], [m.id for m in contact_file_sorted]) self.assertNotEqual(contact_file, contact_file_sorted) - # ====================================================== - # Test Case 2 + + def test_sort_2(self): contact_file = ContactFile('test') for map in [ContactMap('foo'), ContactMap('bar'), ContactMap('doe')]: contact_file.add(map) contact_file_sorted = contact_file.sort('id', reverse=True, inplace=False) self.assertEqual(['foo', 'doe', 'bar'], [m.id for m in contact_file_sorted]) self.assertNotEqual(contact_file, contact_file_sorted) - # ====================================================== - # Test Case 3 + + def test_sort_3(self): contact_file = ContactFile('test') for map in [ContactMap('foo'), ContactMap('bar'), ContactMap('doe')]: contact_file.add(map) contact_file_sorted = contact_file.sort('id', reverse=False, inplace=True) self.assertEqual(['bar', 'doe', 'foo'], [m.id for m in contact_file_sorted]) self.assertEqual(contact_file, contact_file_sorted) - # ====================================================== - # Test Case 4 + + def test_sort_4(self): contact_file = ContactFile('test') for map in [ContactMap('foo'), ContactMap('bar'), ContactMap('doe')]: contact_file.add(map) diff --git a/conkit/core/tests/test_ContactMap.py b/conkit/core/tests/test_ContactMap.py index 316e421f..65390ab9 100644 --- a/conkit/core/tests/test_ContactMap.py +++ b/conkit/core/tests/test_ContactMap.py @@ -14,9 +14,7 @@ class Test(unittest.TestCase): - def test_coverage(self): - # ====================================================== - # Test Case 1 + def test_coverage_1(self): contact_map = ContactMap('test') contact_map.add(Contact(1, 4, 1.0)) contact_map.add(Contact(2, 4, 1.0)) @@ -24,8 +22,8 @@ def test_coverage(self): contact_map.add(Contact(3, 6, 1.0)) contact_map.sequence = Sequence('TEST', 'ABCDEFGH') self.assertEqual(0.875, contact_map.coverage) - # ====================================================== - # Test Case 2 + + def test_coverage_2(self): contact_map = ContactMap('test') contact_map.add(Contact(1, 4, 1.0)) contact_map.add(Contact(2, 4, 1.0)) @@ -37,26 +35,22 @@ def test_coverage(self): contact_map.remove((3, 6)) self.assertEqual(0.375, contact_map.coverage) - def test_ncontacts(self): - # ====================================================== - # Test Case 1 + def test_ncontacts_1(self): contact_map = ContactMap('test') self.assertEqual(0, contact_map.ncontacts) - # ====================================================== - # Test Case 2 + + def test_ncontacts_2(self): contact_map = ContactMap('test') contact_map.add(Contact(1, 5, 1.0)) self.assertEqual(1, contact_map.ncontacts) - # ====================================================== - # Test Case 3 + + def test_ncontacts_3(self): contact_map = ContactMap('test') contact_map.add(Contact(1, 5, 1.0)) contact_map.add(Contact(2, 10, 1.0)) self.assertEqual(2, contact_map.ncontacts) - def test_precision(self): - # ====================================================== - # Test Case 1 + def test_precision_1(self): contact_map = ContactMap('test') for c in [Contact(1, 5, 1.0), Contact(3, 3, 0.4), Contact(2, 4, 0.1), Contact(5, 1, 0.2)]: contact_map.add(c) @@ -68,7 +62,7 @@ def test_precision(self): contact.define_false_positive() self.assertEqual(0.5, contact_map.precision) - def test_repr_sequence(self): + def test_repr_sequence_1(self): # ====================================================== # Test Case 1 contact_map = ContactMap('test') @@ -77,8 +71,8 @@ def test_repr_sequence(self): contact_map.sequence = Sequence('foo', 'ABCDE') self.assertEqual('AB-DE', contact_map.repr_sequence.seq) contact_map.remove((2, 4)) - # ====================================================== - # Test Case 2 + + def test_repr_sequence_2(self): contact_map = ContactMap('test') for contact in [Contact(1, 5, 1.0), Contact(2, 4, 0.1), Contact(5, 1, 0.2)]: contact_map.add(contact) @@ -87,9 +81,7 @@ def test_repr_sequence(self): contact_map.remove((2, 4)) self.assertEqual('A---E', contact_map.repr_sequence.seq) - def test_repr_sequence_altloc(self): - # ====================================================== - # Test Case 1 + def test_repr_sequence_altloc_1(self): contact_map = ContactMap('test') for contact, altseq in [(Contact(1, 5, 1.0), (3, 4)), (Contact(2, 4, 0.1), (1, 5)), @@ -100,8 +92,8 @@ def test_repr_sequence_altloc(self): contact_map.sequence = Sequence('foo', 'ABCDE') self.assertEqual('A-CDE', contact_map.repr_sequence_altloc.seq) self.assertEqual('AB-DE', contact_map.repr_sequence.seq) - # ====================================================== - # Test Case 2 + + def test_repr_sequence_altloc_2(self): contact_map = ContactMap('test') for contact, altseq in [(Contact(1, 5, 1.0), (3, 4)), (Contact(2, 4, 0.1), (1, 5)), @@ -116,17 +108,15 @@ def test_repr_sequence_altloc(self): self.assertEqual('--CD-', contact_map.repr_sequence_altloc.seq) self.assertEqual('A---E', contact_map.repr_sequence.seq) - def test_sequence(self): - # ====================================================== - # Test Case 1 + def test_sequence_1(self): contact_map = ContactMap('test') for contact in [Contact(1, 5, 1.0), Contact(3, 3, 0.4), Contact(2, 4, 0.1), Contact(5, 1, 0.2)]: contact_map.add(contact) seq_obj = Sequence('bar', 'ABCDE') contact_map.sequence = seq_obj self.assertEqual(seq_obj, contact_map.sequence) - # ====================================================== - # Test Case 2 + + def test_sequence_2(self): contact_map = ContactMap('test') for contact in [Contact(1, 5, 1.0), Contact(3, 3, 0.4), Contact(2, 4, 0.1), Contact(5, 1, 0.2)]: contact_map.add(contact) @@ -135,19 +125,17 @@ def test_sequence(self): with self.assertRaises(TypeError): contact_map.sequence([sequence1, sequence2]) - def test_top_contact(self): - # ====================================================== - # Test Case 1 + def test_top_contact_1(self): contact_map = ContactMap('test') self.assertEqual(None, contact_map.top_contact) - # ====================================================== - # Test Case 2 + + def test_top_contact_2(self): contact_map = ContactMap('test') contact = Contact(1, 10, 1.0) contact_map.add(contact) self.assertEqual(contact, contact_map.top_contact) - # ====================================================== - # Test Case 3 + + def test_top_contact_3(self): contact_map = ContactMap('test') contact1 = Contact(1, 10, 1.0) contact2 = Contact(2, 100, 1.0) @@ -155,33 +143,31 @@ def test_top_contact(self): contact_map.add(contact2) self.assertEqual(contact1, contact_map.top_contact) - def test__construct_repr_sequence(self): - # ====================================================== - # Test Case 1 + def test__construct_repr_sequence_1(self): contact_map = ContactMap('test') for contact in [Contact(1, 5, 1.0), Contact(3, 3, 0.4), Contact(2, 4, 0.1), Contact(5, 1, 0.2)]: contact_map.add(contact) seq_obj = Sequence('bar', 'ABCDE') contact_map.sequence = seq_obj self.assertEqual('ABCDE', contact_map._construct_repr_sequence([1, 2, 3, 4, 5]).seq) - # ====================================================== - # Test Case 2 + + def test__construct_repr_sequence_2(self): contact_map = ContactMap('test') for contact in [Contact(1, 5, 1.0), Contact(2, 4, 0.1), Contact(5, 1, 0.2)]: contact_map.add(contact) seq_obj = Sequence('bar', 'ABCDE') contact_map.sequence = seq_obj self.assertEqual('AB-DE', contact_map._construct_repr_sequence([1, 2, 4, 5]).seq) - # ====================================================== - # Test Case 3 + + def test__construct_repr_sequence_3(self): contact_map = ContactMap('test') for contact in [Contact(1, 5, 1.0), Contact(5, 1, 0.2)]: contact_map.add(contact) seq_obj = Sequence('bar', 'ABCDE') contact_map.sequence = seq_obj self.assertEqual('A---E', contact_map._construct_repr_sequence([1, 5]).seq) - # ====================================================== - # Test Case 4 + + def test__construct_repr_sequence_4(self): contact_map = ContactMap('test') for contact in [Contact(1, 5, 1.0), Contact(5, 1, 0.2)]: contact_map.add(contact) @@ -189,18 +175,14 @@ def test__construct_repr_sequence(self): contact_map.sequence = seq_obj self.assertEqual('----E', contact_map._construct_repr_sequence([-1, 5]).seq) - def test_calculate_scalar_score(self): - # ====================================================== - # Test Case 1 + def test_calculate_scalar_score_1(self): contact_map = ContactMap('test') for c in [Contact(1, 5, 1.0), Contact(3, 3, 0.4), Contact(2, 4, 0.1), Contact(5, 1, 0.2)]: contact_map.add(c) contact_map.calculate_scalar_score() self.assertListEqual([2.352941, 0.941176, 0.235294, 0.470588], [round(c.scalar_score, 6) for c in contact_map]) - def test_calculate_jaccard_score(self): - # ====================================================== - # Test Case 1 + def test_calculate_jaccard_score_1(self): contact_map1 = ContactMap('foo') for c in [Contact(1, 5, 1.0), Contact(3, 3, 0.4), Contact(2, 4, 0.1), Contact(5, 1, 0.2)]: contact_map1.add(c) @@ -209,8 +191,8 @@ def test_calculate_jaccard_score(self): contact_map2.add(c) jindex = contact_map1.calculate_jaccard_index(contact_map2) self.assertEqual(0.333333, round(jindex, 6)) - # ====================================================== - # Test Case 2 + + def test_calculate_jaccard_score_2(self): contact_map1 = ContactMap('foo') for c in [Contact(1, 5, 1.0), Contact(3, 3, 0.4), Contact(2, 4, 0.1), Contact(5, 1, 0.2)]: contact_map1.add(c) @@ -219,8 +201,8 @@ def test_calculate_jaccard_score(self): contact_map2.add(c) jindex = contact_map1.calculate_jaccard_index(contact_map2) self.assertEqual(0.0, jindex) - # ====================================================== - # Test Case 3 + + def test_calculate_jaccard_score_3(self): contact_map1 = ContactMap('foo') for c in [Contact(1, 5, 1.0), Contact(3, 3, 0.4), Contact(2, 4, 0.1), Contact(5, 1, 0.2)]: contact_map1.add(c) @@ -229,16 +211,14 @@ def test_calculate_jaccard_score(self): contact_map2.add(c) jindex = contact_map1.calculate_jaccard_index(contact_map2) self.assertEqual(1.0, jindex) - # ====================================================== - # Test Case 2 + + def test_calculate_jaccard_score_4(self): contact_map1 = ContactMap('foo') contact_map2 = ContactMap('bar') jindex = contact_map1.calculate_jaccard_index(contact_map2) self.assertEqual(1.0, jindex) - def test_find(self): - # ====================================================== - # Test Case 1 + def test_find_1(self): contact_map1 = ContactMap('1') for comb in [(1, 5, 1.0), (2, 6, 1.0), (1, 4, 1.0), (3, 6, 1.0), (2, 5, 1.0)]: contact_map1.add(Contact(*comb)) @@ -248,8 +228,8 @@ def test_find(self): self.assertEqual(2, len(found)) self.assertEqual([1, 1], [c.res1_seq for c in found]) self.assertEqual([5, 4], [c.res2_seq for c in found]) - # ====================================================== - # Test Case 2 + + def test_find_2(self): contact_map1 = ContactMap('1') for comb in [(1, 5, 1.0), (2, 6, 1.0), (1, 4, 1.0), (3, 6, 1.0), (2, 5, 1.0)]: contact_map1.add(Contact(*comb)) @@ -259,8 +239,8 @@ def test_find(self): self.assertEqual(0, len(found)) self.assertEqual([], [c.res1_seq for c in found]) self.assertEqual([], [c.res2_seq for c in found]) - # ====================================================== - # Test Case 3 + + def test_find_3(self): contact_map1 = ContactMap('1') for comb in [(1, 5, 1.0), (2, 6, 1.0), (1, 4, 1.0), (3, 6, 1.0), (2, 5, 1.0)]: contact_map1.add(Contact(*comb)) @@ -270,8 +250,8 @@ def test_find(self): self.assertEqual(5, len(found)) self.assertEqual([1, 2, 1, 3, 2], [c.res1_seq for c in found]) self.assertEqual([5, 6, 4, 6, 5], [c.res2_seq for c in found]) - # ====================================================== - # Test Case 4 + + def test_find_4(self): contact_map1 = ContactMap('1') for comb in [(1, 5, 1.0), (2, 6, 1.0), (1, 4, 1.0), (3, 6, 1.0), (2, 5, 1.0)]: contact_map1.add(Contact(*comb)) @@ -282,9 +262,7 @@ def test_find(self): self.assertEqual([1, 2, 1, 3], [c.res1_seq for c in found]) self.assertEqual([5, 6, 4, 6], [c.res2_seq for c in found]) - def test_assign_sequence_register(self): - # ====================================================== - # Test Case 1 + def test_assign_sequence_register_1(self): contact_map1 = ContactMap('1') for comb in [(1, 5, 1.0), (2, 6, 1.0), (1, 4, 1.0), (3, 6, 1.0), (2, 5, 1.0)]: contact_map1.add(Contact(*comb)) @@ -294,8 +272,8 @@ def test_assign_sequence_register(self): [('A', 'E'), ('B', 'F'), ('A', 'D'), ('C', 'F'), ('B', 'E')], [(c.res1, c.res2) for c in contact_map1] ) - # ====================================================== - # Test Case 2 + + def test_assign_sequence_register_2(self): contact_map1 = ContactMap('1') for comb, alt in [((101, 105, 1.0), (1, 5)), ((102, 106, 1.0), (2, 6)), @@ -313,9 +291,7 @@ def test_assign_sequence_register(self): [(c.res1, c.res2) for c in contact_map1] ) - def test_match(self): - # ====================================================== - # Test Case 1 + def test_match_1(self): contact_map1 = ContactMap('foo') for params in [(1, 5, 1.0), (1, 6, 1.0), (2, 7, 1.0), (3, 5, 1.0), (2, 8, 1.0)]: contact = Contact(*params) @@ -342,8 +318,8 @@ def test_match(self): Contact._UNKNOWN], [c.status for c in contact_map1] ) - # ====================================================== - # Test Case 2 + + def test_match_2(self): contact_map1 = ContactMap('foo') for params in [(1, 5, 1.0), (1, 6, 1.0), (2, 7, 1.0), (3, 5, 1.0), (2, 8, 1.0)]: contact = Contact(*params) @@ -369,8 +345,8 @@ def test_match(self): [Contact._TRUE_POSITIVE, Contact._FALSE_POSITIVE, Contact._TRUE_POSITIVE], [c.status for c in contact_map1] ) - # ====================================================== - # Test Case 3 + + def test_match_3(self): contact_map1 = ContactMap('foo') for params in [(1, 5, 1.0), (1, 6, 1.0), (2, 7, 1.0), (3, 5, 1.0), (2, 8, 1.0)]: contact = Contact(*params) @@ -397,8 +373,8 @@ def test_match(self): [Contact._FALSE_POSITIVE, Contact._TRUE_POSITIVE], [c.status for c in contact_map1] ) - # ====================================================== - # Test Case 4 + + def test_match_4(self): contact_map1 = ContactMap('foo') for params in [(1, 5, 1.0), (1, 6, 1.0), (2, 7, 1.0), (3, 5, 1.0), (2, 8, 1.0)]: contact = Contact(*params) @@ -426,8 +402,8 @@ def test_match(self): ) self.assertEqual([2, 2, 3], [c.res1_altseq for c in contact_map2]) self.assertEqual([6, 7, 5], [c.res2_altseq for c in contact_map2]) - # ====================================================== - # Test Case 5 + + def test_match_5(self): contact_map1 = ContactMap('foo') for params in [(1, 5, 1.0), (1, 6, 1.0), (2, 7, 1.0), (3, 5, 1.0), (2, 8, 1.0)]: contact = Contact(*params) @@ -470,8 +446,8 @@ def test_match(self): Contact._UNKNOWN], [c.status for c in contact_map1] ) - # ====================================================== - # Test Case 6 + + def test_match_6(self): contact_map1 = ContactMap('foo') for params in [(1, 5, 1.0), (1, 6, 1.0), (2, 7, 1.0), (3, 5, 1.0), (2, 8, 1.0)]: contact = Contact(*params) @@ -513,8 +489,8 @@ def test_match(self): [Contact._TRUE_POSITIVE, Contact._FALSE_POSITIVE, Contact._TRUE_POSITIVE], [c.status for c in contact_map1] ) - # ====================================================== - # Test Case 7 + + def test_match_7(self): contact_map1 = ContactMap('foo') for params in [(1, 5, 1.0), (1, 6, 1.0), (2, 7, 1.0), (3, 5, 1.0), (2, 8, 1.0)]: contact = Contact(*params) @@ -561,8 +537,8 @@ def test_match(self): self.assertEqual(['A', 'A', '', 'A', ''], [c.res1_chain for c in contact_map1]) self.assertEqual([30, 31, 9999, 30, 9999], [c.res2_seq for c in contact_map1]) self.assertEqual(['B', 'B', '', 'B', ''], [c.res2_chain for c in contact_map1]) - # ====================================================== - # Test Case 8 + + def test_match_8(self): contact_map1 = ContactMap('foo') for params in [(1, 5, 1.0), (1, 6, 1.0), (2, 7, 1.0), (3, 5, 1.0), (2, 8, 1.0)]: contact = Contact(*params) @@ -608,8 +584,8 @@ def test_match(self): self.assertEqual(['A', 'A', 'A'], [c.res1_chain for c in contact_map1]) self.assertEqual([30, 31, 30], [c.res2_seq for c in contact_map1]) self.assertEqual(['B', 'B', 'B'], [c.res2_chain for c in contact_map1]) - # ====================================================== - # Test Case 9 + + def test_match_9(self): contact_map1 = ContactMap('foo') for params in [(1, 5, 1.0), (1, 6, 1.0), (2, 7, 1.0), (3, 5, 1.0), (2, 8, 1.0)]: contact = Contact(*params) @@ -672,8 +648,8 @@ def test_match(self): self.assertEqual(['A', 'A', 'A', 'A', 'A'], [c.res1_chain for c in contact_map1]) self.assertEqual([30, 31, 32, 30, 33], [c.res2_seq for c in contact_map1]) self.assertEqual(['B', 'B', 'B', 'B', 'B'], [c.res2_chain for c in contact_map1]) - # ====================================================== - # Test Case 10 + + def test_match_10(self): contact_map1 = ContactMap('foo') for params in [(1, 5, 1.0), (1, 6, 1.0), (2, 7, 1.0), (3, 5, 1.0), (2, 8, 1.0)]: contact = Contact(*params) @@ -746,17 +722,15 @@ def test_match(self): [(c.res1_chain, c.res2_chain) for c in contact_map1] ) - def test_remove_neighbors(self): - # ====================================================== - # Test Case 1 + def test_remove_neighbors_1(self): contact_map = ContactMap('test') for c in [Contact(1, 5, 1.0), Contact(3, 3, 0.4), Contact(2, 4, 0.1), Contact(5, 1, 0.2)]: contact_map.add(c) contact_map_mod = contact_map.remove_neighbors(min_distance=2) self.assertListEqual([(1, 5), (2, 4), (5, 1)], [c.id for c in contact_map_mod]) self.assertEqual([(1, 5), (2, 4), (5, 1)], sorted(contact_map_mod.child_dict.keys())) - # ====================================================== - # Test Case 2 + + def test_remove_neighbors_2(self): contact_map = ContactMap('test') for c in [Contact(1, 5, 1.0), Contact(3, 3, 0.4), Contact(2, 4, 0.1), Contact(5, 1, 0.2)]: contact_map.add(c) @@ -765,17 +739,15 @@ def test_remove_neighbors(self): self.assertDictEqual({}, contact_map_mod.child_dict) self.assertEqual(contact_map, contact_map_mod) - def test_rescale(self): - # ====================================================== - # Test Case 1 + def test_rescale_1(self): contact_map = ContactMap('test') for c in [Contact(1, 5, 1.0), Contact(3, 3, 0.4), Contact(2, 4, 0.1), Contact(5, 1, 0.2)]: contact_map.add(c) contact_map_rescaled = contact_map.rescale() self.assertListEqual([1.0, 0.333, 0.0, 0.111], [round(c.raw_score, 3) for c in contact_map_rescaled]) self.assertNotEqual(contact_map, contact_map_rescaled) - # ====================================================== - # Test Case 2 + + def test_rescale_2(self): contact_map = ContactMap('test') for c in [Contact(1, 5, 1.0), Contact(3, 3, 0.4), Contact(2, 4, 0.1), Contact(5, 1, 0.2)]: contact_map.add(c) @@ -783,33 +755,31 @@ def test_rescale(self): self.assertListEqual([1.0, 0.333, 0.0, 0.111], [round(c.raw_score, 3) for c in contact_map]) self.assertEqual(contact_map, contact_map_rescaled) - def test_sort(self): - # ====================================================== - # Test Case 1 + def test_sort_1(self): contact_map = ContactMap('test') for c in [Contact(1, 5, 1.0), Contact(3, 3, 0.4), Contact(2, 4, 0.1), Contact(5, 1, 0.2)]: contact_map.add(c) contact_map_sorted = contact_map.sort('res1_seq', reverse=False, inplace=False) self.assertEqual([(1, 5), (2, 4), (3, 3), (5, 1)], [c.id for c in contact_map_sorted]) self.assertNotEqual(contact_map, contact_map_sorted) - # ====================================================== - # Test Case 2 + + def test_sort_2(self): contact_map = ContactMap('test') for c in [Contact(1, 5, 1.0), Contact(3, 3, 0.4), Contact(2, 4, 0.1), Contact(5, 1, 0.2)]: contact_map.add(c) contact_map_sorted = contact_map.sort('res1_seq', reverse=True, inplace=False) self.assertEqual([(5, 1), (3, 3), (2, 4), (1, 5)], [c.id for c in contact_map_sorted]) self.assertNotEqual(contact_map, contact_map_sorted) - # ====================================================== - # Test Case 3 + + def test_sort_3(self): contact_map = ContactMap('test') for c in [Contact(1, 5, 1.0), Contact(3, 3, 0.4), Contact(2, 4, 0.1), Contact(5, 1, 0.2)]: contact_map.add(c) contact_map_sorted = contact_map.sort('raw_score', reverse=False, inplace=True) self.assertEqual([(2, 4), (5, 1), (3, 3), (1, 5)], [c.id for c in contact_map_sorted]) self.assertEqual(contact_map, contact_map_sorted) - # ====================================================== - # Test Case 4 + + def test_sort_4(self): contact_map = ContactMap('test') for c in [Contact(1, 5, 1.0), Contact(3, 3, 0.4), Contact(2, 4, 0.1), Contact(5, 1, 0.2)]: contact_map.add(c) @@ -817,11 +787,9 @@ def test_sort(self): self.assertEqual([(1, 5), (2, 4), (3, 3), (5, 1)], [c.id for c in contact_map_sorted]) self.assertEqual(contact_map, contact_map_sorted) - def test__adjust(self): - # ====================================================== - # Test Case 1 + def test__adjust_1(self): contact_map = ContactMap("test") - for contact in [Contact(1, 5, 1.0), Contact(3, 3, 0.4), Contact(2, 4, 0.1), + for contact in [Contact(1, 5, 1.0), Contact(3, 3, 0.4), Contact(2, 4, 0.1), Contact(1, 1, 0.2)]: contact_map.add(contact) contact.res1_altseq = contact.res1_seq @@ -833,8 +801,8 @@ def test__adjust(self): adjusted = ContactMap._adjust(contact_map, contact_map_keymap) self.assertEqual([1, 3, 2, 1], [c.res1_altseq for c in adjusted]) self.assertEqual([5, 3, 4, 1], [c.res2_altseq for c in adjusted]) - # ====================================================== - # Test Case 2 + + def test__adjust_2(self): contact_map = ContactMap("test") for contact in [Contact(1, 5, 1.0), Contact(2, 4, 0.1), Contact(1, 1, 0.2)]: contact_map.add(contact) @@ -848,9 +816,7 @@ def test__adjust(self): self.assertEqual([1, 2, 1], [c.res1_altseq for c in adjusted]) self.assertEqual([5, 4, 1], [c.res2_altseq for c in adjusted]) - def test__create_keymap(self): - # ====================================================== - # Test Case 1 + def test__create_keymap_1(self): contact_map = ContactMap("test") for contact in [Contact(1, 5, 1.0), Contact(3, 3, 0.4), Contact(2, 4, 0.1), Contact(1, 1, 0.2)]: @@ -861,8 +827,8 @@ def test__create_keymap(self): self.assertEqual([1, 2, 3, 4, 5], [c.res_seq for c in contact_map_keymap]) self.assertEqual(['A', 'B', 'C', 'D', 'E'], [c.res_name for c in contact_map_keymap]) self.assertEqual([0, 0, 0, 0, 0], [c.res_altseq for c in contact_map_keymap]) - # ====================================================== - # Test Case 2 + + def test__create_keymap_2(self): contact_map = ContactMap("test") for contact, res_altloc in [(Contact(1, 5, 1.0), (10, 20)), (Contact(3, 3, 0.4), (12, 12)), @@ -877,8 +843,8 @@ def test__create_keymap(self): self.assertEqual([1, 2, 3, 4, 5], [c.res_seq for c in contact_map_keymap]) self.assertEqual(['A', 'B', 'C', 'D', 'E'], [c.res_name for c in contact_map_keymap]) self.assertEqual([10, 11, 12, 13, 20], [c.res_altseq for c in contact_map_keymap]) - # ====================================================== - # Test Case 3 + + def test__create_keymap_3(self): contact_map = ContactMap("test") for contact, res_altloc in [(Contact(1, 5, 1.0), (10, 20)), (Contact(2, 4, 0.1), (11, 13)), @@ -893,9 +859,7 @@ def test__create_keymap(self): self.assertEqual(['A', 'B', 'D', 'E'], [c.res_name for c in contact_map_keymap]) self.assertEqual([10, 11, 13, 20], [c.res_altseq for c in contact_map_keymap]) - def test__find_single(self): - # ====================================================== - # Test Case 1 + def test__find_single_1(self): contact_map = ContactMap("test") for contact, res_altloc in [(Contact(1, 5, 1.0), (10, 20)), (Contact(2, 4, 0.1), (11, 13)), @@ -909,8 +873,8 @@ def test__find_single(self): self.assertEqual([(2, 4)], [c.id for c in found_contacts]) found_contacts = ContactMap._find_single(contact_map, 8) self.assertEqual([], list(found_contacts)) - # ====================================================== - # Test Case 2 + + def test__find_single_2(self): contact_map = ContactMap("test") for contact, res_altloc in [(Contact(1, 5, 1.0), (10, 20)), (Contact(2, 4, 0.1), (11, 13)), @@ -927,26 +891,22 @@ def test__find_single(self): found_contacts = ContactMap._find_single(contact_map, 4) self.assertEqual([(2, 4)], [c.id for c in found_contacts]) - def test__insert_states(self): - # ====================================================== - # Test Case 1 + def test__insert_states_1(self): keymap = [_Residue(1, 1, 'X', ''), _Residue(2, 2, 'X', ''), _Residue(3, 3, 'X', '')] - reindex = ContactMap._reindex(keymap) sequence = [ord(x) for x in 'XXX'] inserts_added = ContactMap._insert_states(sequence, keymap) self.assertEqual(3, len(inserts_added)) self.assertEqual([True, True, True], [isinstance(r, _Residue) for r in inserts_added]) - # ====================================================== - # Test Case 2 + + def test__insert_states_2(self): keymap = [_Residue(2, 2, 'X', ''), _Residue(3, 3, 'X', '')] - reindex = ContactMap._reindex(keymap) sequence = [ord(x) for x in '-XX'] inserts_added = ContactMap._insert_states(sequence, keymap) self.assertEqual(3, len(inserts_added)) self.assertEqual([False, True, True], [isinstance(r, _Residue) for r in inserts_added]) self.assertEqual([True, False, False], [isinstance(r, _Gap) for r in inserts_added]) - # ====================================================== - # Test Case 3 + + def test__insert_states_3(self): keymap = [_Residue(2, 10, 'X', ''), _Residue(3, 11, 'X', '')] sequence = [ord(x) for x in '-X-X--'] inserts_added = ContactMap._insert_states(sequence, keymap) @@ -956,33 +916,31 @@ def test__insert_states(self): self.assertEqual([2, 3], [r.res_seq for r in inserts_added if isinstance(r, _Residue)]) self.assertEqual([10, 11], [r.res_altseq for r in inserts_added if isinstance(r, _Residue)]) - def test__reindex(self): - # ====================================================== - # Test Case 1 + def test__reindex_1(self): keymap = [_Residue(1, 1, 'X', ''), _Residue(2, 2, 'X', ''), _Residue(3, 3, 'X', '')] reindex = ContactMap._reindex(keymap) self.assertEqual([1, 2, 3], [c.res_seq for c in reindex]) self.assertEqual([1, 2, 3], [c.res_altseq for c in reindex]) - # ====================================================== - # Test Case 2 + + def test__reindex_2(self): keymap = [_Residue(1, -5, 'X', ''), _Residue(2, -4, 'X', ''), _Residue(3, -3, 'X', '')] reindex = ContactMap._reindex(keymap) self.assertEqual([1, 2, 3], [c.res_seq for c in reindex]) self.assertEqual([1, 2, 3], [c.res_altseq for c in reindex]) - # ====================================================== - # Test Case 3 + + def test__reindex_3(self): keymap = [_Gap(), _Residue(2, 1, 'X', ''), _Residue(3, 2, 'X', '')] reindex = ContactMap._reindex(keymap) self.assertEqual([9999, 2, 3], [c.res_seq for c in reindex]) self.assertEqual([9999, 2, 3], [c.res_altseq for c in reindex]) - # ====================================================== - # Test Case 4 + + def test__reindex_4(self): keymap = [_Gap(), _Residue(200000, 10000, 'X', ''), _Gap(), _Gap()] reindex = ContactMap._reindex(keymap) self.assertEqual([9999, 200000, 9999, 9999], [c.res_seq for c in reindex]) self.assertEqual([9999, 2, 9999, 9999], [c.res_altseq for c in reindex]) - # ====================================================== - # Test Case 5 + + def test__reindex_5(self): keymap = [_Gap(), _Gap(), _Gap(), _Gap()] reindex = ContactMap._reindex(keymap) self.assertEqual([9999, 9999, 9999, 9999], [c.res_seq for c in reindex]) diff --git a/conkit/core/tests/test_Entity.py b/conkit/core/tests/test_Entity.py index ed9bc8be..a8f955b9 100644 --- a/conkit/core/tests/test_Entity.py +++ b/conkit/core/tests/test_Entity.py @@ -10,14 +10,12 @@ class Test(unittest.TestCase): - def test_contains(self): - # ====================================================== - # Test Case 1 + def test_contains_1(self): entity = Entity('test') entity.add(Entity('foo')) self.assertTrue('foo' in entity) - # ====================================================== - # Test Case 2 + + def test_contains_2(self): entity = Entity('test') entity.add(Entity('foo')) entity.add(Entity('bar')) @@ -25,15 +23,13 @@ def test_contains(self): self.assertTrue('bar' in entity) self.assertFalse('cho' in entity) - def test_delitem(self): - # ====================================================== - # Test Case 1 + def test_delitem_1(self): entity = Entity('test') entity.add(Entity('foo')) del entity['foo'] self.assertFalse('foo' in entity) - # ====================================================== - # Test Case 2 + + def test_delitem_2(self): entity = Entity('test') entity.add(Entity('foo')) entity.add(Entity('bar')) @@ -42,21 +38,19 @@ def test_delitem(self): self.assertTrue('bar' in entity) del entity['bar'] self.assertFalse('bar' in entity) - # ====================================================== - # Test Case 3 + + def test_delitem_3(self): entity = Entity('test') with self.assertRaises(KeyError): del entity['foo'] - def test_getitem(self): - # ====================================================== - # Test Case 1 + def test_getitem_1(self): entity = Entity('test') child_entity = Entity('foo') entity.add(child_entity) self.assertEqual(child_entity, entity['foo']) - # ====================================================== - # Test Case 2 + + def test_getitem_2(self): entity = Entity('test') child_entity1 = Entity('foo') child_entity2 = Entity('bar') @@ -64,8 +58,8 @@ def test_getitem(self): entity.add(child_entity2) self.assertEqual(child_entity1, entity['foo']) self.assertEqual(child_entity2, entity['bar']) - # ====================================================== - # Test Case 3 + + def test_getitem_3(self): entity = Entity('test') child_entity1 = Entity('foo') child_entity2 = Entity('bar') @@ -73,14 +67,14 @@ def test_getitem(self): entity.add(child_entity2) self.assertEqual(child_entity1, entity['foo']) self.assertEqual(child_entity2, entity['bar']) - # ====================================================== - # Test Case 4 + + def test_getitem_4(self): entity = Entity('test') child_entity1 = Entity('foo') entity.add(child_entity1) self.assertEqual(child_entity1, entity[0]) - # ====================================================== - # Test Case 4 + + def test_getitem_5(self): entity = Entity('test') child_entity1 = Entity('foo') child_entity2 = Entity('bar') @@ -92,8 +86,8 @@ def test_getitem(self): self.assertEqual(child_entity2, entity[1]) self.assertEqual(child_entity2, entity[-2]) self.assertEqual(child_entity3, entity[-1]) - # ====================================================== - # Test Case 5 + + def test_getitem_6(self): entity = Entity('test') for i in range(10): entity.add(Entity('foo_{0}'.format(i))) @@ -101,8 +95,8 @@ def test_getitem(self): self.assertEqual(type(entity), type(new_entity)) self.assertEqual(5, len(new_entity)) self.assertEqual(['foo_0', 'foo_1', 'foo_2', 'foo_3', 'foo_4'], [e.id for e in new_entity]) - # ====================================================== - # Test Case 6 + + def test_getitem_7(self): entity = Entity('test') for i in range(10): entity.add(Entity('foo_{0}'.format(i))) @@ -111,30 +105,24 @@ def test_getitem(self): self.assertEqual(5, len(new_entity)) self.assertEqual(['foo_1', 'foo_3', 'foo_5', 'foo_7', 'foo_9'], [e.id for e in new_entity]) - def test_iter(self): - # ====================================================== - # Test Case 1 + def test_iter_1(self): entity = Entity('test') for i in range(10): entity.add(Entity('foo_{0}'.format(i))) for i, e in enumerate(entity): self.assertEqual('foo_{0}'.format(i), e.id) - def test_len(self): - # ====================================================== - # Test Case 1 + def test_len_1(self): entity = Entity('test') for i in range(10): entity.add(Entity('foo_{0}'.format(i))) self.assertEqual(10, len(entity)) - # ====================================================== - # Test Case 2 + + def test_len_2(self): entity = Entity('test') self.assertEqual(0, len(entity)) - def test_reversed(self): - # ====================================================== - # Test Case 1 + def test_reversed_1(self): entity = Entity('test') for i in range(10): entity.add(Entity('foo_{0}'.format(i))) @@ -143,16 +131,14 @@ def test_reversed(self): self.assertNotEqual('foo_{0}'.format(i), e.id) self.assertEqual('foo_{0}'.format(rev[i]), e.id) - def test_child_list(self): - # ====================================================== - # Test Case 1 + def test_child_list_1(self): entity = Entity('test') child_entity1 = Entity('foo') entity.add(child_entity1) self.assertEqual(1, len(entity.child_list)) self.assertEqual([child_entity1], entity.child_list) - # ====================================================== - # Test Case 2 + + def test_child_list_2(self): entity = Entity('test') child_entity1 = Entity('foo') child_entity2 = Entity('bar') @@ -161,15 +147,13 @@ def test_child_list(self): self.assertEqual(2, len(entity.child_list)) self.assertEqual([child_entity1, child_entity2], entity.child_list) - def test_child_dict(self): - # ====================================================== - # Test Case 1 + def test_child_dict_1(self): entity = Entity('test') child_entity1 = Entity('foo') entity.add(child_entity1) self.assertDictEqual({'foo': child_entity1}, entity.child_dict) - # ====================================================== - # Test Case 2 + + def test_child_dict_2(self): entity = Entity('test') child_entity1 = Entity('foo') child_entity2 = Entity('bar') @@ -177,24 +161,22 @@ def test_child_dict(self): entity.add(child_entity2) self.assertDictEqual({'foo': child_entity1, 'bar': child_entity2}, entity.child_dict) - def test_full_id(self): - # ====================================================== - # Test Case 1 + def test_full_id_1(self): entity = Entity('test') entity.add(Entity('foo')) self.assertEqual(('test', 'foo'), entity[0].full_id) - # ====================================================== - # Test Case 2 + + def test_full_id_2(self): entity = Entity('test') self.assertEqual(('test',), entity.full_id) - # ====================================================== - # Test Case 3 + + def test_full_id_3(self): entity = Entity('test') entity.add(Entity('foo')) entity[0].add(Entity('bar')) self.assertEqual(('test', 'foo', 'bar'), entity[0][0].full_id) - # ====================================================== - # Test Case 4 + + def test_full_id_4(self): entity = Entity('test') entity.add(Entity('foo')) entity[0].add(Entity('bar')) @@ -202,31 +184,23 @@ def test_full_id(self): self.assertEqual(('test', 'foo', 'bar'), entity[0][0].full_id) self.assertEqual(('test', 'foo', 'cho'), entity[0][1].full_id) - def test_id(self): - # ====================================================== - # Test Case 1 + def test_id_1(self): entity = Entity('test') self.assertEqual('test', entity.id) - # ====================================================== - # Test Case 2 - # self.assertRaises(TypeError, Entity, 3) - # self.assertRaises(TypeError, Entity, 1.0) - # ====================================================== - # Test Case 3 + + def test_id_2(self): entity = Entity((1, 2)) self.assertEqual((1, 2), entity.id) - # ====================================================== - # Test Case 4 + + def test_id_3(self): entity = Entity([1, 2]) self.assertEqual((1, 2), entity.id) - # ====================================================== - # Test Case 5 + + def test_id_4(self): entity = Entity((1., 2.)) self.assertEqual((1., 2.), entity.id) - def test_parent(self): - # ====================================================== - # Test Case 1 + def test_parent_1(self): entity = Entity('test') child_entity = Entity('foo') entity.add(child_entity) @@ -238,52 +212,46 @@ def test_parent(self): self.assertEqual(child_entity, entity[0][0].parent) self.assertEqual(child_entity, entity[0][1].parent) - def test__inplace(self): - # ====================================================== - # Test Case 1 + def test__inplace_1(self): entity = Entity('foo') entity_inplace = entity._inplace(True) self.assertEqual(entity, entity_inplace) - # ====================================================== - # Test Case 2 + + def test__inplace_2(self): entity = Entity('foo') entity_inplace = entity._inplace(False) self.assertNotEqual(entity, entity_inplace) - def test__sort(self): - # ====================================================== - # Test Case 1 + def test__sort_1(self): entity = Entity('test') entity.add(Entity('foo')) entity.add(Entity('bar')) entity._sort('id', False) self.assertEqual(['bar', 'foo'], [e.id for e in entity]) - # ====================================================== - # Test Case 2 + + def test__sort_2(self): entity = Entity('test') entity.add(Entity('foo')) entity.add(Entity('bar')) entity._sort('id', True) self.assertEqual(['foo', 'bar'], [e.id for e in entity]) - # ====================================================== - # Test Case 3 + + def test__sort_3(self): entity = Entity('test') entity.add(Entity('foo')) entity.add(Entity('bar')) with self.assertRaises(ValueError): entity._sort('test', True) - def test_add(self): - # ====================================================== - # Test Case 1 + def test_add_1(self): entity = Entity('test') self.assertFalse('foo' in entity.child_dict) child_entity = Entity('foo') entity.add(child_entity) self.assertTrue(child_entity in entity.child_list) self.assertTrue('foo' in entity.child_dict) - # ====================================================== - # Test Case 2 + + def test_add_2(self): entity = Entity('test') child_entity = Entity('foo') entity.add(child_entity) @@ -292,9 +260,7 @@ def test_add(self): with self.assertRaises(ValueError): entity.add(Entity('foo')) - def test_copy(self): - # ====================================================== - # Test Case 1 + def test_copy_1(self): entity = Entity('test') entity.add(Entity('foo')) shallow = entity.copy() @@ -302,8 +268,8 @@ def test_copy(self): self.assertTrue(entity.id, shallow.id) self.assertNotEqual(entity[0], shallow[0]) self.assertEqual(entity[0].id, shallow[0].id) - # ====================================================== - # Test Case 2 + + def test_copy_2(self): entity = Entity('test') entity.add(Entity('foo')) shallow = entity[0].copy() @@ -312,9 +278,7 @@ def test_copy(self): self.assertIsNone(shallow.parent) self.assertEqual('foo', entity[0].id) - def test_deepcopy(self): - # ====================================================== - # Test Case 1 + def test_deepcopy_1(self): entity = Entity('test') entity.add(Entity('foo')) deep = entity.deepcopy() @@ -322,8 +286,8 @@ def test_deepcopy(self): self.assertTrue(entity.id, deep.id) self.assertNotEqual(entity[0], deep[0]) self.assertEqual(entity[0].id, deep[0].id) - # ====================================================== - # Test Case 2 + + def test_deepcopy_2(self): entity = Entity('test') entity.add(Entity('foo')) deep = entity[0].deepcopy() @@ -332,15 +296,13 @@ def test_deepcopy(self): self.assertIsNone(deep.parent) self.assertEqual('foo', entity[0].id) - def test_remove(self): - # ====================================================== - # Test Case 1 + def test_remove_1(self): entity = Entity('test') entity.add(Entity('foo')) entity.remove('foo') self.assertFalse('foo' in entity) - # ====================================================== - # Test Case 2 + + def test_remove_2(self): entity = Entity('test') entity.add(Entity('foo')) entity.add(Entity('bar')) @@ -349,8 +311,8 @@ def test_remove(self): self.assertTrue('bar' in entity) entity.remove('bar') self.assertFalse('bar' in entity) - # ====================================================== - # Test Case 3 + + def test_remove_3(self): entity = Entity('test') with self.assertRaises(KeyError): entity.remove('foo') diff --git a/conkit/core/tests/test_Sequence.py b/conkit/core/tests/test_Sequence.py index 743bd89c..bcac115f 100644 --- a/conkit/core/tests/test_Sequence.py +++ b/conkit/core/tests/test_Sequence.py @@ -10,50 +10,44 @@ class Test(unittest.TestCase): - def test_remark(self): - # ====================================================== - # Test Case 1 + def test_remark_1(self): sequence = Sequence('foo', 'GSMFTPK') sequence.remark = 'bar' self.assertEqual(['bar'], sequence.remark) - # ====================================================== - # Test Case 2 + + def test_remark_2(self): sequence = Sequence('foo', 'GSMFTPK') sequence.remark = 'bar' sequence.remark = 'baz' self.assertEqual(['bar', 'baz'], sequence.remark) - def test_seq(self): - # ====================================================== - # Test Case 1 + def test_seq_1(self): sequence = Sequence('foo', 'GSMFTPK') self.assertEqual('foo', sequence.id) self.assertEqual('GSMFTPK', sequence.seq) - # ====================================================== - # Test Case 2 + + def test_seq_2(self): sequence = Sequence('foo', 'GSMFTPK') sequence.seq = 'AAAAAA' self.assertEqual('foo', sequence.id) self.assertEqual('AAAAAA', sequence.seq) - # ====================================================== - # Test Case 3 + + def test_seq_3(self): sequence = Sequence('foo', 'GSMFTPK') with self.assertRaises(ValueError): sequence.seq = 'A2A' - # ====================================================== - # Test Case 3 + + def test_seq_4(self): sequence = Sequence('foo', 'GSMFTPK') sequence.seq = '-------' - def test_seq_len(self): - # ====================================================== - # Test Case 1 + def test_seq_len_1(self): sequence = Sequence('foo', 'GSMFTPK') self.assertEqual('foo', sequence.id) self.assertEqual('GSMFTPK', sequence.seq) self.assertEqual(7, sequence.seq_len) - # ====================================================== - # Test Case 2 + + def test_seq_len_2(self): sequence = Sequence('foo', 'GSMFTPK') self.assertEqual('foo', sequence.id) self.assertEqual('GSMFTPK', sequence.seq) @@ -63,9 +57,7 @@ def test_seq_len(self): self.assertEqual('AAAAAAAAAA', sequence.seq) self.assertEqual(10, sequence.seq_len) - def test_align_local(self): - # ====================================================== - # Test Case 1 + def test_align_local_1(self): sequence1 = Sequence('foo', 'GSMFTPKPPQDSAVIKAGYCVKQGAVMKNWKRRYFQLDENTI' 'GYFKSELEKEPLRVIPLKEVHKVQECKQSDIMMRDNLFEIVT' 'TSRTFYVQADSPEEMHSWIKAVSGAIVAQRGPGRSASSEHP') @@ -78,8 +70,8 @@ def test_align_local(self): "----F----------VQADSPEEMHSWIKAVSGAIVAQR-----------" self.assertEqual(aligned1, sequence1.seq) self.assertEqual(aligned2, sequence2.seq) - # ====================================================== - # Test Case 2 + + def test_align_local_2(self): sequence1 = Sequence('foo', 'DDLTISSLAKGETTKAAFNQMVQGHKLPAWVMKGGTYTPAQTV' 'TLGDETYQVMSACKPHDCGSQRIAVMWSEKSNQMTGLFSTIDE' 'KTSQEKLTWLNVNDALSIDGKTVLFAALTGSLENHPDGFNFKV' @@ -103,8 +95,8 @@ def test_align_local(self): "----NG--------------D----IRGC-" self.assertEqual(aligned1, sequence1.seq) self.assertEqual(aligned2, sequence2.seq) - # ====================================================== - # Test Case 3 + + def test_align_local_3(self): sequence1 = Sequence('foo', '------------------------------------------' '------------------------------------------' '----------W------------TV-----------------' diff --git a/conkit/core/tests/test_SequenceFile.py b/conkit/core/tests/test_SequenceFile.py index 4adbfcbc..b002736e 100644 --- a/conkit/core/tests/test_SequenceFile.py +++ b/conkit/core/tests/test_SequenceFile.py @@ -12,63 +12,57 @@ class Test(unittest.TestCase): - def test_is_alignment(self): - # ====================================================== - # Test Case 1 + def test_is_alignment_1(self): sequence_file = SequenceFile('test') sequence_file.add(Sequence('foo', 'AAAAA')) sequence_file.add(Sequence('bar', 'BBBBB')) self.assertTrue(sequence_file.is_alignment) - # ====================================================== - # Test Case 2 + + def test_is_alignment_2(self): sequence_file = SequenceFile('test') sequence_file.add(Sequence('foo', 'AAAAA')) sequence_file.add(Sequence('bar', 'BBBB')) self.assertFalse(sequence_file.is_alignment) - def test_nseqs(self): - # ====================================================== - # Test Case 1 + def test_nseqs_1(self): sequence_file = SequenceFile('test') self.assertEqual(0, sequence_file.nseqs) - # ====================================================== - # Test Case 2 + + def test_nseqs_2(self): sequence_file = SequenceFile('test') sequence_file.add(Sequence('foo', 'AAAAA')) self.assertEqual(1, sequence_file.nseqs) - # ====================================================== - # Test Case 3 + + def test_nseqs_3(self): sequence_file = SequenceFile('test') sequence_file.add(Sequence('foo', 'AAAAA')) sequence_file.add(Sequence('bar', 'BBBBB')) self.assertEqual(2, sequence_file.nseqs) - def test_remark(self): - # ====================================================== - # Test Case 1 + def test_remark_1(self): sequence_file = SequenceFile('test') sequence_file.remark = 'Hello' self.assertEqual(['Hello'], sequence_file.remark) - # ====================================================== - # Test Case 2 + + def test_remark_2(self): sequence_file = SequenceFile('test') sequence_file.remark = 'Hello' sequence_file.remark = 'World' self.assertEqual(['Hello', 'World'], sequence_file.remark) - # ====================================================== - # Test Case 3 + + def test_remark_3(self): sequence_file = SequenceFile('test') sequence_file.remark = 'Hello' sequence_file.remark = '5' sequence_file.remark = 'World' sequence_file.remark = '!' self.assertEqual(['Hello', '5', 'World', '!'], sequence_file.remark) - # ====================================================== - # Test Case 4 + + def test_remark_4(self): sequence_file = SequenceFile('test') self.assertEqual([], sequence_file.remark) - # ====================================================== - # Test Case 5 + + def test_remark_5(self): sequence_file = SequenceFile('test') sequence_file.remark = 'hello' sequence = Sequence('foo', 'GSMFTPK') @@ -77,19 +71,17 @@ def test_remark(self): self.assertEqual(['hello'], sequence_file.remark) self.assertEqual(['bar'], sequence_file[0].remark) - def test_top_sequence(self): - # ====================================================== - # Test Case 1 + def test_top_sequence_1(self): sequence_file = SequenceFile('test') self.assertEqual(None, sequence_file.top_sequence) - # ====================================================== - # Test Case 2 + + def test_top_sequence_2(self): sequence_file = SequenceFile('test') sequence1 = Sequence('foo', 'AAAAA') sequence_file.add(sequence1) self.assertEqual(sequence1, sequence_file.top_sequence) - # ====================================================== - # Test Case 3 + + def test_top_sequence_3(self): sequence_file = SequenceFile('test') sequence1 = Sequence('foo', 'AAAAA') sequence2 = Sequence('bar', 'BBBBB') @@ -98,9 +90,7 @@ def test_top_sequence(self): self.assertEqual(sequence1, sequence_file.top_sequence) @unittest.skipUnless(SCIPY, "SciPy not installed") - def test_calculate_meff(self): - # ====================================================== - # Test Case 1 + def test_calculate_meff_1(self): sequence_file = SequenceFile('test') for s in [Sequence('foo', 'AAAAAAA'), Sequence('bar', 'AAAAAAA'), Sequence('cho', 'AAAAAAA'), Sequence('baz', 'AAAAAAA')]: @@ -108,8 +98,9 @@ def test_calculate_meff(self): m_eff = sequence_file.calculate_meff(identity=0.7) self.assertTrue(isinstance(m_eff, int)) self.assertEqual(1, m_eff) - # ====================================================== - # Test Case 2 + + @unittest.skipUnless(SCIPY, "SciPy not installed") + def test_calculate_meff_2(self): sequence_file = SequenceFile('test') for s in [Sequence('foo', 'AAAAAAA'), Sequence('bar', 'AAAAAAA'), Sequence('cho', 'AAAAAAA'), Sequence('baz', 'BBBBBBB')]: @@ -117,8 +108,9 @@ def test_calculate_meff(self): m_eff = sequence_file.calculate_meff(identity=0.7) self.assertTrue(isinstance(m_eff, int)) self.assertEqual(2, m_eff) - # ====================================================== - # Test Case 3 + + @unittest.skipUnless(SCIPY, "SciPy not installed") + def test_calculate_meff_3(self): sequence_file = SequenceFile('test') for s in [Sequence('foo', 'AAAAAAA'), Sequence('bar', 'A-AABA-'), Sequence('cho', 'B-BAA--'), Sequence('baz', 'BBBBBBB')]: @@ -126,8 +118,9 @@ def test_calculate_meff(self): m_eff = sequence_file.calculate_meff(identity=0.7) self.assertTrue(isinstance(m_eff, int)) self.assertEqual(4, m_eff) - # ====================================================== - # Test Case 4 + + @unittest.skipUnless(SCIPY, "SciPy not installed") + def test_calculate_meff_4(self): sequence_file = SequenceFile('test') for s in [Sequence('foo', 'AAAAAAA'), Sequence('bar', 'AAAABA-'), Sequence('cho', 'B-BAA--'), Sequence('baz', 'BBBBBBB')]: @@ -135,8 +128,9 @@ def test_calculate_meff(self): m_eff = sequence_file.calculate_meff(identity=0.7) self.assertTrue(isinstance(m_eff, int)) self.assertEqual(3, m_eff) - # ====================================================== - # Test Case 5 + + @unittest.skipUnless(SCIPY, "SciPy not installed") + def test_calculate_meff_5(self): sequence_file = SequenceFile('test') for s in [Sequence('foo', 'AAAAAAA'), Sequence('bar', 'AA-ABA-'), Sequence('cho', 'B-BAA--'), Sequence('baz', 'BBBBBBB')]: @@ -146,8 +140,9 @@ def test_calculate_meff(self): self.assertEqual(4, m_eff) self.assertNotEqual(3, m_eff) self.assertNotEqual(3, m_eff) - # ====================================================== - # Test Case 5 + + @unittest.skipUnless(SCIPY, "SciPy not installed") + def test_calculate_meff_6(self): sequence_file = SequenceFile('test') for s in [Sequence('foo', 'AAAAAAA'), Sequence('bar', 'AA-ABA-'), Sequence('cho', 'AAACBAA'), Sequence('doo', 'B-BAA--'), @@ -157,32 +152,28 @@ def test_calculate_meff(self): self.assertTrue(isinstance(m_eff, int)) self.assertEqual(4, m_eff) - def test_calculate_freq(self): - # ====================================================== - # Test Case 1 + def test_calculate_freq_1(self): sequence_file = SequenceFile('test') for s in [Sequence('foo', 'AAAAAAA'), Sequence('bar', 'A-AAAA-'), Sequence('cho', '--AAA--')]: sequence_file.add(s) calculated_freqs = [round(i, 6) for i in sequence_file.calculate_freq()] self.assertEqual([0.666667, 0.333333, 1.0, 1.0, 1.0, 0.666667, 0.333333], calculated_freqs) - # ====================================================== - # Test Case 2 + + def test_calculate_freq_2(self): sequence_file = SequenceFile('test') for s in [Sequence('foo', '-------'), Sequence('bar', '-------'), Sequence('cho', '-------')]: sequence_file.add(s) calculated_freqs = [round(i, 6) for i in sequence_file.calculate_freq()] self.assertEqual([0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], calculated_freqs) - # ====================================================== - # Test Case 3 + + def test_calculate_freq_3(self): sequence_file = SequenceFile('test') for s in [Sequence('foo', 'AAAAAAA'), Sequence('bar', 'AAAAAAA'), Sequence('cho', 'AAAAAAA')]: sequence_file.add(s) calculated_freqs = [round(i, 6) for i in sequence_file.calculate_freq()] self.assertEqual([1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0], calculated_freqs) - def test_sort(self): - # ====================================================== - # Test Case 1 + def test_sort_1(self): sequence_file = SequenceFile('test') for seq in [Sequence('foo', 'AAAAA'), Sequence('bar', 'BBBBB'), Sequence('doe', 'CCCCC')]: sequence_file.add(seq) @@ -190,8 +181,8 @@ def test_sort(self): self.assertEqual(['bar', 'doe', 'foo'], [s.id for s in sequence_file_sorted]) self.assertEqual(['BBBBB', 'CCCCC', 'AAAAA'], [s.seq for s in sequence_file_sorted]) self.assertNotEqual(sequence_file, sequence_file_sorted) - # ====================================================== - # Test Case 2 + + def test_sort_2(self): sequence_file = SequenceFile('test') for seq in [Sequence('foo', 'AAAAA'), Sequence('bar', 'BBBBB'), Sequence('doe', 'CCCCC')]: sequence_file.add(seq) @@ -199,8 +190,8 @@ def test_sort(self): self.assertEqual(['foo', 'doe', 'bar'], [s.id for s in sequence_file_sorted]) self.assertEqual(['AAAAA', 'CCCCC', 'BBBBB'], [s.seq for s in sequence_file_sorted]) self.assertNotEqual(sequence_file, sequence_file_sorted) - # ====================================================== - # Test Case 3 + + def test_sort_3(self): sequence_file = SequenceFile('test') for seq in [Sequence('foo', 'AAAAA'), Sequence('bar', 'BBBBB'), Sequence('doe', 'CCCCC')]: sequence_file.add(seq) @@ -208,8 +199,8 @@ def test_sort(self): self.assertEqual(['foo', 'bar', 'doe'], [s.id for s in sequence_file_sorted]) self.assertEqual(['AAAAA', 'BBBBB', 'CCCCC'], [s.seq for s in sequence_file_sorted]) self.assertEqual(sequence_file, sequence_file_sorted) - # ====================================================== - # Test Case 4 + + def test_sort_4(self): sequence_file = SequenceFile('test') for seq in [Sequence('foo', 'AAAAA'), Sequence('bar', 'BBBBB'), Sequence('doe', 'CCCCC')]: sequence_file.add(seq) @@ -218,9 +209,7 @@ def test_sort(self): self.assertEqual(['CCCCC', 'BBBBB', 'AAAAA'], [s.seq for s in sequence_file_sorted]) self.assertEqual(sequence_file, sequence_file_sorted) - def test_trim(self): - # ====================================================== - # Test Case 1 + def test_trim_1(self): sequence_file = SequenceFile('test') for seq in [Sequence('foo', 'AAAAA'), Sequence('bar', 'BBBBB'), Sequence('doe', 'CCCCC')]: sequence_file.add(seq) @@ -228,8 +217,8 @@ def test_trim(self): self.assertEqual(['foo', 'bar', 'doe'], [s.id for s in sequence_file_trimmed]) self.assertEqual(['AAAAA', 'BBBBB', 'CCCCC'], [s.seq for s in sequence_file_trimmed]) self.assertNotEqual(sequence_file, sequence_file_trimmed) - # ====================================================== - # Test Case 2 + + def test_trim_2(self): sequence_file = SequenceFile('test') for seq in [Sequence('foo', 'AAAAA'), Sequence('bar', 'BBBBB'), Sequence('doe', 'CCCCC')]: sequence_file.add(seq) @@ -237,8 +226,8 @@ def test_trim(self): self.assertEqual(['foo', 'bar', 'doe'], [s.id for s in sequence_file_trimmed]) self.assertEqual(['AAA', 'BBB', 'CCC'], [s.seq for s in sequence_file_trimmed]) self.assertNotEqual(sequence_file, sequence_file_trimmed) - # ====================================================== - # Test Case 3 + + def test_trim_3(self): sequence_file = SequenceFile('test') for seq in [Sequence('foo', 'ABCDE'), Sequence('bar', 'BCDEF'), Sequence('doe', 'CDEFG')]: sequence_file.add(seq) @@ -246,8 +235,8 @@ def test_trim(self): self.assertEqual(['foo', 'bar', 'doe'], [s.id for s in sequence_file_trimmed]) self.assertEqual(['ABC', 'BCD', 'CDE'], [s.seq for s in sequence_file_trimmed]) self.assertNotEqual(sequence_file, sequence_file_trimmed) - # ====================================================== - # Test Case 4 + + def test_trim_4(self): sequence_file = SequenceFile('test') for seq in [Sequence('foo', 'ABCDE'), Sequence('bar', 'BCDEF'), Sequence('doe', 'CDEFG')]: sequence_file.add(seq) diff --git a/conkit/io/tests/test_A3mIO.py b/conkit/io/tests/test_A3mIO.py index e5dcbdbe..6ac4607a 100644 --- a/conkit/io/tests/test_A3mIO.py +++ b/conkit/io/tests/test_A3mIO.py @@ -12,9 +12,7 @@ class Test(unittest.TestCase): - def test_read(self): - # ================================================== - # Normal sequence only mode - remove_insert == TRUE + def test_read_1(self): msa = """>d1a1x__ b.63.1.1 (-) p13-MTCP1 {Human (Homo sapiens)} PPDHLWVHQEGIYRDEYQRTWVAVVEEETSFLRARVQQIQVPLGDAARPSHLLTSQL >gi|6678257|ref|NP_033363.1|:(7-103) T-cell lymphoma breakpoint 1 [Mus musculus] @@ -91,11 +89,9 @@ def test_read(self): sequence_entry.id) self.assertEqual('---------PGFYEDEHHRLWMVAKLETCSHSPVHLWQMTRYPQEPAPYNPMNYNFL', sequence_entry.seq) - del parser, sequence_file, sequence_entry os.unlink(f_name) - # ================================================== - # Normal sequence only mode - remove_insert == FALSE + def test_read_2(self): msa = """>d1a1x__ b.63.1.1 (-) p13-MTCP1 {Human (Homo sapiens)} PPDHLWVHQEGIYRDEYQRTWVAVVEEETSFLRARVQQIQVPLGDAARPSHLLTSQL >gi|6678257|ref|NP_033363.1|:(7-103) T-cell lymphoma breakpoint 1 [Mus musculus] @@ -174,11 +170,9 @@ def test_read(self): sequence_entry.id) self.assertEqual('---------PGFYEDEHHRLWMVAKLE--T--C--SH---------SPycnkietcvtVHLWQMTRYPQ-------EPAPYNPMNYN-----FL', sequence_entry.seq) - del parser, sequence_file, sequence_entry os.unlink(f_name) - # ================================================== - # Normal sequence only mode - Duplicate entries + def test_read_3(self): msa = """>d1a1x__ b.63.1.1 (-) p13-MTCP1 {Human (Homo sapiens)} PPDHLWVHQEGIYRDEYQRTWVAVVEEETSFLRARVQQIQVPLGDAARPSHLLTSQL >gi|6678257|ref|NP_033363.1|:(7-103) T-cell lymphoma breakpoint 1 [Mus musculus] @@ -216,13 +210,9 @@ def test_read(self): self.assertGreater(79, len(sequence_entry.id)) self.assertEqual('HPNRLWIWEKHVYLDEFRRSWLPVVIKSNEKFQVILRQEDVTLGEAMSPSQLVPYEL', sequence_entry.seq) - - del parser, sequence_file, sequence_entry os.unlink(f_name) - def test_write(self): - # ================================================== - # Multiple sequence alignment - remove_insert == True + def test_write_1(self): msa = [ ">d1a1x__ b.63.1.1 (-) p13-MTCP1 {Human (Homo sapiens)}", "PPDHLWVHQEGIYRDEYQRTWVAVVEEETSFLRARVQQIQVPLGDAARPSHLLTSQL", @@ -279,12 +269,10 @@ def test_write(self): with open(f_name_out, 'r') as f_in: output = "".join(f_in.readlines()) self.assertEqual(ref, output) - del parser, sequence_file os.unlink(f_name_in) os.unlink(f_name_out) - # ================================================== - # Multiple sequence alignment - remove_insert == False + def test_write_2(self): msa = [ ">d1a1x__ b.63.1.1 (-) p13-MTCP1 {Human (Homo sapiens)}", "PPDHLWVHQEGIYRDEYQRTWVAVVEEETSFLRARVQQIQVPLGDAARPSHLLTSQL", @@ -341,7 +329,6 @@ def test_write(self): with open(f_name_out, 'r') as f_in: output = "".join(f_in.readlines()) self.assertEqual(ref, output) - del parser, sequence_file os.unlink(f_name_in) os.unlink(f_name_out) diff --git a/conkit/io/tests/test_BCLContactIO.py b/conkit/io/tests/test_BCLContactIO.py index 2aab37b1..73a002e6 100644 --- a/conkit/io/tests/test_BCLContactIO.py +++ b/conkit/io/tests/test_BCLContactIO.py @@ -12,9 +12,7 @@ class Test(unittest.TestCase): - def test_read(self): - # ================================================== - # Test Case 1 + def test_read_1(self): content = """5 I 9 Q 0.000 0.286 0.185 0.836 0.875 0.749 5 I 10 R 0.000 0.000 0.105 0.875 0.482 0.634 5 I 11 I 0.000 0.178 0.066 0.730 0.876 0.727 diff --git a/conkit/io/tests/test_BbcontactsIO.py b/conkit/io/tests/test_BbcontactsIO.py index b651a326..0840e22b 100644 --- a/conkit/io/tests/test_BbcontactsIO.py +++ b/conkit/io/tests/test_BbcontactsIO.py @@ -12,9 +12,7 @@ class Test(unittest.TestCase): - def test_read(self): - # ================================================== - # Test Case 1 + def test_read_1(self): content = """#identifier diversity direction viterbiscore indexpred state res1 res2 1EAZ 0.65 Antiparallel 9.860725 1 first 29 24 1EAZ 0.65 Antiparallel 9.860725 1 internal 30 23 diff --git a/conkit/io/tests/test_CCMpredIO.py b/conkit/io/tests/test_CCMpredIO.py index a87000c1..5e4515f9 100644 --- a/conkit/io/tests/test_CCMpredIO.py +++ b/conkit/io/tests/test_CCMpredIO.py @@ -17,9 +17,7 @@ class Test(unittest.TestCase): - def test_read(self): - # ====================================================== - # Test Case 1 + def test_read_1(self): content = """0.00000000000000000000e+00 9.05865192413330078125e-01 4.48399752378463745117e-01 3.83993983268737792969e-02 7.80840754508972167969e-01 5.15280842781066894531e-01 2.66545146703720092773e-01 4.99921828508377075195e-01 4.54095661640167236328e-01 7.60651350021362304688e-01 9.05863702297210693359e-01 0.00000000000000000000e+00 7.22257912158966064453e-01 1.90076664090156555176e-01 1.08203485608100891113e-01 1.23369038105010986328e-01 5.28753221035003662109e-01 3.98827701807022094727e-01 7.34628140926361083984e-01 5.52688777446746826172e-01 4.48399752378463745117e-01 7.22256183624267578125e-01 0.00000000000000000000e+00 1.39001503586769104004e-01 8.06087076663970947266e-01 4.15808916091918945312e-01 3.66488158702850341797e-01 5.48547744750976562500e-01 3.75738739967346191406e-01 6.22575163841247558594e-01 @@ -56,9 +54,7 @@ def test_read(self): ) os.unlink(f_name) - def test_write(self): - # ====================================================== - # Test Case 1 + def test_write_1(self): contact_file = ContactFile('test') contact_map = ContactMap('1') contact_file.add(contact_map) @@ -88,8 +84,8 @@ def test_write(self): data = "".join(f_in.readlines()) self.assertEqual(content, data) os.unlink(f_name) - # ====================================================== - # Test Case 2 + + def test_write_2(self): contact_file = ContactFile('test') contact_map = ContactMap('1') contact_file.add(contact_map) diff --git a/conkit/io/tests/test_CaspIO.py b/conkit/io/tests/test_CaspIO.py index 4b3c87af..0936e54a 100644 --- a/conkit/io/tests/test_CaspIO.py +++ b/conkit/io/tests/test_CaspIO.py @@ -16,9 +16,7 @@ class Test(unittest.TestCase): - def test_read(self): - # ====================================================== - # Test Case 1 + def test_read_1(self): content = """PFRMAT RR TARGET R9999 AUTHOR 1234-5678-9000 @@ -49,8 +47,7 @@ def test_read(self): self.assertEqual("HLEG-IGILL-K-E-------------------", contact_map1.repr_sequence.seq) os.unlink(f_name) - # ====================================================== - # Test Case 2 + def test_read_2(self): content = """PFRMAT RR TARGET R9999 AUTHOR 1234-5678-9000 @@ -79,8 +76,7 @@ def test_read(self): _ = contact_map1.repr_sequence os.unlink(f_name) - # ====================================================== - # Test Case 3 + def test_read_3(self): content = """PFRMAT RR MODEL 1 1 9 0 8 0.70 @@ -105,8 +101,7 @@ def test_read(self): _ = contact_map1.repr_sequence os.unlink(f_name) - # ====================================================== - # Test Case 4 + def test_read_4(self): content = """PFRMAT RR TARGET R9999 AUTHOR 1234-5678-9000 @@ -154,8 +149,7 @@ def test_read(self): self.assertEqual("HLEG-IGILL-K-E-----------------", contact_map2.repr_sequence.seq) os.unlink(f_name) - # ====================================================== - # Test Case 5 + def test_read_5(self): content = """PFRMAT RR TARGET R9999 MODEL 1 @@ -196,8 +190,7 @@ def test_read(self): self.assertEqual("HLEG-IGILL-K-E-------------------", contact_map2.repr_sequence.seq) os.unlink(f_name) - # ====================================================== - # Test Case 6 + def test_read_6(self): content = """1 9 0 8 0.70 1 10 0 8 0.70 1 12 0 8 0.60 @@ -215,47 +208,45 @@ def test_read(self): CaspParser().read(f_in) os.unlink(f_name) -# # ====================================================== -# # Test Case 7 -# content = """PFRMAT RR -# TARGET R9999 -# AUTHOR 1234-5678-9000 -# REMARK Predictor remarks -# METHOD Description of methods used -# METHOD Description of methods used -# MODEL 1 -# HLEGSIGILLKKHEIVFDGC -# HDFGRTYIWQMSD -# A1 B9 0 8 0.70 -# A1 B10 0 8 0.70 -# A1 B12 0 8 0.60 -# A1 B14 0 8 0.20 -# A1 B15 0 8 0.10 -# A1 B17 0 8 0.30 -# A1 B19 0 8 0.50 -# A2 B8 0 8 0.90 -# A3 B7 0 8 0.70 -# A3 B12 0 8 0.40 -# A3 B14 0 8 0.70 -# A3 B15 0 8 0.30 -# A4 B6 0 8 0.90 -# A7 B14 0 8 0.30 -# A9 B14 0 8 0.50 -# END -# """ -# f_name = create_tmp_f(content=content) -# with open(f_name, 'r') as f_in: -# contact_file = CaspParser().read(f_in) -# contact_map1 = contact_file.top_map -# self.assertEqual(1, len(contact_file)) -# self.assertEqual(15, len(contact_map1)) -# self.assertEqual("HLEGSIGILLKKHEIVFDGCHDFGRTYIWQMSD", contact_map1.sequence.seq) -# self.assertEqual("HLEG-IGILL-K-E-------------------", contact_map1.repr_sequence.seq) -# os.unlink(f_name) + @unittest.skip("Not yet implemented") + def test_read_7(self): + content = """PFRMAT RR +TARGET R9999 +AUTHOR 1234-5678-9000 +REMARK Predictor remarks +METHOD Description of methods used +METHOD Description of methods used +MODEL 1 +HLEGSIGILLKKHEIVFDGC +HDFGRTYIWQMSD +A1 B9 0 8 0.70 +A1 B10 0 8 0.70 +A1 B12 0 8 0.60 +A1 B14 0 8 0.20 +A1 B15 0 8 0.10 +A1 B17 0 8 0.30 +A1 B19 0 8 0.50 +A2 B8 0 8 0.90 +A3 B7 0 8 0.70 +A3 B12 0 8 0.40 +A3 B14 0 8 0.70 +A3 B15 0 8 0.30 +A4 B6 0 8 0.90 +A7 B14 0 8 0.30 +A9 B14 0 8 0.50 +END +""" + f_name = create_tmp_f(content=content) + with open(f_name, 'r') as f_in: + contact_file = CaspParser().read(f_in) + contact_map1 = contact_file.top_map + self.assertEqual(1, len(contact_file)) + self.assertEqual(15, len(contact_map1)) + self.assertEqual("HLEGSIGILLKKHEIVFDGCHDFGRTYIWQMSD", contact_map1.sequence.seq) + self.assertEqual("HLEG-IGILL-K-E-------------------", contact_map1.repr_sequence.seq) + os.unlink(f_name) - def test_write(self): - # ====================================================== - # Test Case 1 + def test_write_1(self): contact_file = ContactFile('RR') contact_file.target = 'R9999' contact_file.author = '1234-5678-9000' @@ -294,8 +285,7 @@ def test_write(self): self.assertEqual(content, data) os.unlink(f_name) - # ====================================================== - # Test Case 2 + def test_write_2(self): contact_file = ContactFile('RR') contact_map = ContactMap('1') contact_file.add(contact_map) @@ -324,8 +314,7 @@ def test_write(self): self.assertEqual(content, data) os.unlink(f_name) - # ====================================================== - # Test Case 3 + def test_write_3(self): contact_file = ContactFile('RR') contact_map = ContactMap('1') contact_file.add(contact_map) @@ -352,8 +341,7 @@ def test_write(self): self.assertEqual(content, data) os.unlink(f_name) - # ====================================================== - # Test Case 4 + def test_write_4(self): contact_file = ContactFile('RR') contact_map = ContactMap('1') contact_file.add(contact_map) @@ -383,8 +371,7 @@ def test_write(self): self.assertEqual(content, data) os.unlink(f_name) - # ====================================================== - # Test Case 5 + def test_write_5(self): contact_file = ContactFile('RR') contact_map = ContactMap('1') contact_file.add(contact_map) @@ -414,8 +401,7 @@ def test_write(self): self.assertEqual(content, data) os.unlink(f_name) - # ====================================================== - # Test Case 6 + def test_write_6(self): contact_file = ContactFile('RR') contact_map = ContactMap('1') contact_file.add(contact_map) diff --git a/conkit/io/tests/test_ComsatIO.py b/conkit/io/tests/test_ComsatIO.py index 2c904256..b6ee17f9 100644 --- a/conkit/io/tests/test_ComsatIO.py +++ b/conkit/io/tests/test_ComsatIO.py @@ -16,9 +16,7 @@ class Test(unittest.TestCase): - def test_read(self): - # ====================================================== - # Test Case 1 + def test_read_1(self): content = """19 A 41 A H1-H2 19 A 42 C H1-H2 11 L 47 L H1-H2 @@ -60,9 +58,7 @@ def test_read(self): ) os.unlink(f_name) - def test_write(self): - # ====================================================== - # Test Case 1 + def test_write_1(self): contact_file = ContactFile('RR') contact_file.target = 'R9999' contact_file.author = '1234-5678-9000' diff --git a/conkit/io/tests/test_EPCMapIO.py b/conkit/io/tests/test_EPCMapIO.py index 603db1f5..fba32aa2 100644 --- a/conkit/io/tests/test_EPCMapIO.py +++ b/conkit/io/tests/test_EPCMapIO.py @@ -16,9 +16,7 @@ class Test(unittest.TestCase): - def test_read(self): - # ================================================== - # Test Case 1 + def test_read_1(self): content = """46 78 0 8 9.301869 80 105 0 8 8.856009 111 129 0 8 7.252451 @@ -45,9 +43,7 @@ def test_read(self): ) os.unlink(f_name) - def test_write(self): - # ====================================================== - # Test Case 1 + def test_write_1(self): contact_file = ContactFile('RR') contact_file.target = 'R9999' contact_file.author = '1234-5678-9000' diff --git a/conkit/io/tests/test_EVfoldIO.py b/conkit/io/tests/test_EVfoldIO.py index 2429d3da..67f751f7 100644 --- a/conkit/io/tests/test_EVfoldIO.py +++ b/conkit/io/tests/test_EVfoldIO.py @@ -16,9 +16,7 @@ class Test(unittest.TestCase): - def test_read(self): - # ================================================== - # Test Case 1 + def test_read_1(self): content = """1 M 2 V 0 0.0338619 1 M 3 G 0 0.0307956 1 M 4 L 0 0.0268079 @@ -45,9 +43,7 @@ def test_read(self): ) os.unlink(f_name) - def test_write(self): - # ====================================================== - # Test Case 1 + def test_write_1(self): contact_file = ContactFile('RR') contact_file.target = 'R9999' contact_file.author = '1234-5678-9000' diff --git a/conkit/io/tests/test_FastaIO.py b/conkit/io/tests/test_FastaIO.py index 710201f8..5f5d9438 100644 --- a/conkit/io/tests/test_FastaIO.py +++ b/conkit/io/tests/test_FastaIO.py @@ -12,9 +12,7 @@ class Test(unittest.TestCase): - def test_read(self): - # ================================================== - # Normal sequence only mode + def test_read_1(self): seq = """>00FAF_A GSMFTPKPPQDSAVIKAGYCVKQGAVMKNWKRRYFQLDENTIGYFKSELEKEPLRVIPLK EVHKVQECKQSDIMMRDNLFEIVTTSRTFYVQADSPEEMHSWIKAVSGAIVAQRGPGRSA @@ -29,11 +27,9 @@ def test_read(self): self.assertEqual(ref_id, sequence_entry.id) ref_seq = "GSMFTPKPPQDSAVIKAGYCVKQGAVMKNWKRRYFQLDENTIGYFKSELEKEPLRVIPLKEVHKVQECKQSDIMMRDNLFEIVTTSRTFYVQADSPEEMHSWIKAVSGAIVAQRGPGRSASSEHP" self.assertEqual(ref_seq, sequence_entry.seq) - del parser, sequence_file, sequence_entry os.unlink(f_name) - # ================================================== - # Comments at the beginning of the file + def test_read_2(self): seq = """# Hello World >00FAF_A GSMFTPKPPQDSAVIKAGYCVKQGAVMKNWKRRYFQLDENTIGYFKSELEKEPLRVIPLK @@ -49,11 +45,9 @@ def test_read(self): self.assertEqual(ref_id, sequence_entry.id) ref_seq = "GSMFTPKPPQDSAVIKAGYCVKQGAVMKNWKRRYFQLDENTIGYFKSELEKEPLRVIPLK" self.assertEqual(ref_seq, sequence_entry.seq) - del parser, sequence_file, sequence_entry os.unlink(f_name) - # ================================================== - # Multiple sequence alignment + def test_read_3(self): msa = """#foo #bar >seq1 @@ -78,12 +72,9 @@ def test_read(self): elif i == 2: self.assertEqual('seq3', sequence_entry.id) self.assertEqual('EVHKVQECKQSDIMMRDNLFEIVTTSRTFWKRRYFQLDENTIGYF', sequence_entry.seq) - del parser, sequence_file, sequence_entry os.unlink(f_name) - def test_write(self): - # ================================================== - # Normal sequence mode + def test_write_1(self): seq = [ ">00FAF_A|", "GSMFTPKPPQDSAVIKAGYCVKQGAVMKNWKRRYFQLDENTIGYFKSELEKEPLRVIPLK", @@ -101,11 +92,10 @@ def test_write(self): with open(f_name_out, 'r') as f_in: output = "".join(f_in.readlines()) self.assertEqual(seq, output) - del parser, sequence_file os.unlink(f_name_in) os.unlink(f_name_out) - # ================================================== - # Normal sequence mode - with comment + + def test_write_2(self): seq = [ "# Hello World", ">00FAF_A|", @@ -122,11 +112,10 @@ def test_write(self): with open(f_name_out, 'r') as f_in: output = "".join(f_in.readlines()) self.assertEqual(seq, output) - del parser, sequence_file os.unlink(f_name_in) os.unlink(f_name_out) - # ================================================== - # Multiple sequence alignment + + def test_write_3(self): msa = [ "#foo", "#bar", @@ -148,7 +137,6 @@ def test_write(self): with open(f_name_out, 'r') as f_in: output = "".join(f_in.readlines()) self.assertEqual(msa, output) - del parser, sequence_file os.unlink(f_name_in) os.unlink(f_name_out) diff --git a/conkit/io/tests/test_FreeContactIO.py b/conkit/io/tests/test_FreeContactIO.py index 5fe5eb98..ea63c19e 100644 --- a/conkit/io/tests/test_FreeContactIO.py +++ b/conkit/io/tests/test_FreeContactIO.py @@ -16,9 +16,7 @@ class Test(unittest.TestCase): - def test_read(self): - # ================================================== - # Test Case 1 + def test_read_1(self): content = """1 M 2 V 0.0338619 0 1 M 3 G 0.0307956 0 1 M 4 L 0.0268079 0 @@ -45,9 +43,7 @@ def test_read(self): ) os.unlink(f_name) - def test_write(self): - # ====================================================== - # Test Case 1 + def test_write_1(self): contact_file = ContactFile('RR') contact_file.target = 'R9999' contact_file.author = '1234-5678-9000' diff --git a/conkit/io/tests/test_GremlinIO.py b/conkit/io/tests/test_GremlinIO.py index 9952aad4..b690993c 100644 --- a/conkit/io/tests/test_GremlinIO.py +++ b/conkit/io/tests/test_GremlinIO.py @@ -16,9 +16,7 @@ class Test(unittest.TestCase): - def test_read(self): - # ====================================================== - # Test Case 1 + def test_read_1(self): content = """i j i_id j_id r_sco s_sco prob 179 246 179_C 246_L 0.2019 4.740 1.000 262 305 262_G 305_Y 0.1742 4.090 1.000 @@ -47,8 +45,7 @@ def test_read(self): ) os.unlink(f_name) - # ====================================================== - # Test Case 2 + def test_read_2(self): content = """# Some comments # That are here for whatever reason i j i_id j_id r_sco s_sco prob @@ -79,8 +76,7 @@ def test_read(self): ) os.unlink(f_name) - # ====================================================== - # Test Case 3 + def test_read_3(self): content = """i j gene i_id j_id r_sco s_sco prob I_prob 127 187 A 127_V 187_I 0.183 3.635 1.000 N/A 83 87 A 83_E 87_Q 0.183 3.633 1.000 N/A @@ -115,9 +111,7 @@ def test_read(self): self.assertEqual(raw_scores, [c.raw_score for c in cmap]) os.unlink(f_name) - def test_write(self): - # ====================================================== - # Test Case 1 + def test_write_1(self): contact_file = ContactFile('test') contact_map = ContactMap('A') contact_file.add(contact_map) @@ -143,8 +137,7 @@ def test_write(self): self.assertEqual(content, data) os.unlink(f_name) - # ====================================================== - # Test Case 2 + def test_write_2(self): contact_file = ContactFile('TEST') contact_map = ContactMap('1') contact_file.add(contact_map) @@ -168,8 +161,7 @@ def test_write(self): self.assertEqual(content, data) os.unlink(f_name) - # ====================================================== - # Test Case 3 + def test_write_3(self): contact_file = ContactFile('TEST') contact_maps = [ContactMap('A'), ContactMap('AB'), ContactMap('B')] contacts = [(Contact(1, 9, 0.7), Contact(1, 10, 0.7), Contact(2, 8, 0.9), Contact(3, 12, 0.4)), diff --git a/conkit/io/tests/test_JonesIO.py b/conkit/io/tests/test_JonesIO.py index 6ab3614a..c6ad8034 100644 --- a/conkit/io/tests/test_JonesIO.py +++ b/conkit/io/tests/test_JonesIO.py @@ -12,9 +12,7 @@ class Test(unittest.TestCase): - def test_read(self): - # ================================================== - # Multiple sequence alignment + def test_read_1(self): msa = """GSMFTPKPPQDSAVI--GYCVKQGAVMKNWKRRY--LDENTIGYF EVHK--ECKQSDIMMRD--FEIVTTSRTFYVQADSPEEMHSWIKA EVHKVQECK--DIMMRDNLFEI--TSRTFWKRRY--LDENTIGYF @@ -37,11 +35,9 @@ def test_read(self): elif i == 3: self.assertEqual('seq_3', sequence_entry.id) self.assertEqual('EVHKVQECK--DIMMRDNLFEI--TSRTF--RRY--LDENTIGYF', sequence_entry.seq) - del parser, sequence_file, sequence_entry os.unlink(f_name) - # ================================================== - # Multiple sequence alignment - crash + def test_read_2(self): msa = """>header1 GSMFTPKPPQDSAVI--GYCVKQGAVMKNWKRRY--LDENTIGYF >header2 @@ -56,12 +52,9 @@ def test_read(self): with open(f_name, 'r') as f_in: with self.assertRaises(ValueError): parser.read(f_in) - del parser os.unlink(f_name) - def test_write(self): - # ================================================== - # Multiple sequence alignment + def test_write_1(self): msa = [ "GSMFTPKPPQDSAVI--GYCVKQGAVMKNWKRRY--LDENTIGYF", "EVHK--ECKQSDIMMRD--FEIVTTSRTFYVQADSPEEMHSWIKA", @@ -79,7 +72,6 @@ def test_write(self): with open(f_name_out, 'r') as f_in: output = "".join(f_in.readlines()) self.assertEqual(msa, output) - del parser, sequence_file os.unlink(f_name_in) os.unlink(f_name_out) diff --git a/conkit/io/tests/test_MemBrainIO.py b/conkit/io/tests/test_MemBrainIO.py index 374b2708..e01a3594 100644 --- a/conkit/io/tests/test_MemBrainIO.py +++ b/conkit/io/tests/test_MemBrainIO.py @@ -16,9 +16,7 @@ class Test(unittest.TestCase): - def test_read(self): - # ================================================== - # Test Case 1 + def test_read_1(self): content = """Helix Position Residue Helix Position Residue Probability H1 30 F H2 55 F 1.000000 H1 33 L H2 51 A 0.944091 @@ -48,9 +46,7 @@ def test_read(self): ) os.unlink(f_name) - def test_write(self): - # ====================================================== - # Test Case 1 + def test_write_1(self): contact_file = ContactFile('RR') contact_file.target = 'R9999' contact_file.author = '1234-5678-9000' diff --git a/conkit/io/tests/test_PconsIO.py b/conkit/io/tests/test_PconsIO.py index b4fa045c..42e5bab9 100644 --- a/conkit/io/tests/test_PconsIO.py +++ b/conkit/io/tests/test_PconsIO.py @@ -16,9 +16,7 @@ class Test(unittest.TestCase): - def test_read(self): - # ====================================================== - # Test Case 1 + def test_read_1(self): content = """1 2 0.93514 1 3 0.67324 1 4 0.23692 @@ -47,8 +45,7 @@ def test_read(self): self.assertEqual([0.93514, 0.67324, 0.23692, 0.13166, 0.09188], [c.raw_score for c in contact_map1][:5]) os.unlink(f_name) - # ====================================================== - # Test Case 2 + def test_read_2(self): content = """# Check one two Hello WOrld 1 2 0.93514 @@ -79,8 +76,7 @@ def test_read(self): self.assertEqual([0.93514, 0.67324, 0.23692, 0.13166, 0.09188], [c.raw_score for c in contact_map1][:5]) os.unlink(f_name) - # ====================================================== - # Test Case 3 + def test_read_3(self): content = """############################################################################## PconsC3 result file Generated from test_remark @@ -128,8 +124,7 @@ def test_read(self): self.assertEqual('HLEGSIGILLKKHEIVFDGCHDFGRTYIWQMSD', contact_map1.sequence.seq) os.unlink(f_name) - # ====================================================== - # Test Case 4 + def test_read_4(self): content = """############################################################################## PconsC3 result file Generated from test_remark @@ -180,9 +175,7 @@ def test_read(self): contact_map1.sequence.seq) os.unlink(f_name) - def test_write(self): - # ====================================================== - # Test Case 1 + def test_write_1(self): contact_file = ContactFile('RR') contact_file.target = 'R9999' contact_file.author = '1234-5678-9000' diff --git a/conkit/io/tests/test_PdbIO.py b/conkit/io/tests/test_PdbIO.py index 54636027..ddb5a411 100644 --- a/conkit/io/tests/test_PdbIO.py +++ b/conkit/io/tests/test_PdbIO.py @@ -12,9 +12,7 @@ class Test(unittest.TestCase): - def test_read(self): - # ====================================================== - # Test Case 1 + def test_read_1(self): content = """ATOM 1 N TYR A 36 39.107 51.628 3.103 0.50 43.13 N ATOM 2 CA TYR A 36 38.300 50.814 2.204 0.50 41.80 C ATOM 3 O TYR A 36 38.712 48.587 1.405 0.50 41.03 O @@ -43,8 +41,8 @@ def test_read(self): self.assertEqual([86, 208], [c.res2_seq for c in contact_map1 if c.is_true_positive]) self.assertEqual([0.934108, 0.920229], [c.raw_score for c in contact_map1 if c.is_true_positive]) os.unlink(f_name) - # ====================================================== - # Test Case 2 + + def test_read_2(self): content = """ATOM 1 N TYR A 36 39.107 51.628 3.103 0.50 43.13 N ATOM 2 CA TYR A 36 38.300 50.814 2.204 0.50 41.80 C ATOM 3 O TYR A 36 38.712 48.587 1.405 0.50 41.03 O @@ -73,8 +71,8 @@ def test_read(self): self.assertEqual([86], [c.res2_seq for c in contact_map1 if c.is_true_positive]) self.assertEqual([0.934927], [c.raw_score for c in contact_map1 if c.is_true_positive]) os.unlink(f_name) - # ====================================================== - # Test Case 3 + + def test_read_3(self): content = """ATOM 1 N TYR A 36 39.107 51.628 3.103 0.50 43.13 N ATOM 2 CA TYR A 36 38.300 50.814 2.204 0.50 41.80 C ATOM 3 O TYR A 36 38.712 48.587 1.405 0.50 41.03 O @@ -103,8 +101,8 @@ def test_read(self): self.assertEqual([86], [c.res2_seq for c in contact_map1 if c.is_true_positive]) self.assertEqual([0.934108], [c.raw_score for c in contact_map1 if c.is_true_positive]) os.unlink(f_name) - # ====================================================== - # Test Case 4 + + def test_read_4(self): content = """ATOM 1 N TYR A 36 39.107 51.628 3.103 0.50 43.13 N ATOM 2 CA TYR A 36 38.300 50.814 2.204 0.50 41.80 C ATOM 3 O TYR A 36 38.712 48.587 1.405 0.50 41.03 O diff --git a/conkit/io/tests/test_PlmDCAIO.py b/conkit/io/tests/test_PlmDCAIO.py index 0be053a3..5eafdd57 100644 --- a/conkit/io/tests/test_PlmDCAIO.py +++ b/conkit/io/tests/test_PlmDCAIO.py @@ -16,9 +16,7 @@ class Test(unittest.TestCase): - def test_read(self): - # ================================================== - # Test Case 1 + def test_read_1(self): content = """1,2,0.12212 1,3,0.14004 1,4,0.12926 @@ -44,9 +42,7 @@ def test_read(self): ) os.unlink(f_name) - def test_write(self): - # ====================================================== - # Test Case 1 + def test_write_1(self): contact_file = ContactFile('RR') contact_file.target = 'R9999' contact_file.author = '1234-5678-9000' diff --git a/conkit/io/tests/test_PsicovIO.py b/conkit/io/tests/test_PsicovIO.py index 0382612e..4b524a44 100644 --- a/conkit/io/tests/test_PsicovIO.py +++ b/conkit/io/tests/test_PsicovIO.py @@ -16,9 +16,7 @@ class Test(unittest.TestCase): - def test_read(self): - # ================================================== - # Test Case 1 + def test_read_1(self): content = """46 78 0 8 9.301869 80 105 0 8 8.856009 111 129 0 8 7.252451 @@ -45,9 +43,7 @@ def test_read(self): ) os.unlink(f_name) - def test_write(self): - # ====================================================== - # Test Case 1 + def test_write_1(self): contact_file = ContactFile('RR') contact_file.target = 'R9999' contact_file.author = '1234-5678-9000' diff --git a/conkit/io/tests/test_StockholmIO.py b/conkit/io/tests/test_StockholmIO.py index b7ed0b37..e1b303c8 100644 --- a/conkit/io/tests/test_StockholmIO.py +++ b/conkit/io/tests/test_StockholmIO.py @@ -12,9 +12,7 @@ class Test(unittest.TestCase): - def test_read(self): - # ================================================== - # Normal sequence only mode + def test_read_1(self): msa = """# STOCKHOLM 1.0 #=GF ID 1EAZ:A|PDBID|CHAIN|SEQUENCE-i5 @@ -128,12 +126,9 @@ def test_read(self): 'apsaspora owczarzaki (strain ATCC 30864) RepID=A0A0D2WIY8_CAPO3'], sequence_entry.remark) - del parser, hierarchy, sequence_entry os.unlink(f_name) - def test_write(self): - # ================================================== - # Multiple sequence alignment + def test_write_1(self): msa = [ "# STOCKHOLM 1.0", "#=GF ID 1EAZ:A|PDBID|CHAIN|SEQUENCE-i5", @@ -212,7 +207,6 @@ def test_write(self): with open(f_name_out, 'r') as f_in: output = "".join(f_in.readlines()) self.assertEqual(ref, output) - del parser, hierarchy os.unlink(f_name_in) os.unlink(f_name_out) diff --git a/conkit/io/tests/test__ParserIO.py b/conkit/io/tests/test__ParserIO.py index bd6a7d66..d48f35e7 100644 --- a/conkit/io/tests/test__ParserIO.py +++ b/conkit/io/tests/test__ParserIO.py @@ -16,39 +16,33 @@ class Test1(unittest.TestCase): """Test for _ContactFileParser""" - def test__reconstruct(self): - parser = _ContactFileParser() - # ====================================================== - # Test Case 1 - hierarchy = parser._reconstruct(Contact(1, 3, 1.0)) + def test__reconstruct_1(self): + hierarchy = _ContactFileParser()._reconstruct(Contact(1, 3, 1.0)) self.assertTrue(isinstance(hierarchy, ContactFile)) self.assertTrue(isinstance(hierarchy[0], ContactMap)) self.assertTrue(isinstance(hierarchy[0][0], Contact)) self.assertEqual((1, 3), (hierarchy[0][0].res1_seq, hierarchy[0][0].res2_seq)) - # ====================================================== - # Test Case 2 - hierarchy = parser._reconstruct(ContactMap('test')) + + def test__reconstruct_2(self): + hierarchy = _ContactFileParser()._reconstruct(ContactMap('test')) self.assertTrue(isinstance(hierarchy, ContactFile)) self.assertTrue(isinstance(hierarchy[0], ContactMap)) self.assertEqual('test', hierarchy[0].id) - # ====================================================== - # Test Case 3 - hierarchy = parser._reconstruct(ContactFile('test')) + + def test__reconstruct_3(self): + hierarchy = _ContactFileParser()._reconstruct(ContactFile('test')) self.assertTrue(isinstance(hierarchy, ContactFile)) self.assertEqual('test', hierarchy.id) class Test2(unittest.TestCase): """Test for _SequenceFileParser""" - def test__reconstruct(self): - parser = _SequenceFileParser() - # ====================================================== - # Test Case 1 - hierarchy = parser._reconstruct(SequenceFile('test')) + def test__reconstruct_1(self): + hierarchy = _SequenceFileParser()._reconstruct(SequenceFile('test')) self.assertTrue(isinstance(hierarchy, SequenceFile)) - # ====================================================== - # Test Case 2 - hierarchy = parser._reconstruct(Sequence('test', 'AAA')) + + def test__reconstruct_2(self): + hierarchy = _SequenceFileParser()._reconstruct(Sequence('test', 'AAA')) self.assertTrue(isinstance(hierarchy, SequenceFile)) if __name__ == "__main__": diff --git a/conkit/io/tests/test__iotools.py b/conkit/io/tests/test__iotools.py index cfe0ad26..a6d47f08 100644 --- a/conkit/io/tests/test__iotools.py +++ b/conkit/io/tests/test__iotools.py @@ -12,14 +12,12 @@ class Test(unittest.TestCase): - def test_create_tmp_f(self): - # =============================================== - # Test Case 1 + def test_create_tmp_f_1(self): fname = _iotools.create_tmp_f() self.assertTrue(os.path.isfile(fname)) os.unlink(fname) - # =============================================== - # Test Case 2 + + def test_create_tmp_f_2(self): content = 'Hello, World!' fname = _iotools.create_tmp_f(content=content, mode='w') self.assertTrue(os.path.isfile(fname)) @@ -27,19 +25,19 @@ def test_create_tmp_f(self): written_content = f_in.read() self.assertEqual(content, written_content) os.unlink(fname) - # =============================================== - # Test Case 3 + + def test_create_tmp_f_3(self): content = 'Hello, World!' content_bytes = content.encode('utf-8') fname = _iotools.create_tmp_f(content=content_bytes, mode='wb') self.assertTrue(os.path.isfile(fname)) with open(fname, 'rb') as f_in: written_content_bytes = f_in.read() - writte_content = written_content_bytes.decode('utf-8') + written_content = written_content_bytes.decode('utf-8') self.assertEqual(content, written_content) os.unlink(fname) - def test_is_str_like(self): + def test_is_str_like_1(self): self.assertTrue(_iotools.is_str_like('foo')) # str self.assertFalse(_iotools.is_str_like(1)) # int self.assertFalse(_iotools.is_str_like(1.)) # float @@ -48,9 +46,7 @@ def test_is_str_like(self): self.assertFalse(_iotools.is_str_like({})) # dict self.assertFalse(_iotools.is_str_like(set())) # set - def test_open_f_handle(self): - # =============================================== - # Test Case 1 + def test_open_f_handle_1(self): fname = _iotools.create_tmp_f() with _iotools.open_f_handle(fname, 'append') as fhandle: self.assertEqual('a' + _iotools.MODE_APPENDIX, fhandle.mode) @@ -58,8 +54,8 @@ def test_open_f_handle(self): with _iotools.open_f_handle(f_in_handle, 'append') as fhandle: self.assertEqual('a' + _iotools.MODE_APPENDIX, fhandle.mode) os.unlink(fname) - # =============================================== - # Test Case 2 + + def test_open_f_handle_2(self): fname = _iotools.create_tmp_f() with _iotools.open_f_handle(fname, 'read') as fhandle: self.assertEqual('r' + _iotools.MODE_APPENDIX, fhandle.mode) @@ -67,8 +63,8 @@ def test_open_f_handle(self): with _iotools.open_f_handle(f_in_handle, 'read') as fhandle: self.assertEqual('r' + _iotools.MODE_APPENDIX, fhandle.mode) os.unlink(fname) - # =============================================== - # Test Case 3 + + def test_open_f_handle_3(self): fname = _iotools.create_tmp_f() with _iotools.open_f_handle(fname, 'write') as fhandle: self.assertEqual('w' + _iotools.MODE_APPENDIX, fhandle.mode) @@ -76,14 +72,14 @@ def test_open_f_handle(self): with _iotools.open_f_handle(f_in_handle, 'write') as fhandle: self.assertEqual('w' + _iotools.MODE_APPENDIX, fhandle.mode) os.unlink(fname) - # =============================================== - # Test Case 4 + + def test_open_f_handle_4(self): with self.assertRaises(TypeError): _iotools.open_f_handle(1, 'read') with self.assertRaises(TypeError): _iotools.open_f_handle(1.0, 'write') - # =============================================== - # Test Case 5 + + def test_open_f_handle_5(self): fname = _iotools.create_tmp_f() with self.assertRaises(ValueError): _iotools.open_f_handle(fname, 'foo') diff --git a/conkit/plot/tests/test__Figure.py b/conkit/plot/tests/test__Figure.py index 64bdd1b8..a5dd0a68 100644 --- a/conkit/plot/tests/test__Figure.py +++ b/conkit/plot/tests/test__Figure.py @@ -10,12 +10,13 @@ class Test(unittest.TestCase): - def test__init__(self): + def test__init__1(self): f = Figure() self.assertEqual(300, f.dpi) self.assertEqual("png", f.format) self.assertEqual("conkit", f.prefix) + def test__init__2(self): f = Figure(dpi=20, format="svg") self.assertEqual(20, f.dpi) self.assertEqual("svg", f.format) @@ -23,13 +24,13 @@ def test__init__(self): self.assertRaises(ValueError, Figure, format="ooo") - def test_dpi(self): + def test_dpi_1(self): f = Figure() self.assertEqual(300, f.dpi) f.dpi = 20 self.assertEqual(20, f.dpi) - def test_filename(self): + def test_filename_1(self): f = Figure() self.assertEqual("conkit.png", f.file_name) f.file_name = "test.eps" @@ -42,7 +43,7 @@ def test_filename(self): self.assertEqual("test", f.prefix) self.assertRaises(ValueError, setattr, f, "file_name", "test.ooo") - def test_format(self): + def test_format_1(self): f = Figure() self.assertEqual("png", f.format) f.format = "pdf" @@ -53,7 +54,7 @@ def test_format(self): self.assertEqual("png", f.format) self.assertRaises(ValueError, setattr, f, "format", "bbb") - def test_prefix(self): + def test_prefix_1(self): f = Figure() self.assertEqual("conkit", f.prefix) f.prefix = "test"