-
Notifications
You must be signed in to change notification settings - Fork 86
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
empty bed files #30
Comments
Thanks. Could you post a patch file? Sorry about the repo size...working
|
Let me know if you get the patch -- attempting to send via email since In case it doesn't come through: https://gist.github.com/4048664 Actually, I think the correct test is ios::bad(). Patch updated. Sorry for the confusion. On Fri, Nov 9, 2012 at 1:48 PM, Aaron Quinlan notifications@github.comwrote:
|
Thanks, I got the gist. Will patch this in soon. Cheers. |
When the open fails, Certainly Aaron has already realised this... what I mainly came to say is when this is being disentangled, please could you add printing out
- if ( !(_bedStream->good()) ) {
+ if ( _bedStream->fail() ) {
cerr << "Error: The requested bed file ("
<< bedFile
- << ") could not be opened. Exiting!" << endl;
+ << ") could not be opened: "
+ << strerror(errno)
+ << ". Exiting!" << endl; Printing out this sort of detail from the OS can help head off user problems like the "broadPeak file format in BEDTools" one the other day -- if that was indeed partly down to filename extension mistakes. (The better more-work change would probably be to check for errors straight after each |
Thanks for the pointers, John. I am rather swamped at the moment, but will integrate these changes as soon as I have a breather. |
John, you're correct, I didn't fully appreciate the subtleties of this problem. That being said, I think ios::bad() works, at least as I understand it. There are three bits: bad, fail, and eof. When opening a non-existent file, (at least) bad gets set. It does not get set for an empty file, but isGzipFile sets fail and eof (but not bad). Thus, I think bad() is sufficient. Or perhaps I'm still missing something -- my C++ is a bit rusty. In either case, I think the non-minimal solution you suggest is the correct one. And it could be factored out and re-used, rather than copied. |
@jpaulLD: I think you will find that opening a non-existent file causes |
Thanks for the great suggestions. Commit |
bedtools exhibits incorrect behavior when the bed file is empty (i.e. no records), saying that the file cannot be opened. I've chased this down to the use of ios::good() after the file has been opened instead of ios::fail(). This occurs in 4 different places in the code.
I've fixed locally, but don't really want to download/fork the 500MB git repo to give you a pull request. Nonetheless, thought I'd let you know.
The text was updated successfully, but these errors were encountered: