Snp file from a command line
Brought to you by:
koadman
Hi
I came across the post here:
https://sourceforge.net/p/mauve/mailman/message/31871278/
I'm able to run:
java -cp Mauve.jar org.gel.mauve.analysis.SnpExporter -f aln.xmfa -o aln.snps
on both mac and linux I get the output below:
Loading alignment file...
Exporting SNPs...
But the aln.snps file is empty, it doesn't even contain header information. If I run it in the GUI I get the correct ouput:
SNP pattern sequence_1_Contig sequence_1_PosInContg sequence_1_GenWidePos1 sequence_2_Contig sequence_2_PosInContg sequence_2_GenWidePos2
2 GA NZ_CP014696.2 3316289 3316289 1 451846 451846
Any ideas on how to get the correct output from the command line?
Hello, I'm not the developer, but I think I know may know what is happening:
If you downloaded it directly from the website (development snapshot 2015-02-26, or really any version that is older than the latest revision r4736 (made on 2016-06-08), using the SnpExporter may result in an incomplete output file.
Your choices are:
1. Build Mauve from source
2. Take the code from https://sourceforge.net/p/mauve/code/HEAD/tree//mauve/trunk/src/org/gel/mauve/analysis/SnpExporter.java, compile it, so you get SnpExporter.class, find Mauve.jar in wherever you installed Mauve, open it with a program like WinRar or7zip, and put the SnpExporter.class file you compiled in org/gel/mauve/analysis/ which will replace the old one.
To compile it you will need to do something like
javac -cp "path to mauve.jar" SnpExporter.java
Thanks John for the quick reponse.
I tried doing a fresh build in a docker container, following the build instructions
(http://darlinglab.org/mauve/developer-guide/building.html) ran into a Makefile error:
Makefile:761: recipe for target 'Aligner.lo' failed
make[1]: [Aligner.lo] Error 1
make[1]: Leaving directory '/root/build/libMems/libMems'
Makefile:546: recipe for target 'install-recursive' failed
make: [install-recursive] Error 1
compiled SnpExporter.java into org/gel/mauve/analysis/ and re-created the jar file but getting a version error:
Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/cli/ParseException
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
at java.lang.Class.privateGetMethodRecursive(Class.java:3048)
at java.lang.Class.getMethod0(Class.java:3018)
at java.lang.Class.getMethod(Class.java:1784)
at sun.launcher.LauncherHelper.validateMainClass(LauncherHelper.java:544)
at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:526)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.cli.ParseException
at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 7 more
I can't help you much with #1 since I never tried building from source myself, but for #2 make sure you still have the other necessary libraries in their proper place - your error isn't a version error but a "I can't find the stuff this program relies on error"
Specifically, the file/folder layout should be (relative to Mauve.jar's directory)
./Mauve.jar
./ext/bytecode-1.9.2-SNAPSHOT.jar
./ext/commons-cli-1.2.jar
./ext/core-1.9.2-SNAPSHOT.jar
./ext/gui-1.9.2-SNAPSHOT.jar
These libraries should have come with the mauve download off their site so you could find them in the original installation destination.
Last edit: John Joe 2019-08-20
Thanks John! That helped.
I had to run:
jar cf Mauve-2.jar ext images org
Just FYI I changed:
line 133 output.flush(); -> output.close();
The file was closing before it was done writing.
That's weird - as far as I can tell the stream never closes itself until the program exits so output.flush() should have had the same effect. I had a similar problem a few days before you posted your issue where the file was not completely written and added output.flush() using a different method which solved it for me. The code is convoluted so I might be missing something.
Well, as long as it eventually ended up working it's fine I guess.