SAMRecordIterator iterator = reader.iterator();
Map<String, Out> map = new TreeMap<String, DecomposeBAM.Out>();
long bases = 0;
while (iterator.hasNext() && params.maxRecords-- > 0) {
SAMRecord record = iterator.next();
bases += record.getReadLength();
put(map, "QNAME", record.getReadName());
put(map, "FLAG", String.valueOf(record.getFlags()));
put(map, "RNAME", record.getReferenceName());
put(map, "POS", String.valueOf(record.getAlignmentStart()));
put(map, "MAPQ", String.valueOf(record.getMappingQuality()));
put(map, "CIGAR", record.getCigarString());
put(map, "RNEXT", record.getMateReferenceName());
put(map, "PNEXT", String.valueOf(record.getMateAlignmentStart()));
put(map, "TLEN", String.valueOf(record.getInferredInsertSize()));
put(map, "SEQ", record.getReadString());
put(map, "QUAL", record.getBaseQualityString());
for (SAMTagAndValue tv : record.getAttributes()) {
writeTagValue(map, tv);
}
}
close(map);