예제 #1
0
    def setUp(self):
        fasta = Fasta(testdata.PARSE_FASTA, 'test_data', None, False)
        ref_fasta = Fasta(testdata.PARSE_FASTA, 'test_data', None, True)

        self.analysis = GenomeAnalysis(10, .9)
        self.coroutine_fn = lambda *arg: (self.CoroutineMock(),
                                          self.CoroutineMock())
        self.dups_contig = fasta
        self.reference_contig = ref_fasta.get_contig(
            'ContigWithFilePositionOffset')
        self.sample_groups = ((fasta, fasta), (fasta, ), (fasta, fasta))
예제 #2
0
    def test_sample_analysis(self):
        with TemporaryDirectory() as tmpdir:
            matrix_dir = os.path.join(tmpdir, 'matrices')
            stats_dir = os.path.join(tmpdir, 'statistics')

            os.mkdir(matrix_dir)
            os.mkdir(stats_dir)

            genome_analysis = GenomeAnalysis(10, .9)
            reference_fasta = Fasta(testdata.REFERENCE_FASTA, 'reference', 'aligner', is_reference=True)
            reference_dups = Fasta(testdata.REFERENCE_DUPS, 'dups', 'aligner', is_reference=True)
            write_matrix.analyze_samples(matrix_dir, stats_dir, genome_analysis, reference_fasta, reference_dups, sample_groups, max_workers=1)
예제 #3
0
    def setUp(self):
        fasta = Fasta(testdata.PARSE_FASTA, 'test_data', None, False)
        ref_fasta = Fasta(testdata.PARSE_FASTA, 'test_data', None, True)

        self.analysis = GenomeAnalysis(10, .9)
        self.coroutine_fn = lambda *arg: (self.CoroutineMock(), self.CoroutineMock())
        self.dups_contig = fasta
        self.reference_contig = ref_fasta.get_contig('ContigWithFilePositionOffset')
        self.sample_groups = (
            (
                fasta,
                fasta
            ), (
                fasta,
            ), (
                fasta,
                fasta
            )
        )
예제 #4
0
class FastaTestCase(unittest.TestCase):
    @classmethod
    def setUp(self):
        self.fasta = Fasta(testdata.PARSE_FASTA,
                           'test_fasta',
                           'test_aligner',
                           is_reference=False)

    def test_repr(self):
        expected = "Fasta(filepath='{0}', name='test_fasta', aligner='test_aligner', is_reference=False)".format(
            testdata.PARSE_FASTA)
        self.assertEqual(expected, repr(self.fasta))

    def test_identifier(self):
        expected = 'test_fasta::test_aligner'
        self.assertEqual(expected, self.fasta.identifier)

    def test_get_contig(self):
        """
        The following tests assume FastaContig is working.
        """
        # It should return the correct contig at any file position or in any order.
        contig0 = self.fasta.get_contig('contig0')
        contig2 = self.fasta.get_contig('contig2')
        contig1 = self.fasta.get_contig('contig1')

        self.assertEqual('contig0', contig0.name)
        self.assertEqual('contig1', contig1.name)
        self.assertEqual('contig2', contig2.name)

    def test_get_contig_empty(self):
        contig = self.fasta.get_contig('DoesNotExist')
        self.assertIsInstance(contig, EmptyContig)

    def test_yields_contigs_longest_to_shortest(self):
        expected = [
            'gi|129295|sp|P01013|OVAX_CHICK', '100CharacterContig',
            '90CharacterContig', '90CharacterContigNoBreak',
            '90CharacterContig2'
        ]
        for contig, expect in zip(self.fasta.contigs, expected):
            self.assertEqual(expect, contig.name)
예제 #5
0
class FastaTestCase(unittest.TestCase):
    @classmethod
    def setUp(self):
        self.fasta = Fasta(testdata.PARSE_FASTA, 'test_fasta', 'test_aligner', is_reference=False)

    def test_repr(self):
        expected = "Fasta(filepath='{0}', name='test_fasta', aligner='test_aligner', is_reference=False)".format(
            testdata.PARSE_FASTA)
        self.assertEqual(expected, repr(self.fasta))

    def test_identifier(self):
        expected = 'test_fasta::test_aligner'
        self.assertEqual(expected, self.fasta.identifier)

    def test_get_contig(self):
        """
        The following tests assume FastaContig is working.
        """
        # It should return the correct contig at any file position or in any order.
        contig0 = self.fasta.get_contig('contig0')
        contig2 = self.fasta.get_contig('contig2')
        contig1 = self.fasta.get_contig('contig1')

        self.assertEqual('contig0', contig0.name)
        self.assertEqual('contig1', contig1.name)
        self.assertEqual('contig2', contig2.name)

    def test_get_contig_empty(self):
        contig = self.fasta.get_contig('DoesNotExist')
        self.assertIsInstance(contig, EmptyContig)

    def test_yields_contigs_longest_to_shortest(self):
        expected = [
            'gi|129295|sp|P01013|OVAX_CHICK',
            '100CharacterContig',
            '90CharacterContig',
            '90CharacterContigNoBreak',
            '90CharacterContig2'
        ]
        for contig, expect in zip(self.fasta.contigs, expected):
            self.assertEqual(expect, contig.name)
예제 #6
0
 def setUp(self):
     self.fasta = Fasta(testdata.PARSE_FASTA, 'test_fasta', 'test_aligner', is_reference=False)
예제 #7
0
 def setUp(self):
     self.fasta = Fasta(testdata.PARSE_FASTA,
                        'test_fasta',
                        'test_aligner',
                        is_reference=False)