@@ -259,6 +259,16 @@ def compare(self) -> ClauseElement:
259
259
]
260
260
261
261
262
+ def _transform_gene_term (term : tuple [str , Any ]) -> str :
263
+ if term [0 ].startswith ("KO:K" ):
264
+ return term [0 ].replace ("KO:K" , KeggTerms .ORTHOLOGY [0 ])
265
+ if term [0 ].startswith ("COG" ):
266
+ return term [0 ].replace ("COG" , "COG:COG" )
267
+ if term [0 ].startswith ("PF" ):
268
+ return term [0 ].replace ("PF" , "PFAM:PF" )
269
+ return term [0 ]
270
+
271
+
262
272
# This is the base class for all table specific queries. It is responsible for performing
263
273
# both searches and facet aggregations. At a high level, the queries are generated as follows:
264
274
# 1. group conditions by table/field
@@ -333,18 +343,14 @@ def transform_condition(self, db, condition: BaseConditionSchema) -> List[BaseCo
333
343
)
334
344
)
335
345
)
346
+ term_list = list (gene_terms )
347
+ if not term_list :
348
+ return [condition ]
336
349
else :
337
350
# This is not a condition we know how to transform.
338
351
return [condition ]
339
352
if gene_terms :
340
- if gene_terms [0 ][0 ].startswith ("KO:K" ):
341
- gene_terms = [
342
- term [0 ].replace ("KO:K" , KeggTerms .ORTHOLOGY [0 ]) for term in gene_terms
343
- ]
344
- elif gene_terms [0 ][0 ].startswith ("COG" ):
345
- gene_terms = [term [0 ].replace ("COG" , "COG:COG" ) for term in gene_terms ]
346
- elif gene_terms [0 ][0 ].startswith ("PF" ):
347
- gene_terms = [term [0 ].replace ("PF" , "PFAM:PF" ) for term in gene_terms ]
353
+ gene_terms = [_transform_gene_term (term ) for term in gene_terms ]
348
354
return [
349
355
SimpleConditionSchema (
350
356
op = "==" ,
0 commit comments