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

All Samples(64)  |  Call(52)  |  Derive(0)  |  Import(12)
It returns a stream of seqs in different codings: seqrecords, seqitems...

        def read_seqs(fhands, out_format=None, prefered_seq_classes=None):
    'It returns a stream of seqs in different codings: seqrecords, seqitems...'

    if not prefered_seq_classes:
        prefered_seq_classes = [SEQITEM, SEQRECORD]
    try:
        in_format = get_format(fhands[0])
    except FileIsEmptyError:
        return []
    # seqitems is incompatible with different input and output formats
    # or when in_format != a fasta or fastq
    if ((out_format not in (None, GUESS_FORMAT) and in_format != out_format
         and SEQITEM in prefered_seq_classes) or
        (in_format not in ('fasta',) + SANGER_FASTQ_FORMATS +
         ILLUMINA_FASTQ_FORMATS)):
        prefered_seq_classes.pop(prefered_seq_classes.index(SEQITEM))

    if not prefered_seq_classes:
        msg = 'No valid seq class left or prefered'
        raise ValueError(msg)

    for seq_class in prefered_seq_classes:
        if seq_class == SEQITEM:
            try:
                return _read_seqitems(fhands)
            except NotImplementedError:
                continue
        elif seq_class == SEQRECORD:
            try:
                seqs = _read_seqrecords(fhands)
                return assing_kind_to_seqs(SEQRECORD, seqs, None)
            except NotImplementedError:
                continue
        else:
            raise ValueError('Unknown class for seq: ' + seq_class)
    raise RuntimeError('We should not be here, fixme')
        


src/s/e/seq_crumbs-HEAD/crumbs/bulk_filters.py   seq_crumbs(Download)
from crumbs.seq import get_str_seq
from crumbs.pairs import group_pairs_by_name, group_pairs
from crumbs.seqio import read_seqs, write_seqs
from crumbs.utils.tags import SEQITEM
from crumbs.iterutils import sorted_items, unique, unique_unordered
def _read_pairs(in_fhands, paired_reads):
    seqs = read_seqs(in_fhands, prefered_seq_classes=[SEQITEM])
    if paired_reads:
        pairs = group_pairs_by_name(seqs)
    else:

src/s/e/seq_crumbs-HEAD/crumbs/filters.py   seq_crumbs(Download)
                            get_or_create_bwa_index, map_with_bwamem,
                            alignedread_to_seqitem)
from crumbs.seqio import write_seqs, read_seqs
from crumbs.pairs import group_pairs, group_pairs_by_name, deinterleave_pairs
 
        f_fhand = NamedTemporaryFile()
        r_fhand = NamedTemporaryFile()
        seqs = read_seqs(in_fhands)
        deinterleave_pairs(seqs, f_fhand, r_fhand, file_format)
        paired_fpaths = [f_fhand.name, r_fhand.name]

src/s/e/seq_crumbs-HEAD/crumbs/annotation.py   seq_crumbs(Download)
from crumbs.utils.tags import FIVE_PRIME, THREE_PRIME
from crumbs.seq import get_description, get_name, get_str_seq
from crumbs.seqio import write_seqs, read_seqs
from crumbs.blast import Blaster
from crumbs.settings import get_setting
def _read_estcan_result(fhand, result, file_type):
    'It reads a dna or pep ESTscan result file'
    for seq in read_seqs([fhand]):
        items = [i.strip() for i in get_description(seq).split(';')]
        strand = -1 if 'minus strand' in items else 1

