/** * Gets the SAM file associated with a given reader ID. * @param id The reader for which to retrieve the source file. * @return the file actually associated with the id. */ public File getSAMFile(SAMReaderID id) { return id.getSamFile(); }
logger.debug(String.format("Processing file (%d of %d) %s...", readerNumber++, totalNumberOfFiles, readerID.getSamFile())); readers.put(init.readerID,init.reader); if ( ++nExecutedTotal % tickSize == 0) {
/** * Returns true if the reader caches its SAMFileHeader for each iterator. * @return true if this reader caches its SAMFileHeader for each iterator. */ private boolean isIteratorSAMFileHeaderCached(final SAMReaderID readerID) { // example: https://github.com/samtools/htsjdk/blob/ee4308ede60962f3ab4275473ac384724b471149/src/java/htsjdk/samtools/CRAMFileReader.java#L183 return !readerID.getSamFile().getName().toLowerCase().endsWith(SamReader.Type.CRAM_TYPE.fileExtension()); }
public ReaderInitializer call() { try { if (threadAllocation.getNumIOThreads() > 0) blockInputStream = new BlockInputStream(dispatcher,readerID,false); SamReaderFactory factory = SamReaderFactory.makeDefault() .validationStringency(validationStringency) .setOption(SamReaderFactory.Option.EAGERLY_DECODE, false); if (SRAAccession.isValid(readerID.getSamFile().getPath())) { reader = factory.open(SamInputResource.of(new SRAAccession(readerID.getSamFile().getPath()))); } else { reader = factory.referenceSequence(referenceFile) .setOption(SamReaderFactory.Option.INCLUDE_SOURCE_IN_RECORDS, true) .open(readerID.getSamFile()); } } catch ( RuntimeIOException e ) { throw new UserException.CouldNotReadInputFile(readerID.getSamFile(), e); } catch ( SAMFormatException e ) { throw new UserException.MalformedBAM(readerID.getSamFile(), e.getMessage()); } // Picard is throwing a RuntimeException here when BAMs are malformed with bad headers (and so look like SAM files). // Let's keep this separate from the SAMFormatException (which ultimately derives from RuntimeException) case, // just in case we want to change this behavior later. catch ( RuntimeException e ) { throw new UserException.MalformedBAM(readerID.getSamFile(), e.getMessage()); } return this; } }
this.length = reader.getSamFile().length(); if(validate) { System.out.printf("BlockInputStream %s: BGZF block validation mode activated%n",this); validatingInputStream = new BlockCompressedInputStream(reader.getSamFile());
throw new UserException.MalformedBAM(id.getSamFile(), e.getMessage()); iterator = new MalformedBAMErrorReformatingIterator(id.getSamFile(), iterator); if(shard.getGenomeLocs().size() > 0) iterator = new IntervalOverlapFilteringIterator(iterator,shard.getGenomeLocs());
if (!SRAAccession.isValid(readerID.getSamFile().getPath()) && !readerID.getSamFile().canRead() ) throw new UserException.CouldNotReadInputFile(readerID.getSamFile(),"file is not present or user does not have appropriate permissions. " + "Please check that the file is present and readable and try again."); throw new UserException.MalformedBAM(readers.getReaderID(reader).getSamFile(), "SAM file doesn't have any read groups defined in the header. The GATK no longer supports SAM files without read groups"); File indexFile = findIndexFile(id.getSamFile()); if(indexFile != null) { bamIndices.put(id, new GATKBAMIndexFromFile(indexFile, samSequenceDictionary)); bamIndices.put(id, new GATKBAMIndexFromDataSource(id.getSamFile(), reader.getFileHeader(), reader.indexing().getBrowseableIndex()));