2.1. wc_rules package

2.1.1. Submodules

2.1.2. wc_rules.attributes module

class wc_rules.attributes.BioSeqAttribute[source]

Bases: obj_model.extra_attributes.BioSeqAttribute

class wc_rules.attributes.BooleanAttribute[source]

Bases: obj_model.core.BooleanAttribute

class wc_rules.attributes.FloatAttribute[source]

Bases: obj_model.core.FloatAttribute

class wc_rules.attributes.IdAttribute[source]

Bases: obj_model.core.StringAttribute

class wc_rules.attributes.IntegerAttribute[source]

Bases: obj_model.core.IntegerAttribute

class wc_rules.attributes.LongStringAttribute[source]

Bases: obj_model.core.LongStringAttribute

class wc_rules.attributes.ManyToManyAttribute(related_class, related_name='', default=[], default_cleaned_value=[], related_default=[], min_related=0, max_related=inf, min_related_rev=0, max_related_rev=inf, verbose_name='', verbose_related_name='', help='')[source]

Bases: obj_model.core.ManyToManyAttribute

class wc_rules.attributes.ManyToOneAttribute(related_class, related_name='', default=None, default_cleaned_value=None, related_default=[], min_related=0, min_related_rev=0, max_related_rev=inf, verbose_name='', verbose_related_name='', help='')[source]

Bases: obj_model.core.ManyToOneAttribute

class wc_rules.attributes.OneToManyAttribute(related_class, related_name='', default=[], default_cleaned_value=[], related_default=None, min_related=0, max_related=inf, min_related_rev=0, verbose_name='', verbose_related_name='', help='')[source]

Bases: obj_model.core.OneToManyAttribute

class wc_rules.attributes.OneToOneAttribute(related_class, related_name='', default=None, default_cleaned_value=None, related_default=None, min_related=0, min_related_rev=0, verbose_name='', verbose_related_name='', help='')[source]

Bases: obj_model.core.OneToOneAttribute

class wc_rules.attributes.PositiveIntegerAttribute[source]

Bases: obj_model.core.PositiveIntegerAttribute

class wc_rules.attributes.RegexAttribute[source]

Bases: obj_model.core.RegexAttribute

class wc_rules.attributes.StringAttribute[source]

Bases: obj_model.core.StringAttribute

2.1.3. wc_rules.base module

Language for describing whole-cell models

Author:John Sekar <johnarul.sekar@gmail.com>
Date:2017-12-13
Copyright:2017, Karr Lab
License:MIT
class wc_rules.base.BaseClass(**kwargs)[source]

Bases: obj_model.core.Model

Base class for bioschema objects.

id[source]

unique id that can be used to pick object from a list

Type:str
Properties:
label (str): name of the leaf class from which object is created
class GraphMeta[source]

Bases: wc_rules.graph_utils.GraphMeta

outward_edges = ()[source]
semantic = ()[source]
class Meta[source]

Bases: obj_model.core.Meta

attribute_order = ()[source]
attributes = {'id': <wc_rules.attributes.IdAttribute object>}[source]
frozen_columns = 1[source]
indexed_attrs_tuples = ()[source]
inheritance = (<class 'wc_rules.base.BaseClass'>,)[source]
ordering = ('id',)[source]
primary_attribute = <wc_rules.attributes.IdAttribute object>[source]
related_attributes = {}[source]
tabular_orientation = 1[source]
unique_together = ()[source]
verbose_name = 'Base class'[source]
verbose_name_plural = 'Base classes'[source]
attribute_properties = {}[source]
duplicate(id=None, preserve_id=False, attrlist=None)[source]

duplicates node up to scalar attributes

duplicate_relations(target, nodemap, attrlist=None)[source]

Duplicates self’s relations, converts them using nodemap {id:new_node}, and applies to targetself. E.g. if old A1->X1, and nodemap { A1.id:A2, X1.id:X2 } A1.duplicate_relations(A2,nodemap) builds the new edge A2->X2

get_graph(recurse=True, memo=None)[source]
get_id()[source]
get_nonempty_scalar_attributes(ignore_id=True)[source]
get_scalar_attributes()[source]
graph[source]
id = <wc_rules.attributes.IdAttribute object>[source]
label[source]

Name of the leaf class from which object is created.

make_attribute_properties_dict()[source]
objects = <obj_model.core.Manager object>[source]
set_id(id)[source]

Sets id attribute.

Parameters:id (str) –
Returns:self

2.1.4. wc_rules.bioseq module

Language for describing whole-cell models

Author:John Sekar <johnarul.sekar@gmail.com>
Date:2018-05-02
Copyright:2017, Karr Lab
License:MIT
class wc_rules.bioseq.DNA(*args, **kwargs)[source]

Bases: wc_rules.bioseq.Polynucleotide

class Meta[source]

Bases: obj_model.core.Meta

