-
Notifications
You must be signed in to change notification settings - Fork 105
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
Is there a flushing process for temp files #112
Comments
I guess one can specify the output and flush it when the program ends from within the program itself, but in case he doesn't, it owuld be good if the pybedtools 'remembers' all the files generated on a given session and when the prog exits it just clear those out |
Yep, any tempfiles created are automatically cleaned up when the Python interpreter exits. Specifically, the last line in helpers.py registers Within a single session, you can always call By default, If you kill a running Python process that created a lot of tempfiles, Also note that if you're creating new tempfiles across multiple processes, the list of tempfiles is not shared across process boundaries. That's why the functions in stats.py are careful about deleting files as they go. |
hmm good to know, thanks @daler for explaining this The reason I am asking is that I was thinking a malformedBedLineError would be caused by that
This is the section from the temp file
This looks good for me though, and it used to work before, I don't really understand the reason of such message any idea ? ps : I cleaned all temp files before running |
Ah, that's because your start coord is greater than your stop coord for the third line in your example. See this recent BEDtools mailing list post for details. |
But that's not supposed to be coordinates, that's pybedtools.genome_coverage called with no bg or bga option it returns chromosome, depth, number of reads, size, fraction, no ? |
Sorry, I missed that. In that case, this is similar to issue #110, where it's not actually a valid BED/GTF/GFF/VCF/BAM format file. The problem here is that sometimes I suppose I could manually check for which parameters were passed, and detect whether a file will be formatted to work nicely with a So far, I've chosen to not pay attention to kwargs passed and just always return a |
Hmm, I see, well I guess this could be solved with another function similar to #110 but instead of returning a BedTool + dataframe, this will return 2 dataframes instead. In general, I think it is better to place a watcher kind of function, something that checks if kwargs are provided then the object saved will be a BedTool, otherwise, the object will be any exploitable / parsable kind of data, a DataFrame will be ideal I guess for now I can play with the solution provided in #110 , but that's good to know, thanks for clarifying this @daler |
btw, is there another utility similar to pybedtools.create_interval_from_list ? pubedtools.create_csv ?? |
What are you aiming to do? If you'd like a CSV version of a import pybedtools
a = pybedtools.example_bedtool('a.bed')
a.to_dataframe().to_csv('output.csv') |
Is that merged in the master branch ? Should I pull the repo again ? |
Yep -- I committed it yesterday after you said the method I proposed would work for your purposes. It's in the master branch now. |
Awesome, thanks a lot @daler, I will update, I am generating a couple of examples on pybedtools usage and will be publishing some runnable examples at CodersCrowd soon |
OK. Closing this for now, but feel free to re-open if needed. Also, I opened #113 for detecting valid BedTool output as you mentioned. |
👍 |
When using pybedtools we are creating temporary files for access later on, when a call is done to one of pybedtools function (the so referenced x.fn)
My question is, sometimes these files can be big, and this will continue to pileup in the /tmp of the user or on servers.
Is there a way of flushing these temp files when the program exits, I don't think it is reasonable to flush while the program is still running but it is definitely useful to clean up a little bit after doing stuff
any thoughts ?
Thanks
The text was updated successfully, but these errors were encountered: