Beispiel #1
0
    def test_multiple_sequence_alignment(self):
        """Test multiple sequence alignment.
        """
        seqs = [DNA('caccggcggcccggtggtggccattattattgggtctaaag',
                    metadata={'id': 'seq_1'}, lowercase=True),
                DNA('caccggcggcccgagtggtggccattattattgggtcaagg',
                    metadata={'id': 'seq_2'}, lowercase=True),
                DNA('caccggcggcccgagtgatggccattattattgggtctaaag',
                    metadata={'id': 'seq_3'}, lowercase=True),
                DNA('aaccggcggcccaagtggtggccattattattgggtctaaag',
                    metadata={'id': 'seq_4'}, lowercase=True),
                DNA('caccgggcccgagtggtggccattattattgggtctaaag',
                    metadata={'id': 'seq_5'}, lowercase=True)]

        seqs_fp = join(self.working_dir, "seqs.fna")
        with open(seqs_fp, 'w') as o:
            for seq in seqs:
                seq.write(o, format='fasta')
        alignment_file = multiple_sequence_alignment(seqs_fp)
        aligned_seqs = [DNA(item[1], metadata={'id': item[0]}, lowercase=True)
                        for item in sequence_generator(alignment_file)]

        align_exp = [
            DNA('caccggcggcccg-gtggtggccattattattgggtctaaag',
                lowercase=True, metadata={'id': 'seq_1'}),
            DNA('caccggcggcccgagtggtggccattattattgggtcaagg-',
                lowercase=True, metadata={'id': 'seq_2'}),
            DNA('caccggcggcccgagtgatggccattattattgggtctaaag',
                lowercase=True, metadata={'id': 'seq_3'}),
            DNA('aaccggcggcccaagtggtggccattattattgggtctaaag',
                lowercase=True, metadata={'id': 'seq_4'}),
            DNA('caccg--ggcccgagtggtggccattattattgggtctaaag',
                lowercase=True, metadata={'id': 'seq_5'})]
        self.assertEqual(aligned_seqs, align_exp)
Beispiel #2
0
 def test_multiple_sequence_alignment(self):
     """Test multiple sequence alignment.
     """
     seqs = [
         DNA('caccggcggcccggtggtggccattattattgggtctaaag', id='seq_1'),
         DNA('caccggcggcccgagtggtggccattattattgggtcaagg', id='seq_2'),
         DNA('caccggcggcccgagtgatggccattattattgggtctaaag', id='seq_3'),
         DNA('aaccggcggcccaagtggtggccattattattgggtctaaag', id='seq_4'),
         DNA('caccgggcccgagtggtggccattattattgggtctaaag', id='seq_5')
     ]
     seqs_col = SequenceCollection(seqs)
     seqs_fp = join(self.working_dir, "seqs.fna")
     with open(seqs_fp, 'w') as o:
         o.write(seqs_col.to_fasta())
     alignment = multiple_sequence_alignment(seqs_fp)
     align_exp = [
         DNA('caccggcggcccg-gtggtggccattattattgggtctaaag', id='seq_1'),
         DNA('caccggcggcccgagtggtggccattattattgggtcaagg-', id='seq_2'),
         DNA('caccggcggcccgagtgatggccattattattgggtctaaag', id='seq_3'),
         DNA('aaccggcggcccaagtggtggccattattattgggtctaaag', id='seq_4'),
         DNA('caccg--ggcccgagtggtggccattattattgggtctaaag', id='seq_5')
     ]
     self.assertItemsEqual(alignment, align_exp)