Skip to content

Commit

Permalink
Fixed a bug introduced by previous commit, always for EI-CoreBioinfor…
Browse files Browse the repository at this point in the history
…matics#142, implemented new unit-test for EI-CoreBioinformatics#137
  • Loading branch information
lucventurini committed Nov 9, 2018
1 parent 8f18b3c commit 8983973
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 2 deletions.
1 change: 1 addition & 0 deletions Mikado/loci/locus.py
Original file line number Diff line number Diff line change
Expand Up @@ -1078,6 +1078,7 @@ def _enlarge_start(transcript: Transcript,
up_exons.extend([(_[0], _[1]) for _ in upstream_exons])
elif intersecting_upstream[0].value == "intron":
# Now we have to expand until the first exon in the upstream_exons
to_remove = True
upstream_exon = upstream_exons[-1]
new_first_exon = (upstream_exon[0], transcript.exons[0][1])
upstream_exons.remove(upstream_exon)
Expand Down
38 changes: 36 additions & 2 deletions Mikado/tests/locus_tester.py
Original file line number Diff line number Diff line change
Expand Up @@ -2500,7 +2500,6 @@ def test_expand_multi_end(self):
(12751895, 12752032),
(12752078, 12752839)])
transcript.finalize()
backup = transcript.deepcopy()

template = Transcript()
template.chrom, template.strand, template.id = "Chr5", "-", "template"
Expand All @@ -2519,11 +2518,46 @@ def test_expand_multi_end(self):
with self.subTest():
expanded = expand_transcript(transcript, template, template,
fai=self.fai, logger=logger)
self.assertEqual(transcript.exons,
self.assertEqual(expanded.exons,
[(12751151, 12751579),
(12751669, 12751808), (12751895, 12752032),
(12752078, 12752839), (12752974, 12753102)])

def test_expand_both_sides(self):

transcript = Transcript()
transcript.chrom, transcript.strand, transcript.id = "Chr5", "+", "test"
transcript.add_exons([(100053, 100220), (100657, 101832)])
transcript.finalize()

template = Transcript()
template.chrom, template.strand, template.id = "Chr5", "+", "template"
template.add_exons([(99726, 100031), (100657, 102000)])
template.finalize()

with self.subTest():
backup = transcript.deepcopy()
logger = create_null_logger()
expand_transcript(transcript, template, template, self.fai, logger=logger)
self.assertEqual(
transcript.exons,
[(99726, 100220), (100657, 102000)]

)

def no_expansion(self):
transcript = Transcript()
transcript.chrom, transcript.strand, transcript.id = "Chr5", "+", "test"
transcript.add_exons([(100053, 100220), (100657, 101832)])
transcript.finalize()
backup = transcript.deepcopy()
logger = create_null_logger(level="DEBUG")
with self.assertLogs(logger=logger, level="DEBUG") as cm:

expand_transcript(transcript, None, None, self.fai, logger)
self.assertEqual(transcript, backup)

self.assertIn("DEBUG:null:test does not need to be expanded, exiting", cm.output)

if __name__ == '__main__':
unittest.main(verbosity=2)

0 comments on commit 8983973

Please sign in to comment.