cafaeval.graph

class cafaeval.graph.Graph(namespace, terms_dict, ia_dict=None, orphans=False)[source]

Bases: object

Ontology class. One ontology == one namespace DAG is the adjacence matrix (sparse) which represent a Directed Acyclic Graph where DAG(i,j) == 1 means that the go term i is_a (or is part_of) j Parents that are in a different namespace are discarded

top_sort()[source]

Takes a sparse matrix representing a DAG and returns an array with nodes indexes in topological order https://en.wikipedia.org/wiki/Topological_sorting

set_ia(ia_dict)[source]
class cafaeval.graph.Prediction(ids, matrix, namespace=None)[source]

Bases: object

The score matrix contains the scores given by the predictor for every node of the ontology

class cafaeval.graph.GroundTruth(ids, matrix, namespace=None)[source]

Bases: object

cafaeval.graph.propagate(matrix, ont, order, mode='max', parallel=0, chunk_rows=65536, _shm_name=None, _shape=None, _dtype_str=None, _row_start=None, _row_end=None, _deepest=None, _triples=None)[source]

Update inplace the score matrix (proteins x terms) propagating scores up to the root. mode='max' takes the max of each term and its children; mode='fill' only updates rows where the current term is zero.

When parallel > 1 and the estimated work is above the threshold the matrix is shared across processes via shared_memory (spawn context) and rows are partitioned among workers. Recursive calls re-enter this function through the _shm_name path.