int end = 300000000;
int start = end / 5;
BAMFileReader bamreader = new BAMFileReader(new File(bamfile));
SAMReader samreader = new SAMReader(samfile);
CloseableIterator<PicardAlignment> bamiter = bamreader.query(chr, start, end, true);
CloseableIterator<PicardAlignment> samiter = samreader.iterator();
int count = 0;
while (bamiter.hasNext()) {
Alignment bamrecord = bamiter.next();
Alignment samrecord = samiter.next();