compspec package

Subpackages

Submodules

compspec.entity module

class compspec.entity. Counter ( prefix = 'id' ) [source]

Bases: object

A simple counter (iterator) that will yield the next number with some prefix.

compspec.entity. get_counter ( prefix = 'id' ) [source]

Return an iterable counter.

class compspec.entity. node ( nodeid , name , value , is_connector = False ) [source]

Bases: object

A node in a graph.

property args
describe ( ) [source]
to_dict ( ) [source]
class compspec.entity. relation ( fromid , toid , relation = 'has' ) [source]

Bases: object

A relation in a graph.

property args
to_dict ( ) [source]

compspec.graph module

class compspec.graph. Graph [source]

Bases: object

A graph implicitly is scoped to one namespace

add_node ( node ) [source]

Add an already generated node.

add_relation ( relation ) [source]

Add an already generated relation.

classmethod from_dict ( obj ) [source]

Return a new graph loaded from a dictionary.

gen ( name , value , parent , nodeid = None , relation = 'has' , is_connector = False ) [source]

Generate a node and relation in one swoop! A parent is required.

iter_connectors ( ) [source]

Yield connector nodes only

iter_nodes ( ) [source]

Yield nodes. If a comparison is being done, a namespace needs to be added (e.g., node, namespace, * args)

iter_relations ( ) [source]

Yield relations in the same manner.

new_node ( name , value , nodeid = None , is_connector = False ) [source]

Generate a node with a name (type) and value

is_connector is a flag that indicates the node is included in the graph, but itself should not be assessed for add/change/remove.

new_relation ( fromid , relation , toid ) [source]

Generate a relation between parent (fromid) and child (toid). The relation here does not hard code a namespace, but it will be required to compare between two graphs.

next ( ) [source]

Return next id in the counter.

to_dict ( ) [source]

Output dictionary representation of nodes and relations.

class compspec.graph. GraphGroup [source]

Bases: object

A graph group is intended to hold and yield named graphs.

extract ( ) [source]

compspec.logger module

class compspec.logger. ColorizingStreamHandler ( nocolor=False , stream=<_io.TextIOWrapper name='<stderr>' mode='w' encoding='utf-8'> , use_threads=False ) [source]

Bases: StreamHandler

BLACK = 0
BLUE = 4
BOLD_SEQ = '\x1b[1m'
COLOR_SEQ = '\x1b[%dm'
CYAN = 6
GREEN = 2
MAGENTA = 5
RED = 1
RESET_SEQ = '\x1b[0m'
WHITE = 7
YELLOW = 3
can_color_tty ( ) [source]
colors = {'CRITICAL': 1, 'DEBUG': 4, 'ERROR': 1, 'INFO': 2, 'WARNING': 3}
decorate ( record ) [source]
emit ( record ) [source]

Emit a record.

If a formatter is specified, it is used to format the record. The record is then written to the stream with a trailing newline. If exception information is present, it is formatted using traceback.print_exception and appended to the stream. If the stream has an ‘encoding’ attribute, it is used to determine how to do the output to the stream.

property is_tty
class compspec.logger. Logger [source]

Bases: object

cleanup ( ) [source]
debug ( msg ) [source]
error ( msg ) [source]
exit ( msg , return_code = 1 ) [source]
handler ( msg ) [source]
info ( msg ) [source]
location ( msg ) [source]
progress ( done = None , total = None ) [source]
set_level ( level ) [source]
set_stream_handler ( stream_handler ) [source]
shellcmd ( msg ) [source]
text_handler ( msg ) [source]

The default snakemake log handler. Prints the output to the console. Args:

msg (dict): the log message dictionary

warning ( msg ) [source]
compspec.logger. setup_logger ( quiet = False , printshellcmds = False , nocolor = False , stdout = False , debug = False , use_threads = False , wms_monitor = None ) [source]

compspec.solver module

class compspec.solver. AspFunction ( name , args = None ) [source]

Bases: object

An asp function

symbol ( positive = True ) [source]
class compspec.solver. AspFunctionBuilder [source]

Bases: object

class compspec.solver. PyclingoDriver ( cores = True , out = None , quiet = False ) [source]

Bases: object

comment ( msg ) [source]
devnull ( ) [source]
fact ( head ) [source]

ASP fact (a rule without a body).

h1 ( name ) [source]
h2 ( name ) [source]
newline ( ) [source]
set_verbosity ( out , quiet = False ) [source]

Set (or update) verbosity or output stream.

solve ( setup , nmodels = 0 , stats = False , logic_programs = None , facts_only = False ) [source]

Run the solver for a model and some number of logic programs

title ( name , char ) [source]
class compspec.solver. Result ( asp = None ) [source]

Bases: object

Result of an ASP solve.

compspec.solver. argify ( arg ) [source]

Convert an argument into a clingo one.

compspec.utils module

compspec.utils. normalize_key ( key ) [source]

A key needs to be all lowercase, ideally with no spaces, etc.

compspec.utils. read_file ( filename ) [source]
compspec.utils. read_json ( filename ) [source]
compspec.utils. read_yaml ( filepath ) [source]
compspec.utils. recursive_find ( base , pattern = '*.py' ) [source]

recursive find will yield python files in all directory levels below a base path.

Arguments:
  • base (str) : the base directory to search

  • pattern: a pattern to match, defaults to * .py

compspec.utils. row ( cols ) [source]
compspec.utils. run_command ( cmd , stream = False ) [source]

use subprocess to send a command to the terminal.

Parameters

cmd: the command to send

compspec.utils. write_json ( data , filename ) [source]

compspec.version module

Module contents