Did I find the right examples for you? yes no      Crawl my project      Python Jobs

All Samples(8)  |  Call(7)  |  Derive(0)  |  Import(1)

        def _itemize_fastx(fhand):
    try:
        for read in _itemize_fastx_multiline(fhand):
            yield read
    except IsSingleLineFastqError:
        for read in _itemize_fastq_singleline(fhand):
            yield read
        


src/s/e/seq_crumbs-HEAD/test/test_seqio.py   seq_crumbs(Download)
from crumbs.utils.test_utils import TEST_DATA_DIR
from crumbs.utils.bin_utils import BIN_DIR
from crumbs.seqio import (guess_seq_type, fastaqual_to_fasta, seqio,
                          _write_seqrecords, _read_seqrecords,
                          _itemize_fastx, read_seqs, write_seqs)
    def test_singleline_itemizer(self):
        fhand = StringIO('@s1\nACTG\n+\n1234\n' * 1100)
        seqs = list(_itemize_fastx(fhand))
        names = [seq[0] for seq in seqs]
        assert len(names) == 1100
    def test_fasta_itemizer(self):
        'It tests the fasta itemizer'
        fhand = StringIO('>s1\nACTG\n>s2 desc\nACTG\n')
        seqs = list(_itemize_fastx(fhand))
        assert seqs == [('s1', ['>s1\n', 'ACTG\n'], {}),
                        ('s2', ['>s2 desc\n', 'ACTG\n'], {})]
 
        # with several lines
        fhand = StringIO('>s1\nACTG\nGTAC\n>s2 desc\nACTG\n')
        seqs = list(_itemize_fastx(fhand))
        # With empty lines
        fhand = StringIO('>s1\nACTG\n\n>s2 desc\nACTG\n')
        seqs = list(_itemize_fastx(fhand))
        assert seqs == [('s1', ['>s1\n', 'ACTG\n'], {}),
                        ('s2', ['>s2 desc\n', 'ACTG\n'], {})]