-
Notifications
You must be signed in to change notification settings - Fork 245
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TabixReader bug in query(String) method for coordiantes with 0 values #908
Comments
Genomic locations in the format that you use are interpreted using 1-based coordinate system. this is not a bug. |
Hello, So with that experience changing to the query(final String, int, int) method fails again, but differently. The inner most used query(final int tid, final int beg, final int end) which is the same in both cases seems to need a range information versus a position information for beginPos and endPosition.
Both mentioned cases which end in a crash or wrong finding are handled correctly by the command tool. |
@Vernando Thanks for the clear explanation. I think that we can now solve this problem. |
For @phanikishore2's case, the code works correctly and an The "fix" is to make the code more robust. The changes should go in
to
|
Follow up to #908. Move the bad coordinates check to the root method, `public Iterator query(final String reg)`. If this public method is used by an application, the bad coordinates will return an `EOF_ITERATOR;`
The following method breaks if coordinate value is 0.
For example chr2:0-1
TabixReader.query("chr2:0-1") returns (tid,-1,1)
TabixReader.query("chr2",0,1) returns (tid,0,1)
Digging down in method parseReg(String) method ret[1] value assignment does subtract 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;
}
Thanks,
Phani
The text was updated successfully, but these errors were encountered: