Unconfigured Ad

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sphil
    Senior Member
    • Apr 2010
    • 192

    #1

    Parse Labels from newick tree

    Hey there,

    I am searching for script which extract the node labels from a given newick String. Is there any tool available at the internet, or maybe someone of you guys can help me...


    Best,

    Phil
  • maubp
    Peter (Biopython etc)
    • Jul 2009
    • 1544

    #2
    There are several options available - which programing language are you happiest with? If Python, then Biopython includes a Newick parser.

    Also it would help if you could clarify exactly what you want to get out - just a list of the node labels, throwing away the tree structure?

    Comment

    • sphil
      Senior Member
      • Apr 2010
      • 192

      #3
      I just want to have the labels. Tree structure can be thrown away... Python is fine...

      Comment

      • maubp
        Peter (Biopython etc)
        • Jul 2009
        • 1544

        #4
        If there are internal node labels, do you want the terminal (leaf) names only?

        e.g. Using Biopython

        Code:
        from Bio import Phylo
        tree = Phylo.read("int_node_labels.nwk", "newick")
        for leaf in tree.get_terminals(): print leaf.name
        Last edited by maubp; 05-24-2012, 06:27 AM. Reason: Adding script

        Comment

        • sphil
          Senior Member
          • Apr 2010
          • 192

          #5
          Internal as well would be great...

          Comment

          • maubp
            Peter (Biopython etc)
            • Jul 2009
            • 1544

            #6
            Originally posted by sphil View Post
            Internal as well would be great...
            For just the internal nodes,
            Code:
            from Bio import Phylo
            tree = Phylo.read("int_node_labels.nwk", "newick")
            for node in tree.get_nonterminals(): print node.name
            For everything try:
            Code:
            from Bio import Phylo
            tree = Phylo.read("int_node_labels.nwk", "newick")
            for node in tree.find_clades():
                #Don't print anything if there is no name
                if node.name:
                    print node.name

            Comment

            • sphil
              Senior Member
              • Apr 2010
              • 192

              #7
              thanks alot!

              Comment

              Latest Articles

              Collapse

              • SEQadmin2
                The Factors Reshaping Genome Assembly
                by SEQadmin2



                When the Human Genome Project declared the human genome finished in 2003, portions of the sequence were still missing, including many of its most repetitive and structurally complex regions.1 Still, for the next two decades, researchers analyzed their sequencing data against the single linear reference that came out of this effort. Released in 2013 as GRCh38, that reference has powered countless discoveries, but it has gaps and cannot capture the genetic diversity of the world’s...
                11-24-2026, 07:04 AM
              • SEQadmin2
                16S/ITS Profiling vs. Shotgun Metagenomics: What Changes in Your Workflow?
                by SEQadmin2





                NGS has revolutionized clinical microbiology by offering new ways to identify and surveil pathogens without prior knowledge of the target. One popular approach is 16S rRNA and ITS amplicon sequencing, which targets specific microbial markers. But studies are increasingly incorporating shotgun metagenomics, a technique that sequences all DNA from a sample without targeting specific microbial markers. This approach allows more detailed taxonomic classification,...
                10-30-2026, 06:46 AM

              ad_right_rmr

              Collapse

              News

              Collapse

              Topics Statistics Last Post
              Started by SEQadmin2, 11-23-2026, 11:11 AM
              0 responses
              39 views
              0 reactions
              Last Post SEQadmin2  
              Started by SEQadmin2, 11-17-2026, 06:27 AM
              0 responses
              47 views
              0 reactions
              Last Post SEQadmin2  
              Started by SEQadmin2, 11-12-2026, 07:59 AM
              0 responses
              68 views
              0 reactions
              Last Post SEQadmin2  
              Started by SEQadmin2, 11-05-2026, 09:25 AM
              0 responses
              68 views
              0 reactions
              Last Post SEQadmin2  
              Working...