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

critical(msg, loc=None)[source]

Critical level messages

debug(msg, loc=None)[source]

Debug level messages

error(msg, loc=None)[source]

Error level messages

get_logger(loc=None)[source]

From a given loc string returns the correct python logger. Loc string should be of the form:

‘FILE_PATH : MODULE.METHOD’

info(msg, loc=None)[source]

Info level messages

warning(msg, loc=None)[source]

Warning level messages

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

define_parser()[source]
is_before_model(action_name)[source]
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.

bionetgen.core.utils.utils.test_bngexec(bngexec)[source]

A simple function that test if BNG2.pl given runs

Usage: test_bngexec(path)

Arguments

bngexecstr

path to BNG2.pl to test

bionetgen.core.utils.utils.test_perl(app=None, perl_path=None)[source]

Test if perl is working

Arguments

perl_pathstr

(optional) path to the folder that contains perl

Module contents