New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.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.11 to 0.0.12

98

lib/edit.js

@@ -980,4 +980,5 @@ /**

* Merge another graph (addition) into the current graph. Includes the
* copying of annotations for the graph.
* Graph ID is /not/ copied.
* copying of annotations for the graph. This is an /additive/
* operation (e.g. annotations and other non-unique entities
* accumulate). Graph ID is /not/ copied.
*

@@ -1017,2 +1018,91 @@ * @param {graph} in_graph - the graph to merge in

/**
* This uses a subgraph to update the contents of the current
* graph. The update graph is considered to be an updated complete
* self-contained subsection of the graph, clobbering nodes, edges,
* and the graph annotations. In the case of edges, all edges for the
* incoming nodes are deleted, and the ones described in the incoming
* graph are added (again, update).
*
* For example: you can think of it like this: if we have a graph:
* A, B, C, and A.1, where A, B, and C are nodes and A.1 is an annotation for A.
* And we have an argument subgraph:
* A, B, and edge (A,B), and A.2, B.1.
* The final graph would be:
* A, B, C and edge (A,B), and A.2, B.1.
*
* Essentially, any entity in the new graph clobbers the "old"
* version; nodes not mentioned are left alone, the subgraph edges are
* assumed to be complete with reference to the contained nodes. This
* can express removal of things like annotations and sometimes edges,
* but not of nodes and edges not contained in within the subgraph.
*
* See the unit tests for examples.
*
* Be careful of what happens when using with the various loaders as
* the contents of top-level entities can be very different--you
* probably want to apply the right loader first.
*
* @param {graph} in_graph - the graph to update with
* @returns {Boolean} if graph was loaded
*/
noctua_graph.prototype.update_with = function(update_graph){
var anchor = this;
// Prefer the new graph annotations by nuking the old.
anchor._annotations = [];
var update_graph_anns = update_graph.annotations();
each(update_graph_anns, function(ann){
anchor.add_annotation(ann.clone());
});
// Next, look at individuals/nodes for addition or updating.
var updatable_nodes = {};
each(update_graph.all_nodes(), function(ind){
// Update node by clobbering. This is preferred since deleting
// it would mean that all the connections would have to be
// reconstructed as well.
var update_node = anchor.get_node(ind.id());
if( update_node ){
//console.log('update node: ' + ind.id());
}else{
//console.log('add new node' + ind.id());
}
// Mark as a modified node.
updatable_nodes[ind.id()] = true;
// Add new node to edit core.
anchor.add_node(ind.clone());
});
// Now look at edges (by individual) for purging and
// reinstating--no going to try and update edges, just clobber.
each(update_graph.all_nodes(), function(source_node){
//console.log('looking at node: ' + source_node.id());
// Look up what edges it has in /core/, as they will be the
// ones to update.
var snid = source_node.id();
var src_edges = anchor.get_edges_by_subject(snid);
// Delete all edges for said node in model. We cannot
// (apparently?) go from connection ID to connection easily,
// so removing from UI is a separate step.
each(src_edges, function(src_edge){
// Remove from model.
var removed_p = anchor.remove_edge_by_id(src_edge.id());
//console.log('remove edge (' + removed_p + '): ' + src_edge.id());
});
});
// All edges should have IDs, so get them out of the graph if they
// are incoming.
each(update_graph.all_edges(), function(edge){
var in_id = edge.id();
anchor.remove_edge_by_id(in_id);
anchor.add_edge(edge.clone());
});
return true;
};
/**
* Load minerva data response.

@@ -1109,4 +1199,4 @@ *

console.log('singletons');
console.log(us.keys(singletons).length);
//console.log('singletons');
//console.log(us.keys(singletons).length);

@@ -1113,0 +1203,0 @@ // Add the evidence singletons into the structure by

2

package.json
{
"name": "bbop-graph-noctua",
"version": "0.0.11",
"version": "0.0.12",
"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.",

@@ -323,2 +323,46 @@ ////

describe("clobbering updating", function(){
it('updating with a subgraph is not the same as a merge', function(){
// Setup.
var g = new model.graph();
var raw_resp = require('./minerva-01.json');
g.load_data_go_noctua(raw_resp['data']);
// Make a new graph to operate on.
var update_g = new model.graph();
// Graph annotations.
var an1 = new model.annotation({"key": "title", "value": "meow"});
update_g.add_annotation(an1);
// Graph parts.
var un1 = new model.node('gomodel:taxon_559292-5525a0fc0000001-GO-0005515-5525a0fc0000023');
var un2 = new model.node('gomodel_taxon_559292-5525a0fc0000001-GO-1990334-553ff9ed0000011');
var un3 = new model.node('blahblah');
var ue1 = new model.edge(un1.id(), un2.id(), 'RO:1234567');
update_g.add_node(un1);
update_g.add_node(un2);
update_g.add_node(un3);
update_g.add_edge(ue1);
// Double check.
assert.equal(update_g.all_nodes().length, 3, 'subgraph has 3 nodes');
assert.equal(update_g.all_edges().length, 1, 'subgraph has 1 edge');
assert.equal(update_g.annotations().length, 1, 'subgraph has 1 ann');
// Update our graph with new graph.
g.update_with(update_g);
// Graph annotations clobbered to one.
assert.equal(g.annotations().length, 1, 'updated graph has 1 ann');
assert.equal(g.annotations()[0].key(), 'title', 'has title');
assert.equal(g.annotations()[0].value(), 'meow', 'title "meow"');
// We have one new node and same edges.
assert.equal(g.all_nodes().length, 8, 'updated graph has eight nodes');
assert.equal(g.all_edges().length, 4, 'updated graph has seven edges');
});
});
// var assert = require('chai').assert;

@@ -325,0 +369,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