attribute_order = ()[source]
attributes = {'id': <wc_rules.attributes.IdAttribute object>, 'sequence': <obj_model.extra_attributes.BioSeqAttribute object>}[source]
frozen_columns = 1[source]
indexed_attrs_tuples = ()[source]
inheritance = (<class 'wc_rules.bioseq.DNA'>, <class 'wc_rules.bioseq.Polynucleotide'>, <class 'wc_rules.seq.SequenceMolecule'>, <class 'wc_rules.chem.Molecule'>, <class 'wc_rules.entity.Entity'>, <class 'wc_rules.base.BaseClass'>)[source]
ordering = ('id',)[source]
primary_attribute = <wc_rules.attributes.IdAttribute object>[source]
related_attributes = {'sites': <wc_rules.attributes.ManyToOneAttribute object>}[source]
tabular_orientation = 1[source]
unique_together = ()[source]
verbose_name = 'D n a'[source]
verbose_name_plural = 'D n a s'[source]
alphabet_dict = {'permissive': IUPACAmbiguousDNA(), 'strict': IUPACUnambiguousDNA()}[source]
get_dna(*args, **kwargs)[source]
get_protein(*args, **kwargs)[source]
get_rna(*args, **kwargs)[source]
objects = <obj_model.core.Manager object>[source]
class wc_rules.bioseq.Polynucleotide(*args, **kwargs)[source]

Bases: wc_rules.seq.SequenceMolecule

class Meta[source]

Bases: obj_model.core.Meta

attribute_order = ()[source]
attributes = {'id': <wc_rules.attributes.IdAttribute object>, 'sequence': <obj_model.extra_attributes.BioSeqAttribute object>}[source]
frozen_columns = 1[source]
indexed_attrs_tuples = ()[source]
inheritance = (<class 'wc_rules.bioseq.Polynucleotide'>, <class 'wc_rules.seq.SequenceMolecule'>, <class 'wc_rules.chem.Molecule'>, <class 'wc_rules.entity.Entity'>, <class 'wc_rules.base.BaseClass'>)[source]
ordering = ('id',)[source]
primary_attribute = <wc_rules.attributes.IdAttribute object>[source]
related_attributes = {'sites': <wc_rules.attributes.ManyToOneAttribute object>}[source]
tabular_orientation = 1[source]
unique_together = ()[source]
verbose_name = 'Polynucleotide'[source]
verbose_name_plural = 'Polynucleotides'[source]
convert_sequence(start=None, end=None, length=None, option='coding')[source]
objects = <obj_model.core.Manager object>[source]
translate(start=None, end=None, length=None, option='coding', table=1, to_stop=False)[source]
class wc_rules.bioseq.PolynucleotideFeature(**kwargs)[source]

Bases: wc_rules.seq.SequenceFeature

class Meta[source]

Bases: obj_model.core.Meta

attribute_order = ()[source]
attributes = {'end': <obj_model.core.IntegerAttribute object>, 'id': <wc_rules.attributes.IdAttribute object>, 'molecule': <wc_rules.attributes.ManyToOneAttribute object>, 'start': <obj_model.core.IntegerAttribute object>}[source]
frozen_columns = 1[source]
indexed_attrs_tuples = ()[source]
inheritance = (<class 'wc_rules.bioseq.PolynucleotideFeature'>, <class 'wc_rules.seq.SequenceFeature'>, <class 'wc_rules.chem.Site'>, <class 'wc_rules.entity.Entity'>, <class 'wc_rules.base.BaseClass'>)[source]
ordering = ('id',)[source]
primary_attribute = <wc_rules.attributes.IdAttribute object>[source]
related_attributes = {'bond': <wc_rules.attributes.OneToManyAttribute object>, 'overlaps': <wc_rules.attributes.ManyToManyAttribute object>}[source]
tabular_orientation = 1[source]
unique_together = ()[source]
verbose_name = 'Polynucleotide feature'[source]
verbose_name_plural = 'Polynucleotide features'[source]
allowed_molecule_types = (<class 'wc_rules.bioseq.Polynucleotide'>,)[source]
objects = <obj_model.core.Manager object>[source]
class wc_rules.bioseq.Polypeptide(*args, **kwargs)[source]

Bases: wc_rules.seq.SequenceMolecule

class Meta[source]

Bases: obj_model.core.Meta

