Giter Club home page Giter Club logo

Comments (5)

pvjones avatar pvjones commented on July 27, 2024

Hi, I think I may have figured out what was wrong with my isSickleCellAffected.js file. I need to instead create the query method there, constructed of gql methods, and then export it, like this:

const gql = require('gql');

module.exports = function() {
let query = gql.or([
gql.exact('rs334', 'TT'),
gql.exact('i3003137', 'AA')
]);
return query;
};

However, after doing this I instead get a TypeError saying query.stream() is not a function.

from gql.

yocontra avatar yocontra commented on July 27, 2024

@pvjones Not sure what version you're using, but all of the streaming stuff got removed a long time ago - you should check out the new API docs. It's more performant to load the SNP-JSON ahead of time as an object than to stream it through, so the format of the JSON and querying was changed.

So you would basically do this:

main.js:

const dna = require('./some-genome.json')
const query = require('./isSickleCellAffected')

const matches = query(dna) // true or false

isSickleCellAffected.js:

const gql = require('gql')

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

GQL is a light querying language that basically just does object checks. If you have any advanced logic (percentages, etc.) you can check the object yourself.

You could rewrite the same thing as:

dna.rs334 === 'TT' || dna.i3003137 === 'AA'

from gql.

pvjones avatar pvjones commented on July 27, 2024

Hey, I can't thank you enough for the help! This works like a charm now.
Next I'm going to work on a percentage-based query. If I can get this figured out, I'd like to make a bunch of these genoset files. I may (with the help of a colleague) attempt to scrape SNPedia and automate the creation of many more. If this ends up working out, would I be able to submit these for the community somewhere?

Thanks again!

from gql.

yocontra avatar yocontra commented on July 27, 2024

@pvjones Yep! You can publish them on NPM as genoset-* and tag them like so (most important is the genoset ID and genoset)

Here's the full boilerplate for a genoset module: https://github.com/genomejs/genoset-boilerplate - I'll make sure it's up to date with the latest additions now.

I'd love to get all of SNPedia published as modules that can be iterated on and used in cool projects.

from gql.

yocontra avatar yocontra commented on July 27, 2024

Actually no need for the boilerplate repo (deleted it), you can use this as a reference if needed: https://github.com/genomejs/genoset-norovirus

from gql.

Related Issues (8)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.