-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Chase Yakaboski
committed
May 8, 2021
1 parent
41323ae
commit fe4a6b2
Showing
11 changed files
with
628 additions
and
110 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
|
||
from chp_client.query import build_onehop_query | ||
import itertools | ||
import tqdm | ||
import logging | ||
import pickle | ||
import random | ||
import json | ||
from collections import defaultdict | ||
|
||
from trapi_model.constants import * | ||
from chp.trapi_interface import TrapiInterface | ||
|
||
logging.basicConfig(level=logging.INFO) | ||
logger = logging.getLogger(__name__) | ||
logger.setLevel(logging.INFO) | ||
|
||
# Set number of queries to build | ||
NUM_QUERIES = 10 | ||
|
||
TRAPI_VERSIONS = ['1.0', '1.1'] | ||
|
||
# Set seed | ||
random.seed(111) | ||
|
||
# Get client | ||
#client = get_client() | ||
|
||
# Get curies | ||
logger.info('Getting curies.') | ||
curies = TrapiInterface().get_curies() | ||
#curies = client.curies() | ||
logger.info('Got curies.') | ||
|
||
# Build all simple single gene, single drug, breast cancer, survival queries. | ||
queries = defaultdict(lambda: defaultdict(list)) | ||
disease = ['MONDO:0007254'] | ||
outcome_name = 'survival_time' | ||
outcome = 'EFO:0000714' | ||
outcome_op = '>' | ||
|
||
# Build batch gene to disease query | ||
for trapi_version in TRAPI_VERSIONS: | ||
genes = [gene for gene in random.choices(list(curies['biolink:Gene'].keys()), k=random.randint(1,4))] | ||
q = build_onehop_query( | ||
genes, | ||
[BIOLINK_GENE], | ||
disease, | ||
[BIOLINK_DISEASE], | ||
outcome=outcome, | ||
outcome_op=outcome_op, | ||
outcome_value=random.randint(500,1500), | ||
trapi_version=trapi_version, | ||
) | ||
print(q) | ||
input() | ||
queries[trapi_version]['gene_to_disease_proxy'] = q.to_dict() | ||
|
||
|
||
# Build batch drug to disease query | ||
drugs = [gene for gene in random.choices(list(curies['biolink:Drug'].keys()), k=random.randint(1,4))] | ||
q = build_onehop_query( | ||
drugs, | ||
[BIOLINK_DRUG], | ||
disease, | ||
[BIOLINK_DISEASE], | ||
outcome=outcome, | ||
outcome_op=outcome_op, | ||
outcome_value=random.randint(500,1500), | ||
trapi_version=trapi_version, | ||
) | ||
print(q) | ||
input() | ||
queries[trapi_version]['drug_to_disease_proxy'] = q.to_dict() | ||
|
||
# Build batch gene to drug query | ||
genes = [gene for gene in random.choices(list(curies['biolink:Gene'].keys()), k=random.randint(1,4))] | ||
drugs = [gene for gene in random.choices(list(curies['biolink:Drug'].keys()), k=random.randint(1,4))] | ||
q = build_onehop_query( | ||
genes, | ||
[BIOLINK_GENE], | ||
drugs, | ||
[BIOLINK_DRUG], | ||
outcome=outcome, | ||
outcome_op=outcome_op, | ||
outcome_value=random.randint(500,1500), | ||
trapi_version=trapi_version, | ||
) | ||
print(q) | ||
input() | ||
queries[trapi_version]['gene_to_drug_proxy'] = q.to_dict() | ||
|
||
|
||
# Build gene to drug query | ||
genes = [gene for gene in random.choices(list(curies['biolink:Gene'].keys()), k=random.randint(1,4))] | ||
drugs = [gene for gene in random.choices(list(curies['biolink:Drug'].keys()), k=random.randint(1,4))] | ||
q = build_onehop_query( | ||
drugs, | ||
[BIOLINK_DRUG], | ||
genes, | ||
[BIOLINK_GENE], | ||
outcome=outcome, | ||
outcome_op=outcome_op, | ||
outcome_value=random.randint(500,1500), | ||
trapi_version=trapi_version, | ||
) | ||
print(q) | ||
input() | ||
queries[trapi_version]['drug_to_gene_proxy'] = q.to_dict() | ||
|
||
# Build gene to disease with proxy and context | ||
genes = [gene for gene in random.choices(list(curies['biolink:Gene'].keys()), k=random.randint(1,4))] | ||
drugs = [gene for gene in random.choices(list(curies['biolink:Drug'].keys()), k=random.randint(1,4))] | ||
q = build_onehop_query( | ||
genes, | ||
[BIOLINK_GENE], | ||
disease, | ||
[BIOLINK_DISEASE], | ||
outcome=outcome, | ||
outcome_op=outcome_op, | ||
outcome_value=random.randint(500,1500), | ||
trapi_version=trapi_version, | ||
drugs=drugs, | ||
) | ||
print(q) | ||
input() | ||
queries[trapi_version]['gene_to_disease_proxy_context'] = q.to_dict() | ||
|
||
|
||
# Pickle the queries | ||
with open('standard_batch_onehop_queries.pk', 'wb') as f_: | ||
pickle.dump(dict(queries), f_) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
from chp_client.query import build_onehop_query | ||
import itertools | ||
import tqdm | ||
import logging | ||
import pickle | ||
import random | ||
import json | ||
from collections import defaultdict | ||
|
||
from trapi_model.constants import * | ||
from chp.trapi_interface import TrapiInterface | ||
|
||
logging.basicConfig(level=logging.INFO) | ||
logger = logging.getLogger(__name__) | ||
logger.setLevel(logging.INFO) | ||
|
||
# Set number of queries to build | ||
NUM_QUERIES = 10 | ||
|
||
TRAPI_VERSIONS = ['1.0', '1.1'] | ||
|
||
# Set seed | ||
random.seed(111) | ||
|
||
# Get client | ||
#client = get_client() | ||
|
||
# Get curies | ||
logger.info('Getting curies.') | ||
curies = TrapiInterface().get_curies() | ||
#curies = client.curies() | ||
logger.info('Got curies.') | ||
|
||
# Build all simple single gene, single drug, breast cancer, survival queries. | ||
queries = defaultdict(lambda: defaultdict(list)) | ||
disease = ['MONDO:0007254'] | ||
outcome_name = 'survival_time' | ||
outcome = 'EFO:0000714' | ||
outcome_op = '>' | ||
|
||
# Build batch gene to disease query | ||
for trapi_version in TRAPI_VERSIONS: | ||
# Build batch gene wildcard and drug wildcard to disease query | ||
drug = [random.choice(list(curies["biolink:Drug"].keys()))] | ||
gene = [random.choice(list(curies["biolink:Gene"].keys()))] | ||
q = build_onehop_query( | ||
None, | ||
[BIOLINK_GENE, BIOLINK_DRUG], | ||
disease, | ||
[BIOLINK_DISEASE], | ||
outcome=outcome, | ||
outcome_op=outcome_op, | ||
outcome_value=random.randint(500,1500), | ||
trapi_version=trapi_version, | ||
drugs=drug, | ||
genes=gene, | ||
) | ||
print(q) | ||
input() | ||
queries[trapi_version]['batchwildcard_to_disease_proxy'] = q.to_dict() | ||
|
||
# Pickle the queries | ||
with open('wildcard_batch_onehop_queries.pk', 'wb') as f_: | ||
pickle.dump(dict(queries), f_) |
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
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
Oops, something went wrong.