Check if a BAM file is corrupt in Java
1
0
Entering edit mode
4 months 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 • 495 views
ADD COMMENT
1
Entering edit mode
ADD REPLY
1
Entering edit mode
3 months 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: 1793 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