Skip to content

Commit

Permalink
RFCT Remove use of intermediate list object
Browse files Browse the repository at this point in the history
  • Loading branch information
luispedro committed May 3, 2024
1 parent f10cb6b commit 7c6e2db
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions argnorm/drug_categorization.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,26 +14,26 @@ def confers_resistance_to(aro_num: str) -> List[str]:
aro_num (str): ARO number. Needs to be in the form 'ARO:number'.
Returns:
drugs_list (list[str]):
target (list[str]):
A list with ARO number of the drugs/antibiotics to which the input gene confers resistance to.
'''

if aro_num not in ARO.terms():
if aro_num not in ARO:
return []

drugs_list = []
target = set()

for term in ARO[aro_num].superclasses():
for drug in term.relationships.get(confers_resistance_to_drug_class_rel, []):
drugs_list.append(drug.id)
target.add(drug.id)

for drug in term.relationships.get(confers_resistance_to_antibiotic_rel, []):
drugs_list.append(drug.id)
target.add(drug.id)

if drugs_list:
if target:
break

return sorted(set(drugs_list))
return sorted(target)

def drugs_to_drug_classes(drugs_list: List[str]) -> List[str]:
'''
Expand Down

0 comments on commit 7c6e2db

Please sign in to comment.