def test_duplicate_input_ids_across_aligned_and_unaligned(self): input_fp = self.get_data_path('aligned-duplicate-ids-2.fasta') alignment = DNAFASTAFormat(input_fp, mode='r') _, sequences, _ = self._prepare_sequence_data() with self.assertRaisesRegex(ValueError, 'aligned and unaligned.*seq1'): with redirected_stdio(stderr=os.devnull): mafft_add(alignment, sequences)
def test_duplicate_input_ids_in_unaligned(self): input_fp = self.get_data_path('unaligned-duplicate-ids.fasta') sequences = DNAFASTAFormat(input_fp, mode='r') alignment, _, _ = self._prepare_sequence_data() with self.assertRaisesRegex(ValueError, 'the unaligned.*id1'): with redirected_stdio(stderr=os.devnull): mafft_add(alignment, sequences)
def test_mafft_add_flags(self): alignment, sequences, exp = self._prepare_sequence_data() with patch('q2_alignment._mafft.run_command') as patched_run_cmd: with patch('q2_alignment._mafft.skbio.TabularMSA.read', return_value=exp): _ = mafft_add(alignment, sequences) patched_run_cmd.assert_called_with([ "mafft", "--preservecase", "--inputorder", "--thread", "1", "--add", ANY, ANY ], ANY) _ = mafft_add(alignment, sequences, addfragments=True) patched_run_cmd.assert_called_with([ "mafft", "--preservecase", "--inputorder", "--thread", "1", "--addfragments", ANY, ANY ], ANY)
def test_mafft_add_fragments(self): alignment, sequences, exp = self._prepare_sequence_data() with redirected_stdio(stderr=os.devnull): result = mafft_add(alignment, sequences, addfragments=True) obs = skbio.io.read(str(result), into=skbio.TabularMSA, constructor=skbio.DNA) self.assertEqual(obs, exp)
def test_long_ids_are_not_truncated_aligned(self): input_fp = self.get_data_path('aligned-long-ids.fasta') alignment = DNAFASTAFormat(input_fp, mode='r') _, sequences, _ = self._prepare_sequence_data() with redirected_stdio(stderr=os.devnull): result = mafft_add(alignment, sequences) with open(str(result), 'r') as fh: obs = fh.read() self.assertIn('a' * 250, obs) self.assertIn('b' * 250, obs) self.assertIn('seq1', obs) self.assertIn('seq2', obs)