Issue
I've tried to execute a few different commands in picard (currently AddOrReplaceReadGroups; see below), but get the error: "Unable to access jarfile". I've tried all of the solutions to this seemingly common problem but can't seem to resolve this. I'm working in bash (on a linux server) within a conda virtual environment; picard is installed in the bin of this virtual environment and I'm running the code while the environment is activated.
I've tried running the code in the same directory where picard is installed. I've added the directory where picard is saved to my path: export PATH=/home/scarvey/miniconda3/envs/stacks_venv/bin:$PATH
. I saved picard as an environment variable: PICARD="/path/to/picard/picard.java"
. I've run the code with full paths to picard and to the files being called. I checked that I have java installed java --version
and the results were: openjdk 17.0.3-internal 2022-04-19
Code to run AddOrReplaceReadGroups:
java -jar $PICARD AddOrReplaceReadGroups I=ATPU_MSI_101505899.1.sorted.bam O=ATPU.MSI.101505899.rg.sorted.bam RGID=NovaSeq.QCarvey1.TACAT RGLB=NovaSeq.QCarvey1 RGPL=illumina RGPU=NovaSeq.QCarvey1.TACAT RGSM=MSI.101505899
I imagine there is an element to this that I haven't considered but I feel like I've tried all the solutions I can find. I sincerely appreciate any help.
Solution
If you install the most recent version of picard from the bioconda channel (v2.27.4) and activate the conda environment, you will then have a program picard
in your path. You can then run it like this:
$ picard AddOrReplaceReadGroups I=ATPU_MSI_101505899.1.sorted.bam O=ATPU.MSI.101505899.rg.sorted.bam RGID=NovaSeq.QCarvey1.TACAT RGLB=NovaSeq.QCarvey1 RGPL=illumina RGPU=NovaSeq.QCarvey1.TACAT RGSM=MSI.101505899
The picard
program is a shell script that executes java -jar ...
so you don't need to directly run java
.
Answered By - Will Holtz
Answer Checked By - Robin (JavaFixing Admin)