htsjdk.samtools.util.RuntimeEOFException Java Examples

The following examples show how to use htsjdk.samtools.util.RuntimeEOFException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SamMultiRestrictingIterator.java    From rtg-tools with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
public SAMRecord next() {
  if (mNextRecord == null) {
    throw new NoSuchElementException();
  }
  final SAMRecord ret = mNextRecord;
  try {
    populateNext(false);
  } catch (IOException | RuntimeIOException | RuntimeEOFException e) {
    throw new RuntimeIOException(mLabel + ": " + e.getMessage(), e);
  }
  return ret;
}
 
Example #2
Source File: SAMRecordSparkCodec.java    From gatk with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Read the next record from the input stream and convert into a java object.
 *
 * @return null if no more records.  Should throw exception if EOF is encountered in the middle of
 *         a record.
 */
@Override
public SAMRecord decode() {
    int recordLength = 0;
    try {
        recordLength = this.binaryCodec.readInt();
    }
    catch (RuntimeEOFException e) {
        return null;
    }

    if (recordLength < BAMFileConstants.FIXED_BLOCK_SIZE) {
        throw new SAMFormatException("Invalid record length: " + recordLength);
    }
    
    final int referenceID = this.binaryCodec.readInt();
    final int coordinate = this.binaryCodec.readInt() + 1;
    final short readNameLength = this.binaryCodec.readUByte();
    final short mappingQuality = this.binaryCodec.readUByte();
    final int bin = this.binaryCodec.readUShort();
    final int cigarLen = this.binaryCodec.readUShort();
    final int flags = this.binaryCodec.readUShort();
    final int readLen = this.binaryCodec.readInt();
    final int mateReferenceID = this.binaryCodec.readInt();
    final int mateCoordinate = this.binaryCodec.readInt() + 1;
    final int insertSize = this.binaryCodec.readInt();
    final byte[] restOfRecord = new byte[recordLength - BAMFileConstants.FIXED_BLOCK_SIZE];
    this.binaryCodec.readBytes(restOfRecord);
    final BAMRecord ret = this.samRecordFactory.createBAMRecord(
            null, referenceID, coordinate, readNameLength, mappingQuality,
            bin, cigarLen, flags, readLen, mateReferenceID, mateCoordinate, insertSize, restOfRecord);
    return ret;
}