/** * If true, uses the caching version of the index reader. * @param enabled true to use the caching version of the reader. */ @Override protected void enableIndexCaching(final boolean enabled) { if(mIndex != null) throw new SAMException("Unable to turn on index caching; index file has already been loaded."); this.mEnableIndexCaching = enabled; }
public String md5() { if(hash == null) { throw new SAMException("Attempting to access md5 digest before the entire file is read! Call close first."); } return hash; }
private void validatePositive(final String attributeName, final int attribute) { if (attribute <= 0) { throw new SAMException(attributeName + " is not positive: " + attribute + " for chain " + id); } }
/** * If true, uses the caching version of the index reader. * @param enabled true to use the caching version of the reader. */ @Override protected void enableIndexCaching(final boolean enabled) { if(mIndex != null) throw new SAMException("Unable to turn on index caching; index file has already been loaded."); this.mEnableIndexCaching = enabled; }
@Override public Interval clone() { try { return (Interval) super.clone(); } catch (CloneNotSupportedException cnse) { throw new SAMException("That's unpossible", cnse); } }
@Override public Interval clone() { try { return (Interval) super.clone(); } catch (CloneNotSupportedException cnse) { throw new SAMException("That's unpossible", cnse); } } }
private String makeHash() { if(hash == null) { hash = new BigInteger(1, md5.digest()).toString(16); if (hash.length() != 32) { final String zeros = "00000000000000000000000000000000"; hash = zeros.substring(0, 32 - hash.length()) + hash; } return hash; } else { throw new SAMException("MD5InputStream is already closed!"); } }
public Character getCharacterAttribute(final String tag) { final Object val = getAttribute(tag); if (val == null) return null; if (val instanceof Character) { return (Character)val; } throw new SAMException("Value for tag " + tag + " is not a Character: " + val.getClass()); }
public static void assertNonDefectiveFile(final File file) throws IOException { if (checkTermination(file) == FileTermination.DEFECTIVE) { throw new SAMException(file.getAbsolutePath() + " does not have a valid GZIP block at the end of the file."); } }
/** * If true, uses the caching version of the index reader. * * @param enabled true to write source information into each SAMRecord. */ public void enableIndexCaching(final boolean enabled) { if (mIndex != null) throw new SAMException("Unable to turn on index caching; index file has already been loaded."); mReader.enableIndexCaching(enabled); }
/** * If false, disable the use of memory mapping for accessing index files (default behavior is to use memory mapping). * This is slower but more scalable when accessing large numbers of BAM files sequentially. * * @param enabled True to use memory mapping, false to use regular I/O. */ public void enableIndexMemoryMapping(final boolean enabled) { if (mIndex != null) { throw new SAMException("Unable to change index memory mapping; index file has already been loaded."); } mReader.enableIndexMemoryMapping(enabled); }
public String getStringAttribute(final String tag) { final Object val = getAttribute(tag); if (val == null) return null; if (val instanceof String) { return (String)val; } throw new SAMException("Value for tag " + tag + " is not a String: " + val.getClass()); }
public float[] getFloatArrayAttribute(final String tag) { final Object val = getAttribute(tag); if (val != null && !(val instanceof float[])) { throw new SAMException("Value for tag " + tag + " is not a float[]: " + val.getClass()); } return (float[]) val; }
static IntervalListInputType forFile(final File intervalListExtractable) { for (final IntervalListInputType intervalListInputType : IntervalListInputType.values()) { for (final String s : intervalListInputType.applicableExtensions) { if (intervalListExtractable.getName().endsWith(s)) { return intervalListInputType; } } } throw new SAMException("Cannot figure out type of file " + intervalListExtractable.getAbsolutePath() + " from extension. Current implementation understands the following types: " + Arrays.toString(IntervalListInputType.values())); }
@Override public void write(final FastqRecord rec) { // encode without creating a String FastqEncoder.write(writer, rec); // and print a new line writer.println(); if (writer.checkError()) { throw new SAMException("Error in writing fastq file " + path); } }
@Override public TestMetric clone() { try { return (TestMetric) super.clone(); } catch (CloneNotSupportedException cnse) { throw new SAMException("That's Unpossible!"); } } }
/** * Method to read the header from a metrics file. */ public static List<Header> readHeaders(final File file) { try { final MetricsFile<MetricBase, ?> metricsFile = new MetricsFile<>(); metricsFile.read(new FileReader(file)); return metricsFile.getHeaders(); } catch (FileNotFoundException e) { throw new SAMException(e.getMessage(), e); } }
/** * Throw an exception if all the "to" sequence names in the chains are not found in the given sequence dictionary. */ public void validateToSequences(final SAMSequenceDictionary sequenceDictionary) { for (final Chain chain : chains.getAll()) { if (sequenceDictionary.getSequence(chain.toSequenceName) == null) { throw new SAMException("Sequence " + chain.toSequenceName + " from chain file is not found in sequence dictionary."); } } }
private static void assertSortOrdersAreEqual(final SAMFileHeader newHeader, final File inputFile) throws IOException { final SamReader reader = SamReaderFactory.makeDefault().open(inputFile); final SAMFileHeader origHeader = reader.getFileHeader(); final SAMFileHeader.SortOrder newSortOrder = newHeader.getSortOrder(); if (newSortOrder != SAMFileHeader.SortOrder.unsorted && newSortOrder != origHeader.getSortOrder()) { throw new SAMException("Sort order of new header does not match the original file, needs to be " + origHeader.getSortOrder()); } reader.close(); } }
private void processAlignment(final SBIIndexWriter indexWriter, final SAMRecord rec) { final SAMFileSource source = rec.getFileSource(); if (source == null) { throw new SAMException("No source (virtual file offsets); needed for indexing on BAM Record " + rec); } final BAMFileSpan filePointer = (BAMFileSpan) source.getFilePointer(); indexWriter.processRecord(filePointer.getFirstOffset()); }