npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

gql

v1.1.2

Published

Query language for interpreting genome SNPs

Downloads

17,621

Readme

Build Status

NPM version

Information

Compatibility

This query language is for use with the genomejs JSON format. See the dna2json repository for more information.

Just a reminder: deletions are represented as -!

Usage

This example will create a query that determines if a person is sickle cell effected.

var gql = require('gql');
var dna = require('./genome.json');

var query = gql.or([
  gql.exact('rs334', 'TT'),
  gql.exact('i3003137', 'AA')
]);

var isMatch = query(dna);
console.log(isMatch); // true or false

API

All of these APIs return a boolean-returning function that acts as the truth test. These functions take in one argument, a DNA-JSON object. You can nest as deep as you want, or be as basic as you want.

For example, checking if a person is immune to norovirus is pretty simple:

var dna = require('./my-dna.json');

var query = gql.exact('rs601338', 'AA');
var isImmune = query(dna);

Conditions

exact(id, genotype)

Evaluates to true if this was the only allele observed.

q.exact('rs2032651', 'D'); // will only match genotype D
q.exact('rs2032651', 'AT'); // will only match genotype AT

has(id, genotype)

Evaluates to true if the allele was observed at all.

q.has('rs2032651', 'A'); // will match GA, GAT, AB, etc.

exists(id)

Evaluates to true if any allele has been observed.

q.exists('rs2032651');

doesntExist(id)

Evaluates to true if no allele has been observed.

q.doesntExist('rs2032651');

not(condition)

Inverts the result of another condition.

// evaluates to true if rs2032651 != AA
var query = q.not(q.exact('rs2032651', 'AA'));

query({
  rs2032651: {
    genotype: 'TT'
  }
}); // true

query({
  rs2032651: {
    genotype: 'AA'
  }
}); // false

only(id, allele)

Evaluates to true if only the allele was observed at the specified position.

q.only('rs2032651', 'A'); // will match A, AA, AAA, etc.

Aggregate Conditions

or(conditions...)

Evaluates to true if any of the given condition functions evaluate to true.

q.or([
  q.has('rs2032651', 'A'),
  q.doesntExist('rs2032651')
]);

and(conditions...)

Evaluates to true if all of the given condition functions evaluate to true.

q.and([
  q.exists('rs2032652'),
  q.has('rs2032651', 'A')
]);

atLeast(number, conditions...)

Evaluates to true if the number of given condition functions evaluating to true is equal to or greater than the given number.

q.atLeast(2, [
  q.exists('rs2032652'),
  q.has('rs2032651', 'A'),
  q.exact('rs2032653', 'AT'),
  q.exact('rs2032654', 'GG')
]);

none(conditions...)

Evaluates to true if all of the given condition functions evaluate to false.

q.none([
  q.has('rs2032651', 'A'),
  q.doesntExist('rs2032651')
]);

LICENSE

(MIT License)

Copyright (c) 2013 Fractal [email protected]

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.