Comparing version 1.0.0 to 1.1.0
21
index.js
@@ -11,5 +11,5 @@ var roughMatch = require('./lib/genotypeMatch'); | ||
// higher-level, operates on nested conditions | ||
all: function(conditions){ | ||
and: function(conditions){ | ||
if (!Array.isArray(conditions) || conditions.length === 0) { | ||
throw new Error('all must receive an array with conditions'); | ||
throw new Error('and must receive an array with conditions'); | ||
} | ||
@@ -32,2 +32,19 @@ return function(data){ | ||
}, | ||
only: function(k, v){ | ||
if (typeof v !== 'string') { | ||
throw new Error('only can only check for strings'); | ||
} | ||
if (v.length !== 1) { | ||
throw new Error('only accepts only one allele') | ||
} | ||
return function(data){ | ||
var snp = data[k]; | ||
if (!(snp && snp.genotype)) { | ||
return false; | ||
} | ||
return snp.genotype.split('').every(function(allele) { | ||
return allele === v; | ||
}); | ||
}; | ||
}, | ||
or: function(conditions){ | ||
@@ -34,0 +51,0 @@ if (!Array.isArray(conditions) || conditions.length === 0) { |
{ | ||
"name": "gql", | ||
"description": "Query language for interpreting genome SNPs", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"homepage": "http://github.com/genomejs/gql", | ||
@@ -6,0 +6,0 @@ "repository": "git://github.com/genomejs/gql.git", |
@@ -97,5 +97,5 @@ [![Build Status](https://travis-ci.org/genomejs/gql.png?branch=master)](https://travis-ci.org/genomejs/gql) | ||
// evaluates to true if rs2032651 != AA | ||
q.not(q.exact('rs2032651', 'AA')); | ||
var query = q.not(q.exact('rs2032651', 'AA')); | ||
q({ | ||
query({ | ||
rs2032651: { | ||
@@ -106,3 +106,3 @@ genotype: 'TT' | ||
q({ | ||
query({ | ||
rs2032651: { | ||
@@ -114,2 +114,10 @@ genotype: 'AA' | ||
#### only(id, allele) | ||
Evaluates to true if only the allele was observed at the specified position. | ||
```javascript | ||
q.only('rs2032651', 'A'); // will match A, AA, AAA, etc. | ||
``` | ||
### Aggregate Conditions | ||
@@ -128,3 +136,3 @@ | ||
#### all(conditions...) | ||
#### and(conditions...) | ||
@@ -134,3 +142,3 @@ Evaluates to true if all of the given condition functions evaluate to true. | ||
```javascript | ||
q.all([ | ||
q.and([ | ||
q.exists('rs2032652'), | ||
@@ -137,0 +145,0 @@ q.has('rs2032651', 'A') |
Sorry, the diff of this file is not supported yet
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
20602
18
558
179
0