Entering edit mode
7.6 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
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 ?
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.