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

All Samples(41)  |  Call(41)  |  Derive(0)  |  Import(0)
Write complete set of alignments to a file.

Arguments:
 - alignments - A list (or iterator) of Alignment objects (ideally the
               new MultipleSeqAlignment objects), or (if using Biopython
               1.54 or later) a single alignment object.
 - 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.
(more...)

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

    Arguments:
     - alignments - A list (or iterator) of Alignment objects (ideally the
                   new MultipleSeqAlignment objects), or (if using Biopython
                   1.54 or later) a single alignment object.
     - 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 alignments written (as an integer).
    """
    from Bio import SeqIO

    #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(alignments, Alignment):
        #This raised an exception in older versions of Biopython
        alignments = [alignments]

    with as_handle(handle, 'w') as fp:
        #Map the file format to a writer class
        if format in _FormatToWriter:
            writer_class = _FormatToWriter[format]
            count = writer_class(fp).write_file(alignments)
        elif format in SeqIO._FormatToWriter:
            #Exploit the existing SeqIO parser to do the dirty work!
            #TODO - Can we make one call to SeqIO.write() and count the alignments?
            count = 0
            for alignment in alignments:
                if not isinstance(alignment, Alignment):
                    raise TypeError(
                        "Expect a list or iterator of Alignment objects.")
                SeqIO.write(alignment, fp, format)
                count += 1
        elif format in _FormatToIterator or format in SeqIO._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 alignment count, not %s" \
           % (format, repr(count))

    return count
        


src/c/l/CladeCompare-0.2/cladecomparelib/core.py   CladeCompare(Download)
    os.close(bfd)
    try:
        AlignIO.write(fg_aln, aseqfname, 'fasta')
        AlignIO.write(bg_aln, bseqfname, 'fasta')
        output = subprocess.check_output([
    # Save a copy
    # ENH: choose a reasonable name
    AlignIO.write(full_aln, '_cc_combined.seq', 'fasta')
    logging.info("Wrote _cc_combined.seq")
    return full_aln

src/p/h/phyloGenerator-HEAD/phyloGenerator.py   phyloGenerator(Download)
    if outgroup:
        options += ' -o ' + outgroup
    AlignIO.write(alignment, inputFile, "phylip-relaxed")
    if 'startingOnly' in method:
        algorithm = ''
            geneOutput = []
            for j,method in enumerate(gene):
                AlignIO.write(method, tempStem+"Input.fasta", "fasta")
                fileLine = " -in " + tempStem + "Input.fasta -out " + tempStem + "Output.fasta -fasta"
                trimalVersion = "trimal"
        geneDistances = []
        for j,method in enumerate(gene):
            AlignIO.write(method, str(j)+"_"+tempStem+".fasta", "fasta")
            alignLocations.append(str(j)+"_"+tempStem+".fasta")
        for j in range(0, len(alignLocations)-1):
                    for i,gene in enumerate(self.geneNames()):
                        for j,method in enumerate(self.alignmentMethods):
                            AlignIO.write(self.alignment[i][j], self.stem+"_"+gene+"_"+method+".fasta", 'fasta')
                    os.chdir(oldWD)
                    print "...output written!"
        if type(self.alignment) is list:
            for i,align in enumerate(self.alignment):
                AlignIO.write(align, self.stem+"_"+self.geneNames()[i]+"_alignment.fasta", 'fasta')
        else:
            AlignIO.write(self.alignment, self.stem+"_alignment.fasta", 'fasta')

src/i/v/ivy-phylo-20120228/ivy/align.py   ivy-phylo(Download)
def write(data, f, format='fasta'):
    AlignIO.write(data, f, format)
 
def find(aln, substr):
    """

src/f/a/fammer-0.2/fammerlib/cluster.py   fammer(Download)
    aln = alnutils.blocks(aln, 0.4)
    with tempfile.NamedTemporaryFile(mode='w') as tmp:
        AlignIO.write(aln, tmp, 'fasta')
        tmp.flush()
        treedata = subprocess.check_output(['fasttree',

src/b/i/bioscripts.convert-0.4/bioscripts/convert/convalign.py   bioscripts.convert(Download)
			for s in in_alns:
				s._alphabet = opts.seqtype 
		AlignIO.write (in_alns, out_hndl, out_fmt)
		out_hndl.close()
 

src/c/l/CladeCompare-0.2/cladecomparelib/ancestrallrt.py   CladeCompare(Download)
    #     rec.description == ''
    cog_full_fname = '_cog_full.fasta'
    AlignIO.write(full_aln, cog_full_fname, 'fasta')
 
    for rec in fg_aln:
        rec.description = ''
    cog_fg_fname = '_cog_fg.fasta'
    AlignIO.write(fg_aln, cog_fg_fname, 'fasta')
def build_tree_fasttree(full_aln, fg_labels):
    """Build a phylogenetic tree w/ FastTree, given alignment and outgroup."""
 
    alnfname = '_tmp.seq'
    AlignIO.write(full_aln, alnfname, 'fasta')
    # with tempfile.NamedTemporaryFile() as tmpfile:
    alnfname = '_tmp.phy'
    AlignIO.write(full_aln, alnfname, 'phylip-relaxed')
 
    for oldfname in glob('RAxML_*.tmp'):

src/b/i/biopython-1.63/Bio/SeqIO/__init__.py   biopython(Download)
            #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 " \

src/m/a/Mapp-0.1.0/mapp/utils/alignconverter.py   Mapp(Download)
 
    output_handler = open(args.output, "w")    
    AlignIO.write(alignments, output_handler, args.outformat)
    output_handler.close()
 

src/b/i/biopython-HEAD/Bio/SeqIO/__init__.py   biopython(Download)
            #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 " \

src/b/i/biocma-0.2.1/biocma/biocma.py   biocma(Download)
        write(records, out_file)
    else:
        AlignIO.write(records, out_file, out_fmt)
 
 

  1 | 2 | 3  Next