@Override public void close() throws IOException { log.debug("close() called"); if (reference != null) reference.close(); }
public boolean cleanUp() { log.debug("Cleaning up task ", fileNameBase); inProgressMarkerFile.delete(); failedMarkerFile.delete(); successMarkerFile.delete(); outputFile.delete(); errorFile.delete(); if (outputFiles != null) for (File file : outputFiles) file.delete(); return STATUS.NONE == status(); }
private OrderedByteArray flushStripe(ByteArrayOutputStream baos) throws InterruptedException, IOException { OrderedByteArray stripe = new OrderedByteArray(); stripe.bytes = baos.toByteArray(); log.debug(String.format("adding stripe: order=%d, ref=%d, records=%d, bytes=%d", order, refId, recordCounter, stripe.bytes.length)); stripe.order = order++; baos.reset(); recordCounter = 0; return stripe; } }
private void syncEnsureNext() { while (!isClosed.get() && buffer.isEmpty()) { try { log.debug(String.format("%d alignments outstanding", outstandingReads.get())); Thread.sleep(POLL_INTERVAL); } catch (InterruptedException e) { log.warn(e); return; } } } /**
private void remove(VariantContextDirectedBreakpoint bp) { lookup.remove(bp); byQual.remove(bp); VariantContextDirectedBreakpoint mate = id.get(bp.getAttribute(VcfSvConstants.PARTNER_BREAKEND_ID_KEY)); if (mate != null) { lookup.remove(mate); byQual.remove(mate); } else { log.debug(String.format("%s missing mate", bp.getID())); } } private void write(File output) throws IOException {
private static long seek(List<CramIndex.Entry> index, int seqId, int start, int end, SeekableStream cramStream) throws IOException { List<Entry> found = CramIndex.find(index, seqId, start, end - start + 1); if (found == null || found.size() == 0) return -1; cramStream.seek(found.get(0).containerStartOffset); log.debug("Found query at offset: " + found.get(0).containerStartOffset); return found.get(0).containerStartOffset; }
/** * Prepare to compress at the given compression level * @param compressionLevel 1 <= compressionLevel <= 9 * @param deflaterFactory custom factory to create deflaters (overrides the default) */ public BlockCompressedOutputStream(final Path path, final int compressionLevel, final DeflaterFactory deflaterFactory) { this.file = path; codec = new BinaryCodec(path, true); deflater = deflaterFactory.makeDeflater(compressionLevel, true); log.debug("Using deflater: " + deflater.getClass().getSimpleName()); }
/** * Prepare to compress at the given compression level * @param compressionLevel 1 <= compressionLevel <= 9 * @param deflaterFactory custom factory to create deflaters (overrides the default) */ public BlockCompressedOutputStream(final Path path, final int compressionLevel, final DeflaterFactory deflaterFactory) { this.file = path; codec = new BinaryCodec(path, true); deflater = deflaterFactory.makeDeflater(compressionLevel, true); log.debug("Using deflater: " + deflater.getClass().getSimpleName()); }
private Alignment getCurrentAlignment() throws ErrorMsg { if (!isAligned) { throw new RuntimeException("Should be called for aligned records only"); } if (alignmentIterator == null) { log.debug("Recovering SAM record after detaching from iterator. Alignment id: " + sraAlignmentId); if (sraAlignmentId == null) { throw new RuntimeException("Cannot recover SAM object after detaching from iterator: no alignment id"); } alignmentIterator = getReadCollection().getAlignment(sraAlignmentId); } return alignmentIterator; }
private ReadCollection getReadCollection() { if (run != null) { return run; } log.debug("Recovering SRA read collection. Accession: " + accession); try { return run = NGS.openReadCollection(accession.toString()); } catch (ErrorMsg e) { throw new RuntimeException(e); } }
private ReadCollection getReadCollection() { if (run != null) { return run; } log.debug("Recovering SRA read collection. Accession: " + accession); try { return run = NGS.openReadCollection(accession.toString()); } catch (ErrorMsg e) { throw new RuntimeException(e); } }
public static void ensureIndexed(File fa) throws IOException { try (ReferenceSequenceFile reference = ReferenceSequenceFileFactory.getReferenceSequenceFile(fa)) { if (!reference.isIndexed()) { String msg = String.format("Unable to find index for %1$s. Please run 'samtools faidx %1$s' or picard tools BuildBamIndex to generate an index file.", fa); log.error(msg); throw new IOException(msg); } else { log.debug(fa, " is indexed."); } } } public void ensureDictionariesMatch() throws IOException {
protected byte[] findBasesByMD5(String md5) throws MalformedURLException, IOException { for (PathPattern p : refPatterns) { String path = p.format(md5); byte[] data = loadFromPath(path, md5); if (data == null) continue; log.debug("Reference found at the location ", path); return data; } return null; }
/** * Reads through the records in the provided SAM reader and uses their quality scores to sanity check the expected * quality passed in. If the expected quality format is sane we just hand this back otherwise we throw a * {@link SAMException}. */ public static FastqQualityFormat detect(final SAMFileReader reader, final FastqQualityFormat expectedQualityFormat) { //sanity check expectedQuality final QualityEncodingDetector detector = new QualityEncodingDetector(); final long recordCount = detector.add(DEFAULT_MAX_RECORDS_TO_ITERATE, reader); log.debug(String.format("Read %s records from %s.", recordCount, reader)); return detector.generateBestGuess(FileContext.SAM, expectedQualityFormat); }
@Override public void close() { log.debug("Closing UntemplatedSequenceAnnotator"); // TODO: close feeding thread more cleanly than just shutting down the process vcfStream.close(); try { aligner.close(); } catch (IOException e) { log.warn(e); } } }
/** * Reads through the records in the provided SAM reader and uses their quality scores to sanity check the expected * quality passed in. If the expected quality format is sane we just hand this back otherwise we throw a * {@link SAMException}. */ public static FastqQualityFormat detect(final SamReader reader, final FastqQualityFormat expectedQualityFormat) { //sanity check expectedQuality final QualityEncodingDetector detector = new QualityEncodingDetector(); final long recordCount = detector.add(DEFAULT_MAX_RECORDS_TO_ITERATE, reader.iterator()); log.debug(String.format("Read %s records from %s.", recordCount, reader)); return detector.generateBestGuess(FileContext.SAM, expectedQualityFormat); }
/** * Reads through the records in the provided SAM reader and uses their quality scores to sanity check the expected * quality passed in. If the expected quality format is sane we just hand this back otherwise we throw a * {@link SAMException}. */ public static FastqQualityFormat detect(final SamReader reader, final FastqQualityFormat expectedQualityFormat) { //sanity check expectedQuality final QualityEncodingDetector detector = new QualityEncodingDetector(); final long recordCount = detector.add(DEFAULT_MAX_RECORDS_TO_ITERATE, reader.iterator()); log.debug(String.format("Read %s records from %s.", recordCount, reader)); return detector.generateBestGuess(FileContext.SAM, expectedQualityFormat); }
private void closeCurrentAssembler() { if (currentAssembler.getExportTracker() != null) { try { currentAssembler.getExportTracker().close(); } catch (IOException e) { log.debug(e); } } currentAssembler = null; } private void ensureAssembler(boolean attemptRecovery) {
@Override public boolean apply(final VariantContext vc) { final boolean include = !intervalsOfInterestDetector.getOverlaps(new Interval(vc.getContig(), vc.getStart(), vc.getEnd())).isEmpty(); if (!include) LOG.debug("Filtering variant at ", vc.getContig(), ":", vc.getStart(), "-", vc.getEnd()); return include; } }
@Override public boolean apply(final VariantContext vc) { final boolean include = !intervalsOfInterestDetector.getOverlaps(new Interval(vc.getContig(), vc.getStart(), vc.getEnd())).isEmpty(); if (!include) LOG.debug("Filtering variant at ", vc.getContig(), ":", vc.getStart(), "-", vc.getEnd()); return include; } }