why htsjdk SamReader query() not work?
0
0
Entering edit mode
7.1 years ago
wkk.215774 ▴ 10

l am using htsjdk package to handle my bam file, but it seems the SamReader query() method does not work for me. This is my program code:

SamReader reader=SamReaderFactory.makeDefault().open(new File(in_bam_file));
    SAMFileWriter outputstream=new SAMFileWriterFactory().makeSAMWriter(reader.getFileHeader(), true, new File(out_bam_file));
    SAMRecordIterator recordQuery=reader.query("chr1",1, 10000000,true);
    while(recordQuery.hasNext())
    System.out.println("query size is:\t"+recordQuery.next());

when l running this program, nothing print out. l have already read the htsjdk api doc, but l don't know why. Someone know this? l use htsjdk 2.9.1

next-gen software error genome • 1.2k views
ADD COMMENT
0
Entering edit mode

1) are you sure there is a 'chr1' in your bam file ('chr1" , not '1' ). What the output of

samtools -c your.bam "chr1:1-10000000"

2) what's the point of this SAMFileWriter ?

ADD REPLY
0
Entering edit mode

1) yes, pretty sure, cause l use "samtools view -H R7103052.bam" to check the header @SQ, it's chr1 not 1. 2) "SAMFileWriter" is just for testing.

ADD REPLY

Login before adding your answer.

Traffic: 2930 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