Skip to content

Commit

Permalink
regex search for clinvar revstat
Browse files Browse the repository at this point in the history
  • Loading branch information
northwestwitch committed Mar 5, 2019
1 parent 77b143a commit eafc1b6
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 22 deletions.
6 changes: 4 additions & 2 deletions scout/adapter/mongo/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,8 +287,10 @@ def build_query(self, case_id, query=None, variant_ids=None, category='snv'):
{ 'value' : { '$in': rank }},
{ 'value' : re.compile('|'.join(str_rank)) }
],
'revstat':
{ '$in': trusted_revision_level }
'$or' : [
{'revstat': { '$in': trusted_revision_level }},
{'revstat' : re.compile('|'.join(trusted_revision_level)) }
]
}
}
}
Expand Down
36 changes: 16 additions & 20 deletions tests/adapter/mongo/test_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ def test_build_clinsig_filter(adapter, real_variant_database):
def test_build_clinsig_always(adapter, real_variant_database):
case_id = 'cust000'
clinsig_confident_always_returned = True
trusted_revstat_lev = ['mult', 'single', 'exp', 'guideline']
clinsig_items = [ 4, 5 ]
clinsig_mapped_items = []
all_clinsig = [] # both numerical and human readable values
Expand All @@ -225,7 +226,6 @@ def test_build_clinsig_always(adapter, real_variant_database):

mongo_query = adapter.build_query(case_id, query=query)


assert mongo_query['$or'] == [
{ '$and':
[ {
Expand All @@ -240,18 +240,17 @@ def test_build_clinsig_always(adapter, real_variant_database):
]},
{ 'clnsig':
{
'$elemMatch': { '$or' :
[
'$elemMatch': {
'$or' :[
{ 'value' : { '$in': all_clinsig }},
{ 'value' : re.compile('|'.join(clinsig_mapped_items)) }
],
'revstat':
{ '$in' : ['mult',
'single',
'exp',
'guideline']
}
}
'$or' : [
{ 'revstat' : {'$in' : trusted_revstat_lev }},
{ 'revstat' : re.compile('|'.join(trusted_revstat_lev)) }
]

}
}
}
]
Expand Down Expand Up @@ -322,6 +321,7 @@ def test_build_spidex_high(adapter):
def test_build_clinsig_always_only(adapter):
case_id = 'cust000'
clinsig_confident_always_returned = True
trusted_revstat_lev = ['mult', 'single', 'exp', 'guideline']
clinsig_items = [ 4, 5 ]
clinsig_mapped_items = []
all_clinsig = [] # both numerical and human readable values
Expand All @@ -338,19 +338,15 @@ def test_build_clinsig_always_only(adapter):

assert mongo_query['clnsig'] == {
'$elemMatch': {
'$or' :
[
'$or' : [
{ 'value' : { '$in': all_clinsig }},
{ 'value' : re.compile('|'.join(clinsig_mapped_items)) }
],
'revstat':
{ '$in' : ['mult',
'single',
'exp',
'guideline']
}
}
}
'$or': [
{ 'revstat' : {'$in' : trusted_revstat_lev }},
{'revstat' : re.compile('|'.join(trusted_revstat_lev)) }
]
}}

def test_build_chrom(adapter):
case_id = 'cust000'
Expand Down

0 comments on commit eafc1b6

Please sign in to comment.