Check if a BAM file is corrupt in Java
1
0
Entering edit mode
6 weeks ago

Hi!

I am building a program in java and part of it would be creating and handling BAM files. My problem is the following: before writing I would like to check if a BAM file with the same name already exists and if yes, is it corrupt. I have found solutions for checking BAM files using samtools and picard, but these seem to be command-line based. Is there a way to check in java? My only option so far seems to be calling either samtools or picard using ProcessBuilder, but I would like to avoid this if possible, as I plan to have lot of BAMs and this doesn't seem to be an efficient solution.

Thanks in advance

bam java • 432 views
ADD COMMENT
1
Entering edit mode
4 weeks ago

well you can use picard itself as a library.

java -cp /path/to/picard.jar:path/to/your.jar your.package.Main

and in your java code:

     // see https://github.com/broadinstitute/picard/blob/master/src/main/java/picard/sam/ValidateSamFile.java
     picard.sam.ValidateSamFile prog = new  picard.sam.ValidateSamFile();
     int returnValue = prog.instanceMain(new String[]{"-I","/path/to/your/bam", etc... etc..};
ADD COMMENT

Login before adding your answer.

Traffic: 1046 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6