attribute_order = ()[source]
attributes = {'id': <wc_rules.attributes.IdAttribute object>, 'sequence': <obj_model.extra_attributes.BioSeqAttribute object>}[source]
frozen_columns = 1[source]
indexed_attrs_tuples = ()[source]
inheritance = (<class 'wc_rules.bioseq.Polypeptide'>, <class 'wc_rules.seq.SequenceMolecule'>, <class 'wc_rules.chem.Molecule'>, <class 'wc_rules.entity.Entity'>, <class 'wc_rules.base.BaseClass'>)[source]
ordering = ('id',)[source]
primary_attribute = <wc_rules.attributes.IdAttribute object>[source]
related_attributes = {'sites': <wc_rules.attributes.ManyToOneAttribute object>}[source]
tabular_orientation = 1[source]
unique_together = ()[source]
verbose_name = 'Polypeptide'[source]
verbose_name_plural = 'Polypeptides'[source]
alphabet_dict = {'permissive': ExtendedIUPACProtein(), 'strict': IUPACProtein()}[source]
objects = <obj_model.core.Manager object>[source]
class wc_rules.bioseq.PolypeptideFeature(**kwargs)[source]

Bases: wc_rules.seq.SequenceFeature

class Meta[source]

Bases: obj_model.core.Meta

attribute_order = ()[source]
attributes = {'end': <obj_model.core.IntegerAttribute object>, 'id': <wc_rules.attributes.IdAttribute object>, 'molecule': <wc_rules.attributes.ManyToOneAttribute object>, 'start': <obj_model.core.IntegerAttribute object>}[source]
frozen_columns = 1[source]
indexed_attrs_tuples = ()[source]
inheritance = (<class 'wc_rules.bioseq.PolypeptideFeature'>, <class 'wc_rules.seq.SequenceFeature'>, <class 'wc_rules.chem.Site'>, <class 'wc_rules.entity.Entity'>, <class 'wc_rules.base.BaseClass'>)[source]
ordering = ('id',)[source]
primary_attribute = <wc_rules.attributes.IdAttribute object>[source]
related_attributes = {'bond': <wc_rules.attributes.OneToManyAttribute object>, 'overlaps': <wc_rules.attributes.ManyToManyAttribute object>}[source]
tabular_orientation = 1[source]
unique_together = ()[source]
verbose_name = 'Polypeptide feature'[source]
verbose_name_plural = 'Polypeptide features'[source]
allowed_molecule_types = (<class 'wc_rules.bioseq.Polypeptide'>,)[source]
objects = <obj_model.core.Manager object>[source]
class wc_rules.bioseq.Protein(*args, **kwargs)[source]

Bases: wc_rules.bioseq.Polypeptide

class Meta[source]

Bases: obj_model.core.Meta

attribute_order = ()[source]
attributes = {'id': <wc_rules.attributes.IdAttribute object>, 'sequence': <obj_model.extra_attributes.BioSeqAttribute object>}[source]
frozen_columns = 1[source]
indexed_attrs_tuples = ()[source]
inheritance = (<class 'wc_rules.bioseq.Protein'>, <class 'wc_rules.bioseq.Polypeptide'>, <class 'wc_rules.seq.SequenceMolecule'>, <class 'wc_rules.chem.Molecule'>, <class 'wc_rules.entity.Entity'>, <class 'wc_rules.base.BaseClass'>)[source]
ordering = ('id',)[source]
primary_attribute = <wc_rules.attributes.IdAttribute object>[source]
related_attributes = {'sites': <wc_rules.attributes.ManyToOneAttribute object>}[source]
tabular_orientation = 1[source]
unique_together = ()[source]
verbose_name = 'Protein'[source]
verbose_name_plural = 'Proteins'[source]
objects = <obj_model.core.Manager object>[source]
class wc_rules.bioseq.RNA(*args, **kwargs)[source]

Bases: wc_rules.bioseq.Polynucleotide

class Meta[source]

Bases: obj_model.core.Meta

attribute_order = ()[source]
attributes = {'id': <wc_rules.attributes.IdAttribute object>, 'sequence': <obj_model.extra_attributes.BioSeqAttribute object>}[source]
frozen_columns = 1[source]
indexed_attrs_tuples = ()[source]
inheritance = (<class 'wc_rules.bioseq.RNA'>, <class 'wc_rules.bioseq.Polynucleotide'>, <class 'wc_rules.seq.SequenceMolecule'>, <class 'wc_rules.chem.Molecule'>, <class 'wc_rules.entity.Entity'>, <class 'wc_rules.base.BaseClass'>)[source]
ordering = ('id',)[source]
primary_attribute = <wc_rules.attributes.IdAttribute object>[source]
related_attributes = {'sites': <wc_rules.attributes.ManyToOneAttribute object>}[source]
tabular_orientation = 1[source]
unique_together = ()[source]
verbose_name = 'R n a'[source]
verbose_name_plural = 'R n a s'[source]
alphabet_dict = {'permissive': IUPACAmbiguousRNA(), 'strict': IUPACUnambiguousRNA()}[source]
get_dna(*args, **kwargs)[source]
get_protein(*args, **kwargs)[source]
get_rna(*args, **kwargs)[source]
objects = <obj_model.core.Manager object>[source]

2.1.5. wc_rules.chem module

