Beispiel #1
0
    def test_odd(self):
        seqs = [
                SeqRecord(Seq('ATGACCAACTGA'), id='1'),
                SeqRecord(Seq('ATGACCAACTGT'), id='2'),
                SeqRecord(Seq('ATGACCAACTGC'), id='3'),
                SeqRecord(Seq('ATGACCAACTGG'), id='4'),
                SeqRecord(Seq('ATGACCAACTAT'), id='5'),
                SeqRecord(Seq('ATGACCAACTAC'), id='6'),
                SeqRecord(Seq('TTGACCAACTAC'), id='7'),
                ]
        batch_iter = sequtils.seq_batch_iter(seqs, 3)
        self.assertIsInstance(batch_iter, types.GeneratorType)
        batch_iter = list(batch_iter)
        self.assertEqual(len(batch_iter), 3)
        new_seqs = []
        for seq_iter in batch_iter:
            self.assertIsInstance(seq_iter, seqsift.utils.dataio.BufferedIter)
            for s in seq_iter:
                new_seqs.append(s)
        self.assertSameData(seqs, new_seqs)

        batch_iter = sequtils.seq_batch_iter(seqs, 4)
        self.assertIsInstance(batch_iter, types.GeneratorType)
        batch_iter = list(batch_iter)
        self.assertEqual(len(batch_iter), 2)
        new_seqs = []
        for seq_iter in batch_iter:
            self.assertIsInstance(seq_iter, seqsift.utils.dataio.BufferedIter)
            for s in seq_iter:
                new_seqs.append(s)
        self.assertSameData(seqs, new_seqs)
Beispiel #2
0
    def test_odd(self):
        seqs = [
            SeqRecord(Seq('ATGACCAACTGA'), id='1'),
            SeqRecord(Seq('ATGACCAACTGT'), id='2'),
            SeqRecord(Seq('ATGACCAACTGC'), id='3'),
            SeqRecord(Seq('ATGACCAACTGG'), id='4'),
            SeqRecord(Seq('ATGACCAACTAT'), id='5'),
            SeqRecord(Seq('ATGACCAACTAC'), id='6'),
            SeqRecord(Seq('TTGACCAACTAC'), id='7'),
        ]
        batch_iter = sequtils.seq_batch_iter(seqs, 3)
        self.assertIsInstance(batch_iter, types.GeneratorType)
        batch_iter = list(batch_iter)
        self.assertEqual(len(batch_iter), 3)
        new_seqs = []
        for seq_iter in batch_iter:
            self.assertIsInstance(seq_iter, seqsift.utils.dataio.BufferedIter)
            for s in seq_iter:
                new_seqs.append(s)
        self.assertSameData(seqs, new_seqs)

        batch_iter = sequtils.seq_batch_iter(seqs, 4)
        self.assertIsInstance(batch_iter, types.GeneratorType)
        batch_iter = list(batch_iter)
        self.assertEqual(len(batch_iter), 2)
        new_seqs = []
        for seq_iter in batch_iter:
            self.assertIsInstance(seq_iter, seqsift.utils.dataio.BufferedIter)
            for s in seq_iter:
                new_seqs.append(s)
        self.assertSameData(seqs, new_seqs)
Beispiel #3
0
def get_seq_batch_iter_from_files(file_objs,
        number_per_batch,
        format = None,
        data_type = 'dna',
        ambiguities = True):
    seqs = get_seq_iter(file_objs, format = format, data_type = data_type,
            ambiguities = ambiguities)
    return sequtils.seq_batch_iter(seqs, number_per_batch)
Beispiel #4
0
def get_seq_batch_iter_from_files(file_objs,
                                  number_per_batch,
                                  format=None,
                                  data_type='dna',
                                  ambiguities=True):
    seqs = get_seq_iter(file_objs,
                        format=format,
                        data_type=data_type,
                        ambiguities=ambiguities)
    return sequtils.seq_batch_iter(seqs, number_per_batch)