This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Mark duplicates PICARD error: Unable to access jarfile 'MarkDuplicates.jar' with commandline/with R dupRadar package

I've converted SAM file to BAM, sorted the BAM file and indexed it. Then tried to mark duplicates with PICARD using R dupRadar package:

library(dupRadar)
PICARD_path='/Applications/Anaconda/pkgs/qualimap-2.2.2a-2/share/qualimap-2.2.2a-2/picard-1.70.jar'
BAM_file='/Volumes/PereiraCytolab/Tania/RNA_seq_analysis_Newmethods/Results/BJs/STAR_alignments/1A_ATCACG_withoutadapters'
bamDuprm <- markDuplicates(dupremover="picard", bam=BAM_file, path=PICARD_path, rminput=TRUE)

And got this error:

Unable to access jarfile /Applications/Anaconda/pkgs/qualimap-2.2.2a-2/share/qualimap-2.2.2a-2/picard-1.70.jar/MarkDuplicates.jar
Error in picardMarkDuplicates(bam = bam, out = out, path = path, verbose = verbose,  : 
  picard returned error code1in command: java -XX:ParallelGCThreads=1 -Xmx4g -jar /Applications/Anaconda/pkgs/qualimap-2.2.2a-2/share/qualimap-2.2.2a-2/picard-1.70.jar/MarkDuplicates.jar INPUT=/Volumes/PereiraCytolab/Tania/RNA_seq_analysis_Newmethods/Results/BJs/STAR_alignments/1A_ATCACG_withoutadapters OUTPUT=/Volumes/PereiraCytolab/Tania/RNA_seq_analysis_Newmethods/Results/BJs/STAR_alignments/1A_ATCACG_withoutadapters METRICS_FILE=/Volumes/PereiraCytolab/Tania/RNA_seq_analysis_Newmethods/Results/BJs/STAR_alignments/1A_ATCACG_withoutadapters REMOVE_DUPLICATES=false ASSUME_SORTED=true PROGRAM_RECORD_ID='null'

Then I tried to use the commandline instead:

java -jar $PICARD MarkDuplicates INPUT=1A_ATCACG_withoutadapters_sorted.bam OUTPUT=1A_ATCACG_withoutadapters_sorted_dupmarked.bam METRICS_FILE=dupmarkmetrics.txt

And got this error:

Error: Unable to access jarfile MarkDuplicates

To test if PICARD was correctly installed I did:

java -jar $PICARD -h

And got the list of tools of Picard, so what is wrong?

markduplicates picard rna-seq
java -jar $PICARD MarkDuplicates
java -jar $PICARD -h

are you doing both tests inside your shell and/or both inside R ? For the first line $PICARD is empty. I suspect your R script doesn't contain the environment variable $PICARD. Further more add some double quotesn, use "${PICARD}" instead of $PICARD . It will bne easier to debug.

by doing on commandline:

java -jar $PICARD -h

it prints an output, but with:

java -jar $PICARD MarkDuplicates

gives error:

Error: Unable to access jarfile MarkDuplicates

in Rstudio any doesn't work with or without quotes

1 answer

show me the output of

echo java -jar $PICARD -h && echo java -jar $PICARD MarkDuplicates

it's this:

 java -jar -h
 java -jar MarkDuplicates

so $PICARD is not defined. And, unlike what you said,

java -jar -h

will only show the java help

Usage: java [-options] class [args...]
           (to execute a class)
   or  java [-options] -jar jarfile [args...]
           (to execute a jar file)
where options include:
    -d32      use a 32-bit data model if available
    -d64      use a 64-bit data model if available
    -server   to select the "server" VM

right. I though it was PICARD's help menu but it's java help menu. So I have to write the path to the picard.jar file is that it?

when providing full path to picard. jar file:

java -jar /Applications/Anaconda/pkgs/qualimap-2.2.2a-2/share/qualimap-2.2.2a-2/picard-1.70.jar -h

still gives error:

no main manifest attribute, in /Applications/Anaconda/pkgs/qualimap-2.2.2a-2/share/qualimap-2.2.2a-2/picard-1.70.jar

Now with picard 2.18 I run this:

BAM_file=/Volumes/PereiraLab/Tania/RNAseqcourse/material/results/results_fastqexamples/alignments/HISAT2_adapter_removed_qualitytrim_20150821.A-2_BGVR_P218_R1_paired_with_retrievedgenome_ensembl.bam
output=/Volumes/PereiraLab/Tania/RNAseqcourse/material/results/results_fastqexamples/alignments/result.bam
java -jar /Applications/Anaconda/share/picard-2.18.7-2/picard.jar MarkDuplicates INPUT=BAM_file OUTPUT=output METRICS_FILE=dupmarkmetrics.txt

and got an error:

[Fri Jul 06 15:14:15 WEST 2018] picard.sam.markduplicates.MarkDuplicates done. Elapsed time: 0.00 minutes.
Runtime.totalMemory()=257425408
To get help, see http://broadinstitute.github.io/picard/index.html#GettingHelp
Exception in thread "main" htsjdk.samtools.SAMException: Cannot read non-existent file: file:///Users/Lab/BAM_file
    at htsjdk.samtools.util.IOUtil.assertFileIsReadable(IOUtil.java:426)
    at htsjdk.samtools.util.IOUtil.assertFileIsReadable(IOUtil.java:413)
    at htsjdk.samtools.util.IOUtil.assertInputIsValid(IOUtil.java:389)
    at htsjdk.samtools.util.IOUtil.assertInputsAreValid(IOUtil.java:465)
    at picard.sam.markduplicates.MarkDuplicates.doWork(MarkDuplicates.java:224)
    at picard.cmdline.CommandLineProgram.instanceMain(CommandLineProgram.java:282)
    at picard.cmdline.PicardCommandLine.instanceMain(PicardCommandLine.java:103)
    at picard.cmdline.PicardCommandLine.main(PicardCommandLine.java:113)

and the file was not created in OUTPUT directory. what's hapening?

p.s. you suggested v2.19, but i don't know how to install 2.19 with Anaconda (I used conda install -c bioconda picard to update to v2.18

the file BAM_file doesn't exist.

at this point, I stop helping you.

the file was there, it was missing $. no need to be rude... thank you for your help

Log in to answer this question.