/** * * @see #parseReg(String) * @param reg a chromosome * @param start start interval * @param end end interval * @return a tabix iterator */ public Iterator query(final String reg,int start,int end) { int tid=this.chr2tid(reg); if(tid==-1) return EOF_ITERATOR; return query(tid, start, end); }
/** * * @see #parseReg(String) * @param reg a chromosome * @param start start interval * @param end end interval * @return a tabix iterator */ public Iterator query(final String reg,int start,int end) { int tid=this.chr2tid(reg); if(tid==-1) return EOF_ITERATOR; return query(tid, start, end); }
/** * * @see #parseReg(String) * @param reg a chromosome * @param start start interval * @param end end interval * @return a tabix iterator */ public Iterator query(final String reg,int start,int end) { int tid=this.chr2tid(reg); if(tid==-1) return EOF_ITERATOR; return query(tid, start, end); }
/** * Parse a region in the format of "chr1", "chr1:100" or "chr1:100-1000" * * @param reg Region string * @return An array where the three elements are sequence_id, * region_begin and region_end. On failure, sequence_id==-1. */ public int[] parseReg(final String reg) { // FIXME: NOT working when the sequence name contains : or -. String chr; int colon, hyphen; int[] ret = new int[3]; colon = reg.indexOf(':'); hyphen = reg.indexOf('-'); chr = colon >= 0 ? reg.substring(0, colon) : reg; ret[1] = colon >= 0 ? Integer.parseInt(reg.substring(colon + 1, hyphen >= 0 ? hyphen : reg.length())) - 1 : 0; ret[2] = hyphen >= 0 ? Integer.parseInt(reg.substring(hyphen + 1)) : 0x7fffffff; ret[0] = this.chr2tid(chr); return ret; }
/** * Parse a region in the format of "chr1", "chr1:100" or "chr1:100-1000" * * @param reg Region string * @return An array where the three elements are sequence_id, * region_begin and region_end. On failure, sequence_id==-1. */ public int[] parseReg(final String reg) { // FIXME: NOT working when the sequence name contains : or -. String chr; int colon, hyphen; int[] ret = new int[3]; colon = reg.indexOf(':'); hyphen = reg.indexOf('-'); chr = colon >= 0 ? reg.substring(0, colon) : reg; ret[1] = colon >= 0 ? Integer.parseInt(reg.substring(colon + 1, hyphen >= 0 ? hyphen : reg.length())) - 1 : 0; ret[2] = hyphen >= 0 ? Integer.parseInt(reg.substring(hyphen + 1)) : 0x7fffffff; ret[0] = this.chr2tid(chr); return ret; }
/** * Parse a region in the format of "chr1", "chr1:100" or "chr1:100-1000" * * @param reg Region string * @return An array where the three elements are sequence_id, * region_begin and region_end. On failure, sequence_id==-1. */ public int[] parseReg(final String reg) { // FIXME: NOT working when the sequence name contains : or -. String chr; int colon, hyphen; int[] ret = new int[3]; colon = reg.indexOf(':'); hyphen = reg.indexOf('-'); chr = colon >= 0 ? reg.substring(0, colon) : reg; ret[1] = colon >= 0 ? Integer.parseInt(reg.substring(colon + 1, hyphen >= 0 ? hyphen : reg.length())) - 1 : 0; ret[2] = hyphen >= 0 ? Integer.parseInt(reg.substring(hyphen + 1)) : 0x7fffffff; ret[0] = this.chr2tid(chr); return ret; }
++col; if (col == mSc) { intv.tid = chr2tid(end != -1 ? s.substring(beg, end) : s.substring(beg)); } else if (col == mBc) { intv.beg = intv.end = Integer.parseInt(end != -1 ? s.substring(beg, end) : s.substring(beg));
++col; if (col == mSc) { intv.tid = chr2tid(end != -1 ? s.substring(beg, end) : s.substring(beg)); } else if (col == mBc) { intv.beg = intv.end = Integer.parseInt(end != -1 ? s.substring(beg, end) : s.substring(beg));
++col; if (col == mSc) { intv.tid = chr2tid(end != -1 ? s.substring(beg, end) : s.substring(beg)); } else if (col == mBc) { intv.beg = intv.end = Integer.parseInt(end != -1 ? s.substring(beg, end) : s.substring(beg));
/** * Test reading a local tabix file * * @throws java.io.IOException */ @Test public void testLocalQuery() throws IOException { TabixIteratorLineReader lineReader = new TabixIteratorLineReader( tabixReader.query(tabixReader.chr2tid("4"), 320, 330)); int nRecords = 0; String nextLine; while ((nextLine = lineReader.readLine()) != null) { Assert.assertTrue(nextLine.startsWith("4")); nRecords++; } Assert.assertTrue(nRecords > 0); }
/** * Return iterator over all features overlapping the given interval * * @param chr * @param start * @param end * @return * @throws IOException */ @Override public CloseableTribbleIterator<T> query(final String chr, final int start, final int end) throws IOException { final List<String> mp = getSequenceNames(); if (mp == null) throw new TribbleException.TabixReaderFailure("Unable to find sequence named " + chr + " in the tabix index. ", path); if (!mp.contains(chr)) { return new EmptyIterator<T>(); } final TabixIteratorLineReader lineReader = new TabixIteratorLineReader(tabixReader.query(tabixReader.chr2tid(chr), start - 1, end)); return new FeatureIterator<T>(lineReader, start - 1, end); }
/** * Return iterator over all features overlapping the given interval * * @param chr * @param start * @param end * @return * @throws IOException */ @Override public CloseableTribbleIterator<T> query(final String chr, final int start, final int end) throws IOException { final List<String> mp = getSequenceNames(); if (mp == null) throw new TribbleException.TabixReaderFailure("Unable to find sequence named " + chr + " in the tabix index. ", path); if (!mp.contains(chr)) { return new EmptyIterator<T>(); } final TabixIteratorLineReader lineReader = new TabixIteratorLineReader(tabixReader.query(tabixReader.chr2tid(chr), start - 1, end)); return new FeatureIterator<T>(lineReader, start - 1, end); }
/** * Return iterator over all features overlapping the given interval * * @param chr * @param start * @param end * @return * @throws IOException */ public CloseableTribbleIterator<T> query(final String chr, final int start, final int end) throws IOException { final List<String> mp = getSequenceNames(); if (mp == null) throw new TribbleException.TabixReaderFailure("Unable to find sequence named " + chr + " in the tabix index. ", path); if (!mp.contains(chr)) { return new EmptyIterator<T>(); } final TabixIteratorLineReader lineReader = new TabixIteratorLineReader(tabixReader.query(tabixReader.chr2tid(chr), start - 1, end)); return new FeatureIterator<T>(lineReader, start - 1, end); }
/** * Test reading a tabix file over http * * @throws java.io.IOException */ @Test public void testRemoteQuery() throws IOException { String tabixFile = TestUtil.BASE_URL_FOR_HTTP_TESTS +"igvdata/tabix/trioDup.vcf.gz"; TabixReader tabixReader = new TabixReader(tabixFile); TabixIteratorLineReader lineReader = new TabixIteratorLineReader( tabixReader.query(tabixReader.chr2tid("4"), 320, 330)); int nRecords = 0; String nextLine; while ((nextLine = lineReader.readLine()) != null) { Assert.assertTrue(nextLine.startsWith("4")); nRecords++; } Assert.assertTrue(nRecords > 0); }