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

All Samples(32)  |  Call(26)  |  Derive(0)  |  Import(6)
It gets the format or it looks in the inventory

        def get_format(fhand):
    'It gets the format or it looks in the inventory'
    id_ = _get_fhand_id(fhand)
    try:
        file_format = FILEFORMAT_INVENTORY[id_]
    except KeyError:
        file_format = None

    if file_format is None:
        file_format = _guess_format(fhand, force_file_as_non_seek=False)
        FILEFORMAT_INVENTORY[id_] = file_format

    return file_format
        


src/s/e/seq_crumbs-HEAD/crumbs/utils/bin_utils.py   seq_crumbs(Download)
from crumbs.utils.file_utils import (wrap_in_buffered_reader,
                                     uncompress_if_required, compress_fhand)
from crumbs.utils.file_formats import get_format, set_format
from crumbs.settings import get_setting
from crumbs.utils.tags import (OUTFILE, GUESS_FORMAT, BGZF, GZIP, BZIP2,
    if in_format == GUESS_FORMAT:
        for wrapped_fhand in wrapped_fhands:
            get_format(wrapped_fhand)
    else:
        if in_format != get_format(wrapped_fhands[0]):
        if 'fastq' in in_format:
            for wrapped_fhand in wrapped_fhands:
                get_format(wrapped_fhand)
        else:
            # we dont set the first one because already did in the previous
    # The default output format is the same as the first file
    if 'fastq' in in_format or in_format == GUESS_FORMAT:
        out_format = get_format(wrapped_fhands[0])
    else:
        out_format = in_format

src/s/e/seq_crumbs-HEAD/crumbs/filters.py   seq_crumbs(Download)
from __future__ import division
from tempfile import NamedTemporaryFile
from crumbs.utils.file_formats import get_format, set_format
from bisect import bisect
 
        set_format(fhand, file_format)
    else:
        file_format = get_format(fhand)
    index_fpath = get_or_create_bwa_index(ref_fpath, directory)
    extra_params = ['-a', '-M']
def filter_chimeras(ref_fpath, out_fhand, chimeras_fhand, in_fhands,
                    unknown_fhand, unpaired=False, paired_result=True,
                    settings=get_setting('CHIMERAS_SETTINGS'),
                    min_seed_len=None, directory=None):
    file_format = get_format(in_fhands[0])

src/s/e/seq_crumbs-HEAD/crumbs/seqio.py   seq_crumbs(Download)
from crumbs.iterutils import group_in_packets, group_in_packets_fill_last
from crumbs.utils.file_utils import rel_symlink, flush_fhand
from crumbs.utils.file_formats import get_format, peek_chunk_from_file
 
from crumbs.utils.tags import (GUESS_FORMAT, SEQS_PASSED, SEQS_FILTERED_OUT,
def _read_seqrecords(fhands):
    'It returns an iterator of seqrecords'
    seq_iters = []
    for fhand in fhands:
        fmt = get_format(fhand)
        raise IncompatibleFormatError("This output format is not supported")
 
    in_formats = [get_format(fhand) for fhand in in_fhands]
 
    if len(in_fhands) == 1 and in_formats[0] == out_format:
def _read_seqitems(fhands):
    'it returns an iterator of seq items (tuples of name and chunk)'
    seq_iters = []
    for fhand in fhands:
        file_format = get_format(fhand)
        prefered_seq_classes = [SEQITEM, SEQRECORD]
    try:
        in_format = get_format(fhands[0])
    except FileIsEmptyError:
        return []

src/s/e/seq_crumbs-HEAD/crumbs/mapping.py   seq_crumbs(Download)
import subprocess
import pysam
from crumbs.utils.file_formats import get_format
from crumbs.seq import SeqItem, SeqWrapper, get_str_seq, get_name
from crumbs.utils.tags import SEQITEM
def sort_by_position_in_ref(in_fhands, ref_fpath, directory=None,
                            tempdir=None):
    in_fpaths = [fhand.name for fhand in in_fhands]
    file_format = get_format(in_fhands[0])
    extra_params = ['-f'] if 'fasta' in file_format else []

src/s/e/seq_crumbs-HEAD/test/test_utils.py   seq_crumbs(Download)
from crumbs.seqio import guess_seq_type
from crumbs.settings import get_setting
from crumbs.utils.file_formats import get_format, FILEFORMAT_INVENTORY,\
    set_format
 
        id_ = id(fhand)
 
        file_format = get_format(fhand)
        assert FILEFORMAT_INVENTORY[(id_, name)] == file_format
        num_keys = len(FILEFORMAT_INVENTORY)
 
        file_format = get_format(fhand)
        set_format(fhand, 'fasta')
 
        assert 'fasta' == get_format(fhand)
 
    def test_get_format_stringio(self):
        id_ = id(stringIO_fhand)
 
        file_format = get_format(stringIO_fhand)
        assert FILEFORMAT_INVENTORY[(id_, striongIOhash)] == file_format
 

src/s/e/seq_crumbs-HEAD/test/test_guess_seq_format.py   seq_crumbs(Download)
 
from crumbs.utils.bin_utils import BIN_DIR
from crumbs.utils.file_formats import get_format, _guess_format
from crumbs.exceptions import (UnknownFormatError, FileIsEmptyError,
                               UndecidedFastqVersionError)
    def test_fasta(self):
        'It guess fasta formats'
        fhand = StringIO('>seq\nACTC\n')
        assert get_format(fhand) == 'fasta'
 
        # multiline fasta
        fhand = StringIO('>seq\nACTC\nACTG\n>seq2\nACTG\n')
        assert get_format(fhand) == 'fasta'
        # qual
        fhand = StringIO('>seq\n10 20\n')
        assert get_format(fhand) == 'qual'
 
        # qual
        qual = ">seq1\n30 30 30 30 30 30 30 30\n>seq2\n30 30 30 30 30 30 30"
        qual += " 30\n>seq3\n30 30 30 30 30 30 30 30\n"
 
        fhand = StringIO(qual)
        assert get_format(fhand) == 'qual'