@@ -129,50 +129,62 @@ def cache_missing_features(conn: GraphKBConnection) -> None:
129
129
130
130
def match_category_variant (
131
131
conn : GraphKBConnection ,
132
- gene_name : str ,
132
+ reference_name : str ,
133
133
category : str ,
134
134
root_exclude_term : str = "" ,
135
135
gene_source : str = "" ,
136
136
gene_is_source_id : bool = False ,
137
137
ignore_cache : bool = False ,
138
+ reference_class : str = 'Feature' ,
138
139
) -> List [Variant ]:
139
140
"""
140
141
Returns a list of variants matching the input variant
141
142
142
143
Args:
143
144
conn (GraphKBConnection): the graphkb connection object
144
- gene_name (str): the name of the gene the variant is in reference to
145
+ reference_name (str): the name of the Feature( gene)/Signature the variant is in reference to
145
146
category (str): the variant category (ex. copy loss)
146
147
gene_source: The source database the gene is defined by (ex. ensembl)
147
148
gene_is_source_id: Indicates the gene name(s) input should be treated as sourceIds not names
149
+ reference_class (str): Class name of the variant reference. Default to 'Feature'
148
150
Raises:
149
151
FeatureNotFoundError: The gene could not be found in GraphKB
150
152
151
153
Returns:
152
154
Array.<dict>: List of variant records from GraphKB which match the input
153
155
"""
154
- # disambiguate the gene to find all equivalent representations
155
- features = convert_to_rid_list (
156
- get_equivalent_features (
157
- conn ,
158
- gene_name ,
159
- source = gene_source ,
160
- is_source_id = gene_is_source_id ,
161
- ignore_cache = ignore_cache ,
156
+ # disambiguate the reference to find all equivalent representations
157
+ references : List [str ] = []
158
+ if reference_class == 'Feature' :
159
+ references = convert_to_rid_list (
160
+ get_equivalent_features (
161
+ conn ,
162
+ reference_name ,
163
+ source = gene_source ,
164
+ is_source_id = gene_is_source_id ,
165
+ ignore_cache = ignore_cache ,
166
+ )
162
167
)
163
- )
164
-
165
- if not features :
166
- raise FeatureNotFoundError (
167
- f"unable to find the gene ({ gene_name } ) or any equivalent representations"
168
+ if not references :
169
+ raise FeatureNotFoundError (
170
+ f"unable to find the gene ({ reference_name } ) or any equivalent representations"
171
+ )
172
+ if reference_class == 'Signature' :
173
+ references = convert_to_rid_list (
174
+ get_equivalent_terms (
175
+ conn ,
176
+ reference_name .lower (),
177
+ ontology_class = 'Signature' ,
178
+ ignore_cache = ignore_cache ,
179
+ )
168
180
)
169
181
170
182
# get the list of terms that we should match
171
- terms = convert_to_rid_list (
183
+ types = convert_to_rid_list (
172
184
get_term_tree (conn , category , root_exclude_term , ignore_cache = ignore_cache )
173
185
)
174
186
175
- if not terms :
187
+ if not types :
176
188
raise ValueError (f"unable to find the term/category ({ category } ) or any equivalent" )
177
189
178
190
# find the variant list
@@ -183,8 +195,8 @@ def match_category_variant(
183
195
"target" : {
184
196
"target" : "CategoryVariant" ,
185
197
"filters" : [
186
- {"reference1" : features , "operator" : "IN" },
187
- {"type" : terms , "operator" : "IN" },
198
+ {"reference1" : references , "operator" : "IN" },
199
+ {"type" : types , "operator" : "IN" },
188
200
],
189
201
},
190
202
"queryType" : "similarTo" ,
0 commit comments