BrooksLabUCSC / flair

Full-Length Alternative Isoform analysis of RNA
Other
207 stars 71 forks source link

Running collapse_isoforms_precise.py in a main entry point #314

Closed andyjslee closed 9 months ago

andyjslee commented 9 months ago

Thank you for developing your tool.

I was wondering if you could make the core logic inside collapse_isoforms_precise.py run inside a main entry point (i.e. move all of the code outside the functions into if __name__ == '__main__':). Depending on how you run FLAIR, I've noticed that the global variables such as isoforms are not accessible inside the worker functions for multiprocessing if you don't provide the main scope.

Thanks!

andyjslee commented 9 months ago

This might lead to a higher memory usage but, alternatively, could you supply isoforms to run_find_best_sites?

def run_find_best_sites(isoforms, chrom):
    ...

from functools import partial
run_find_best_sites_worker = partial(run_find_best_sites, isoforms)
res = p.map(run_find_best_sites_worker, list(isoforms.keys()))
Jeltje commented 9 months ago

Thanks for using Flair, and especially for suggesting ways to improve it.

We're aware of the irritating complexity of running with map() inside a function. We're currently doing a major refactoring of Flair to make it easier to parallelize, so the need to implement your solution will hopefully no longer exist.

For now please change it in your own code. I'm moving this ticket to our Discussion section so others will be able to find it.