/** * Write the meta data represented by the chunkLists associated with bin MAX_BINS 37450 * * @param metaData information describing numAligned records, numUnAligned, etc */ private void writeChunkMetaData(final int reference, final BAMIndexMetaData metaData) { final int nChunks = metaData == null ? 0 : 2; pw.print(" Ref " + reference + " bin 37450 has n_chunk= " + nChunks); if (nChunks == 0) { pw.println(); } else { pw.println(" Chunk: " + // c.toString() + " start: " + Long.toString(metaData.getFirstOffset(), 16) + " end: " + Long.toString(metaData.getLastOffset(), 16)); pw.println(" Chunk: " + // c.toString() + " start: " + Long.toString(metaData.getAlignedRecordCount(), 16) + " end: " + Long.toString(metaData.getUnalignedRecordCount(), 16)); } }
/** * Write the meta data represented by the chunkLists associated with bin MAX_BINS 37450 * * @param metaData information describing numAligned records, numUnAligned, etc */ private void writeChunkMetaData(final int reference, final BAMIndexMetaData metaData) { final int nChunks = metaData == null ? 0 : 2; pw.print(" Ref " + reference + " bin 37450 has n_chunk= " + nChunks); if (nChunks == 0) { pw.println(); } else { pw.println(" Chunk: " + // c.toString() + " start: " + Long.toString(metaData.getFirstOffset(), 16) + " end: " + Long.toString(metaData.getLastOffset(), 16)); pw.println(" Chunk: " + // c.toString() + " start: " + Long.toString(metaData.getAlignedRecordCount(), 16) + " end: " + Long.toString(metaData.getUnalignedRecordCount(), 16)); } }
/** * Write the meta data represented by the chunkLists associated with bin MAX_BINS 37450 * * @param metaData information describing numAligned records, numUnAligned, etc */ private void writeChunkMetaData(final int reference, final BAMIndexMetaData metaData) { final int nChunks = metaData == null ? 0 : 2; pw.print(" Ref " + reference + " bin 37450 has n_chunk= " + nChunks); if (nChunks == 0) { pw.println(); } else { pw.println(" Chunk: " + // c.toString() + " start: " + Long.toString(metaData.getFirstOffset(), 16) + " end: " + Long.toString(metaData.getLastOffset(), 16)); pw.println(" Chunk: " + // c.toString() + " start: " + Long.toString(metaData.getAlignedRecordCount(), 16) + " end: " + Long.toString(metaData.getUnalignedRecordCount(), 16)); } }
/** * Write the meta data represented by the chunkLists associated with bin MAX_BINS 37450 * * @param metaData information describing numAligned records, numUnAligned, etc */ private void writeChunkMetaData(final BAMIndexMetaData metaData) { codec.writeInt(GenomicIndexUtil.MAX_BINS); final int nChunk = 2; codec.writeInt(nChunk); codec.writeLong(metaData.getFirstOffset()); codec.writeLong(metaData.getLastOffset()); codec.writeLong(metaData.getAlignedRecordCount()); codec.writeLong(metaData.getUnalignedRecordCount()); }
continue; System.out.println("\tAligned= " + data[i].getAlignedRecordCount() + "\tUnaligned= " + data[i].getUnalignedRecordCount());
continue; System.out.println("\tAligned= " + data[i].getAlignedRecordCount() + "\tUnaligned= " + data[i].getUnalignedRecordCount());
/** * Write the meta data represented by the chunkLists associated with bin MAX_BINS 37450 * * @param metaData information describing numAligned records, numUnAligned, etc */ private void writeChunkMetaData(final BAMIndexMetaData metaData) { codec.writeInt(GenomicIndexUtil.MAX_BINS); final int nChunk = 2; codec.writeInt(nChunk); codec.writeLong(metaData.getFirstOffset()); codec.writeLong(metaData.getLastOffset()); codec.writeLong(metaData.getAlignedRecordCount()); codec.writeLong(metaData.getUnalignedRecordCount()); }
count += meta.getAlignedRecordCount();
/** * Write the meta data represented by the chunkLists associated with bin MAX_BINS 37450 * * @param metaData information describing numAligned records, numUnAligned, etc */ private void writeChunkMetaData(final BAMIndexMetaData metaData) { codec.writeInt(GenomicIndexUtil.MAX_BINS); final int nChunk = 2; codec.writeInt(nChunk); codec.writeLong(metaData.getFirstOffset()); codec.writeLong(metaData.getLastOffset()); codec.writeLong(metaData.getAlignedRecordCount()); codec.writeLong(metaData.getUnalignedRecordCount()); }
/** * Write the meta data represented by the chunkLists associated with bin MAX_BINS 37450 * * @param metaData information describing numAligned records, numUnAligned, etc */ private void writeChunkMetaData(final BAMIndexMetaData metaData) { codec.writeInt(GenomicIndexUtil.MAX_BINS); final int nChunk = 2; codec.writeInt(nChunk); codec.writeLong(metaData.getFirstOffset()); codec.writeLong(metaData.getLastOffset()); codec.writeLong(metaData.getAlignedRecordCount()); codec.writeLong(metaData.getUnalignedRecordCount()); }
/** * Write the meta data represented by the chunkLists associated with bin MAX_BINS 37450 * * @param metaData information describing numAligned records, numUnAligned, etc */ private void writeChunkMetaData(final BAMIndexMetaData metaData) { codec.writeInt(GenomicIndexUtil.MAX_BINS); final int nChunk = 2; codec.writeInt(nChunk); codec.writeLong(metaData.getFirstOffset()); codec.writeLong(metaData.getLastOffset()); codec.writeLong(metaData.getAlignedRecordCount()); codec.writeLong(metaData.getUnalignedRecordCount()); }
public static long getAlignedReadCount(String bam) throws IOException{ /* ------------------------------------------------------ */ /* This chunk prepares SamReader from local bam or URL bam */ UrlValidator urlValidator = new UrlValidator(); SamReaderFactory srf=SamReaderFactory.make(); srf.validationStringency(ValidationStringency.SILENT); SamReader samReader; if(urlValidator.isValid(bam)){ samReader = SamReaderFactory.makeDefault().open( SamInputResource.of(new URL(bam)).index(new URL(bam + ".bai")) ); } else { samReader= srf.open(new File(bam)); } /* ------------------------------------------------------ */ List<SAMSequenceRecord> sequences = samReader.getFileHeader().getSequenceDictionary().getSequences(); long alnCount= 0; for(SAMSequenceRecord x : sequences){ alnCount += samReader.indexing().getIndex().getMetaData(x.getSequenceIndex()).getAlignedRecordCount(); } samReader.close(); return alnCount; }
final BAMIndexMetaData metaData_0 = index.getMetaData(0); Assert.assertNotNull(metaData_0); Assert.assertEquals(metaData_0.getAlignedRecordCount(), 1); Assert.assertEquals(metaData_1.getAlignedRecordCount(), 3); Assert.assertEquals(metaData_2.getAlignedRecordCount(), 2);
continue; System.out.println("\tAligned= " + data[i].getAlignedRecordCount() + "\tUnaligned= " + data[i].getUnalignedRecordCount());
public static long countSamTotalRecord(final File samFile) { final SamReader reader = SamReaderFactory.make().open(samFile); assert reader.hasIndex(); long total = 0; for (int i = 0; i < reader.getFileHeader().getSequenceDictionary().size(); i++) { total += reader.indexing().getIndex().getMetaData(i).getAlignedRecordCount(); total += reader.indexing().getIndex().getMetaData(i).getUnalignedRecordCount(); } return total; } }
BAMIndexMetaData metaData = reader.indexing().getIndex().getMetaData(sequenceIndex); Assert.assertEquals(EXPECTED_ALL_READS - EXPECTED_UNMAPPED_READS, metaData.getAlignedRecordCount());