Skip to content

Commit

Permalink
Solving EI-CoreBioinformatics#126, also adding unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
lucventurini committed Sep 26, 2018
1 parent c2f72c6 commit cc5f8e6
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 0 deletions.
45 changes: 45 additions & 0 deletions Mikado/tests/test_transcript_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,51 @@ def test_suspicious(self):
self.assertTrue(self.model.suspicious_splicing)
self.assertTrue(self.model.only_non_canonical_splicing)

def test_reverse_with_cds_negative(self):

model = Transcript()
model.chrom, model.start, model.end = "Chr5", 1251, 5043
model.id, model.parent, model.strand = "AT5G01010.1", "AT5G01010", "-"
model.add_exons([(4765, 5043), (4552, 4679), (4335, 4467), (4102, 4258), (3927, 4005), (3762, 3802),
(3543, 3659), (3303, 3383), (2872, 2934), (2748, 2799), (2435, 2509), (1914, 1961),
(1745, 1780), (1572, 1646), (1251, 1459)])
model.add_exons([(4765, 4924), (4552, 4679), (4335, 4467), (4102, 4258), (3927, 4005), (3762, 3802),
(3543, 3659), (3303, 3383), (2872, 2934), (2748, 2799), (2435, 2509), (1914, 1961),
(1745, 1780), (1572, 1646), (1388, 1459)],
features="CDS")
model.finalize()
model_fasta = self.fasta["Chr5"][model.start - 1:model.end]
check_model = TranscriptChecker(model, model_fasta)
check_model.check_strand()
self.assertEqual(check_model.strand, "-")
self.assertGreater(check_model.combined_cds_length, 0)
model.unfinalize()
model.strand = "+"
check_model = TranscriptChecker(model, model_fasta)
check_model.check_strand()
self.assertEqual(check_model.strand, "-")
self.assertFalse(check_model.is_coding)

def test_reverse_with_cds_positive(self):

model = Transcript()
model.chrom, model.start, model.end = "Chr5", 9930, 13235
model.id, model.parent, model.strand = "AT5G01030.1", "AT5G01030", "+"
model.add_exons([(9930, 10172), (10620, 12665), (12797, 13235)])
model.add_exons([(10638, 12665), (12797, 13003)], features="CDS")
model.finalize()
model_fasta = self.fasta["Chr5"][model.start - 1:model.end]
check_model = TranscriptChecker(model, model_fasta)
check_model.check_strand()
self.assertEqual(check_model.strand, "+")
self.assertGreater(check_model.combined_cds_length, 0)
model.unfinalize()
model.strand = "-"
check_model = TranscriptChecker(model, model_fasta)
check_model.check_strand()
self.assertEqual(check_model.strand, "+")
self.assertFalse(check_model.is_coding)

def test_monoexonic_suspicious(self):

"""A monoexonic transcript should never appear as a suspicious transcript, in terms of splicing."""
Expand Down
1 change: 1 addition & 0 deletions Mikado/transcripts/transcript.py
Original file line number Diff line number Diff line change
Expand Up @@ -999,6 +999,7 @@ def reverse_strand(self):
self.strand = "+"
elif self.strand is None:
pass
self.strip_cds()
self.logger.warning("Transcript %s has been assigned to the wrong strand, reversing it.",
self.id)
return
Expand Down

0 comments on commit cc5f8e6

Please sign in to comment.