Comments (3)
Naive early morning attempt but here are a few possible APIs, slowly getting sugarier
var test = gql.percentage([
{test: gql.exact('rs6625163', 'AA'), magnitude: 1.2},
{test: gql.exact('rs1160312', 'AA'), magnitude: 2},
{test: gql.exact('rs1160312', 'AG'), magnitude: 2},
{test: gql.exact('rs201571', 'TT'), magnitude: 2},
{test: gql.exact('rs6036025', 'GG'), magnitude: 1.2}
]);
test(someDNA); // 85
// gql.magnitude would have to error when being used outside of a percentage
// also kind of breaks the whole "everything is a function" thing
// also magnitude should probably be the second arg here but i was too lazy to change the code
var test = gql.percentage([
gql.magnify(1.2, gql.exact('rs6625163', 'AA')),
gql.magnify(2, gql.exact('rs1160312', 'AA')),
gql.magnify(2, gql.exact('rs1160312', 'AG')),
gql.magnify(2, gql.exact('rs201571', 'TT')),
gql.magnify(1.2, gql.exact('rs6036025', 'GG'))
]);
test(someDNA); // 85
// every gql test function would have a magnitude fn that returns a clone of the fn with a new _magnitude property that percentage knows about
// this would allow stuff like gql.percentage([isMale.magnitude(2)])
// but it also limits usage of vanilla functions without wrapping them or adding the _magnitude manually
var test = gql.percentage([
gql.exact('rs6625163', 'AA').magnitude(1.2),
gql.exact('rs1160312', 'AA').magnitude(2),
gql.exact('rs1160312', 'AG').magnitude(2),
gql.exact('rs201571', 'TT').magnitude(2),
gql.exact('rs6036025', 'GG').magnitude(1.2)
]);
test(someDNA); // 85
We should think about how this plays into being a part of other queries. If (for example) the isMale module is not a boolean and instead returns a percentage a module that depends on it could do what amounts to gql.and([ifPercentage(isMale, 85), otherStuff...])
but at that point it might be easier/cleaner to just write it out and not have an API for that case
gql.and([
function(dna){
return isMale(dna) >= 85;
},
otherStuff...
]);
from gql.
API-wise my preference is option 3 (although it could be a bit hairy to implement), then 2.
As a side note, Iād prefer to return actual percentages, e.g. 0.85
over 85
.
from gql.
With the new update this should be fixed - you can calculate this however you want now, the dna is just an object.
from gql.
Related Issues (8)
- Publish 0.3.0 to npm HOT 8
- Beginner-level issue implementing gql HOT 5
- naming conventions HOT 2
- Testing for deletions HOT 16
- Offer .json format export. HOT 6
- Meaning of `-` in gs syntax HOT 15
- Can this be used to look for genes? HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
š Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ā¤ļø Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gql.