diff --git a/beacon/conf/conf.py b/beacon/conf/conf.py index 3d678a2..2dee48b 100644 --- a/beacon/conf/conf.py +++ b/beacon/conf/conf.py @@ -26,7 +26,7 @@ default_beacon_granularity = "record" # boolean, count or record security_levels = ['PUBLIC', 'REGISTERED', 'CONTROLLED'] documentation_url = 'https://b2ri-documentation-demo.ega-archive.org/' -alphanumeric_terms = ['libraryStrategy', 'molecularAttributes.geneIds', 'diseases.ageOfOnset.iso8601duration', 'molecularAttributes.aminoacidChanges'] +alphanumeric_terms = ['libraryStrategy', 'molecularAttributes.geneIds', 'diseases.ageOfOnset.iso8601duration', 'molecularAttributes.aminoacidChanges','phenotypicFeatures.onset.iso8601duration'] cors_urls = ["http://localhost:3000","https://cancer-beacon-demo.ega-archive.org", "https://beacon-network-demo2.ega-archive.org", "https://beacon.ega-archive.org"] diff --git a/beacon/connections/mongo/filters.py b/beacon/connections/mongo/filters.py index 66a15be..276dab3 100644 --- a/beacon/connections/mongo/filters.py +++ b/beacon/connections/mongo/filters.py @@ -938,7 +938,7 @@ def apply_alphanumeric_filter(self, query: dict, filter: AlphanumericFilter, col age_in_number = age_in_number+char except Exception:# pragma: no cover continue - new_age_list=[] + new_age_list='' if "=" in filter.operator: z = int(age_in_number)# pragma: no cover @@ -946,10 +946,13 @@ def apply_alphanumeric_filter(self, query: dict, filter: AlphanumericFilter, col z = int(age_in_number)+1 while z < 150: newagechar="P"+str(z)+"Y" - new_age_list.append(newagechar) + if new_age_list == '': + new_age_list+=newagechar + else: + new_age_list+='|'+newagechar z+=1 dict_in={} - dict_in["$in"]=new_age_list + dict_in["$regex"]=new_age_list query[filter.id] = dict_in query=cross_query(self, query, scope, collection, {}, dataset) elif '<' in filter.operator: @@ -960,17 +963,34 @@ def apply_alphanumeric_filter(self, query: dict, filter: AlphanumericFilter, col age_in_number = age_in_number+char except Exception:# pragma: no cover continue - new_age_list=[] + new_age_list='' if "=" in filter.operator: z = int(age_in_number)# pragma: no cover else: z = int(age_in_number)-1 while z > 0: newagechar="P"+str(z)+"Y" - new_age_list.append(newagechar) + if new_age_list == '': + new_age_list+=newagechar + else: + new_age_list+='|'+newagechar z-=1 dict_in={} - dict_in["$in"]=new_age_list + dict_in["$regex"]=new_age_list + query[filter.id] = dict_in + query=cross_query(self, query, scope, collection, {}, dataset) + elif '=' in filter.operator: + age_in_number="" + for char in filter.value: + try: + int(char) + age_in_number = age_in_number+char + except Exception:# pragma: no cover + continue + z = int(age_in_number)# pragma: no cover + newagechar="P"+str(z)+"Y" + dict_in={} + dict_in["$regex"]=newagechar query[filter.id] = dict_in query=cross_query(self, query, scope, collection, {}, dataset) else: