pm3argparse
- Parsing Command Lines¶
Introduction¶
A lot of the actions in ProMod3 have a bunch of command line parameters/
arguments in common. For example we need an input alignment quite often and
usually for an alignment we need information on what is the target sequence,
what identifies a template sequence and eventually a hint on the format. That
means we need the same functionality on the command line in several actions.
There PM3ArgumentParser
serves as a
simplification. It provides a set of standard arguments you just need to
activate for your action plus it comes with some verification functionality for
input.
"""
Place the description of your script right in the file and import
it via '__doc__' as description to the parser ('-h', '--help').
"""
from promod3.core import pm3argparse
# make sure we see output when passing '-h'
import ost
ost.PushVerbosityLevel(2)
parser = pm3argparse.PM3ArgumentParser(__doc__)
parser.AddAlignment()
parser.AssembleParser()
opts = parser.Parse()
When the example above is run with pm
and no additional arguments, the
script exits with a code 2. If it is run with an additional argument -h
or
--help
, it exits with a code 0 and displays the help message given as a
docstring in your script.