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.
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?
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);
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
Log in to answer this question.
You may also want to take a look at this: http://www.biostars.org/post/show/13452/parsing-ncbi-taxonomic-tree/#13464