This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""Grakn python client.""" | |
from typing import Dict, Any | |
import requests | |
_HEADERS: Dict[str, str] = {'Accept': 'application/graql+json'} | |
_QUERY_ENDPOINT: str = '/kb/{}/graql' | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
match | |
$triggering_relationship (triggering: $triggering, triggered: $triggered) isa triggering-relationship; | |
$triggering has name "B. fragilis"; | |
$triggered has name "spermine oxidase"; | |
get | |
$triggering_relationship; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
triggering-cascade sub rule | |
when { | |
$rel (triggering: $triggering, triggered: $triggered) isa triggering-relationship; | |
$rel2 (triggering: $triggered, triggered: $triggered2) isa triggering-relationship; | |
} | |
then { | |
(triggering: $triggering, triggered: $triggered2) isa triggering-relationship; | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
match | |
$triggering_relationship (triggering: $triggering, triggered: $triggered) isa triggering-relationship; | |
$triggering has name "B. fragilis" has valence "UP"; | |
get | |
$triggering_relationship; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
match | |
$triggering_relationship (triggering: $triggering, triggered: $triggered) isa triggering-relationship; | |
$triggered has name "reactive oxygen species" has valence "UP"; | |
get | |
$triggering_relationship; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
match | |
$triggering_relationship (triggering: $triggering, triggered: $triggered) isa triggering-relationship; | |
$triggering has name "B. fragilis" has valence "UP"; | |
$triggered has name "cancer" has valence "UP"; | |
get | |
$triggering_relationship; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"sent_i": 3, | |
"start_idx": 273, | |
"text": "Overstimulation of mTOR by its ligands, amino acids, sugars, and/or growth factors leads to physiological disorders, including cancer and neurodegenerative diseases", | |
"tokens": [ | |
{ | |
"dep_": "nsubj", | |
"dep_i": 12, | |
"i": 0, | |
"idx": 0, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
//---------// | |
// Imports // | |
//---------// | |
const Koa = require('koa') | |
, sqliteToRest = require('sqlite-to-rest') | |
, cors = require('@koa/cors'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from itertools import groupby | |
def groupby_(obj, key=None, to_lists=True): | |
sorted_ = sorted(obj, key=key) | |
grouped = groupby(sorted_, key) | |
if to_lists: | |
grouped = {k: list(g) for k, g in grouped} | |
return grouped | |
unique_theme_key = lambda mapping: (mapping['theme']['name']), mapping['theme']['group']) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import gzip | |
import jsonlines # pip install jsonlines | |
def load_jsonlines(path): | |
is_gzip = path[-2:] == 'gz' | |
if is_gzip: | |
with gzip.open(path, 'rb') as f: | |
reader = jsonlines.Reader(f) | |
for obj in reader: | |
yield obj |
OlderNewer