/** * Read one line from the data file. */ public String readLine() throws IOException { return readLine(mFp, DEFAULT_BUFFER_SIZE); }
public static String readLine(final InputStream is) throws IOException { return readLine(is, DEFAULT_BUFFER_SIZE); }
/** * Read one line from the data file. */ public String readLine() throws IOException { return readLine(mFp, DEFAULT_BUFFER_SIZE); }
/** * Read one line from the data file. */ public String readLine() throws IOException { return readLine(mFp); }
public static String readLine(final InputStream is) throws IOException { return readLine(is, DEFAULT_BUFFER_SIZE); }
public static void main(String[] args) { if (args.length < 1) { System.out.println("Usage: java -cp .:sam.jar TabixReader <in.gz> [region]"); System.exit(1); } try { TabixReader tr = new TabixReader(args[0]); String s; if (args.length == 1) { // no region is specified; print the whole file while ((s = tr.readLine()) != null) System.out.println(s); } else { // a region is specified; random access TabixReader.Iterator iter = tr.query(args[1]); // get the iterator while ((s = iter.next()) != null) System.out.println(s); } } catch (IOException e) { } }
@Override public String next() throws IOException { if (iseof) return null; for (; ;) { if (curr_off == 0 || !less64(curr_off, off[i].v)) { // then jump to the next chunk if (i == off.length - 1) break; // no more chunks if (i >= 0) assert (curr_off == off[i].v); // otherwise bug if (i < 0 || off[i].v != off[i + 1].u) { // not adjacent chunks; then seek mFp.seek(off[i + 1].u); curr_off = mFp.getFilePointer(); //++n_seeks; } ++i; } String s; if ((s = readLine(mFp)) != null) { TIntv intv; char[] str = s.toCharArray(); curr_off = mFp.getFilePointer(); if (str.length == 0 || str[0] == mMeta) continue; intv = getIntv(s); if (intv.tid != tid || intv.beg >= end) break; // no need to proceed else if (intv.end > beg && intv.beg < end) return s; // overlap; return } else break; // end of file } iseof = true; return null; } }
/** Return true if fileName has a valid tabix index. * @throws IOException * */ public static boolean hasTabixIndex(String fileName) throws IOException{ if((new UrlValidator()).isValid(fileName) && fileName.startsWith("ftp")){ // Because of issue #51 return false; } try{ TabixReader tabixReader= new TabixReader(fileName); tabixReader.readLine(); tabixReader.close(); return true; } catch (Exception e){ return false; } }
/** * Test TabixReader.readLine * * @throws java.io.IOException */ @Test public void testTabixReaderReadLine() throws IOException { TabixReader tabixReader = new TabixReader(tabixFile); Assert.assertNotNull(tabixReader.readLine()); tabixReader.close(); } }