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

All Samples(73)  |  Call(73)  |  Derive(0)  |  Import(0)
Parse a file in the given format and return a single tree.

Raises a `ValueError` if there are zero or multiple trees -- if this occurs,
use `parse` instead to get the complete sequence of trees.

        def read(file, format, **kwargs):
    """Parse a file in the given format and return a single tree.

    Raises a `ValueError` if there are zero or multiple trees -- if this occurs,
    use `parse` instead to get the complete sequence of trees.
    """
    try:
        tree_gen = parse(file, format, **kwargs)
        tree = next(tree_gen)
    except StopIteration:
        raise ValueError("There are no trees in this file.")
    try:
        next(tree_gen)
    except StopIteration:
        return tree
    else:
        raise ValueError(
                "There are multiple trees in this file; use parse() instead.")
        


src/p/h/phyloGenerator-HEAD/phyloGenerator.py   phyloGenerator(Download)
        with open('unrootingOutput.tre', 'w') as f:
            f.write(treeText)
        tree = Phylo.read('unrootingOutput.tre', 'newick')
    os.remove('unrootingOutput.tre')
    return tree
    if not pipe.failure:
        if 'startingOnly' in method:
            tree = Phylo.read('RAxML_parsimonyTree.' + outputFile, "newick")
        elif 'integratedBootstrap' in method:
            tree = Phylo.read('RAxML_bipartitions.' + outputFile, "newick")
        else:
            tree = Phylo.read('RAxML_bestTree.' + outputFile, "newick")
                        with open(tempSmoothedOutput, 'w') as tempFile:
                            tempFile.write(tempText)
                        datedPhylo = Phylo.read(tempSmoothedOutput, 'newick')
                    dirList = os.listdir(os.getcwd())
                    for each in dirList:

src/c/l/CladeCompare-0.2/cladecomparelib/ancestrallrt.py   CladeCompare(Download)
    # - root at the common_ancestor of BG
    # - create another tree of just the outgroup
    _tree = Phylo.read(treefname, 'newick')
 
    # Validation

src/r/a/ragout-0.2b/scripts/debug-report.py   ragout(Download)
def draw_phylogeny(phylogeny_txt, out_file):
    tree_string, target_name = open(phylogeny_txt, "r").read().splitlines()
    g2c.table[target_name] = "red"
 
    tree = Phylo.read(StringIO(tree_string), "newick")

src/f/a/fammer-0.2/fammerlib/cluster.py   fammer(Download)
                                            '-pseudo', '-gamma', '-wag',
                                            tmp.name])
    tree = Phylo.read(StringIO(treedata), 'newick')
 
    # Collapse weakly supported splits

src/r/a/ragout-0.2b/ragout/breakpoint_graph/phylogeny.py   ragout(Download)
    def __init__(self, newick_string):
        self.tree = Phylo.read(StringIO(newick_string), "newick")
        self.validate_tree()
        self.tree_string = newick_string
 

src/f/f/FFPopSim-2.0/src/python/FFPopSim.py   FFPopSim(Download)
        treedata = self.print_newick()
        handle = StringIO(treedata)
        tree = Phylo.read(handle, "newick")
        return tree
 

src/t/a/taxtastic-0.5.2/taxtastic/refpkg.py   taxtastic(Download)
        with self.open_resource('tree') as f:
            try:
                Bio.Phylo.read(f, 'newick')
            except:
                return 'tree file is not valid Newick.'

src/b/i/biopython-1.63/Tests/test_Phylo.py   biopython(Download)
    def test_newick_read_single(self):
        """Read a Newick file with one tree."""
        tree = Phylo.read(EX_NEWICK, 'newick')
        self.assertEqual(len(tree.get_terminals()), 28)
 
        tree = Phylo.read(EX_NEWICK2, 'newick')
        self.assertEqual(tree.find_any('Equus caballus').comment, "wild horse; also 'Equus ferus caballus'")
        self.assertEqual(tree.root.confidence, 80)
        tree = Phylo.read(EX_NEWICK2, 'newick', comments_are_confidence=True)
        self.assertEqual(tree.root.confidence, 100)
 
        tree = Phylo.read(EX_NEXUS2, 'nexus')
    def test_newick_write(self):
        """Parse a Nexus file with multiple trees."""
        # Tree with internal node labels
        mem_file = StringIO()
        tree = Phylo.read(StringIO('(A,B,(C,D)E)F;'), 'newick')

src/b/i/biopython-HEAD/Tests/test_Phylo.py   biopython(Download)
    def test_newick_read_single1(self):
        """Read first Newick file with one tree."""
        tree = Phylo.read(EX_NEWICK, 'newick')
        self.assertEqual(len(tree.get_terminals()), 28)
 
    def test_newick_read_single2(self):
        """Read second Newick file with one tree."""
        tree = Phylo.read(EX_NEWICK2, 'newick')
        self.assertEqual(tree.find_any('Equus caballus').comment, "wild horse; also 'Equus ferus caballus'")
        self.assertEqual(tree.root.confidence, 80)
        tree = Phylo.read(EX_NEWICK2, 'newick', comments_are_confidence=True)
        self.assertEqual(tree.root.confidence, 100)
 
    def test_newick_read_single3(self):
        """Read Nexus file with one tree."""
        tree = Phylo.read(EX_NEXUS2, 'nexus')
            # Must specify the encoding on Windows
            with open(EX_NEWICK_BOM, encoding="utf-8") as handle:
                tree = Phylo.read(handle, 'newick')
            self.assertEqual(len(tree.get_terminals()), 3)
 

src/b/i/biopython-HEAD/Tests/test_Phylo_depend.py   biopython(Download)
    def test_draw(self):
        """Run the tree layout algorithm, but don't display it."""
        pyplot.ioff()   # Turn off interactive display
        dollo = Phylo.read(EX_DOLLO, 'phyloxml')
        apaf = Phylo.read(EX_APAF, 'phyloxml')
    def test_draw_ascii(self):
        """Tree to Graph conversion."""
        handle = StringIO()
        tree = Phylo.read(EX_APAF, 'phyloxml')
        Phylo.draw_ascii(tree, file=handle)
        def test_to_networkx(self):
            """Tree to Graph conversion, if networkx is available."""
            tree = Phylo.read(EX_DOLLO, 'phyloxml')
            G = Phylo.to_networkx(tree)
            self.assertEqual(len(G.nodes()), 659)

  1 | 2  Next