bionetgen.core.utils package
Submodules
bionetgen.core.utils.logging module
- class bionetgen.core.utils.logging.BNGLogger(app=None, level='INFO', loc=None)[source]
Bases:
object
Logger class that handles all logging in PyBNG. This class specifically tries to bridge the gap of using colorlog by itself and Cement frameworks own logging system.
See [python logging](https://docs.python.org/3/howto/logging.html) for more information how logging in python works in general.
- Usage: BNGLogger()
BNGLogger(app=app, level=”DEBUG”)
Attributes
- appCement App
if using the logger with Cement framework, this will be the Cement app and each method will call app.log
- locstr
this attribute keeps track of the location string for better error reporting. for cement app this will be passed directly to app.log, for regular logging this will be parsed to get the right logger
- log_levelstr
this attribute sets the logging level to output. Options are the same as regular python logging, “DEBUG”, “INFO”, “WARNING”, “ERROR”, “CRITICAL”
Methods
- get_loggerlogger
this method returns the correct logger after parsing the loc string
- debugNone
same as all python logging, writes a message at DEBUG level
- infoNone
same as all python logging, writes a message at INFO level
- warningNone
same as all python logging, writes a message at WARNING level
- errorNone
same as all python logging, writes a message at ERROR level
- criticalNone
same as all python logging, writes a message at CRITICAL level
bionetgen.core.utils.utils module
- class bionetgen.core.utils.utils.ActionList[source]
Bases:
object
Class to store everything related to BioNetGen actions. This class stores information about the list of BNG actions, their arguments as well as their syntax information. The class also provides an argument parser using pyparsing.
Usage: ActionList()
Attributes
normal_types : list
- no_setter_syntaxlist
actions without => syntax
- square_braceslist
actions that use [] syntax in them
- before_modellist
actions that are supposed to come before the model
- possible_typeslist
the list of all possible actions
- arg_dictdict
dictionary that contains every argument of every action
- irregular_argsdict
actions that have arguments that aren’t simply arg=>val
Methods
- is_before_modelbool
checks if a given action is supposed to come before begin model
- define_parserNone
sets ActionList.action_parser to a pyparsing parser that’s capable of splitting up any BNG action into parts
- bionetgen.core.utils.utils.find_BNG_path(BNGPATH=None)[source]
A simple function finds the path to BNG2.pl from * Environment variable * Assuming it’s under PATH * Given optional path as argument
- Usage: test_bngexec(path)
test_bngexec()
Arguments
- BNGPATHstr
(optional) path to the folder that contains BNG2.pl
- bionetgen.core.utils.utils.run_command(command, suppress=True, timeout=None)[source]
A convenience function to run a given command. The command should be given as a list of values e.g. [‘command’, ‘arg1’, ‘arg2’] etc.
Suppress kwarg suppresses all output from the command and timeout kwarg allows you to set a time period in seconds after which the command will be killed.