@Override public void close() { if (mReader != null) { try { mReader.close(); } finally { mReader = null; } } }
@Override public void close() { if (mReader != null) { try { mReader.close(); } finally { mReader = null; } } }
public void close() { if (mReader != null) { try { mReader.close(); } finally { mReader = null; } } }
/** * Closes the underlying stream */ public void close() { if (reader != null) { reader.close(); } for(final InputStream stream : inputs){ CloserUtil.close(stream); } }
/** * Closes the underlying stream */ public void close() { if (reader != null) { reader.close(); } for(final InputStream stream : inputs){ CloserUtil.close(stream); } }
/** * Read all the chains and load into an OverlapDetector. * @param chainFile File in UCSC chain format. * @return OverlapDetector will all Chains from reader loaded into it. */ static OverlapDetector<Chain> loadChains(final File chainFile) { final Set<Integer> ids = new HashSet<Integer>(); BufferedLineReader reader = new BufferedLineReader(IOUtil.openFileForReading(chainFile)); final OverlapDetector<Chain> ret = new OverlapDetector<Chain>(0, 0); Chain chain; while ((chain = Chain.loadChain(reader, chainFile.toString())) != null) { if (ids.contains(chain.id)) { throw new SAMException("Chain id " + chain.id + " appears more than once in chain file."); } ids.add(chain.id); ret.addLhs(chain, chain.interval); } reader.close(); return ret; }
/** * Read all the chains and load into an OverlapDetector. * @param chainFile File in UCSC chain format. * @return OverlapDetector will all Chains from reader loaded into it. */ static OverlapDetector<Chain> loadChains(final File chainFile) { final BufferedLineReader reader = new BufferedLineReader(IOUtil.openFileForReading(chainFile)); final OverlapDetector<Chain> ret = new OverlapDetector<Chain>(0, 0); Chain chain; while ((chain = Chain.loadChain(reader, chainFile.toString())) != null) { ret.addLhs(chain, chain.interval); } reader.close(); return ret; }
/** * Read all the chains and load into an OverlapDetector. * @param chainFile File in UCSC chain format. * @return OverlapDetector will all Chains from reader loaded into it. */ static OverlapDetector<Chain> loadChains(final File chainFile) { final BufferedLineReader reader = new BufferedLineReader(IOUtil.openFileForReading(chainFile)); final OverlapDetector<Chain> ret = new OverlapDetector<Chain>(0, 0); Chain chain; while ((chain = Chain.loadChain(reader, chainFile.toString())) != null) { ret.addLhs(chain, chain.interval); } reader.close(); return ret; }
@Test public void testSeek() throws Exception { String expectedLine = "ccccccccc"; File testFile = new File("src/test/resources/htsjdk/samtools/seekablestream/seekTest.txt"); SeekableFileStream is = new SeekableFileStream(testFile); is.seek(20); BufferedLineReader reader = new BufferedLineReader(is); String nextLine = reader.readLine(); Assert.assertEquals(expectedLine, nextLine); reader.close(); } }
/** * Finds and loads the sequence file dictionary. * @param file Fasta file to read. Also acts as a prefix for supporting files. */ AbstractFastaSequenceFile(final File file) { this.file = file; final File dictionary = findSequenceDictionary(file); if (dictionary != null) { IOUtil.assertFileIsReadable(dictionary); try { final SAMTextHeaderCodec codec = new SAMTextHeaderCodec(); final BufferedLineReader reader = new BufferedLineReader(new FileInputStream(dictionary)); final SAMFileHeader header = codec.decode(reader, dictionary.toString()); if (header.getSequenceDictionary() != null && header.getSequenceDictionary().size() > 0) { this.sequenceDictionary = header.getSequenceDictionary(); } reader.close(); } catch (Exception e) { throw new SAMException("Could not open sequence dictionary file: " + dictionary, e); } } }
lines.add(reader.readLine()); reader.close(); actualLines = lines.iterator();