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

All Samples(50)  |  Call(40)  |  Derive(0)  |  Import(10)
    Context manager for arguments that can be passed to
    SeqIO and AlignIO read, write, and parse methods: either file objects or strings.

    When given a string, returns a file handle open to handleish with provided
    mode which will be closed when the manager exits.

    All other inputs are returned, and are *not* closed

    - handleish  - Either a string or file handle
    - mode       - Mode to open handleish (used only if handleish is a string)(more...)

            @wraps(func)
    def helper(*args, **kwds):
        return GeneratorContextManager(func(*args, **kwds))
        


src/b/i/biopython-1.63/Bio/Nexus/Nexus.py   biopython(Download)
        # Note we need to add parsing of the path to dir/filename
        try:
            with File.as_handle(input, 'rU') as fp:
                file_contents = fp.read()
                self.filename = getattr(fp, 'name', 'Unknown_nexus_file')
            return
 
        with File.as_handle(filename, mode='w') as fh:
            if not omit_NEXUS:
                fh.write('#NEXUS\n')

src/b/i/biopython-HEAD/Bio/Nexus/Nexus.py   biopython(Download)
        # Note we need to add parsing of the path to dir/filename
        try:
            with File.as_handle(input, 'rU') as fp:
                file_contents = fp.read()
                self.filename = getattr(fp, 'name', 'Unknown_nexus_file')
            return
 
        with File.as_handle(filename, mode='w') as fh:
            if not omit_NEXUS:
                fh.write('#NEXUS\n')

src/b/i/biopython-1.63/Bio/SeqIO/__init__.py   biopython(Download)
 
 
from Bio.File import as_handle
from Bio.SeqRecord import SeqRecord
from Bio.Align import MultipleSeqAlignment
        mode = 'w'
 
    with as_handle(handle, mode) as fp:
        #Map the file format to a writer class
        if format in _FormatToWriter:
        raise ValueError("Invalid alphabet, %s" % repr(alphabet))
 
    with as_handle(handle, mode) as fp:
        #Map the file format to a sequence iterator:
        if format in _FormatToIterator:
    #after we have opened the file which is a shame.
    from ._convert import _handle_convert  # Lazy import
    with as_handle(in_file, in_mode) as in_handle:
        with as_handle(out_file, out_mode) as out_handle:
            count = _handle_convert(in_handle, in_format,

src/b/i/biopython-HEAD/Bio/SeqIO/__init__.py   biopython(Download)
 
 
from Bio.File import as_handle
from Bio.SeqRecord import SeqRecord
from Bio.Align import MultipleSeqAlignment
        mode = 'w'
 
    with as_handle(handle, mode) as fp:
        #Map the file format to a writer class
        if format in _FormatToWriter:
        raise ValueError("Invalid alphabet, %s" % repr(alphabet))
 
    with as_handle(handle, mode) as fp:
        #Map the file format to a sequence iterator:
        if format in _FormatToIterator:
    #after we have opened the file which is a shame.
    from ._convert import _handle_convert  # Lazy import
    with as_handle(in_file, in_mode) as in_handle:
        with as_handle(out_file, out_mode) as out_handle:
            count = _handle_convert(in_handle, in_format,

src/b/i/biopython-1.63/Bio/AlignIO/__init__.py   biopython(Download)
from Bio.Align.Generic import Alignment
from Bio.Alphabet import Alphabet, AlphabetEncoder, _get_base_alphabet
from Bio.File import as_handle
 
from . import StockholmIO
        alignments = [alignments]
 
    with as_handle(handle, 'w') as fp:
        #Map the file format to a writer class
        if format in _FormatToWriter:
        raise TypeError("Need integer for seq_count (sequences per alignment)")
 
    with as_handle(handle, 'rU') as fp:
        #Map the file format to a sequence iterator:
        if format in _FormatToIterator:
    #TODO - Add optimised versions of important conversions
    #For now just off load the work to SeqIO parse/write
    with as_handle(in_file, 'rU') as in_handle:
        #Don't open the output file until we've checked the input is OK:
        alignments = parse(in_handle, in_format, None, alphabet)
 
        #This will check the arguments and issue error messages,
        #after we have opened the file which is a shame.
        with as_handle(out_file, 'w') as out_handle:

src/b/i/biopython-1.63/Bio/SearchIO/__init__.py   biopython(Download)
 
from Bio import BiopythonExperimentalWarning
from Bio.File import as_handle
from Bio.SearchIO._model import QueryResult, Hit, HSP, HSPFragment
from Bio.SearchIO._utils import get_processor
 
    # and start iterating
    with as_handle(handle, 'rU', **handle_kwargs) as source_file:
        generator = iterator(source_file, **kwargs)
 
 
    # write to the handle
    with as_handle(handle, 'w') as target_file:
        writer = writer_class(target_file, **kwargs)
        # count how many qresults, hits, and hsps

src/b/i/biopython-HEAD/Bio/AlignIO/__init__.py   biopython(Download)
from Bio.Align.Generic import Alignment
from Bio.Alphabet import Alphabet, AlphabetEncoder, _get_base_alphabet
from Bio.File import as_handle
 
from . import StockholmIO
        alignments = [alignments]
 
    with as_handle(handle, 'w') as fp:
        #Map the file format to a writer class
        if format in _FormatToWriter:
        raise TypeError("Need integer for seq_count (sequences per alignment)")
 
    with as_handle(handle, 'rU') as fp:
        #Map the file format to a sequence iterator:
        if format in _FormatToIterator:
    #TODO - Add optimised versions of important conversions
    #For now just off load the work to SeqIO parse/write
    with as_handle(in_file, 'rU') as in_handle:
        #Don't open the output file until we've checked the input is OK:
        alignments = parse(in_handle, in_format, None, alphabet)
 
        #This will check the arguments and issue error messages,
        #after we have opened the file which is a shame.
        with as_handle(out_file, 'w') as out_handle:

src/b/i/biopython-HEAD/Bio/SearchIO/__init__.py   biopython(Download)
 
from Bio import BiopythonExperimentalWarning
from Bio.File import as_handle
from Bio.SearchIO._model import QueryResult, Hit, HSP, HSPFragment
from Bio.SearchIO._utils import get_processor
 
    # and start iterating
    with as_handle(handle, 'rU', **handle_kwargs) as source_file:
        generator = iterator(source_file, **kwargs)
 
 
    # write to the handle
    with as_handle(handle, 'w') as target_file:
        writer = writer_class(target_file, **kwargs)
        # count how many qresults, hits, and hsps

src/b/i/biopython-1.63/Bio/Phylo/_io.py   biopython(Download)
    True
    """
    with File.as_handle(file, 'r') as fp:
        for tree in getattr(supported_formats[format], 'parse')(fp, **kwargs):
            yield tree
        # Passed a single tree instead of an iterable -- that's OK
        trees = [trees]
    with File.as_handle(file, 'w+') as fp:
        n = getattr(supported_formats[format], 'write')(trees, fp, **kwargs)
    return n

src/b/i/biopython-HEAD/Bio/Phylo/_io.py   biopython(Download)
    True
    """
    with File.as_handle(file, 'r') as fp:
        for tree in getattr(supported_formats[format], 'parse')(fp, **kwargs):
            yield tree
        # Passed a single tree instead of an iterable -- that's OK
        trees = [trees]
    with File.as_handle(file, 'w+') as fp:
        n = getattr(supported_formats[format], 'write')(trees, fp, **kwargs)
    return n

  1 | 2  Next