Commit ec88ed32 authored by jdhayhurst's avatar jdhayhurst

adding links options

parent eec5332a
Pipeline #59396 passed with stages
in 5 minutes and 17 seconds
......@@ -38,7 +38,7 @@ def associations():
datasets, index_marker, paginate = searcher.search(start=start, size=size, pval_interval=pval_interval, quant_method=quant_method,
tissue=tissue, gene=gene, study=study, trait=trait, paginate=paginate, qtl_group=qtl_group, snp=snp)
data_dict = apiu._get_array_to_display(datasets=datasets, paginate=paginate, links=links)
data_dict = apiu._get_array_to_display(datasets=datasets, links=links)
params = dict(p_lower=p_lower, p_upper=p_upper, quant_method=quant_method, tissue=tissue, gene_id=gene, study=study, molecular_trait_id=trait, qtl_group=qtl_group, variant_id=snp, links=links)
response = apiu._create_response(method_name='api.get_assocs', start=start, size=size, index_marker=index_marker,
data_dict=data_dict, params=params)
......@@ -96,7 +96,7 @@ def trait_associations(trait):
datasets, index_marker, paginate = searcher.search(trait=trait, start=start, size=size, pval_interval=pval_interval, quant_method=quant_method,
tissue=tissue, gene=gene, study=study, snp=snp, paginate=paginate, qtl_group=qtl_group)
data_dict = apiu._get_array_to_display(datasets=datasets, paginate=paginate, links=links)
data_dict = apiu._get_array_to_display(datasets=datasets, links=links)
params = dict(molecular_trait_id=trait, p_lower=p_lower, p_upper=p_upper, quant_method=quant_method, tissue=tissue, gene_id=gene, study=study, variant_id=snp, qtl_group=qtl_group, links=links)
response = apiu._create_response(method_name='api.get_trait_assocs', start=start, size=size,
index_marker=index_marker,
......@@ -211,7 +211,7 @@ def tissue_associations(tissue):
datasets, index_marker, paginate = searcher.search(tissue=tissue, start=start, size=size, pval_interval=pval_interval, quant_method=quant_method,
gene=gene, study=study, trait=trait, snp=snp, paginate=paginate, qtl_group=qtl_group)
data_dict = apiu._get_array_to_display(datasets=datasets, paginate=paginate, links=links)
data_dict = apiu._get_array_to_display(datasets=datasets, links=links)
#params = dict(trait=trait, study=study, p_lower=p_lower, p_upper=p_upper)
params = dict(p_lower=p_lower, p_upper=p_upper, tissue=tissue, quant_method=quant_method, gene_id=gene, study=study, molecular_phenotypes=trait, variant_id=snp, qtl_group=qtl_group, links=links)
response = apiu._create_response(method_name='api.get_tissue_assocs', start=start, size=size,
......@@ -257,14 +257,14 @@ def tissue_study_associations(study, tissue=None):
start=start, size=size, pval_interval=pval_interval,
quant_method=quant_method, paginate=paginate, qtl_group=qtl_group)
data_dict = apiu._get_array_to_display(datasets=datasets, paginate=paginate, links=links)
data_dict = apiu._get_array_to_display(datasets=datasets, links=links)
params = dict(tissue=tissue, molecular_trait_id=trait, study=study, p_lower=p_lower, p_upper=p_upper, gene_id=gene, quant_method=quant_method, qtl_group=qtl_group, links=links)
else:
datasets, index_marker, paginate = searcher.search(study=study, gene=gene, trait=trait, start=start, size=size,
pval_interval=pval_interval, quant_method=quant_method, paginate=paginate, qtl_group=qtl_group)
data_dict = apiu._get_array_to_display(datasets=datasets, paginate=paginate, links=links)
data_dict = apiu._get_array_to_display(datasets=datasets, links=links)
params = dict(study=study, p_lower=p_lower, p_upper=p_upper, gene_id=gene, molecular_trait_id=trait, quant_method=quant_method, qtl_group=qtl_group, links=links)
......@@ -323,7 +323,7 @@ def chromosome_associations(chromosome):
pval_interval=pval_interval, bp_interval=bp_interval,
quant_method=quant_method, tissue=tissue, gene=gene,
trait=trait, paginate=paginate, qtl_group=qtl_group)
data_dict = apiu._get_array_to_display(datasets=datasets, chromosome=chromosome, paginate=paginate, links=links)
data_dict = apiu._get_array_to_display(datasets=datasets, chromosome=chromosome, links=links)
return _create_chromosome_response(dict(chromosome=chromosome, data_dict=data_dict, start=start, size=size,
index_marker=index_marker, bp_lower=bp_lower, bp_upper=bp_upper,
p_lower=p_lower, p_upper=p_upper, study=study, quant_method=quant_method,
......@@ -359,7 +359,7 @@ def variants(variant, chromosome=None):
pval_interval=pval_interval, study=study, quant_method=quant_method,
tissue=tissue, gene=gene, trait=trait, paginate=paginate, qtl_group=qtl_group)
data_dict = apiu._get_array_to_display(datasets=datasets, variant=variant, paginate=paginate, links=links)
data_dict = apiu._get_array_to_display(datasets=datasets, variant=variant, links=links)
params = {'variant_id': variant, 'p_lower': p_lower, 'p_upper': p_upper, 'study': study, 'quant_method': quant_method, 'tissue': tissue, 'gene_id': gene, 'molecular_trait_id': trait, 'qtl_group': qtl_group, 'links': links}
if chromosome is None:
method_name = 'api.get_variant'
......@@ -391,7 +391,7 @@ def variant_resource(variant, chromosome=None):
datasets, index_marker, paginate = searcher.search(snp=variant, chromosome=chromosome, start=start, size=size,
pval_interval=pval_interval, study=study, quant_method=quant_method,
tissue=tissue, gene=gene, trait=trait, paginate=paginate, qtl_group=qtl_group)
data_dict = apiu._get_array_to_display(datasets=datasets, variant=variant, paginate=paginate, links=links)
data_dict = apiu._get_array_to_display(datasets=datasets, variant=variant, links=links)
params = {'variant_id': variant, 'study': study, 'quant_method': quant_method, 'tissue': tissue, 'gene_id': gene, 'molecular_trait_id': trait, 'qtl_group': qtl_group, 'links': links}
if chromosome is not None:
......@@ -475,7 +475,7 @@ def gene_associations(gene):
datasets, index_marker, paginate = searcher.search(gene=gene, start=start, size=size, pval_interval=pval_interval,
quant_method=quant_method, tissue=tissue, study=study, trait=trait, paginate=paginate, qtl_group=qtl_group)
data_dict = apiu._get_array_to_display(datasets=datasets, paginate=paginate, links=links)
data_dict = apiu._get_array_to_display(datasets=datasets, links=links)
params = dict(gene_id=gene, p_lower=p_lower, p_upper=p_upper, quant_method=quant_method, tissue=tissue, study=study, molecular_trait_id=trait, qtl_group=qtl_group, links=links)
response = apiu._create_response(method_name='api.get_gene_assocs', start=start, size=size,
index_marker=index_marker,
......
......@@ -135,7 +135,7 @@ def _add_gwas_catalog_href(info_array, study_accession):
return info_array
def _get_array_to_display(datasets, variant=None, chromosome=None, paginate=True, links=False):
def _get_array_to_display(datasets, variant=None, chromosome=None, links=False):
if datasets is None: return {}
if len(datasets[REFERENCE_DSET]) <= 0: return {}
......@@ -174,7 +174,7 @@ def _get_array_to_display(datasets, variant=None, chromosome=None, paginate=True
element_info['gene_id'] = gene
element_info['tissue'] = tissue
if paginate or links:
if links:
element_info['_links'] = {'self': _create_href(method_name='api.get_chromosome_variants',
params={'variant_id': specific_variant, 'study_accession': datasets[STUDY_DSET][index],
'chromosome': specific_chromosome})}
......@@ -324,6 +324,7 @@ def _get_basic_arguments(args):
paginate = argu.str2bool(_retrieve_endpoint_arguments(args, "paginate", True))
links = argu.str2bool(_retrieve_endpoint_arguments(args, "links", False))
qtl_group = _retrieve_endpoint_arguments(args, "qtl_group", None)
links = False if not paginate else links # links must not be made if unpaginated for performance sake.
return start, size, p_lower, p_upper, pval_interval, quant_method, snp, tissue, gene, study, trait, paginate, links, qtl_group
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment