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

All Samples(21)  |  Call(21)  |  Derive(0)  |  Import(0)
Convert between two sequence file formats, return number of records.

 - in_file - an input handle or filename
 - in_format - input file format, lower case string
 - out_file - an output handle or filename
 - out_format - output file format, lower case string
 - alphabet - optional alphabet to assume

NOTE - If you provide an output filename, it will be opened which will
overwrite any existing file without warning. This may happen if even(more...)

        def convert(in_file, in_format, out_file, out_format, alphabet=None):
    """Convert between two sequence file formats, return number of records.

     - in_file - an input handle or filename
     - in_format - input file format, lower case string
     - out_file - an output handle or filename
     - out_format - output file format, lower case string
     - alphabet - optional alphabet to assume

    NOTE - If you provide an output filename, it will be opened which will
    overwrite any existing file without warning. This may happen if even
    the conversion is aborted (e.g. an invalid out_format name is given).

    For example, going from a filename to a handle:

    >>> from Bio import SeqIO
    >>> try:
    ...     from StringIO import StringIO # Python 2
    ... except ImportError:
    ...     from io import StringIO # Python 3
    ...
    >>> handle = StringIO("")
    >>> SeqIO.convert("Quality/example.fastq", "fastq", handle, "fasta")
    3
    >>> print(handle.getvalue())
    >EAS54_6_R1_2_1_413_324
    CCCTTCTTGTCTTCAGCGTTTCTCC
    >EAS54_6_R1_2_1_540_792
    TTGGCAGGCCAAGGCCGATGGATCA
    >EAS54_6_R1_2_1_443_348
    GTTGCTTCTGGCGTGGGTGGGGGGG
    
    """
    #Hack for SFF, will need to make this more general in future
    if in_format in _BinaryFormats:
        in_mode = 'rb'
    else:
        in_mode = 'rU'

    #Don't open the output file until we've checked the input is OK?
    if out_format in ["sff", "sff_trim"]:
        out_mode = 'wb'
    else:
        out_mode = 'w'

    #This will check the arguments and issue error messages,
    #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,
                                    out_handle, out_format,
                                    alphabet)
    return count
        


src/f/a/fastools-0.9.0/fastools/fastools.py   fastools(Download)
    @type outputHandle: stream
    """
    return SeqIO.convert(inputHandle, "fastq", outputHandle, "fastq-illumina")
#s2i
 

src/f/a/fammer-0.2/fammerlib/refine.py   fammer(Download)
                   % (tempseqfile.name, tempseqfile.name))
                # Build the "lean" HMM w/ hmmbuild
                SeqIO.convert(tempseqfile.name + '.seq', 'fasta',
                              tempseqfile.name + '.stk', 'stockholm')
                sh('hmmbuild %s %s > /dev/null'

src/b/c/bcbio-nextgen-0.7.8/bcbio/bam/fastq.py   bcbio-nextgen(Download)
        return out_file
    with file_transaction(out_file) as tmp_out_file:
        count = SeqIO.convert(in_file, in_qual, tmp_out_file, "fastq-sanger")
    logger.info("Converted %d reads in %s to %s." % (count, in_file, out_file))
    return out_file

src/b/c/bcbio-nextgen-HEAD/bcbio/bam/fastq.py   bcbio-nextgen(Download)
        return out_file
    with file_transaction(out_file) as tmp_out_file:
        count = SeqIO.convert(in_file, in_qual, tmp_out_file, "fastq-sanger")
    logger.info("Converted %d reads in %s to %s." % (count, in_file, out_file))
    return out_file

src/l/o/lociNGS-HEAD/locings/convertingLociNGS.py   lociNGS(Download)
def toNexus (listOfFiles):
	for file in listOfFiles:
		output_handle = file.replace(".fasta", ".nex")
		output_handle = re.sub(".+/.+/", os.getcwd()+"/", output_handle) 
		SeqIO.convert(file, "fasta", output_handle, "nexus", generic_dna)

src/j/c/jcvi-HEAD/formats/fastq.py   jcvi(Download)
    pf = fastqfile.rsplit(".", 1)[0]
    fastafile, qualfile = pf + ".fasta", pf + ".qual"
    SeqIO.convert(fastqfile, "fastq", fastafile, "fasta")
    SeqIO.convert(fastqfile, "fastq", qualfile, "qual")
 

src/p/y/PyPhyloGenomics-0.3.12/pyphylogenomics/NGS.py   PyPhyloGenomics(Download)
    # write file to work on
    wrkfile = os.path.join(folder, "wrk_ionfile.fastq")
    SeqIO.convert(ionfile, "fastq", wrkfile, "fastq-solexa");
    print "Your file has been saved using Solexa quality format as " + wrkfile
 

src/f/a/fammer-0.2/fammerlib/build.py   fammer(Download)
    """
    stk = ext(task.depends[0], 'stk')
    SeqIO.convert(str(task.depends[0]), 'clustal', stk, 'stockholm')
    sh('hmmbuild %s %s' % (task.target, stk))
 

src/b/c/bcbb-HEAD/nextgen/bcbio/bam/fastq.py   bcbb(Download)
        return out_file
 
    count = SeqIO.convert(in_file, in_qual, out_file, "fastq-sanger")
    logger.info("Converted %d reads in %s to %s." % (count, in_file, out_file))
    return out_file

src/b/i/biopython_workshop-HEAD/writing_sequence_files/convert_gb_to_fasta.py   biopython_workshop(Download)
from Bio import SeqIO
input_filename = "NC_000913.gbk"
output_filename = "NC_000913_converted.fasta"
count = SeqIO.convert(input_filename, "gb", output_filename, "fasta")
print(str(count) + " records converted")

  1 | 2  Next