Methods¶
Adding a new Method¶
To implement a new method and integrate it with the Command Line Interface provided by this package, please inherit from Method
class.
-
class
Method
[source]¶ Defines method of pathway analysis & its arguments.
Simple arguments (like
threshold
) can be simply defined as arguments and keyword arguments of __init__.For example:
class MyMethod(Method) def __init__(threshold:float=0.05): pass
- For the simple arguments following information will be deduced:
- type: will be retrieved from type annotations; currently only non-abstract types (int, str, float and so on) are supported. We can implement abstract types from typing if needed.
- default: from keyword arguments.
- help: will be retrieved from docstrings
If you need more advanced options (like aggregation), or just do not like having a mess in your __init__ signature, please define the arguments in body of your class using
Argument
constructor.For example:
class MyMethod(Method): database = Argument( type=argparse.FileType('r'), help='Path to file with the database' ) def __init__(threshold:float=0.05, database=None): pass
If help is given in both
Argument
and docstring, then the help from Argument() takes precedence over the help in docstrings (as docstrings should cover not only CLI usage but also describe how to use the method as a standalone object - to enable advanced users to customize methods).-
help
¶ Return string providing help for this method.
The help message shows up when ./run method_name -h.
-
name
¶ Return method name used internally and in command line interface.
The name should not include any spaces.