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

All Samples(297)  |  Call(295)  |  Derive(0)  |  Import(2)
Write complete set of sequences to a file.

 - sequences - A list (or iterator) of SeqRecord objects, or (if using
               Biopython 1.54 or later) a single SeqRecord.
 - handle    - File handle object to write to, or filename as string
               (note older versions of Biopython only took a handle).
 - format    - lower case string describing the file format to write.

You should close the handle after calling this function.
(more...)

        def write(sequences, handle, format):
    """Write complete set of sequences to a file.

     - sequences - A list (or iterator) of SeqRecord objects, or (if using
                   Biopython 1.54 or later) a single SeqRecord.
     - handle    - File handle object to write to, or filename as string
                   (note older versions of Biopython only took a handle).
     - format    - lower case string describing the file format to write.

    You should close the handle after calling this function.

    Returns the number of records written (as an integer).
    """
    from Bio import AlignIO

    #Try and give helpful error messages:
    if not isinstance(format, basestring):
        raise TypeError("Need a string for the file format (lower case)")
    if not format:
        raise ValueError("Format required (lower case string)")
    if format != format.lower():
        raise ValueError("Format string '%s' should be lower case" % format)

    if isinstance(sequences, SeqRecord):
        #This raised an exception in order version of Biopython
        sequences = [sequences]

    if format in _BinaryFormats:
        mode = 'wb'
    else:
        mode = 'w'

    with as_handle(handle, mode) as fp:
        #Map the file format to a writer class
        if format in _FormatToWriter:
            writer_class = _FormatToWriter[format]
            count = writer_class(fp).write_file(sequences)
        elif format in AlignIO._FormatToWriter:
            #Try and turn all the records into a single alignment,
            #and write that using Bio.AlignIO
            alignment = MultipleSeqAlignment(sequences)
            alignment_count = AlignIO.write([alignment], fp, format)
            assert alignment_count == 1, \
                "Internal error - the underlying writer " \
                " should have returned 1, not %s" % repr(alignment_count)
            count = len(alignment)
            del alignment_count, alignment
        elif format in _FormatToIterator or format in AlignIO._FormatToIterator:
            raise ValueError("Reading format '%s' is supported, but not writing"
                             % format)
        else:
            raise ValueError("Unknown format '%s'" % format)

        assert isinstance(count, int), "Internal error - the underlying %s " \
            "writer should have returned the record count, not %s" \
            % (format, repr(count))

    return count
        


src/j/c/jcvi-HEAD/formats/fasta.py   jcvi(Download)
        after += len(newcds)
        newrec = SeqRecord(newcds, id=name, description=rec.description)
        SeqIO.write([newrec], fw, "fasta")
        if idsfile:
            print >> fwids, "\t".join((name, orf.info))
        seq = Seq(seq)
        s = SeqRecord(seq, id=header, description="")
        SeqIO.write([s], fw, "fasta")
 
 
 
        peprec = SeqRecord(pep, id=name, description=rec.description)
        SeqIO.write([peprec], fw, "fasta")
        fw.flush()
 
            continue
 
        SeqIO.write([rec], fw, "fasta")
        fw.flush()
 
    for key in sortlist:
        rec = f[key]
        SeqIO.write([rec], fw, "fasta")
 
    logging.debug("Sorted file written to `{0}`.".format(sortedfastafile))

src/f/a/fastools-0.9.0/fastools/fastools.py   fastools(Download)
 
    for record in SeqIO.parse(inputHandle, fileFormat):
        SeqIO.write(record, outputHandle, fileFormat)
#sanitise
 
        record.letter_annotations = {"phred_quality":
            [quality] * len(record.seq)}
        SeqIO.write(record, outputHandle, "fastq")
    #for
#fa2fq
    try:
        for record in SeqIO.parse(inputHandle, "fastq"):
            SeqIO.write(record, outputHandle, "fasta")
    except ValueError, error:
        print "Error: %s" % error
        emptyRecord = SeqRecord(Seq.Seq(""), "", "", "")
        SeqIO.write(emptyRecord, outputHandle, "fasta")
        record.seq = sequence + record.seq
        record.letter_annotations = {"phred_quality": addition_q + qual}
        SeqIO.write(record, outputHandle, "fastq")
    #for
#add

