def test_duplicate_input_ids(self): input_fp = self.get_data_path('unaligned-duplicate-ids.fasta') input_sequences = DNAFASTAFormat(input_fp, mode='r') with self.assertRaisesRegex(ValueError, 'the unaligned.*id1'): with redirected_stdio(stderr=os.devnull): mafft(input_sequences)
def test_mafft_parttree_exception(self): input_fp = os.path.join(self.temp_dir.name, 'million.fasta') with open(input_fp, "w") as f: for i in range(0, 1000002): f.write('>%d\nAAGCAAGC\n' % i) input_sequences = DNAFASTAFormat(input_fp, mode='r') with self.assertRaisesRegex(ValueError, '1 million'): with redirected_stdio(stderr=os.devnull): mafft(input_sequences)
def test_multithreaded_mafft(self): input_sequences, exp = self._prepare_sequence_data() with redirected_stdio(stderr=os.devnull): result = mafft(input_sequences, n_threads='auto') obs = skbio.io.read(str(result), into=skbio.TabularMSA, constructor=skbio.DNA) self.assertEqual(obs, exp)
def test_mafft(self): input_fp = self.get_data_path('unaligned-dna-sequences-1.fasta') input_sequences = DNAFASTAFormat(input_fp, mode='r') exp = skbio.TabularMSA( [skbio.DNA('AGGGGGG', metadata={'id': 'seq1', 'description': ''}), skbio.DNA('-GGGGGG', metadata={'id': 'seq2', 'description': ''})] ) with redirected_stdio(stderr=os.devnull): result = mafft(input_sequences) obs = skbio.io.read(str(result), into=skbio.TabularMSA, constructor=skbio.DNA) self.assertEqual(obs, exp)
def test_long_ids_are_not_truncated(self): input_fp = self.get_data_path('unaligned-long-ids.fasta') input_sequences = DNAFASTAFormat(input_fp, mode='r') with redirected_stdio(stderr=os.devnull): result = mafft(input_sequences) with open(str(result), 'r') as fh: obs = fh.read() self.assertIn('a' * 250, obs) self.assertIn('b' * 250, obs) self.assertIn('c' * 250, obs)
def test_mafft(self): input_fp = self.get_data_path('unaligned-dna-sequences-1.fasta') input_sequences = DNAFASTAFormat(input_fp, mode='r') exp = skbio.TabularMSA([ skbio.DNA('AGGGGGG', metadata={ 'id': 'seq1', 'description': '' }), skbio.DNA('-GGGGGG', metadata={ 'id': 'seq2', 'description': '' }) ]) with redirected_stdio(stderr=os.devnull): result = mafft(input_sequences) obs = skbio.io.read(str(result), into=skbio.TabularMSA, constructor=skbio.DNA) self.assertEqual(obs, exp)