Skip to content

Commit

Permalink
command: Use Command docstring as command description in help output
Browse files Browse the repository at this point in the history
  • Loading branch information
jonls committed Jul 22, 2015
1 parent be2d662 commit d4850ab
Showing 1 changed file with 21 additions and 19 deletions.
40 changes: 21 additions & 19 deletions psamm/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@

@add_metaclass(abc.ABCMeta)
class Command(object):
"""Represents a command in the interface, operating on a model
"""Represents a command in the interface, operating on a model.
Subclasses must define name and title as class attributes. The constructor
will be given the NativeModel and the command line namespace. The subclass
Expand Down Expand Up @@ -97,7 +97,7 @@ def run(self):


class SolverCommandMixin(object):
"""Mixin for commands that use an LP solver
"""Mixin for commands that use an LP solver.
This adds a ``--solver`` parameter to the command that the user can use to
select a specific solver. It also adds the method :meth:`_get_solver` which
Expand Down Expand Up @@ -127,7 +127,7 @@ def _get_solver(self, **kwargs):


class ChargeBalanceCommand(Command):
"""Check whether compound charge in a given database or model is balanced
"""Check whether compound charge in a given database or model is balanced.
Balanced reactions are those reactions where the total charge
is consistent on the left and right side of the reaction equation.
Expand Down Expand Up @@ -186,7 +186,7 @@ def reaction_charges(reaction_id):


class ConsoleCommand(Command):
"""Start an interactive Python console with the given model loaded"""
"""Start an interactive Python console with the given model loaded."""

name = 'console'
title = 'Start Python console with metabolic model loaded'
Expand Down Expand Up @@ -237,7 +237,7 @@ def run(self):


class FastGapFillCommand(SolverCommandMixin, Command):
"""Run FastGapFill algorithm on a metabolic model"""
"""Run FastGapFill algorithm on a metabolic model."""

name = 'fastgapfill'
title = 'Run FastGapFill on a metabolic model'
Expand Down Expand Up @@ -362,7 +362,7 @@ def run(self):


class FluxBalanceCommand(SolverCommandMixin, Command):
"""Run flux balance analysis on a metabolic model"""
"""Run flux balance analysis on a metabolic model."""

name = 'fba'
title = 'Run flux balance analysis on a metabolic model'
Expand Down Expand Up @@ -451,7 +451,7 @@ def run_tfba(self, reaction):


class FluxConsistencyCommand(SolverCommandMixin, Command):
"""Check that reactions are flux consistent in a model
"""Check that reactions are flux consistent in a model.
A reaction is flux consistent if there exists any steady-state flux
solution where the flux of the given reaction is non-zero. The
Expand Down Expand Up @@ -554,7 +554,7 @@ def run(self):


class FluxVariabilityCommand(SolverCommandMixin, Command):
"""Run flux variablity analysis on a metabolic model"""
"""Run flux variablity analysis on a metabolic model."""

name = 'fva'
title = 'Run flux variability analysis on a metabolic model'
Expand Down Expand Up @@ -610,10 +610,10 @@ def run(self):


class FormulaBalanceCommand(Command):
"""Check whether reactions in a given database or model are balanced
"""Check whether reactions in a model are elementally balanced.
Balanced reactions are those reactions where the number of atoms
is consistent on the left and right side of the reaction equation.
Balanced reactions are those reactions where the number of elements
(atoms) is consistent on the left and right side of the reaction equation.
Reactions that are not balanced will be printed out.
"""

Expand Down Expand Up @@ -684,7 +684,7 @@ def multiply_formula(compound_list):


class GapFillCommand(SolverCommandMixin, Command):
"""Command that runs GapFind and GapFill on a metabolic model"""
"""Run GapFind and GapFill on a metabolic model."""

name = 'gapfill'
title = 'Run GapFind and GapFill on a metabolic model'
Expand Down Expand Up @@ -741,7 +741,7 @@ def run(self):


class MassConsistencyCommand(SolverCommandMixin, Command):
"""Command that checks whether a database is mass consistent"""
"""Check whether a model is mass consistent."""

name = 'masscheck'
title = 'Run mass consistency check on a database'
Expand Down Expand Up @@ -833,7 +833,7 @@ def run(self):


class RandomSparseNetworkCommand(SolverCommandMixin, Command):
"""Find random minimal network of model
"""Find random minimal network of model.
Given a reaction to optimize and a threshold, delete reactions randomly
until the flux of the reaction to optimize falls under the threshold.
Expand Down Expand Up @@ -949,7 +949,7 @@ def run(self):


class RobustnessCommand(SolverCommandMixin, Command):
"""Run robustness analysis on metabolic model
"""Run robustness analysis on metabolic model.
Given a reaction to maximize and a reaction to vary,
the robustness analysis will run FBA while fixing the
Expand Down Expand Up @@ -1055,7 +1055,7 @@ def run_tfba(model, reaction):


class SBMLExport(Command):
"""Export model as SBML file"""
"""Export model as SBML file."""

name = 'sbmlexport'
title = 'Export model as SBML file'
Expand All @@ -1067,7 +1067,7 @@ def run(self):


class SearchCommand(Command):
"""Defines the search command"""
"""Search for reactions and compounds in a model."""

name = 'search'
title = 'Search the database of reactions or compounds'
Expand Down Expand Up @@ -1194,7 +1194,7 @@ def filter_search_term(s):


def main(command_class=None):
"""Run the command line interface with the given :class:`Command`
"""Run the command line interface with the given :class:`Command`.
If no command class is specified the user will be able to select a specific
command through the first command line argument.
Expand Down Expand Up @@ -1239,7 +1239,9 @@ def main(command_class=None):
subparsers = parser.add_subparsers(title='Command')
for name, values in sorted(iteritems(commands)):
title, command_class = values
subparser = subparsers.add_parser(name, help=title)
description = command_class.__doc__
subparser = subparsers.add_parser(
name, help=title, description=description)
subparser.set_defaults(command=command_class)
command_class.init_parser(subparser)

Expand Down

0 comments on commit d4850ab

Please sign in to comment.