pierrepo / PBxplore

A suite of tools to explore protein structures with Protein Blocks :snake:
https://pbxplore.readthedocs.org/en/latest/
MIT License
28 stars 17 forks source link

Check weblogo is available in PBstat.py #61

Closed HubLot closed 9 years ago

HubLot commented 9 years ago

This PR aims to solve the issue #60.

The availability of the weblogo program is now tested during the parsing step when the --logo option is set.

Since it's not possible to add a callback with a store_trueaction, I created a custom action class (CommandAction). The docstring of this class is pretty straightforward to understand how it works. Basically, it behaves the same way as the store_true but add 2 new keywords:

The test of the availability is done through the subprocess library with the cmd_exists function which is called by CommandAction. This class can be used for any external program, then it can be useful for R for example.

From #60, I choose to prevent PBstat.py to run if the --logo option is set and weblogo is not found by raising a exception which will be handle automatically by argparse. I think it's better to stop the script than silent the error.

jbarnoud commented 9 years ago

This is great! I tested it and it works. The use of a custom argparse action is a bit scary but very clever.

The pull request causes the demo2 to stop prematurely in the absence of weblogo, though. I submitted a pull request to @HubLot branch to fix the issue; see https://github.com/HubLot/PBxplore/pull/1. (Yes, I submitted a pull request to a pull request. It's too bad it does not appear in the initial pull request.)

HubLot commented 9 years ago

Thanks. Indeed, I forgot to adapt demo2. I just merged your pull request.