Author:John Sekar <johnarul.sekar@gmail.com>
Date:2018-04-20
Copyright:2017, Karr Lab
License:MIT
class wc_rules.chem.Bond(**kwargs)[source]

Bases: wc_rules.entity.Entity

class Meta[source]

Bases: obj_model.core.Meta

attribute_order = ()[source]
attributes = {'id': <wc_rules.attributes.IdAttribute object>, 'sites': <wc_rules.attributes.OneToManyAttribute object>}[source]
frozen_columns = 1[source]
indexed_attrs_tuples = ()[source]
inheritance = (<class 'wc_rules.chem.Bond'>, <class 'wc_rules.entity.Entity'>, <class 'wc_rules.base.BaseClass'>)[source]
ordering = ('id',)[source]
primary_attribute = <wc_rules.attributes.IdAttribute object>[source]
related_attributes = {}[source]
tabular_orientation = 1[source]
unique_together = ()[source]
verbose_name = 'Bond'[source]
verbose_name_plural = 'Bonds'[source]
add_sites(*sites)[source]
allowed_site_types = None[source]
get_number_of_sites()[source]
get_sites(**kwargs)[source]
n_max_sites = 2[source]
objects = <obj_model.core.Manager object>[source]
remove_sites(*sites)[source]
sites = <wc_rules.attributes.OneToManyAttribute object>[source]
verify_allowed_site_types()[source]
verify_maximum_number_of_sites()[source]
class wc_rules.chem.Molecule(**kwargs)[source]

Bases: wc_rules.entity.Entity

class Meta[source]

Bases: obj_model.core.Meta

attribute_order = ()[source]
attributes = {'id': <wc_rules.attributes.IdAttribute object>}[source]
frozen_columns = 1[source]
indexed_attrs_tuples = ()[source]
inheritance = (<class 'wc_rules.chem.Molecule'>, <class 'wc_rules.entity.Entity'>, <class 'wc_rules.base.BaseClass'>)[source]
ordering = ('id',)[source]
primary_attribute = <wc_rules.attributes.IdAttribute object>[source]
related_attributes = {'sites': <wc_rules.attributes.ManyToOneAttribute object>}[source]
tabular_orientation = 1[source]
unique_together = ()[source]
verbose_name = 'Molecule'[source]
verbose_name_plural = 'Molecules'[source]
add_sites(*sites)[source]
get_sites(**kwargs)[source]
objects = <obj_model.core.Manager object>[source]
remove_sites(*sites)[source]
class wc_rules.chem.Overlap(**kwargs)[source]

Bases: wc_rules.entity.Entity

class Meta[source]

Bases: obj_model.core.Meta

attribute_order = ()[source]
attributes = {'id': <wc_rules.attributes.IdAttribute object>, 'sites': <wc_rules.attributes.ManyToManyAttribute object>}[source]
frozen_columns = 1[source]
indexed_attrs_tuples = ()[source]
inheritance = (<class 'wc_rules.chem.Overlap'>, <class 'wc_rules.entity.Entity'>, <class 'wc_rules.base.BaseClass'>)[source]
ordering = ('id',)[source]
primary_attribute = <wc_rules.attributes.IdAttribute object>[source]
related_attributes = {}[source]
tabular_orientation = 1[source]
unique_together = ()[source]
verbose_name = 'Overlap'[source]
verbose_name_plural = 'Overlaps'[source]
add_sites(*sites)[source]
get_sites(**kwargs)[source]
objects = <obj_model.core.Manager object>[source]
remove_sites(*sites)[source]
sites = <wc_rules.attributes.ManyToManyAttribute object>[source]
class wc_rules.chem.Site(**kwargs)[source]

Bases: wc_rules.entity.Entity

class Meta[source]

Bases: obj_model.core.Meta

attribute_order = ()[source]
attributes = {'id': <wc_rules.attributes.IdAttribute object>, 'molecule': <wc_rules.attributes.ManyToOneAttribute object>}[source]
frozen_columns = 1[source]
indexed_attrs_tuples = ()[source]
inheritance = (<class 'wc_rules.chem.Site'>, <class 'wc_rules.entity.Entity'>, <class 'wc_rules.base.BaseClass'>)[source]
ordering = ('id',)[source]
primary_attribute = <wc_rules.attributes.IdAttribute object>[source]
related_attributes = {'bond': <wc_rules.attributes.OneToManyAttribute object>, 'overlaps': <wc_rules.attributes.ManyToManyAttribute object>}[source]
tabular_orientation = 1[source]
unique_together = ()[source]
verbose_name = 'Site'[source]
verbose_name_plural = 'Sites'[source]
add_overlaps(*overlaps)[source]
allowed_molecule_types = None[source]
allowed_to_bind = True[source]
get_bond()[source]
get_molecule()[source]
get_overlaps(**kwargs)[source]
molecule = <wc_rules.attributes.ManyToOneAttribute object>[source]
objects = <obj_model.core.Manager object>[source]
remove_overlaps(*overlaps)[source]
set_bond(bond)[source]
set_molecule(molecule)[source]
unset_bond()[source]
unset_molecule()[source]
verify_allowed_molecule_type()[source]
verify_allowed_to_bind()[source]

2.1.6. wc_rules.entity module

Author:John Sekar <johnarul.sekar@gmail.com>
Date:2017-12-13
Copyright:2017, Karr Lab
License:MIT
class wc_rules.entity.Entity(**kwargs)[source]

Bases: wc_rules.base.BaseClass

class Meta[source]

Bases: obj_model.core.Meta

attribute_order = ()[source]
attributes = {'id': <wc_rules.attributes.IdAttribute object>}[source]
frozen_columns = 1[source]
indexed_attrs_tuples = ()[source]
inheritance = (<class 'wc_rules.entity.Entity'>, <class 'wc_rules.base.BaseClass'>)[source]
ordering = ('id',)[source]
primary_attribute = <wc_rules.attributes.IdAttribute object>[source]
related_attributes = {}[source]
tabular_orientation = 1[source]
unique_together = ()[source]
verbose_name = 'Entity'[source]
verbose_name_plural = 'Entitys'[source]
classmethod get_classnames()[source]
objects = <obj_model.core.Manager object>[source]

2.1.7. wc_rules.gml module

wc_rules.gml.generate_gml(node_labels, edge_tuples, node_categories=None)[source]
wc_rules.gml.generate_gml_edge(source, target)[source]
wc_rules.gml.generate_gml_node(idx, label, fill)[source]
wc_rules.gml.get_colors(categories)[source]

2.1.8. wc_rules.graph_utils module

Author:John Sekar <johnarul.sekar@gmail.com>
Date:2017-12-13
Copyright:2017, Karr Lab
License:MIT
class wc_rules.graph_utils.GraphMatcher(g1, g2)[source]

Bases: networkx.algorithms.isomorphism.vf2userfunc.DiGraphMatcher

class wc_rules.graph_utils.GraphMeta[source]

Bases: object

Inner class holding values used in graph methods

outward_edges[source]

attributes to be examined recursively for get_graph(). Only RelatedManager attributes allowed.

Type:str
semantic[source]

attributes/properties should be examined for node_match(). Only attributes/properties that return values comparable by ‘==’ allowed.

Type:str
outward_edges = ()[source]
semantic = ()[source]
wc_rules.graph_utils.edge_match(dict1, dict2)[source]
wc_rules.graph_utils.get_graph(current_obj, recurse=True, memo=None)[source]
wc_rules.graph_utils.node_compare(current, other)[source]
wc_rules.graph_utils.node_match(node1, node2)[source]

2.1.9. wc_rules.indexer module

Author:John Sekar <johnarul.sekar@gmail.com>
Date:2018-05-21
Copyright:2018, Karr Lab
License:MIT
class wc_rules.indexer.BooleanIndexer[source]

Bases: wc_rules.indexer.Indexer

primitive_type[source]

alias of builtins.bool

class wc_rules.indexer.DictSet(iterable=None, keyfunc=None)[source]

Bases: object

A container that is primarily a set, but also indexes the elements using a key function (default keyfunc is getting the object’s id).

add(elem)[source]
remove(elem)[source]
class wc_rules.indexer.HashableDict[source]

Bases: dict

class wc_rules.indexer.Index_By_ID[source]

Bases: dict

A dict that looks like a list, but enables recovering by ID

append(obj1)[source]
remove(obj1)[source]
retrieve(idx)[source]
class wc_rules.indexer.Indexer[source]

Bases: dict

A hashmap between keys (literals or named tuples) and arbitary values of the same type (set by the primitive_type class attribute).

If I is an indexer object, I[key] - returns the value mapped to key I[slice] - returns an indexer which is a subset of the previous indexer, with keys from slice.

In addition to dict-like behavior, Indexer maintains a value cache, which supports reverse lookup of keys from values using the == and != operators

I == value returns a slice of keys such that I[key]==value I == list_of_values returns a slice of keys such that I[key] in list_of_values I1 == I2 returns a slice of keys with equal values in I1 and I2 I != x returns ~(I==x) where x is a value, list of values or indexer.

Alternatively, one can use the slice method I.slice(value) same as I==value I.slice(list_of_values) same as I==list_of_values I.slice(function) returns a slice of keys whose values evaluate to True under function.

Slicing and subsetting can be done simultaneously, e.g., I[I==value].

Also, Indexer maintains a last_updated list of keys, which is propagated by default when a subset is created.

add_key_to_value_cache(key, value)[source]
delete_key_from_value_cache(key)[source]
flush()[source]
primitive_type = None[source]
remove(keylist)[source]
remove_key(key)[source]
slice(value_list=None)[source]
subset(keylist, propagate=True)[source]
update([E, ]**F) → None. Update D from dict/iterable E and F.[source]

If E is present and has a .keys() method, then does: for k in E: D[k] = E[k] If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k]

update_key_value(key, value)[source]
update_last_updated(keylist)[source]
value_is_compatible(value)[source]
class wc_rules.indexer.NumericIndexer[source]

Bases: wc_rules.indexer.Indexer

In additon to operators == and !=, NumericIndexer also supports >,`>=`, < and <=

I1 > I2 returns a slice for all keys in I1 whose values in I1 are greater than their values in I2 I > value returns a slice for all keys in I mapped to values greater than value I > list_of_values is not supported

primitive_type = (<class 'int'>, <class 'float'>)[source]
class wc_rules.indexer.Slicer(default=False)[source]

Bases: dict

A hashmap between keys (literals or namedtuples) and Boolean values. Slicers are dict-like and always return True or False when queried with [key]. Slicers may be positive slicers (psl’s) or negative slicers (nsl’s). Given set A,

psl(A) represents set A nsl(A) represents complement(A)
The operator ~ inverts positive and negative slicers.
~psl(A) = nsl(A) ~nsl(A) = psl(B)
The operator & performs a set intersection according to deMorgan’s laws.
psl(A) & psl(B) = psl(intersection(A,B)) psl(A) & nsl(B) = psl(A - intersection(A,B)) nsl(A) & psl(B) = psl(B - intersection(A,B)) nsl(A) & nsl(B) = nsl(union(A,B))
The operator | performs a set union according to deMorgan’s laws.
psl(A) | psl(B) = psl(union(A,B)) psl(A) | nsl(B) = nsl(B - intersection(A,B)) nsl(A) | psl(B) = nsl(A - intersection(A,B)) nsl(A) | nsl(B) = nsl(intersection(A,B))
add_keys(keys)[source]
delete_keys(keys)[source]
intersection(other)[source]
union(other)[source]
update([E, ]**F) → None. Update D from dict/iterable E and F.[source]

If E is present and has a .keys() method, then does: for k in E: D[k] = E[k] If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k]

class wc_rules.indexer.StringIndexer[source]

Bases: wc_rules.indexer.Indexer

primitive_type[source]

alias of builtins.str

2.1.10. wc_rules.matcher module

class wc_rules.matcher.Matcher[source]

Bases: object

add_pattern(pattern)[source]
get_pattern(pattern_id)[source]
send_token(token, verbose=False)[source]
wc_rules.matcher.main()[source]

2.1.11. wc_rules.pattern module

class wc_rules.pattern.Pattern(idx, nodelist=None, recurse=True)[source]

Bases: wc_rules.indexer.DictSet

add_node(node, recurse=True)[source]
duplicate(idx=None, preserve_ids=False)[source]
generate_queries()[source]
generate_queries_ATTR()[source]

Generates tuples (‘attr’,attrname,operator,value)

generate_queries_REL()[source]

Generate tuples (‘rel’,idx1,attrname,related_attrname,idx2)

generate_queries_TYPE()[source]

Generates tuples (‘type’,_class)

remove_node(node)[source]
wc_rules.pattern.main()[source]

2.1.12. wc_rules.rete_build module

wc_rules.rete_build.add_aliasEDGE(net, current_node, var1, var2)[source]
wc_rules.rete_build.add_aliasNODE(net, current_node, varname)[source]
wc_rules.rete_build.add_aliasPATTERN(net, current_node, name)[source]
wc_rules.rete_build.add_checkATTR_path(net, current_node, attr_vec)[source]
wc_rules.rete_build.add_checkEDGETYPE(net, current_node, attr1, attr2)[source]
wc_rules.rete_build.add_checkTYPE_path(net, current_node, type_vec)[source]
wc_rules.rete_build.add_mergenode(net, node1, node2)[source]
wc_rules.rete_build.add_mergenode_path(net, list_of_nodes)[source]
wc_rules.rete_build.add_store(net, current_node, number_of_variables)[source]
wc_rules.rete_build.check_attribute_and_add_successor(net, current_node, _class_to_init, attr, value)[source]
wc_rules.rete_build.increment_net_with_pattern(net, pattern)[source]

Steps through the queries generated by a pattern and increments the Rete net.

wc_rules.rete_build.sort_tuples(vartuples)[source]

2.1.13. wc_rules.rete_net module

class wc_rules.rete_net.ReteNet[source]

Bases: wc_rules.indexer.DictSet

add_edge(node1, node2)[source]
add_node(node)[source]
draw_as_gml(filename=None, as_string=False)[source]
get_root()[source]

2.1.14. wc_rules.rete_nodes module

class wc_rules.rete_nodes.ReteNode(id=None)[source]

Bases: object

adding_message(token, tab=4)[source]
entry_check(token)[source]
evaluate_token(token)[source]
failing_message(msg='', tab=4)[source]
passing_message(token, tab=4)[source]
process_token(token, sender, verbose=False)[source]
processing_message(token)[source]
receive_token(token, sender, verbose=False)[source]
removing_message(token, tab=4)[source]
send_token(token, verbose=False)[source]
verbose_mode_message(token, tokens_to_pass=[], tokens_to_add=[], tokens_to_remove=[], passthrough_fail='')[source]
class wc_rules.rete_nodes.Root[source]

Bases: wc_rules.rete_nodes.SingleInputNode

class wc_rules.rete_nodes.SingleInputNode(id=None)[source]

Bases: wc_rules.rete_nodes.ReteNode

class wc_rules.rete_nodes.alias(var_tuple, id=None)[source]

Bases: wc_rules.rete_nodes.SingleInputNode

passthrough_fail_message()[source]
process_token(token, sender, verbose)[source]
transform_token(token, keymap)[source]
class wc_rules.rete_nodes.check(id=None)[source]

Bases: wc_rules.rete_nodes.SingleInputNode

class wc_rules.rete_nodes.checkATTR(tuple_of_attr_tuples, id=None)[source]

Bases: wc_rules.rete_nodes.check

entry_check(token)[source]
evaluate_expression(node, attr, op, value)[source]
evaluate_expressions(token)[source]
has_shared_attrs(token)[source]
operator_dict = {'eq': '==', 'ge': '>=', 'gt': '>', 'le': '<=', 'lt': '<', 'ne': '!='}[source]
passthrough_fail_message()[source]
process_token(token, sender, verbose=False)[source]
class wc_rules.rete_nodes.checkEDGETYPE(attrpair, id=None)[source]

Bases: wc_rules.rete_nodes.check

entry_check(token)[source]
evaluate_token(token)[source]
passthrough_fail_message()[source]
class wc_rules.rete_nodes.checkTYPE(_class, id=None)[source]

Bases: wc_rules.rete_nodes.check

entry_check(token)[source]
evaluate_token(token)[source]
passthrough_fail_message()[source]
class wc_rules.rete_nodes.merge(var_tuple, id=None)[source]

Bases: wc_rules.rete_nodes.ReteNode

class wc_rules.rete_nodes.store(id=None, number_of_variables=1)[source]

Bases: wc_rules.rete_nodes.SingleInputNode

entry_check(token)[source]
keys()[source]
passthrough_fail_message(msgtype='add')[source]
process_token(token, sender, verbose)[source]

2.1.15. wc_rules.rete_token module

class wc_rules.rete_token.AddToken(contents=None)[source]

Bases: wc_rules.rete_token.Token

get_type()[source]
class wc_rules.rete_token.RemoveToken(contents=None)[source]

Bases: wc_rules.rete_token.Token

get_type()[source]
class wc_rules.rete_token.Token(contents=None)[source]

Bases: object

get_subtoken(keys)[source]
get_type()[source]
items()[source]
keys()[source]
subset(keys)[source]
update(tok)[source]
class wc_rules.rete_token.TokenRegister[source]

Bases: object

add_token(token)[source]
deregister(key, value, token)[source]
filter(token)[source]
get(token)[source]
getkv(key, value)[source]
register(key, value, token)[source]
remove_token(token)[source]
wc_rules.rete_token.flip_edge_correctly(node1, attr1, attr2, node2)[source]
wc_rules.rete_token.new_token(token, invert=False, keymap=None, subsetkeys=None)[source]
wc_rules.rete_token.token_add_edge(node1, attr1, attr2, node2)[source]
wc_rules.rete_token.token_add_node(node)[source]
wc_rules.rete_token.token_edit_attrs(node, attrlist)[source]
wc_rules.rete_token.token_remove_edge(node1, attr1, attr2, node2)[source]
wc_rules.rete_token.token_remove_node(node)[source]

2.1.16. wc_rules.seq module

Author:John Sekar <johnarul.sekar@gmail.com>
Date:2017-12-13
Copyright:2017, Karr Lab
License:MIT
class wc_rules.seq.SequenceFeature(**kwargs)[source]

Bases: wc_rules.chem.Site

Simple sequence feature with position index and length. .. rubric:: Example

If parent molecule is .A.T.C.G.A.T., feature with start=0,end=0 has sequence ‘’ feature with start=0,end=1 has sequence ‘A’ feature with start=0,end=6 has sequence ‘ATCGAT’ feature with start=5,end=6 has sequence ‘T’ feature with start=6,end=0 has sequence ‘’

class Meta[source]

Bases: obj_model.core.Meta

