bbop-graph-noctua
Advanced tools
Comparing version 0.0.12 to 0.0.13
@@ -1154,3 +1154,6 @@ /** | ||
* | ||
* TODO: inferred individuals | ||
* Currently, a single pass is run to fold evidence individuals into | ||
* other nodes as referenced individuals. However, additional passes | ||
* can very easily be added to fold away references to references as | ||
* long as a matching function is provided. | ||
* | ||
@@ -1201,6 +1204,15 @@ * @param {Object} the "data" portion of a Minerva graph-related response. | ||
// Add the evidence singletons into the structure by | ||
// scanning through the nodes and adding them as referenced | ||
// individuals. | ||
each(anchor.all_nodes(), function(node){ | ||
// Take and, and see if it is an evidence reference. | ||
function is_iri_ev_p(ann){ | ||
var ret = false; | ||
if( ann.key() == 'evidence' && ann.value_type() == 'IRI' ){ | ||
ret = true; | ||
} | ||
return ret; | ||
} | ||
// For any node, look at all of the annotations, and fold in | ||
// ones that 1) pass the test and 2) reference a singleton | ||
// node. | ||
function fold_in_reference(node, test_p){ | ||
each(node.annotations(), function(ann){ | ||
@@ -1211,13 +1223,14 @@ | ||
// Is it an evidence annotation. | ||
if( ann.key() == 'evidence' && ann.value_type() == 'IRI' ){ | ||
//if( ann.key() == 'evidence' && ann.value_type() == 'IRI' ){ | ||
if( test_p(ann) ){ | ||
// If so, and the individual in question is a | ||
// singleton (if not, we don't fold it). | ||
var ev_ref = ann.value(); | ||
if( singletons[ev_ref] ){ | ||
var ref_node_id = ann.value(); | ||
if( singletons[ref_node_id] ){ | ||
// Remove node from the graph. | ||
anchor.remove_node(ref_node_id); | ||
// Remove | ||
anchor.remove_node(ev_ref); | ||
// Add as referenced individual. | ||
var ev_indiv = singletons[ev_ref]; | ||
var ev_indiv = singletons[ref_node_id]; | ||
var c1 = node.add_referenced_individual(ev_indiv); | ||
@@ -1227,6 +1240,13 @@ //console.log('<<' + node.id() + '>1>', c1.length); | ||
//console.log('<<' + node.id() + '>2>', c2.length); | ||
// console.log(node) | ||
// console.log(node) | ||
} | ||
} | ||
}); | ||
} | ||
// Add the evidence singletons into the structure by | ||
// scanning through the nodes and adding them as referenced | ||
// individuals. | ||
each(anchor.all_nodes(), function(node){ | ||
fold_in_reference(node, is_iri_ev_p); | ||
}); | ||
@@ -1237,18 +1257,3 @@ | ||
each(anchor.all_edges(), function(edge){ | ||
each(edge.annotations(), function(ann){ | ||
// Is it an evidence annotation. | ||
if( ann.key() == 'evidence' && ann.value_type() == 'IRI' ){ | ||
// If so, add it in. | ||
var ev_ref = ann.value(); | ||
if( singletons[ev_ref] ){ | ||
// Remove | ||
anchor.remove_node(ev_ref); | ||
// Add as referenced individual. | ||
var ev_indiv = singletons[ev_ref]; | ||
edge.add_referenced_individual(ev_indiv); | ||
} | ||
} | ||
}); | ||
fold_in_reference(edge, is_iri_ev_p); | ||
}); | ||
@@ -1259,3 +1264,3 @@ | ||
// console.log(anchor); | ||
// console.log(anchor); | ||
@@ -1268,5 +1273,6 @@ return ret; | ||
* everything we did for {load_data_evidence_fold}, we're going to | ||
* search for nodes that have enabled_by and/or occurs_in targets | ||
* (that are themselves leaves) fold them in to the contained subgraph | ||
* item, and remove them from the top-level graph. | ||
* search for nodes that have enabled_by and/or occurs_in (or any | ||
* other specified relation) targets (that are themselves leaves) fold | ||
* them in to the contained subgraph item, and remove them from the | ||
* top-level graph. | ||
* | ||
@@ -1276,5 +1282,6 @@ * TODO: inferred individuals | ||
* @param {Object} the "data" portion of a Minerva graph-related response. | ||
* @param {Array} list of relations (as strings) to scan for for collapsing | ||
* @returns {Boolean} if data was loaded | ||
*/ | ||
noctua_graph.prototype.load_data_go_noctua = function(data){ | ||
noctua_graph.prototype.load_data_go_noctua = function(data, relation_list){ | ||
var anchor = this; | ||
@@ -1309,3 +1316,4 @@ | ||
// occurs_in (location). | ||
var collapsable_relations = ['RO:0002333', 'BFO:0000066']; | ||
//var collapsable_relations = ['RO:0002333', 'BFO:0000066']; | ||
var collapsable_relations = relation_list || []; | ||
each(collapsable_relations, function(relation){ | ||
@@ -1312,0 +1320,0 @@ |
{ | ||
"name": "bbop-graph-noctua", | ||
"version": "0.0.12", | ||
"version": "0.0.13", | ||
"license": "BSD-3-Clause", | ||
@@ -5,0 +5,0 @@ "description": "A subclass of bbop-graph that layers on a complete annotation and graph editing model for the Noctua set of tools.", |
@@ -258,3 +258,4 @@ //// | ||
var raw_resp = require('./minerva-01.json'); | ||
g.load_data_go_noctua(raw_resp['data']); | ||
var rellist = ['RO:0002333', 'BFO:0000066']; | ||
g.load_data_go_noctua(raw_resp['data'], rellist); | ||
@@ -304,3 +305,4 @@ // Basic structure count. | ||
var raw_resp = require('./minerva-01.json'); | ||
g.load_data_go_noctua(raw_resp['data']); | ||
var rellist = ['RO:0002333', 'BFO:0000066']; | ||
g.load_data_go_noctua(raw_resp['data'], rellist); | ||
@@ -332,3 +334,4 @@ var nid = 'gomodel:taxon_559292-5525a0fc0000001-GO-0005515-5525a0fc0000023'; | ||
var raw_resp = require('./minerva-01.json'); | ||
g.load_data_go_noctua(raw_resp['data']); | ||
var rellist = ['RO:0002333', 'BFO:0000066']; | ||
g.load_data_go_noctua(raw_resp['data'], rellist); | ||
@@ -335,0 +338,0 @@ // Make a new graph to operate on. |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
6333896
27087