src/s/e/seq_crumbs-HEAD/crumbs/mapping.py   seq_crumbs(Download)
from crumbs.exceptions import IncompatibleFormatError
from crumbs.iterutils import sorted_items
from crumbs.seqio import read_seqs
 
 
def sort_fastx_files(in_fhands, key, ref_fpath=None, directory=None,
                     max_items_in_memory=None, tempdir='/tmp'):
    if key == 'seq':
        reads = read_seqs(in_fhands)
        return sorted_items(reads, key=get_str_seq, tempdir=tempdir,
                                       tempdir=tempdir)
    elif key == 'name':
        reads = read_seqs(in_fhands)
        return sorted_items(reads, key=get_name, tempdir=tempdir,
                            max_items_in_memory=max_items_in_memory)

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_seqitems_io(self):
        'It checks the different seq class streams IO'
        fhand = StringIO('>s1\nACTG\n>s2 desc\nACTG\n')
        seqs = list(read_seqs([fhand], prefered_seq_classes=[SEQITEM]))
        assert seqs[0].kind == SEQITEM
        # SeqRecord
        fhand = StringIO('>s1\nACTG\n>s2 desc\nACTG\n')
        seqs = list(read_seqs([fhand], prefered_seq_classes=[SEQRECORD]))
        assert seqs[0].kind == SEQRECORD
        fhand = StringIO()
        fhand = StringIO('>s1\nACTG\n>s2 desc\nACTG\n')
        try:
            seqs = list(read_seqs([fhand], out_format='fastq',
                        prefered_seq_classes=[SEQITEM]))
            self.fail('ValueError expected')
        except ValueError:
            pass
 
        fhand = StringIO('>s1\nACTG\n>s2 desc\nACTG\n')
        seqs = list(read_seqs([fhand], out_format='fasta',

src/s/e/seq_crumbs-HEAD/test/test_transcriptome_orientation.py   seq_crumbs(Download)
from crumbs.utils.tags import SEQRECORD
from crumbs.seq import get_str_seq
from crumbs.seqio import read_seqs
from crumbs.seq import SeqWrapper
 
        check_output(cmd)
 
        out_seqs = list(read_seqs([open(out_fhand.name)],
                                  prefered_seq_classes=[SEQRECORD]))
        init_seqs = list(read_seqs([open(in_fpath)],
                      '--polya_min_len', '4'])
 
        out_seqs = list(read_seqs([open(out_fhand.name)],
                                  prefered_seq_classes=[SEQRECORD]))
        init_seqs = list(read_seqs([open(in_fpath)],

src/s/e/seq_crumbs-HEAD/test/test_statistics.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 read_seqs
from crumbs.seq import SeqWrapper
from crumbs.utils.tags import SEQRECORD, SEQITEM
            fhand = open(join(TEST_DATA_DIR, 'pairend{0}.sfastq'.format(val)))
            in_fhands.append(fhand)
        seqs = read_seqs(in_fhands, prefered_seq_classes=[SEQRECORD])
        results = calculate_sequence_stats(seqs, nxs=[50])
        assert 'maximum: 4' in results['length']
 
        infhands = [open(join(TEST_DATA_DIR, 'arabidopsis_genes'))]
        seqs = list(read_seqs(infhands, prefered_seq_classes=[SEQRECORD]))
        kmers = calculate_sequence_stats(seqs)['kmer']
        assert not 'Kmer distribution' in kmers
            fhand = open(join(TEST_DATA_DIR, 'pairend{0}.sfastq'.format(val)))
            in_fhands.append(fhand)
        seqs = read_seqs(in_fhands, prefered_seq_classes=[SEQITEM])
        results = calculate_sequence_stats(seqs, nxs=[50])
        assert 'maximum: 4' in results['length']
            fhand = open(join(TEST_DATA_DIR, 'pairend{0}.sfastq'.format(val)))
            in_fhands.append(fhand)
        seqs = read_seqs(in_fhands, prefered_seq_classes=[SEQRECORD])
        counts = count_seqs(seqs)
        assert counts == {'total_length': 96, 'num_seqs': 24}

src/s/e/seq_crumbs-HEAD/test/test_annotation.py   seq_crumbs(Download)
                               PolyaAnnotator, BlastAnnotator)
from crumbs.utils.test_utils import TEST_DATA_DIR
from crumbs.seqio import read_seqs
from crumbs.seq import SeqWrapper
from crumbs.utils.tags import FIVE_PRIME, THREE_PRIME, NUCL, SEQRECORD
        estscan_matrix = os.path.join(TEST_DATA_DIR,
                                      'Arabidopsis_thaliana.smat')
        seq_records = list(read_seqs([open(fpath)],
                                     prefered_seq_classes=[SEQRECORD]))
        orf_annotator = EstscanOrfAnnotator(estscan_matrix)

src/s/e/seq_crumbs-HEAD/test/test_pairing.py   seq_crumbs(Download)
from crumbs.utils.test_utils import TEST_DATA_DIR
from crumbs.seq import get_str_seq
from crumbs.seqio import read_seqs, assing_kind_to_seqs
from crumbs.exceptions import (InterleaveError, PairDirectionError,
                               ItemsNotSortedError)
        file1 = os.path.join(TEST_DATA_DIR, 'pairend1.sfastq')
        file2 = os.path.join(TEST_DATA_DIR, 'pairend2.sfastq')
        fwd_seqs = read_seqs([open(file1)])
        rev_seqs = read_seqs([open(file2)])
 
        file1 = os.path.join(TEST_DATA_DIR, 'pairend1.sfastq')
        file2 = os.path.join(TEST_DATA_DIR, 'pairend3.sfastq')
        fwd_seqs = read_seqs([open(file1)])
        rev_seqs = read_seqs([open(file2)])
        out_fhand = StringIO()

src/s/e/seq_crumbs-HEAD/test/test_split_mates.py   seq_crumbs(Download)
from crumbs.split_mates import MatePairSplitter
from crumbs.settings import get_setting
from crumbs.seqio import read_seq_packets, write_seq_packets, read_seqs
from crumbs.utils.bin_utils import BIN_DIR
from crumbs.utils.test_utils import TEST_DATA_DIR
    def test_giuseppe_reads():
        'It splits some real reads'
        seq_fpath = os.path.join(TEST_DATA_DIR, '454_reads.fastq')
        linker_fpath = os.path.join(TEST_DATA_DIR, 'linkers.fasta')
        linkers = list(read_seqs([open(linker_fpath)]))
        seq_fpath = os.path.join(TEST_DATA_DIR, '454_reads.fastq')
        linker_fpath = os.path.join(TEST_DATA_DIR, 'linkers.fasta')
        linkers = list(read_seqs([open(linker_fpath)]))
 
        splitter = MatePairSplitter(linkers=linkers)
        seq_fpath = os.path.join(TEST_DATA_DIR, '454_reads2.fastq')
        linker_fpath = os.path.join(TEST_DATA_DIR, 'linkers.fasta')
        linkers = list(read_seqs([open(linker_fpath)]))
 
        splitter = MatePairSplitter(linkers=linkers)
        seq_fpath = os.path.join(TEST_DATA_DIR, '454_reads2.fastq')
        linker_fpath = os.path.join(TEST_DATA_DIR, 'linkers.fasta')
        linkers = list(read_seqs([open(linker_fpath)]))
 
        splitter = MatePairSplitter(linkers=linkers)

  1 | 2  Next