Created
October 5, 2017 13:00
-
-
Save vmesel/6221bfc5d41a8fb07d90256e33e16406 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 1 import unittest | |
| 2 from fasta_normalizer import fasta2dict | |
| 3 | |
| 4 def frame_calc(sequence): | |
| 5 modulo = len(sequence) % 3 | |
| 6 if modulo == 0: | |
| 7 return 0 | |
| 8 elif modulo == 1: | |
| 9 return 1 | |
| 10 elif modulo == 2: | |
| 11 return 2 | |
| 12 | |
| 13 | |
| 14 def motif_splitter(sequence): | |
| 15 return [(x, frame_calc(x)) for x in sequence.split("xxxxxx") if x != ""] | |
| 16 | |
| 17 | |
| 18 | |
| 19 class TestesDeMontagemDeSequencia(unittest.TestCase): | |
| 20 def test_calcular_frame_0(self): | |
| 21 frame = frame_calc("aaa") | |
| 22 self.assertEqual(frame, 0) | |
| 23 | |
| 24 def test_calcular_frame_1(self): | |
| 25 frame = frame_calc("aaaa") | |
| 26 self.assertEqual(frame, 1) | |
| 27 | |
| 28 def test_calcular_frame_2(self): | |
| 29 frame = frame_calc("aaaaa") | |
| 30 self.assertEqual(frame, 2) | |
| 31 | |
| 32 | |
| 33 class TesteDeSubstituicaoDeFrame(unittest.TestCase): | |
| 34 def setUp(self): | |
| 35 self.seq0 = "aaaxxxxxxaaaaxxxxxxaaaaaxxxxxx" | |
| 36 self.seq1 = "aaaxxxxxxaaaaaxxxxxx" | |
| 37 self.seq2 = "actxxxxxxactgaxxxxxxactg" | |
| 38 | |
| 39 def test_remover_motif0(self): | |
| 40 output = motif_splitter(self.seq0) | |
| 41 self.assertEqual(output, [("aaa", 0), ("aaaa", 1), ("aaaaa", 2)]) | |
| 42 | |
| 43 def test_remover_motif1(self): | |
| 44 output = motif_splitter(self.seq1) | |
| 45 self.assertEqual(output, [("aaa", 0), ("aaaaa", 2)]) | |
| 46 | |
| 47 def test_remover_motif2(self): | |
| 48 output = motif_splitter(self.seq2) | |
| 49 self.assertEqual() | |
| 50 | |
| 51 if __name__ == "__main__": | |
| 52 unittest.main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment