Gprlogic

class AndNode[source]

AndNode are an class that represents AND connections in a logical formula For further documentation please have a look at the Node Class. .. Authors

  • Thomas Pfau 2016

isValid(self, sizes, step)[source]

Check whether a given step is a valid possibility (no step element larger than sizes :USAGE: res = Node.isValid (sizes,step)

INPUTS
  • sizes – An array of sizes

  • step – An array of suggested selections

OUTPUTS

res – ~any(step > sizes’)

nextcombination(self, sizes, step)[source]

Get the next combination given the current combination :USAGE: combination = Node.nextcombination (sizes,step)

INPUTS
  • sizes – An array of maximal sizes

  • step – The current combination

OUTPUTS

combination – The next allowed element of step incremented, and potentially others reset to 1.

reduce(self)[source]

we can merge any children of and nodes directly.

class FormulaParser[source]

A FormulaParser is used to parse logic formulas in the format specified for the COBRA Toolbox tules field (i.e. logical formulas using | and & as OR and AND symbols and x([0-9]+) as a regexp matching all literals.

FormulaParser()[source]

Default FormulaParser constructor. :USAGE: obj = FormulaParser()

OUTPUTS

obj – The FormulaParser Object

createNodeStructure(self, finalid)[source]

Private Function

parseFormula(self, formula)[source]

Parse a Formula in the COBRA rules format (as detailed above). :USAGE: Head = FormulaParser.parseFormula (formula)

INPUTS

formula – A String of a GPR formula in rules format ( &/| as operators, x(1) as literal symbols

OUTPUTS

Head – The Head of a Tree representing the formula

class LiteralNode(id)[source]

LiteralNode is a class that represents a literal in a logical formula For further documentation please have a look at the Node Class. .. Authors

  • Thomas Pfau 2016

deleteLiteral(self, literalID, keepClauses)[source]

This function is not applicable to a literal node, as a literal node cannot delete itself.

class Node[source]

Node are an Abstract class that handles different types of logical Nodes for a tree representation of a logical formula.

Node()[source]

Default Node constructor. :USAGE: obj = Node()

OUTPUTS

obj – The Node Object

addChild(self, childNode)[source]

Add A Child to the node :USAGE: Node.addchild (childNode)

INPUTS

childNode – The child to add to the node.

contains(self, literal)[source]

Check whether the given literal is part of this node. :USAGE: res = Node.contains (literal)

INPUTS

literal – The literal to look up (a string representation of a number from a rule

OUTPUTS

res – Whether the literal is present in the tree starting at this node.

deleteLiterals(self, literals, keepClauses)[source]

Remove all duplicate literal nodes in this node. :USAGE: node.removeLiterals (literals, keepClauses)

INPUTS
  • literals – The literals to remove

  • keepClauses – Whether to retain AND nodes in which any of the lietrals are nested.

getFunctionalGeneSets(self, geneNames, getCNFSets)[source]

Get all functional gene sets useable for this node :USAGE: geneSets = Node.getFunctionalGeneSets (geneNames)

INPUTS

geneNames – the genes in the order represented by the literals (which represent positions)

OPTIONAL INPUT

getCNFSets – Get the CNF sets from this node instead of the DNF sets. (i.e. get the or clauses instead of the protein representing and clauses) (Default: false)

OUTPUTS
  • geneSets – A cell array of gene Combinations that would make this node active

  • genePos – A set of positions (according to the parsed Rules) of genes that would make this tree evaluate to true.

getID(self)[source]

Get the ID (commonly the class except for Literals :USAGE: id = Node.getID()

OUTPUTS

id – The id for literals the represented literal, or classname for other nodes of the node

getLiterals(self)[source]

Get the set of literals present in the tree below this node. :USAGE: literals = Node.getLiterals()

OUTPUTS

literals – A cell array of all literals present in the tree under this node

hasNestedChildren(self)[source]

Check, whether this Node has nested children (i.e. whether it has non literal children) :USAGE: tf = Node.hasNestedChildren()

OUTPUTS

tf – Whether this node has nested children

isDNF(self)[source]

Check, whether this is a DNF node (i.e.) i.e. it is either a literal node, or an or node which only has children which are and nodes (with only literal children), or literal nodes. Or an AND node with only literal children :USAGE: tf = Node.isDNF()

OUTPUTS

tf – Whether this node is a DNF node or not.

isequal(self, otherNode)[source]

Get all functional gene sets useable for this node :USAGE: tf = Node.isequal (otherNode)

INPUTS

otherNode – The node to compare this node with

OUTPUTS

tf – true, if this node is equal to the other node, i.e. it represents the same boolean truth table.

removeDuplicateLiterals(self)[source]

Remove all duplicate literal nodes in this node. :USAGE: node.removeDuplicateLiterals()

NormaliseGPRs(model, geneRegExp)[source]

Bring all GPRS into a DNF form and reduce them to the minimal DNF Form :USAGE: Outmodel = NormaliseGPRs (model,geneRegExp)

INPUTS
  • model – The Model to convert the GPRs

  • geneRegExp – A Regular expression matching the genes in the model.

OUTPUTS

Outmodel – The output model with all GPRS in minimal DNF form.

class OrNode[source]

OrNode is a class that represents OR connections in a logical formula For further documentation please have a look at the Node Class. .. Authors

  • Thomas Pfau 2016

removeDNFduplicates(self)[source]

Assuming this is a DNF head node, removeDNFDuplicates checks all present AND nodes for equality and removes replicates.

USAGE

Node.removeDNFduplicates()

OUTPUTS

Node – A OrNode with all duplicate And nodes removed.

combineChildren(CNFNode1, CNFNode2)[source]

Combine the children of two nodes such that all children of node 1 are mixed with children of node 2. Conjunct clauses which are superseeded are removed. :USAGE: [outputNode] = combineChildren (CNFNode1,CNFNode2)

INPUTS
  • CNFNode1 – A Node in CNF format

  • CNFNode2 – A Node in CNF format

OUTPUTS

outputNode – A node with all children of the input nodes mixed.

Note

The function will mix all combinations of nodes. E.g. if node 1 is (A | B) & (C | D) and node 2 is (E | F) & G the resulting node will be (A | B | E | F) & (A | B | G) & (C | D | E | F) & (C | D | G)