Skip to content

Commit 8232f95

Browse files
authored
Merge pull request #403 from ImagingDataCommons/idc-prod-sp
Cart
2 parents 5ed9615 + d18743d commit 8232f95

File tree

9 files changed

+2102
-958
lines changed

9 files changed

+2102
-958
lines changed

cohorts/urls.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,12 @@
1919
from . import views
2020

2121

22-
2322
urlpatterns = [
2423
url(r'^$', views.cohorts_list, name='cohort_list'),
24+
url(r'^manifests/fetch/(?P<file_name>[A-Za-z\-0-9]+\/manifest_[0-9_]+(aws|gcs|gcp)\.s5cmd)', views.fetch_user_manifest, name='fetch_user_manifest'),
25+
url(r'^manifests/check/(?P<file_name>[A-Za-z\-0-9]+\/manifest_[0-9_]+(aws|gcs|gcp)\.s5cmd)', views.check_manifest_ready, name='check_user_manifest'),
26+
url(r'^manifests/fetch/$', views.fetch_user_manifest, name='fetch_user_manifest_base'),
27+
url(r'^manifests/check/$', views.check_manifest_ready, name='check_user_manifest_base'),
2528
url(r'^api/$', views.views_api_v1.cohort_list_api, name='cohort_list_api'),
2629
url(r'^api/v1/$', views.views_api_v1.cohort_list_api, name='cohort_list_api'),
2730
url(r'^api/v2/$', views.views_api_v2.cohort_list_api, name='cohort_list_api'),

cohorts/views/views.py

Lines changed: 31 additions & 522 deletions
Large diffs are not rendered by default.

cohorts/views/views_api_v1.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@
4747

4848
logger = logging.getLogger('main_logger')
4949

50-
USER_DATA_ON = settings.USER_DATA_ON
5150

5251
@csrf_exempt
5352
@api_auth

cohorts/views/views_api_v2.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@
4444

4545
logger = logging.getLogger('main_logger')
4646

47-
USER_DATA_ON = settings.USER_DATA_ON
4847

4948
@csrf_exempt
5049
@api_auth

google_helpers/bigquery/bq_support.py

Lines changed: 55 additions & 266 deletions
Large diffs are not rendered by default.

google_helpers/bigquery/utils.py

Lines changed: 544 additions & 0 deletions
Large diffs are not rendered by default.

idc_collections/collex_metadata_utils.py

Lines changed: 1448 additions & 141 deletions
Large diffs are not rendered by default.

metadata/query_helpers.py

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
import re
3535
#from projects.models import Program
3636
from google_helpers.bigquery.bq_support import BigQuerySupport
37+
from google_helpers.bigquery.utils import MOLECULAR_CATEGORIES
3738

3839
#from django.conf import settings
3940

@@ -49,23 +50,6 @@
4950

5051
PREFORMATTED_ATTRIBUTES = {}
5152

52-
# TODO: move this into a table, maybe metadata_attr?
53-
MOLECULAR_CATEGORIES = {
54-
'nonsilent': {
55-
'name': 'Non-silent',
56-
'attrs': [
57-
'Missense_Mutation',
58-
'Nonsense_Mutation',
59-
'Nonstop_Mutation',
60-
'Frame_Shift_Del',
61-
'Frame_Shift_Ins',
62-
'In_Frame_Del',
63-
'In_Frame_Ins',
64-
'Translation_Start_Site',
65-
]
66-
}
67-
}
68-
6953
MOLECULAR_ATTR = [
7054
{'value': 'Missense_Mutation', 'displ_name': 'Missense Mutation'},
7155
{'value': 'Frame_Shift_Del', 'displ_name': 'Frame Shift - Deletion'},

solr_helpers/__init__.py

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
from idc_collections.models import Attribute, DataSource, Attribute_Ranges, DataSetType
1111

12-
from metadata.query_helpers import MOLECULAR_CATEGORIES
12+
from google_helpers.bigquery.utils import MOLECULAR_CATEGORIES
1313

1414
logger = logging.getLogger('main_logger')
1515

@@ -112,9 +112,9 @@ def query_solr_and_format_result(query_settings, normalize_facets=True, normaliz
112112

113113
# Execute a POST request to the solr server available available at settings.SOLR_URI
114114
def query_solr(collection=None, fields=None, query_string=None, fqs=None, facets=None, sort=None, counts_only=True,
115-
collapse_on=None, offset=0, limit=1000, uniques=None, with_cursor=None, stats=None, totals=None):
116-
query_uri = "{}{}/query".format(SOLR_URI, collection)
115+
collapse_on=None, offset=0, limit=1000, uniques=None, with_cursor=None, stats=None, totals=None, op=None):
117116

117+
query_uri = "{}{}/query".format(SOLR_URI, collection)
118118
payload = {
119119
"query": query_string or "*:*",
120120
"limit": 0 if counts_only else limit,
@@ -124,6 +124,9 @@ def query_solr(collection=None, fields=None, query_string=None, fqs=None, facets
124124
}
125125
}
126126

127+
if op:
128+
payload['params']['q.op'] = op
129+
127130
if with_cursor:
128131
payload['params']['cursorMark'] = with_cursor
129132

@@ -174,7 +177,6 @@ def query_solr(collection=None, fields=None, query_string=None, fqs=None, facets
174177

175178
try:
176179
start = time.time()
177-
178180
query_response = requests.post(query_uri, data=json.dumps(payload), headers={'Content-type': 'application/json'}, auth=(SOLR_LOGIN, SOLR_PASSWORD), verify=SOLR_CERT)
179181
stop = time.time()
180182

@@ -392,7 +394,7 @@ def build_solr_facets(attrs, filter_tags=None, include_nulls=True, unique=None,
392394
# still want those records when filtering on this attribute.
393395
#
394396
def build_solr_query(filters, comb_with='AND', with_tags_for_ex=False, subq_join_field=None,
395-
search_child_records_by=None, global_value_op='OR'):
397+
search_child_records_by=None, global_value_op='OR', solr_default_op='OR'):
396398

397399
# subq_join not currently used in IDC
398400
ranged_attrs = Attribute.get_ranged_attrs()
@@ -502,7 +504,10 @@ def build_solr_query(filters, comb_with='AND', with_tags_for_ex=False, subq_join
502504

503505
# If it's looking for a single None value
504506
if len(values) == 1 and values[0] == 'None':
505-
query_str += '(-%s:{* TO *})' % attr_name
507+
if (solr_default_op == "OR"):
508+
query_str += '(-%s:{* TO *})' % attr_name
509+
else:
510+
query_str += '(*:* NOT %s:{* TO *})' % attr_name
506511
# If it's a ranged value, calculate the bins
507512
elif attr_name == 'bmi':
508513
with_none = False
@@ -544,14 +549,19 @@ def build_solr_query(filters, comb_with='AND', with_tags_for_ex=False, subq_join
544549
clause = rngTemp.format(attr_name, values[0], values[1])
545550
else:
546551
clause = "{}:{}".format(attr_name, values[0])
547-
548-
query_str += (('(-(-(%s) +(%s:{* TO *})))' % (clause, attr_name)) if with_none else "(+({}))".format(clause))
552+
if (solr_default_op=="OR"):
553+
query_str += (('(-(-(%s) +(%s:{* TO *})))' % (clause, attr_name)) if with_none else "(+({}))".format(clause))
554+
else:
555+
query_str += (('(%s OR (*:* NOT %s:{* TO *}))' % (clause, attr_name)) if with_none else "(+({}))".format(clause))
549556

550557
else:
551558
vals = "\" {} \"".format(value_op).join(values)
552559
if 'None' in values:
553560
values.remove('None')
554-
query_str += '(-(-(%s:("%s")) +(%s:{* TO *})))' % (attr_name,vals, attr_name)
561+
if (solr_default_op=="OR"):
562+
query_str += '(-(-(%s:("%s")) +(%s:{* TO *})))' % (attr_name,vals, attr_name)
563+
else:
564+
query_str += '((%s:("%s")) OR (*:* NOT %s:{* TO *}))' % (attr_name, vals, attr_name)
555565
else:
556566
query_str += '(+%s:("%s"))' % (attr_name, vals)
557567

0 commit comments

Comments
 (0)