Skip to content

Commit

Permalink
Merge pull request #46 from ccb-hms/development
Browse files Browse the repository at this point in the history
Optimize filter_mappings()
  • Loading branch information
paynejason authored Mar 6, 2024
2 parents 7fc8448 + 2c919a6 commit 8c24c36
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 9 deletions.
1 change: 0 additions & 1 deletion .github/workflows/python-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ jobs:
- name: show python path
run: |
python -c "import sys; print('\n'.join(sys.path))"
echo $PYTHONPATH
- name: Install dependencies
run: |
python -m pip install --upgrade pip
Expand Down
4 changes: 2 additions & 2 deletions text2term/onto_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import text2term
import owlready2
import pandas as pd
from .term import OntologyTermType
from .mapper import Mapper
from text2term.term import OntologyTermType
from text2term.mapper import Mapper
from shutil import rmtree

CACHE_FOLDER = "cache"
Expand Down
8 changes: 3 additions & 5 deletions text2term/t2t.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,13 +265,11 @@ def _add_tags_to_df(df, tags):


def _filter_mappings(mappings_df, min_score):
new_df = pd.DataFrame(columns=mappings_df.columns)
for index, row in mappings_df.iterrows():
if row['Mapping Score'] >= min_score:
new_df.loc[len(new_df.index)] = row
if mappings_df.empty:
return mappings_df
new_df = mappings_df.loc[mappings_df["Mapping Score"] >= min_score]
return new_df


def _add_unmapped_terms(mappings_df, tags, source_terms, source_terms_ids):
if mappings_df.size == 0:
mapped = []
Expand Down
2 changes: 1 addition & 1 deletion text2term/term_collector.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def get_ontology_terms(self, base_iris=(), exclude_deprecated=False, term_type=O
return ontology_terms

def filter_terms(self, onto_terms, iris=(), excl_deprecated=False, term_type=OntologyTermType.ANY):
return filter_terms(onto_terms, iris, exclude_deprecated, term_type)
return filter_terms(onto_terms, iris, excl_deprecated, term_type)

def _get_ontology_signature(self, ontology):
signature = list(ontology.classes())
Expand Down

0 comments on commit 8c24c36

Please sign in to comment.