Java Code Examples for htsjdk.samtools.util.RuntimeIOException#getCause()

The following examples show how to use htsjdk.samtools.util.RuntimeIOException#getCause() . 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: SamUtils.java    From rtg-tools with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/**
 * Entry point for specifically creating a SamReader given a pre-positioned stream, header, and known type
 * @param stream the stream to read from. Must already be performing decompression if required.
 * @param reference the SequencesReader to be used as the reference (required for CRAM files).
 * @param headerOverride the pre-determined SAM header
 * @param assumeType the type of input to assume.
 * @return the SamReader
 * @throws IOException if an I/O problem occurs opening the file
 */
public static SamReader makeSamReader(InputStream stream, SequencesReader reference, SAMFileHeader headerOverride, SamReader.Type assumeType) throws IOException {
  if (assumeType == null) {
    throw new NullPointerException();
  }
  try {
    return getSamReaderFactory(reference)
      .open(SamInputResource.of(stream).header(headerOverride).assumeType(assumeType));
  } catch (final RuntimeIOException e) {
    throw (IOException) e.getCause();
  }
}
 
Example 2
Source File: SamUtils.java    From rtg-tools with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/**
 * Entry point for creating SamReaders using our preferences
 * @param file the file to open
 * @param reference the SequencesReader to be used as the reference (required for CRAM files).
 * @return the SamReader
 * @throws IOException if an I/O problem occurs opening the file
 */
public static SamReader makeSamReader(File file, SequencesReader reference) throws IOException {
  try {
    return getSamReaderFactory(reference).open(file);
  } catch (final RuntimeIOException e) {
    throw (IOException) e.getCause();
  }
}
 
Example 3
Source File: SamUtils.java    From rtg-tools with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/**
 * Entry point for creating SamReaders using our preferences
 * @param file the file to open
 * @return the SamReader
 * @throws IOException if an I/O problem occurs opening the file
 */
public static SamReader makeSamReader(File file) throws IOException {
  try {
    return getSamReaderFactory(null).open(file);
  } catch (final RuntimeIOException e) {
    throw (IOException) e.getCause();
  }
}
 
Example 4
Source File: SamUtils.java    From rtg-tools with BSD 2-Clause "Simplified" License 3 votes vote down vote up
/**
 * Entry point for specifically creating a SamReader given a provided stream and header, but let
 * htsjdk decide the underlying format (including working out whether the input is compressed).
 * @param stream the stream to read from
 * @param reference the SequencesReader to be used as the reference (required for CRAM files).
 * @param headerOverride the pre-determined SAM header (or null to use the header from the stream)
 * @return the SamReader
 * @throws IOException if an I/O problem occurs opening the file
 */
public static SamReader makeSamReader(InputStream stream, SequencesReader reference, SAMFileHeader headerOverride) throws IOException {
  try {
    return getSamReaderFactory(reference).open(SamInputResource.of(stream).header(headerOverride));
  } catch (final RuntimeIOException e) {
    throw (IOException) e.getCause();
  }
}