attribute_order = ()[source]
attributes = {'end': <obj_model.core.IntegerAttribute object>, 'id': <wc_rules.attributes.IdAttribute object>, 'molecule': <wc_rules.attributes.ManyToOneAttribute object>, 'start': <obj_model.core.IntegerAttribute object>}[source]
frozen_columns = 1[source]
indexed_attrs_tuples = ()[source]
inheritance = (<class 'wc_rules.seq.SequenceFeature'>, <class 'wc_rules.chem.Site'>, <class 'wc_rules.entity.Entity'>, <class 'wc_rules.base.BaseClass'>)[source]
ordering = ('id',)[source]
primary_attribute = <wc_rules.attributes.IdAttribute object>[source]
related_attributes = {'bond': <wc_rules.attributes.OneToManyAttribute object>, 'overlaps': <wc_rules.attributes.ManyToManyAttribute object>}[source]
tabular_orientation = 1[source]
unique_together = ()[source]
verbose_name = 'Sequence feature'[source]
verbose_name_plural = 'Sequence features'[source]
end = <obj_model.core.IntegerAttribute object>[source]
get_end()[source]
get_length()[source]
get_location()[source]
get_start()[source]
objects = <obj_model.core.Manager object>[source]
set_location(start=None, end=None, length=None)[source]
start = <obj_model.core.IntegerAttribute object>[source]
class wc_rules.seq.SequenceMolecule(*args, **kwargs)[source]

Bases: wc_rules.chem.Molecule

Generic SequenceMolecule (template for DNA, RNA, protein sequence objects)

class Meta[source]

Bases: obj_model.core.Meta

attribute_order = ()[source]
attributes = {'id': <wc_rules.attributes.IdAttribute object>, 'sequence': <obj_model.extra_attributes.BioSeqAttribute object>}[source]
frozen_columns = 1[source]
indexed_attrs_tuples = ()[source]
inheritance = (<class 'wc_rules.seq.SequenceMolecule'>, <class 'wc_rules.chem.Molecule'>, <class 'wc_rules.entity.Entity'>, <class 'wc_rules.base.BaseClass'>)[source]
ordering = ('id',)[source]
primary_attribute = <wc_rules.attributes.IdAttribute object>[source]
related_attributes = {'sites': <wc_rules.attributes.ManyToOneAttribute object>}[source]
tabular_orientation = 1[source]
unique_together = ()[source]
verbose_name = 'Sequence molecule'[source]
verbose_name_plural = 'Sequence molecules'[source]
alphabet = None[source]
alphabet_dict = {'permissive': None, 'strict': None}[source]
delete_sequence(start=None, end=None, length=None)[source]
get_alphabet(as_string=False)[source]
get_sequence(start=None, end=None, length=None, as_string=False)[source]
get_sequence_length(start=None, end=None)[source]
insert_sequence(start=None, sequence='')[source]
load_alphabet(permissive=True)[source]
objects = <obj_model.core.Manager object>[source]
replace_sequence(start=None, end=None, length=None, sequence='')[source]
static resolve_start_end_length(start=None, end=None, length=None)[source]
sequence = <obj_model.extra_attributes.BioSeqAttribute object>[source]
set_sequence(init_str='')[source]
use_permissive_alphabet = True[source]
verify_location(start=None, end=None)[source]
verify_sequence(start=None, end=None, length=None)[source]

2.1.17. wc_rules.utils module

Author:John Sekar <johnarul.sekar@gmail.com>
Date:2017-12-13
Copyright:2017, Karr Lab
License:MIT
exception wc_rules.utils.AddError(msg=None)[source]

Bases: wc_rules.utils.GenericError

exception wc_rules.utils.AddObjectError(parentobject, currentobject, allowedobjects, methodname='add()')[source]

Bases: Exception

static to_str(obj)[source]
exception wc_rules.utils.FindError(msg=None)[source]

Bases: wc_rules.utils.GenericError

exception wc_rules.utils.GenericError(msg=None)[source]

Bases: Exception

exception wc_rules.utils.IndexerError(msg=None)[source]

Bases: wc_rules.utils.GenericError

exception wc_rules.utils.RemoveError(msg=None)[source]

Bases: wc_rules.utils.GenericError

exception wc_rules.utils.RemoveObjectError(parentobject, currentobject, allowedobjects, methodname='remove()', notfound=False)[source]

Bases: Exception

static to_str(obj)[source]
exception wc_rules.utils.SeqError(msg=None)[source]

Bases: wc_rules.utils.GenericError

exception wc_rules.utils.SetError(msg=None)[source]

Bases: wc_rules.utils.GenericError

exception wc_rules.utils.SlicerError(msg=None)[source]

Bases: wc_rules.utils.GenericError

exception wc_rules.utils.ValidateError(msg=None)[source]

Bases: wc_rules.utils.GenericError

wc_rules.utils.generate_id()[source]
wc_rules.utils.iter_to_string(iterable)[source]
wc_rules.utils.listify(value)[source]

2.1.18. Module contents

Author:John Sekar <johnarul.sekar@gmail.com>
Date:2017-12-13
Copyright:2017, Karr Lab
License:MIT