Skip to content

Commit

Permalink
Other tests for EI-CoreBioinformatics#137
Browse files Browse the repository at this point in the history
  • Loading branch information
lucventurini committed Jan 25, 2019
1 parent 4ba8886 commit 4ea969c
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 6 deletions.
6 changes: 4 additions & 2 deletions Mikado/loci/sublocus.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,15 @@ def __init__(self,

if isinstance(transcript_instance, Transcript):
self.add_transcript_to_locus(transcript_instance)
self.attributes = transcript_instance.attributes.copy()
self.parent = transcript_instance.parent
else:
self.parent = getattr(transcript_instance, "parent")
self.parent = getattr(transcript_instance, "parent", None)
self.chrom = getattr(transcript_instance, "chrom")
self.start = getattr(transcript_instance, "start")
self.end = getattr(transcript_instance, "end")
self.strand = getattr(transcript_instance, "strand")
self.attributes = getattr(transcript_instance, "attributes")
self.attributes = getattr(transcript_instance, "attributes", dict())

self.monosubloci = []
self.logger.debug("Initialized {0}".format(self.id))
Expand Down
8 changes: 4 additions & 4 deletions Mikado/picking/picker.py
Original file line number Diff line number Diff line change
Expand Up @@ -861,7 +861,7 @@ def __submit_multi_threading(self, data_dict):
elif row.is_transcript is True:
if current_transcript is not None and invalid is False:
self.__test_sortedness(row, current_transcript)
if Superlocus.in_locus(
if current_locus is not None and Superlocus.in_locus(
current_locus, current_transcript,
flank=self.json_conf["pick"]["clustering"]["flank"]) is True:
current_locus.add_transcript_to_locus(current_transcript,
Expand Down Expand Up @@ -893,7 +893,7 @@ def __submit_multi_threading(self, data_dict):
intron_range=intron_range)

if current_transcript is not None and invalid is False:
if Superlocus.in_locus(
if current_locus is not None and Superlocus.in_locus(
current_locus, current_transcript,
flank=self.json_conf["pick"]["clustering"]["flank"]) is True:
current_locus.add_transcript_to_locus(
Expand Down Expand Up @@ -1030,7 +1030,7 @@ def __submit_single_threaded(self, data_dict):
elif row.is_transcript is True:
if current_transcript is not None and invalid is False:
self.__test_sortedness(row, current_transcript)
if Superlocus.in_locus(
if current_locus is not None and Superlocus.in_locus(
current_locus, current_transcript,
flank=self.json_conf["pick"]["clustering"]["flank"]) is True:
current_locus.add_transcript_to_locus(current_transcript,
Expand Down Expand Up @@ -1071,7 +1071,7 @@ def __submit_single_threaded(self, data_dict):
intron_range=intron_range, logger=logger)

if current_transcript is not None and invalid is False:
if Superlocus.in_locus(
if current_locus is not None and Superlocus.in_locus(
current_locus, current_transcript,
flank=self.json_conf["pick"]["clustering"]["flank"]) is True:
current_locus.add_transcript_to_locus(
Expand Down
18 changes: 18 additions & 0 deletions Mikado/tests/locus_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,24 @@ def test_evaluate_overlap(self):
self.assertFalse(child1._evaluate_transcript_overlap(self.transcript1, self.transcript2)[0])
self.assertTrue(child1._evaluate_transcript_overlap(self.transcript1, self.transcript1)[0])

def test_invalid_sublocus(self):

with self.assertRaises(ValueError):
self.transcript1.json_conf = None
_ = Sublocus(self.transcript1, json_conf=None)

with self.assertRaises(FileNotFoundError):
_ = Sublocus(self.transcript1, json_conf="test")

def test_sublocus_from_sublocus(self):

s = Sublocus(self.transcript1)
s2 = Sublocus(s)
self.assertFalse(s.fixed_size)
self.assertTrue(s2.fixed_size)
for attr in ["parent", "chrom", "start", "end", "strand", "attributes"]:
self.assertEqual(getattr(s, attr), getattr(s2, attr))


class LocusTester(unittest.TestCase):

Expand Down

0 comments on commit 4ea969c

Please sign in to comment.