Exemplo n.º 1
0
 /** write out any references between the currentReference and the nextReference */
 private void advanceToReference(final int nextReference) {
   while (currentReference < nextReference) {
     final BAMIndexContent content = indexBuilder.processReference(currentReference);
     outputWriter.writeReference(content);
     currentReference++;
     if (currentReference < numReferences) {
       indexBuilder.startNewReference();
     }
   }
 }
Exemplo n.º 2
0
 /**
  * Record any index information for a given BAM record. If this alignment starts a new reference,
  * write out the old reference. Requires a non-null value for rec.getFileSource().
  *
  * @param rec The BAM record
  */
 public void processAlignment(final SAMRecord rec) {
   try {
     final int reference = rec.getReferenceIndex();
     if (reference != SAMRecord.NO_ALIGNMENT_REFERENCE_INDEX && reference != currentReference) {
       // process any completed references
       advanceToReference(reference);
     }
     indexBuilder.processAlignment(rec);
   } catch (final Exception e) {
     throw new SAMException("Exception creating BAM index for record " + rec, e);
   }
 }
Exemplo n.º 3
0
 /**
  * After all the alignment records have been processed, finish is called. Writes any final
  * information and closes the output file.
  */
 public void finish() {
   // process any remaining references
   advanceToReference(numReferences);
   outputWriter.writeNoCoordinateRecordCount(indexBuilder.getNoCoordinateRecordCount());
   outputWriter.close();
 }