s-andrews / FastQC

A quality control analysis tool for high throughput sequencing data
GNU General Public License v3.0
457 stars 86 forks source link

Please provide a build system or some kind of Makefile for complete JAR #68

Closed zamaudio closed 3 years ago

zamaudio commented 3 years ago

For an open source project of this calibre, I would expect to be able to build it from source, rather than output a message to the user:

This is the source distribution of FastQC.  You need to get the compiled version if you want to run the program

Isn't there a build system out there that calls javac and zips up the products into a jar file?

tmancill commented 3 years ago

Hi @zamaudio . The project builds with ant and generates a JAR, that's what the build.xml file for. Debian builds this software from source -see [1,2], which include some patches needed for Debian-based systems.

zamaudio commented 3 years ago

Hi @tmancill I can't seem to generate a JAR of FastQC using ant with the provided build.xml, it doesn't seem to have a JAR target described, can one be added? I'm pretty new at Java (and don't use Eclipse).

[damien@zamx fastqc]$ ant
Buildfile: /home/damien/git/fastqc/build.xml

build-subprojects:

init:
    [mkdir] Created dir: /home/damien/git/fastqc/bin
     [copy] Copying 59 files to /home/damien/git/fastqc/bin

build-project:
     [echo] FastQC: /home/damien/git/fastqc/build.xml
    [javac] Compiling 136 source files to /home/damien/git/fastqc/bin
    [javac] warning: [options] bootstrap class path not set in conjunction with -source 1.5
    [javac] warning: [options] source value 1.5 is obsolete and will be removed in a future release
    [javac] warning: [options] target value 1.5 is obsolete and will be removed in a future release
    [javac] warning: [options] To suppress warnings about obsolete options, use -Xlint:-options.
    [javac] Note: Some input files use unchecked or unsafe operations.
    [javac] Note: Recompile with -Xlint:unchecked for details.
    [javac] 4 warnings

build:

BUILD SUCCESSFUL
Total time: 2 seconds

[damien@zamx fastqc]$ find . -iname "*.jar"
./cisd-jhdf5.jar
./sam-1.103.jar
./jbzip2-0.9.jar
./bin/cisd-jhdf5.jar
./bin/sam-1.103.jar
./bin/jbzip2-0.9.jar
s-andrews commented 3 years ago

FastQC isn't structured to compile down to a jar file. The ant script will compile the source files to class files, but leave them in the existing folder structure. There are parts of the FastQC folder structure which are designed to be user editable after compilation (config files, report templates etc), so we don't package everything into a jar which would make accessing these resources more difficult.

You could probably restructure the build to put the java code into a jar if you wanted, but you'd then need to modify the launch scripts since they expect to be able to see the class files directly.

zamaudio commented 3 years ago

I see, thanks. I seem to have an older version as a standalone jar, perhaps someone here did a custom build. In any case I opened this issue because I think it is very handy to be able to run/transport fastqc as a single file with default settings.

tmancill commented 3 years ago

Hi @zamaudio - apologies for the delay in responding. After compilation, the Debian package builds a JAR with the following command in debian/rules:

cd bin && jar cf fastqc.jar `find uk -name "*.class" -o -name "*.png"` `find net -name "*.class" -o -name "*.png"` Templates

However, to @s-andrews's point, Configuration and Help are shipped separately. The layout of the package on the filesystem for a Debian install ends up being:

/etc/fastqc/Configuration/adapter_list.txt
/etc/fastqc/Configuration/contaminant_list.txt
/etc/fastqc/Configuration/limits.txt
/usr/bin/fastqc
/usr/share/fastqc/Help/...
/usr/share/icons/hicolor/32x32/apps/fastqc_icon.png
/usr/share/java/fastqc-0.11.9.jar
/usr/share/man/man1/fastqc.1.gz
s-andrews commented 3 years ago

If either of you is involved in the Debian pacakge for fastqc could you take a look at #5 and #69 ? Both of these appear to be bugs in the repackaging where the code wasn't patched to account for shifting the confiuration into /etc/ and away from the class files.

tmancill commented 3 years ago

If either of you is involved in the Debian pacakge for fastqc could you take a look at #5 and #69 ? Both of these appear to be bugs in the repackaging where the code wasn't patched to account for shifting the confiuration into /etc/ and away from the class files.

I will. Thank you for the pointer.

s-andrews commented 3 years ago

Great thanks! Let me know if you need any help with putting a suitable patch together.

RandyHarr commented 3 years ago

If you want a single JAR file with a main-entry point for FastQC, you can do the following:

echo -e ""Class-Path: cisd-jhdf5.jar jbzip2-0.9.jar sam-1.103.jar\nMain-Class: uk.ac.babraham.FastQC.FastQCApplication" > Manifest-Update.txt
jar cfm FastQC.jar Manifest-Update.txt uk org net LICENSE* README* RELEASE*

Key is the MANIFEST entry to let the jar know where to find the class'es in the companion jar files. And to set the main entry point. You can then remove the uk/, org/ and net/ directory structures from the original .zip and insert the FastQC.jar file. This MANIFEST would normally be done by Ant or a similar build environment. The CLASS-PATH removes the need to add it to the command line. The run_fastqc.bat file simplifies to: java java -Xmx250m -jar FastQC.jar %* This change is usable on all platforms, The .jar files and Configuration/, Templates/ and Help/ directories must remain and be available. You can add them to the jar file to give a simple way to distribute if you do not want to use the original .zip file. If you do that, then you would use the following command to create the FastQC.jar file: ``` jar cfm FastQC.jar Manifest-Update.txt uk org net LICENSE README RELEASE jar Configuration Templates Help ico To install, your would execute: jar -xf FastQC.jar cisd-jhdf5.jar jbzip2-0.9.jar sam-1.103.jar Configuration Templates Help fastqc_icon.ico inside a fastq directory or wherever you want to use the files and jar. The location must be the same location as the FastQC.jar``` file. This does not buy you much. Just avoids a separate .zip file and .jar file -- they are one in the same..

There is a lot of startup control buried in that perl startup script which is not used by the run_fastqc.bat file and may reference some of these files directly. Not sure. I only tested this on a Win10 system. Both interactive and batch. But not the fastqc perl script. A similar minor cleanup of the perl script could be done to incorporate the use of the FastQC.jar file. Mainly because the CLASSPATH and entry point are set in the MANIFEST.

You can possibly get rid of the three companion jar files. But only by unpacking them back into class directories (like the uk/ and similar) and then including the class directories when creating the original JAR file. Nested jar files are not understood by the Java JVM/JRE. If the jar is called using a (unnamed) main entry point (like a standalone program), then it cannot be unpacked and merged with the FastQC.jar file of classes and must remain separate.