This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Converting Taxonomic Lineages Into A Common Tree

I have a number of lineages like this:

Bacteria;Chlamydiae;Chlamydiae;Chlamydiales;Chlamydiaceae;Chlamydophila;
Bacteria;Firmicutes;Bacilli;Lactobacillales;Lactobacillaceae;Lactobacillus;
Bacteria;Firmicutes;Bacilli;Lactobacillales;Streptococcaceae;Streptococcus;
... (the list continues)

Is there any tool capable of converting these lineages into common tree in Nexus or Newick format?

tree

1 answer

The following java program should work:

compile & run:

javac Biostar52895.java

$ echo "Bacteria;Chlamydiae;Chlamydiae;Chlamydiales;Chlamydiaceae;Chlamydophila;
Bacteria;Firmicutes;Bacilli;Lactobacillales;Lactobacillaceae;Lactobacillus;
Bacteria;Firmicutes;Bacilli;Lactobacillales;Streptococcaceae;Streptococcus;" | java Biostar52895

((((((Chlamydophila)Chlamydiaceae)Chlamydiales)Chlamydiae)Chlamydiae,((((Lactobacillus)Lactobacillaceae,(Streptococcus)Streptococcaceae)Lactobacillales)Bacilli)Firmicutes)Bacteria);

Biostars classic :) "Is there a tool that ...?" Pierre's answer: "Yes, there is. Let me write it for you." Thank you very, very much Pierre.

hey pierre. thanks a lot for this solution. probably a stupid question but i'm a biochemist and this is my first java program ever. i've compiled your program on my mac os x 10.8 and want to run it now, but it just goes into an endless loop. how is the input (the list) specified. thx!

@Pierre, I tried the javascript but somehow it didn't work. Did my miss some dependencies of java packages or something in my installed java program? ( I have no knowledge in java)

echo "Bacteria;Chlamydiae;Chlamydiae;Chlamydiales;Chlamydiaceae;Chlamydophila;Bacteria;Firmicutes;Bacilli;Lactobacillales;Lactobacillaceae;Lactobacillus;Bacteria;Firmicutes;Bacilli;Lactobacillales;Streptococcaceae;Streptococcus;" | java Biostar52895

error message:

Exception in thread "main" java.lang.NoClassDefFoundError: Biostar52895
Caused by: java.lang.ClassNotFoundException: Biostar52895
        at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:323)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:268)
Could not find the main class: Biostar52895. Program will exit.

it's not javascript, it's java. It's compiled compiled with javac Biostar52895.java and executed with java Biostar52895

Now I see javac didn't compile the Biostart52895.java and the expected .class file was missing. can you point me why?

javac Biostar52895.java
Output:
Biostar52895.java:13: > expected
        Map<String,Node> children=new TreeMap<String, Biostar52895.Node="">();
                                                                       ^
Biostar52895.java:13: ';' expected
        Map<String,Node> children=new TreeMap<String, Biostar52895.Node="">();
                                                                        ^
Biostar52895.java:13: illegal start of type
        Map<String,Node> children=new TreeMap<String, Biostar52895.Node="">();
                                                                          ^
Biostar52895.java:13: <identifier> expected
        Map<String,Node> children=new TreeMap<String, Biostar52895.Node="">();
                                                                           ^
Biostar52895.java:13: ';' expected
        Map<String,Node> children=new TreeMap<String, Biostar52895.Node="">();
                                                                            ^
Biostar52895.java:70: '(' or '[' expected
        app.parse(new BufferedReader(new InputStreamReaderSystem.in)));
                                                                   ^
Biostar52895.java:70: ';' expected
        app.parse(new BufferedReader(new InputStreamReaderSystem.in)));
                                                                     ^
7 errors

Ah, I see, it's because the code has been changed by the new version of biostars. It thinks it's HTML.

Give me a few minutes....

Thanks Pierre. It's working now..!! Excellent.

Log in to answer this question.