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.14 to 0.0.15

66

lib/edit.js

@@ -1235,3 +1235,3 @@ /**

/**
* In addition to everything we did for {load_data_evidence_fold},
* In addition to everything we did for {fold_evidence},
* we're going to search for nodes that have enabled_by and/or

@@ -1312,2 +1312,56 @@ * occurs_in (or any other specified relation) targets (that are

/**
* Essentially, undo anything that could be done in a folding
* step--return the graph to its most expanded form.
*
* @returns {Boolean} if unfolded (should always be true)
*/
noctua_graph.prototype.unfold = function(){
var anchor = this;
// For any entity, remove its referenced individuals and re-add
// them to the graph.
function _unfold_reference(item){
// Get.
var refd = item.referenced_individuals();
// Restore to graph.
each(refd, function(r){
anchor.add_node(r);
});
// Remove references.
item.referenced_individuals([]);
}
// Apply to all nodes.
each(anchor.all_nodes(), function(node){ _unfold_reference(node); });
// Apply to all edges.
each(anchor.all_edges(), function(edge){ _unfold_reference(edge); });
// For all individuals, apply its subgraph back to the main graph
// and reset.
each(anchor.all_nodes(), function(node){
// Get the subgraph.
var sub = node.subgraph();
// 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);
});
}
// Destroy the reference.
var sub = node.subgraph(null);
});
// Revisit if we want something meaningful out of here.
var retval = true;
return retval;
};
///

@@ -1561,7 +1615,13 @@ /// Node subclass and overrides.

*
* @param {graph} [subgraph] - the subgraph to "hide" inside this individual in the graph
* @param {graph|null} [subgraph] - the subgraph to "hide" inside this individual in the graph, or null to reset it
* @returns {graph|null} contained subgraph
*/
noctua_node.prototype.subgraph = function(subgraph){
if( subgraph && bbop.what_is(subgraph) == 'bbop-graph-noctua.graph'){
if( typeof(subgraph) === 'undefined' ){
// Just return current state.
}else if( subgraph == null ){
// Reset state (and return).
this._embedded_subgraph = null;
}else if(bbop.what_is(subgraph) == 'bbop-graph-noctua.graph'){
// Update state (and return).
this._embedded_subgraph = subgraph;

@@ -1568,0 +1628,0 @@ }

2

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

@@ -375,2 +375,55 @@ ////

describe("unfolding works", function(){
it('basic unfolded graph checks', function(){
// Setup.
var raw_resp = require('./minerva-01.json');
var g = new model.graph();
g.load_data_basic(raw_resp['data']);
// Double-check fold.
var rellist = ['RO:0002333', 'BFO:0000066'];
g.fold_go_noctua(rellist);
assert.equal(g.all_nodes().length, 7, 'only seven nodes left');
assert.equal(g.all_edges().length, 7, 'only seven edges left');
// Unfold and check.
g.unfold();
assert.equal(g.all_nodes().length, 22, 'return to right num nodes');
assert.equal(g.all_edges().length, 14, 'return to right num edges');
///
/// The next three examples are from various tests
/// above--copied to ensure.
///
// Deeper check.
assert.equal(g.id(),'gomodel:taxon_559292-5525a0fc0000001_all_indivdual',
'graph id');
assert.equal(g.annotations().length, 4, '4 graph annotation');
var anns = g.get_annotations_by_key('date');
assert.equal(anns.length, 1, 'one date annotation');
assert.equal(anns[0].value(), '2015-04-10', 'correct date annotation');
// More exploring.
assert.equal(g.get_singleton_nodes().length, 8, 'ev makes singletons');
assert.equal(g.get_root_nodes().length, 17, 'technically lots of roots');
assert.equal(g.get_leaf_nodes().length, 9, 'leaves are ev + 1 here');
// S'more.
var nid =
'gomodel:taxon_559292-5525a0fc0000001-GO-0005515-5525a0fc0000023';
var n = g.get_node(nid);
assert.equal(n.types().length, 1, 'one std');
assert.equal(n.inferred_types().length, 2, 'two inferred');
assert.equal(n.get_unique_inferred_types().length, 1,
'one unique inferred');
assert.equal(n.types()[0].class_id(), 'GO:0005515',
'std class id');
assert.equal(n.get_unique_inferred_types()[0].class_id(), 'GO:0098772',
'one unique inferred class id');
});
});
// var assert = require('chai').assert;

@@ -377,0 +430,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