Skip to content

Commit

Permalink
adding new cohort
Browse files Browse the repository at this point in the history
  • Loading branch information
costero-e committed Jan 8, 2024
1 parent c5f979c commit bed33eb
Show file tree
Hide file tree
Showing 3 changed files with 133 additions and 14 deletions.
12 changes: 6 additions & 6 deletions beacon/db/g_variants.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,18 @@ def generate_position_filter_start(key: str, value: List[int]) -> List[Alphanume
if len(value) == 1:
filters.append(AlphanumericFilter(
id=VARIANTS_PROPERTY_MAP[key],
value=[value[0]],
value=value[0],
operator=Operator.GREATER_EQUAL
))
elif len(value) == 2:
filters.append(AlphanumericFilter(
id=VARIANTS_PROPERTY_MAP[key],
value=[value[0]],
value=value[0],
operator=Operator.GREATER_EQUAL
))
filters.append(AlphanumericFilter(
id=VARIANTS_PROPERTY_MAP[key],
value=[value[1]],
value=value[1],
operator=Operator.LESS_EQUAL
))
return filters
Expand All @@ -61,18 +61,18 @@ def generate_position_filter_end(key: str, value: List[int]) -> List[Alphanumeri
if len(value) == 1:
filters.append(AlphanumericFilter(
id=VARIANTS_PROPERTY_MAP[key],
value=[value[0]],
value=value[0],
operator=Operator.LESS_EQUAL
))
elif len(value) == 2:
filters.append(AlphanumericFilter(
id=VARIANTS_PROPERTY_MAP[key],
value=[value[0]],
value=value[0],
operator=Operator.GREATER_EQUAL
))
filters.append(AlphanumericFilter(
id=VARIANTS_PROPERTY_MAP[key],
value=[value[1]],
value=value[1],
operator=Operator.LESS_EQUAL
))
return filters
Expand Down
20 changes: 12 additions & 8 deletions beacon/response/build_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ def build_response_summary(exists, qparams, num_total_results):


def build_response_summary_by_dataset(exists, num_total_results, response_dict):
LOG.debug(response_dict)
count=0
try:
for k,v in response_dict.items():
Expand Down Expand Up @@ -174,7 +175,7 @@ def build_beacon_resultset_response_by_dataset(data,
dataset_id = dataset_dict['dataset']
response_dict[dataset_id] = []
dataset_ids_list.append(dataset_id)

LOG.debug(include)
if include == 'MISS':
for doc in data:
for dataset_dict in list_of_dataset_dicts:
Expand Down Expand Up @@ -311,14 +312,16 @@ def build_beacon_resultset_response_by_dataset(data,
dataset_id = dataset_dict['dataset']
response_dict[dataset_id].append(doc)
else:
if doc['id'] in dataset_dict['ids']:
dataset_id = dataset_dict['dataset']
response_dict[dataset_id].append(doc)
elif doc['id'] in dataset_dict['ids']:
dataset_id = dataset_dict['dataset']
response_dict[dataset_id].append(doc)
#LOG.debug(doc['id'])
if doc['id'] in dataset_dict['ids']:
dataset_id = dataset_dict['dataset']
response_dict[dataset_id].append(doc)
elif doc['id'] in dataset_dict['ids']:
dataset_id = dataset_dict['dataset']
response_dict[dataset_id].append(doc)
except Exception as e:
pass
#LOG.debug(response_dict)

limit= qparams.query.pagination.limit
length_to_rest=0
Expand All @@ -338,10 +341,11 @@ def build_beacon_resultset_response_by_dataset(data,
length_to_rest = len(response_dict[dataset_id])
else:
start_record = start_record - len(response_dict[dataset_id])





LOG.debug(response_dict)
beacon_response = {
'meta': build_meta(qparams, entity_schema, Granularity.RECORD),
'responseSummary': build_response_summary_by_dataset(num_total_results > 0, num_total_results, response_dict),
Expand Down
115 changes: 115 additions & 0 deletions deploy/data/cohorts_av.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
[
{
"cohortType": "study-defined",
"collectionEvents": [
{
"eventDiseases": {
"availability": true,
"availabilityCount": 1700,
"distribution": {
"diseases": {
"acutebronchitis": 121,
"agranulocytosis": 111,
"asthma": 134,
"bipolaraffectivedisorder": 134,
"cardiomyopathy": 133,
"dentalcaries": 135,
"eatingdisorders": 134,
"fibrosisandcirrhosisofliver": 132,
"gastro-oesophagealrefluxdisease": 140,
"haemorrhoids": 127,
"influenzaduetocertainidentifiedinfluenzavirus": 135,
"insulin-dependentdiabetesmellitus": 165,
"irondeficiencyanaemia": 142,
"multiplesclerosis": 125,
"obesity": 136,
"sarcoidosis": 136,
"schizophrenia": 138,
"thyroiditis": 141,
"varicoseveinsoflowerextremities": 139
}
}
},
"eventEthnicities": {
"availability": true,
"availabilityCount": 54,
"distribution": {
"ethnicities": {
"African": 3,
"AnyotherAsianbackground": 4,
"AnyotherBlackbackground": 4,
"Anyothermixedbackground": 2,
"Anyotherwhitebackground": 2,
"AsianorAsianBritish": 4,
"Bangladeshi": 3,
"BlackorBlackBritish": 2,
"British": 4,
"Caribbean": 2,
"Chinese": 4,
"Indian": 2,
"Irish": 3,
"Mixed": 2,
"Otherethnicgroup": 4,
"Pakistani": 2,
"White": 2,
"WhiteandAsian": 3,
"WhiteandBlackAfrican": 3,
"WhiteandBlackCaribbean": 1
}
}
},
"eventGenders": {
"availability": true,
"availabilityCount": 3,
"distribution": {
"genders": {
"female": 2,
"male": 1
}
}
},
"eventLocations": {
"availability": true,
"availabilityCount": 1597,
"distribution": {
"locations": {
"England": 2,
"NorthernIreland": 2,
"RepublicofIreland": 3,
"Scotland": 4,
"Wales": 5
}
}
}
}
],
"id": "AV_synthetic_cohort",
"inclusionCriteria": {
"ageRange": {
"end": {
"iso8601duration": "P65Y"
},
"start": {
"iso8601duration": "P18Y"
}
},
"genders": [
{
"id": "NCIT:C16576",
"label": "female"
},
{
"id": "NCIT:C20197",
"label": "male"
}
],
"locations": [
{
"id": "GAZ:00150372",
"label": "UK"
}
]
},
"name": "AV synthetic cohort"
}
]

0 comments on commit bed33eb

Please sign in to comment.