Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

bbop-graph-noctua

Package Overview
Dependencies
Maintainers
1
Versions
33
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bbop-graph-noctua - npm Package Compare versions

Comparing version 0.0.20 to 0.0.21

tests/minerva-04.json

88

lib/edit.js

@@ -1685,50 +1685,76 @@ /**

*
* @param {Object} [incoming_graph] subgraph to unfold into the calling graph (default behaviour would be calling itself; only really used internally by this method for recursion)
* @returns {Boolean} if unfolded (should always be true)
*/
noctua_graph.prototype.unfold = function(){
noctua_graph.prototype.unfold = function(incoming_graph){
var anchor = this;
// If not a recursive, we will operate on ourselves.
if( ! incoming_graph ){
incoming_graph = anchor;
}
// For any entity, remove its referenced individuals and re-add
// them to the graph.
function _unfold_reference(item){
// Get.
var ref_graphs = item.referenced_subgraphs();
function _unfold_subgraph(sub){
// Restore to graph.
each(sub.all_nodes(), function(node){
anchor.add_node(node);
});
each(sub.all_edges(), function(edge){
anchor.add_edge(edge);
});
}
// Apply to all nodes.
each(incoming_graph.all_nodes(), function(node){
// Get references (ev).
var ref_graphs = node.referenced_subgraphs();
// Restore to graph.
each(ref_graphs, function(sub){
each(sub.all_nodes(), function(node){
anchor.add_node(node);
});
each(sub.all_edges(), function(edge){
anchor.add_edge(edge);
});
_unfold_subgraph(sub);
});
// Remove references.
item.referenced_subgraphs([]);
}
// Apply to all nodes.
each(anchor.all_nodes(), function(node){ _unfold_reference(node); });
node.referenced_subgraphs([]);
// Now that they've been removed, try and recur (to help
// prevent loops).
each(ref_graphs, function(sub){
anchor.unfold(sub);
});
// Repeat with any absorbed subgraph.
var asub = node.subgraph();
if( asub ){
_unfold_subgraph(asub);
node.subgraph(null); // eliminate after it has been re-added
// Recur on any found subgraphs, safer since the elimination.
anchor.unfold(asub);
}
});
// Apply to all edges.
each(anchor.all_edges(), function(edge){ _unfold_reference(edge); });
each(incoming_graph.all_edges(), function(edge){
// For all individuals, apply its subgraph back to the main graph
// and reset.
each(anchor.all_nodes(), function(node){
// Get references (ev).
var ref_graphs = edge.referenced_subgraphs();
// Get the subgraph.
var sub = node.subgraph();
// Restore to graph.
each(ref_graphs, function(sub){
_unfold_subgraph(sub);
});
// If extant, walk it and apply all parts to outer graph.
if( sub ){
each(sub.all_nodes(), function(node){
anchor.add_node(node);
});
each(sub.all_edges(), function(edge){
anchor.add_edge(edge);
});
}
// Remove references.
edge.referenced_subgraphs([]);
// Destroy the reference.
sub = node.subgraph(null);
// Now that they've been removed, try and recur (to help
// prevent loops).
each(ref_graphs, function(sub){
anchor.unfold(sub);
});
});

@@ -1735,0 +1761,0 @@

{
"name": "bbop-graph-noctua",
"version": "0.0.20",
"version": "0.0.21",
"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.",

@@ -689,3 +689,3 @@ ////

var c = g.clone()
var c = g.clone();

@@ -700,2 +700,29 @@ //

describe("folding and unfolding of second-order evidence", function(){
it('model is folded & unfold, all individuals should be there', function(){
var raw_resp = require('./minerva-04.json');
var g = new model.graph();
g.load_data_basic(raw_resp['data']);
// Make sure we're starting at a sane point...
assert.equal(g.all_nodes().length, 8, "all nodes accounted for");
assert.equal(g.all_edges().length, 3, "all edges accounted for");
// ...and that fold compacts most out of existance.
var rellist = ['RO:0002333', 'BFO:0000066'];
g.fold_go_noctua(rellist);
assert.equal(g.all_nodes().length, 2, "less nodes in full fold");
assert.equal(g.all_edges().length, 1, "less edges in full fold");
// Now try and unfold.
g.unfold();
assert.equal(g.all_nodes().length, 8, "all nodes returned");
assert.equal(g.all_edges().length, 3, "all edges returned");
});
});
// var assert = require('chai').assert;

@@ -702,0 +729,0 @@ // var model = new require('..');

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc