def test_get_contigs(self):
     '''Test get_contigs'''
     a = assembly.Assembly(os.path.join(data_dir, 'assembly_test_get_contigs.fasta'))
     expected = {
         'contig1': pyfastaq.sequences.Fasta('contig1', 'ACGT'),
         'contig2': pyfastaq.sequences.Fasta('contig2', 'AAAA'),
     }
     self.assertEqual(expected, a.get_contigs())
 def test_init_file_not_dir(self):
     '''Test _init_file_not_dir'''
     contigs_fasta = os.path.join(data_dir, 'assembly_test_init_contigs.fasta')
     a = assembly.Assembly(contigs_fasta)
     self.assertEqual(a.contigs_fasta, contigs_fasta)
     self.assertIsNone(a.contigs_fastg)
     self.assertIsNone(a.assembly_graph_fastg)
     self.assertIsNone(a.spades_dir)
 def test_circular_contigs_just_fasta(self):
     '''Test circular_contigs when input is just fasta'''
     a = assembly.Assembly(
         os.path.join(data_dir,
                      'assembly_test_circular_contigs_only_contigs.fasta'),
         'spades')
     got = a.circular_contigs()
     expected = set()
     self.assertEqual(expected, got)
 def test_circular_contigs_spades_pre_3_6_1(self):
     '''Test circular_contigs with spades pre 3.6.1'''
     a = assembly.Assembly(
         os.path.join(data_dir,
                      'assembly_test_circular_contigs_spades_pre_3_6_1'),
         'spades')
     got = a.circular_contigs()
     expected = {'NODE_1_length_5_cov_42.42_ID_1'}
     self.assertEqual(expected, got)
 def test_init_post_3_6_1_ok(self):
     '''Test _init_post_3_6_1_ok'''
     test_dir = os.path.join(data_dir, 'assembly_test_init_spades_post_3_6_1_ok')
     a = assembly.Assembly(test_dir)
     self.assertEqual(a.spades_dir, test_dir)
     self.assertEqual(a.contigs_fasta, os.path.join(test_dir, 'contigs.fasta'))
     self.assertEqual(a.assembly_graph_fastg, os.path.join(test_dir, 'assembly_graph.fastg'))
     self.assertEqual(a.contigs_paths, os.path.join(test_dir, 'contigs.paths'))
     self.assertIsNone(a.contigs_fastg)
 def test_circular_contigs_spades_post_3_6_1(self):
     '''Test circular_contigs with spades post 3.6.1'''
     a = assembly.Assembly(os.path.join(data_dir, 'assembly_test_circular_contigs_spades_post_3_6_1'))
     got = a.circular_contigs()
     expected = {
         'NODE_5_length_8134_cov_20.6513_ID_2269',
         'NODE_6_length_6712_cov_6.68474_ID_2271',
         'NODE_7_length_4806_cov_3.33747_ID_2273',
         'NODE_8_length_4566_cov_19.8709_ID_2275',
     }
     self.assertEqual(expected, got)
    def test_init_raises_error(self):
        '''Test _init_raises_error'''
        test_dirs = [
            'assembly_test_init_no_fasta',
            'assembly_test_init_spades_pre_3_6_1_no_fastg',
            'assembly_test_init_spades_post_3_6_1_no_contigs_paths',
            'assembly_test_init_spades_post_3_6_1_no_assembly_graph',
            'assembly_test_init_spades_post_3_6_1_no_assembly_graph_or_contig_paths',
        ]

        for test_dir in test_dirs:
            with self.assertRaises(assembly.Error):
                a = assembly.Assembly(os.path.join(data_dir, test_dir))