src/a/r/ARC-HEAD/ARC/runners/finisher.py   ARC(Download)
                    #Bowtie2 crashes if a contig is all 'n' so only write it out if it isn't
                    if len(contig.seq) != contig.seq.count('n'):
                        SeqIO.write(contig, outf, "fasta")
                contig_inf.close()
                logger.info("Sample: %s target: %s iteration: %s Finished writing %s contigs " % (self.params['sample'], target, self.params['iteration'], i))
                        i += 1
                        r.name = r.id = self.params['sample'] + "_:_" + target + "_:_" + "Read%04d" % i
                        SeqIO.write(r, outf, "fasta")
                    for r in SeqIO.parse(inf_PE2, self.params['format']):
                        i += 1
                        r.name = r.id = self.params['sample'] + "_:_" + target + "_:_" + "Read%04d" % i
                        SeqIO.write(r, outf, "fasta")
                    i += 1
                    r.name = r.id = self.params['sample'] + "_:_" + target + "_:_" + "Read%04d" % i
                    SeqIO.write(r, outf, "fasta")
                inf_SE.close()
            num_contigs += i
                    for r in SeqIO.parse(inf_PE1, self.params['format']):
                        r.description = self.params['sample'] + "_:_" + target
                        SeqIO.write(r, outf_PE1, self.params['format'])
                    for r in SeqIO.parse(inf_PE2, self.params['format']):
                        r.description = self.params['sample'] + "_:_" + target

src/b/i/biopython-1.63/Bio/SeqIO/SeqXmlIO.py   biopython(Download)
    stringHandle = StringIO()
 
    SeqIO.write(records, stringHandle, "seqxml")
    SeqIO.write(records, sys.stdout, "seqxml")
    print("")
 
    stringHandle.seek(0)
    records = list(SeqIO.parse(stringHandle, "seqxml"))
 
    SeqIO.write(records, sys.stdout, "seqxml")

src/b/i/biopython-HEAD/Bio/SeqIO/SeqXmlIO.py   biopython(Download)
    stringHandle = StringIO()
 
    SeqIO.write(records, stringHandle, "seqxml")
    SeqIO.write(records, sys.stdout, "seqxml")
    print("")
 
    stringHandle.seek(0)
    records = list(SeqIO.parse(stringHandle, "seqxml"))
 
    SeqIO.write(records, sys.stdout, "seqxml")

src/f/a/fammer-0.2/fammerlib/refine.py   fammer(Download)
                    if rec.id == seq_id:
                        # Put this seq in a separate file
                        SeqIO.write(rec, tempseqfile.name + '.seed', 'fasta')
                    else:
                        SeqIO.write(rec, tempseqfile, 'fasta')

src/b/i/biopython-1.63/Bio/SeqIO/_convert.py   biopython(Download)
    records = GenBankScanner().parse_records(in_handle, do_features=False)
    #For FASTA output we can ignore the alphabet too
    return SeqIO.write(records, out_handle, "fasta")
 
 
    records = EmblScanner().parse_records(in_handle, do_features=False)
    #For FASTA output we can ignore the alphabet too
    return SeqIO.write(records, out_handle, "fasta")
 
 
    else:
        records = SeqIO.parse(in_handle, in_format, alphabet)
        return SeqIO.write(records, out_handle, out_format)
 

src/b/i/biopython-HEAD/Bio/SeqIO/_convert.py   biopython(Download)
    records = GenBankScanner().parse_records(in_handle, do_features=False)
    #For FASTA output we can ignore the alphabet too
    return SeqIO.write(records, out_handle, "fasta")
 
 
    records = EmblScanner().parse_records(in_handle, do_features=False)
    #For FASTA output we can ignore the alphabet too
    return SeqIO.write(records, out_handle, "fasta")
 
 
    else:
        records = SeqIO.parse(in_handle, in_format, alphabet)
        return SeqIO.write(records, out_handle, out_format)
 

src/b/c/bcbb-HEAD/gff/Scripts/gff/gff_to_genbank.py   bcbb(Download)
def main(gff_file, fasta_file):
    out_file = "%s.gb" % os.path.splitext(gff_file)[0]
    fasta_input = SeqIO.to_dict(SeqIO.parse(fasta_file, "fasta", generic_dna))
    gff_iter = GFF.parse(gff_file, fasta_input)
    SeqIO.write(_check_gff(_fix_ncbi_id(gff_iter)), out_file, "genbank")

src/j/c/jcvi-HEAD/apps/ks.py   jcvi(Download)
        acds = f[a]
        bcds = f[b]
        SeqIO.write((acds, bcds), fw, "fasta")
        if pepfile:
            apep = f2[a]
            bpep = f2[b]
            SeqIO.write((apep, bpep), fw2, "fasta")
        print >> align_h, ">{0}\n{1}".format(rec.id, prot_seqs[i])
    align_h.close()
    SeqIO.write(recs, file(nuc_file, "w"), "fasta")
 
    # run the program
    fasta_file = op.join(work_dir, "prot-start.fasta")
    align_file = op.join(work_dir, "prot.aln")
    SeqIO.write(recs, file(fasta_file, "w"), "fasta")
 
    clustal_cl = ClustalwCommandline(cmd=CLUSTALW_BIN("clustalw2"),
    fasta_file = op.join(work_dir, "prot-start.fasta")
    align_file = op.join(work_dir, "prot.aln")
    SeqIO.write(recs, file(fasta_file, "w"), "fasta")
 
    muscle_cl = MuscleCommandline(cmd=MUSCLE_BIN("muscle"),

  1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9  Next