daler/pybedtools

Temporary files usage

ngualand opened this issue · 1 comments

Hi,

I have used pybedtools.intersect (c = True) to count the number of overlap between features stored in 2 pybed files.

Here is my code:

#Open bed file
bed1 = BedTool(bed1)
bed2 = BedTool(bed2)
bed3 = bed1.filter(less_than , 10)

#Intersection 1
res1 = bed2.intersect(b = bed3, c=True)

#Intersection2
res2 = bed2.intersect(b=bed3, c=True)

The command work at first, when create res1, but if I re-run the same command by saving the output in res2 I got 0 counts for all features in the bed file.

Why I get 0 count in all the res2 features, and how can I solve it?
If I reopen the file and re-perform the intersection it works perfectly, am I missing something about temporary file ?

Thank you very much for the help.

Nicolò

daler commented

Yes, that's actually expected since BedTool.filter is a generator -- see this FAQ entry for details.