We’re moving the GATK website, docs and forum to a new platform. Read the full story and breakdown of key changes on this blog.
If you happen to see a question you know the answer to, please do chime in and help your fellow community members. We encourage our fourm members to be more involved, jump in and help out your fellow researchers with their questions. GATK forum is a community forum and helping each other with using GATK tools and research is the cornerstone of our success as a genomics research community.We appreciate your help!
Test-drive the GATK tools and Best Practices pipelines on Terra
Check out this blog post to learn how you can get started with GATK and try out the pipelines in preconfigured workspaces (with a user-friendly interface!) without having to install anything.
We will be out of the office for a Broad Institute event from Dec 10th to Dec 11th 2019. We will be back to monitor the GATK forum on Dec 12th 2019. In the meantime we encourage you to help out other community members with their queries.
Thank you for your patience!
GATK depthofcoverage runtimeerror: nullpointerexception

Hi, I'm getting a nullpointerexception when trying to run the depthofcoverage tool. The stack trace is as follows:
##### ERROR ------------------------------------------------------------------------------------------ ##### ERROR stack trace java.lang.NullPointerException at java.util.TreeMap.compare(TreeMap.java:1290) at java.util.TreeMap.put(TreeMap.java:538) at java.util.TreeSet.add(TreeSet.java:255) at org.broadinstitute.gatk.utils.sam.ReadUtils.getSAMFileSamples(ReadUtils.java:70) at org.broadinstitute.gatk.engine.samples.SampleDBBuilder.addSamplesFromSAMHeader(SampleDBBuilder.java:66) at org.broadinstitute.gatk.engine.GenomeAnalysisEngine.initializeSampleDB(GenomeAnalysisEngine.java:846) at org.broadinstitute.gatk.engine.GenomeAnalysisEngine.execute(GenomeAnalysisEngine.java:296) at org.broadinstitute.gatk.engine.CommandLineExecutable.execute(CommandLineExecutable.java:121) at org.broadinstitute.gatk.utils.commandline.CommandLineProgram.start(CommandLineProgram.java:248) at org.broadinstitute.gatk.utils.commandline.CommandLineProgram.start(CommandLineProgram.java:155) at org.broadinstitute.gatk.engine.CommandLineGATK.main(CommandLineGATK.java:108) ##### ERROR ------------------------------------------------------------------------------------------ ##### ERROR A GATK RUNTIME ERROR has occurred (version nightly-2016-03-23-g4d8dc3c): ##### ERROR ##### ERROR This might be a bug. Please check the documentation guide to see if this is a known problem. ##### ERROR If not, please post the error message, with stack trace, to the GATK forum. ##### ERROR Visit our website and forum for extensive documentation and answers to ##### ERROR commonly asked questions http://www.broadinstitute.org/gatk ##### ERROR ##### ERROR MESSAGE: Code exception (see stack trace for error itself) ##### ERROR ------------------------------------------------------------------------------------------
and the command is called as follows:
java -jar $HOME/software/gatk/nightly_build/GenomeAnalysisTK.jar \ -T DepthOfCoverage \ -R $ref \ -I $bam \ -o $SUBMITDIR/output/seqdepth_s1t
Where $bam is a path pointing to an accepted_hits.sorted.bam aligned using HISAT2. It's directory also contains the bam index (note that I do get a warning stating that my index is older than my bam file). $ref is an ensembl sequence .fasta file
I've tried running the latest stable release and the latest nightly build, both give errors. For what it's worth, GATK should have read/write permissions to the specified output path and the path of the bam-file, but not in the directory holding the reference, could that cause a problem or is it something else? Also, it's run on a cluster using slurm, if that's of any relevance.
Thanks in advance.
-Jonas
Best Answer
-
Sheila Broad Institute admin
@jonasmst
Hi Jonas,The team has figured out that the issue might be that your BAM file header is missing the SM field in the Read Group (@RG). It validates with ValidateSamFile because the SM field is not required by the tool, but GATK requires it. Can you take a look and see if indeed the SM field is missing? You can use samtools view -H "your bam file".
Thanks,
Sheila
Answers
@jonasmst
Hi Jonas,
It could be an issue with the permissions for the reference directory. You can also try validating your bam file with ValidateSamFile.
-Sheila
Hi, Sheila, thank you for replying so quickly.
I've tried copying the reference to an open environment to see if the permissions was the issue. To no avail, I'm afraid. I've also validated the BAM-file and, for good measure, reindexed it to get rid of the warning.
Any other suggestions? Are there specific requirements to java version for instance? Or does the tool depend on any other software such as bedtools or samtools?
Thanks, Jonas
@jonasmst
Hi Jonas,
Ah, yes GATK only supports Java 1.7 right now. Have a look at this document for help on switching between versions. No, the tool should not depend on other software.
-Sheila
I am still getting nullpointerexception when using java version 1.7.0_79, albeit on line 106 and not 108, but the errors look the same. Do you have any suggestions to other ways of calculating sequencing depth?
I appreciate your help, thank you.
-Jonas
Issue · Github
by Sheila
@jonasmst
Hi Jonas,
The team has figured out that the issue might be that your BAM file header is missing the SM field in the Read Group (@RG). It validates with ValidateSamFile because the SM field is not required by the tool, but GATK requires it. Can you take a look and see if indeed the SM field is missing? You can use samtools view -H "your bam file".
Thanks,
Sheila
Missing SM field seems to have been the culprit. For future reference, I added an SM-field by piping
samtools view
tosed
and replacing the line:@RG ID:sample1
with:
@RG ID:sample1 SM:sample1
before running
PicardTools AddOrReplaceReadGroups
to add the other groups.AddOrReplaceReadGroups
would not work without the SM-field either. Reheading the Picard-output withSamtools reheader
produced a bam-file on whichGATK DepthOfCoverage
seems to run fine.Thanks for all your help, Sheila!
@jonasmst
Hi Jonas,
Thanks for reporting your solution!
-Sheila