New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

class-expression

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

class-expression - npm Package Compare versions

Comparing version 0.0.2 to 0.0.3

108

lib/class_expression.js

@@ -192,3 +192,3 @@ /**

class_expression.prototype.svf_class_expression = function(){
var ret = null
var ret = null;
if( this.type() == 'svf' ){

@@ -201,2 +201,15 @@ ret = this._frame[0];

/**
* The class expression when we are dealing with a ComplementOf.
*
* @returns {String|null} type or null
*/
class_expression.prototype.complement_class_expression = function(){
var ret = null;
if( this.type() == 'complement' ){
ret = this._frame[0];
}
return ret;
};
/**
* If the type has a recursive frame, a list of the types it contains.

@@ -273,2 +286,4 @@ *

rettype = 'svf';
}else if( t == 'complement' ){
rettype = 'complement';
}else{

@@ -323,2 +338,13 @@ // No idea...

this._frame = [new class_expression(f_type)];
}else if( t == 'complement' ){ // ComplementOf
// We're then dealing with a ComplementOf. Not too bad.
this._type = t;
this._category = t;
// Okay, let's recur down the class expression. It should just
// be one, but we'll just reuse the frame. Access should be
// though complement_class_expression().
var o_type = in_type['operand'];
this._frame = [new class_expression(o_type)];
}else{

@@ -353,8 +379,7 @@ // Should not be possible, so let's stop it here.

*
* @params {String} property_id - string
* @params {String|class_expression} class_expr - ID string (e.g. GO:0022008) or <class_expression>
* @params {String} property_id - string
* @returns {this} self
*/
class_expression.prototype.as_svf = function(
class_expr, property_id){
class_expression.prototype.as_svf = function(property_id, class_expr){

@@ -379,2 +404,24 @@ // Cheap our way into this--can be almost anything.

/**
* Convert a null class_expression into an arbitrary complement.
*
* @params {String|class_expression} class_expr - ID string (e.g. GO:0022008) or <class_expression>
* @returns {this} self
*/
class_expression.prototype.as_complement = function(class_expr){
// Cheap our way into this--can be almost anything.
var cxpr = new class_expression(class_expr);
// Our list of values must be defined if we go this way.
var expression = {
'type': 'complement',
'operand': cxpr.structure()
};
this.parse(expression);
return this;
};
/**

@@ -449,2 +496,11 @@ * Convert a null class_expression into a set of class expressions.

}else if( t == 'complement' ){ // ComplementOf
expression['type'] = 'complement';
// Recur for someValuesFrom class expression.
var cce = anchor.complement_class_expression();
var ct = cce.type();
expression['operand'] = cce.structure();
}else if( t == 'union' || t == 'intersection' ){ // compositions

@@ -474,2 +530,9 @@

/**
* "Static" function that creates an intersection from a list of
* whatever.
*
* @param {Array} list - list of conformant whatever
* @returns {class_expression} object
*/
class_expression.intersection = function(list){

@@ -481,2 +544,8 @@ var ce = new class_expression();

/**
* "Static" function that creates a union from a list of whatever.
*
* @param {Array} list - list of conformant whatever
* @returns {class_expression} object
*/
class_expression.union = function(list){

@@ -488,8 +557,35 @@ var ce = new class_expression();

class_expression.svf = function(cls_expr, prop_id){
/**
* "Static" function that creates a SomeValueFrom from a property ID
* and a class_expression (or string or whatever).
*
* @param {String} prop_id - ID
* @param {class_expression|String} cls_expr - thing
* @returns {class_expression} object
*/
class_expression.svf = function(prop_id, cls_expr){
var ce = new class_expression();
ce.as_svf(cls_expr, prop_id);
ce.as_svf(prop_id, cls_expr);
return ce;
};
/**
* "Static" function that creates the complement of a given class
* expression.
*
* @param {class_expression|String} cls_expr - thing
* @returns {class_expression} object
*/
class_expression.complement = function(cls_expr){
var ce = new class_expression();
ce.as_complement(cls_expr);
return ce;
};
/**
* "Static" function that creates a class_expression from a class ID.
*
* @param {String} id - string id
* @returns {class_expression} object
*/
class_expression.cls = function(id){

@@ -496,0 +592,0 @@ var ce = new class_expression();

120

package.json
{
"name": "class-expression",
"version": "0.0.2",
"license": "BSD-3-Clause",
"description": "A handling library for OWL-style class expressions in JavaScript.",
"keywords": [
"node",
"npm",
"client",
"server",
"Gene Ontology",
"GO",
"OWL",
"class",
"expression",
"bbop",
"Berkeley BOP",
"math",
"mathematics",
"graph"
],
"author": "SJC <sjcarbon@lbl.gov> (http://berkeleybop.org/)",
"homepage": "http://berkeleybop.org/",
"repository": {
"type": "git",
"url": "git+https://github.com/berkeleybop/class-expression.git"
},
"engines": {
"node": ">= 0.12.2",
"npm": ">= 2.7.4"
},
"dependencies": {
"bbop-core": "0.0.4",
"underscore": "1.8.3"
},
"devDependencies": {
"chai": "^2.3.0",
"del": "^1.1.1",
"gulp": "^3.8.11",
"gulp-bump": "^0.3.0",
"gulp-git": "^1.2.3",
"gulp-jsdoc": "^0.1.4",
"gulp-mocha": "^2.0.1",
"gulp-pandoc": "^0.2.1",
"gulp-rename": "^1.2.2",
"gulp-uglify": "^1.2.0"
},
"bundleDependencies": [],
"private": false,
"directories": {
"doc": "doc",
"test": "tests"
},
"main": "lib/class_expression.js",
"bugs": {
"url": "https://github.com/berkeleybop/class-expression/issues"
},
"scripts": {
"update-docs": "git checkout gh-pages && git pull && git merge master && gulp doc && git commit -a -m 'bump docs' && git push && git checkout master",
"test": "gulp test"
}
"name": "class-expression",
"version": "0.0.3",
"license": "BSD-3-Clause",
"description": "A handling library for OWL-style class expressions in JavaScript.",
"keywords": [
"node",
"npm",
"client",
"server",
"Gene Ontology",
"GO",
"OWL",
"class",
"expression",
"bbop",
"Berkeley BOP",
"math",
"mathematics",
"graph"
],
"author": "SJC <sjcarbon@lbl.gov> (http://berkeleybop.org/)",
"homepage": "http://berkeleybop.org/",
"repository": {
"type": "git",
"url": "git+https://github.com/berkeleybop/class-expression.git"
},
"engines": {
"node": ">= 0.12.2",
"npm": ">= 2.7.4"
},
"dependencies": {
"bbop-core": "0.0.4",
"underscore": "1.8.3"
},
"devDependencies": {
"chai": "^2.3.0",
"del": "^1.1.1",
"gulp": "^3.8.11",
"gulp-bump": "^0.3.0",
"gulp-git": "^1.2.3",
"gulp-jsdoc": "^0.1.4",
"gulp-mocha": "^2.0.1",
"gulp-pandoc": "^0.2.1",
"gulp-rename": "^1.2.2",
"gulp-uglify": "^1.2.0"
},
"bundleDependencies": [],
"private": false,
"directories": {
"doc": "doc",
"test": "tests"
},
"main": "lib/class_expression.js",
"bugs": {
"url": "https://github.com/berkeleybop/class-expression/issues"
},
"scripts": {
"update-docs": "git checkout gh-pages && git pull && git merge master && gulp doc && git commit -a -m 'bump docs' && git push && git checkout master",
"test": "gulp test"
}
}

@@ -95,3 +95,3 @@ ////

var ce = new class_expression(null, true);
ce.as_svf('GO:123', 'RO:456');
ce.as_svf('RO:456', 'GO:123');

@@ -174,3 +174,3 @@ assert.isTrue(ce.id().length == 36,

var ce = new class_expression();
ce.as_svf(int_ce, 'RO:123');
ce.as_svf('RO:123', int_ce);

@@ -220,2 +220,49 @@ assert.isTrue(ce.id().length == 36,

describe('free peanuts', function(){
it("they're complementary", function(){
var int_ce = new class_expression();
int_ce.as_set('intersection', ['GO:123', 'GO:456']);
var ce = new class_expression();
ce.as_complement(int_ce);
assert.isTrue(ce.id().length == 36,
'[complement(int)] id is like 8ccbf846-d7e8-4d86-9e5c-0b48827d178d');
assert.isTrue(ce.nested_p(), '[complement(int)] sets always a little nested');
assert.isFalse(ce.inferred_p(), '[complement(int)] is not inferred');
assert.equal(ce.category(), 'complement', '[complement(int)] graphically itself');
assert.equal(ce.type(), 'complement', '[complment(int)] instance is type of complement');
assert.isNull(ce.class_id(), '[complement(int)] has null ID--nested');
assert.isNull(ce.class_label(), '[complement(int)] has null label--nested');
assert.equal(ce.complement_class_expression().type(), 'intersection',
'[complement(int)] has complement ce');
assert.deepEqual(
ce.structure(),
{
"type": "complement",
"operand": {
'type': 'intersection',
"expressions": [
{
"type": "class",
"id": "GO:123"
},
{
"type": "class",
"id": "GO:456"
}
]
}
},
'[complement(int)] correct nested structure');
});
});
// // Toy REPL.

@@ -222,0 +269,0 @@ // (function(){

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