Skip to content

Commit

Permalink
verify diff label for each term in all rows to ensure same term uses …
Browse files Browse the repository at this point in the history
…same label (#332)

Co-authored-by: Anita Caron <[email protected]>
  • Loading branch information
Anita Caron and anitacaron authored Jul 11, 2024
1 parent 56bfde9 commit d483cb8
Showing 1 changed file with 17 additions and 14 deletions.
31 changes: 17 additions & 14 deletions src/template_generation_tools.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import logging

import pandas as pd
from rdflib.graph import ConjunctiveGraph

from ccf_tools import add_rows, chunks, split_terms, transform_to_str
from uberongraph_tools import UberonGraph
from ccf_tools import chunks, split_terms, transform_to_str, add_rows
import logging

# logger = logging.getLogger('ASCT-b Tables Log')

Expand Down Expand Up @@ -157,18 +159,19 @@ def generate_class_graph_template(ccf_tools_df :pd.DataFrame, log_dict: dict):
terms_images = ug.query_uberon(" ".join(list(terms)), ug.select_image)

for term, label in terms_labels:
row = ccf_tools_df[(ccf_tools_df['s'] == term) | (ccf_tools_df['o'] == term)].iloc[0]
if row['s'] == term and row['slabel'].lower() != label.lower():
log_dict["diff_label"].append({"id": term, "label": label, "asct_label": row['slabel'], "user_label": row['user_slabel'], "row_number": int(row['row_number'])})
# logger.warning(f"Different labels found for {term}. Uberongraph: {label} ; ASCT+b table: {row['slabel']}")
ccf_tools_df.loc[(ccf_tools_df['s'] == term), 'slabel'] = label
ccf_tools_df.loc[(ccf_tools_df['o'] == term), 'olabel'] = label

if row['o'] == term and row['olabel'].lower() != label.lower():
log_dict["diff_label"].append({"id": term, "label": label, "asct_label": row['olabel'], "user_label": row['user_olabel'], "row_number": int(row['row_number'])})
# logger.warning(f"Different labels found for {term}. Uberongraph: {label} ; ASCT+b table: {row['olabel']}")
ccf_tools_df.loc[(ccf_tools_df['o'] == term), 'olabel'] = label
ccf_tools_df.loc[(ccf_tools_df['s'] == term), 'slabel'] = label
rows = ccf_tools_df[(ccf_tools_df['s'] == term) | (ccf_tools_df['o'] == term)]
for _, row in rows.iterrows():
if row['s'] == term and row['slabel'].lower() != label.lower():
log_dict["diff_label"].append({"id": term, "label": label, "asct_label": row['slabel'], "user_label": row['user_slabel'], "row_number": int(row['row_number'])})
# logger.warning(f"Different labels found for {term}. Uberongraph: {label} ; ASCT+b table: {row['slabel']}")
ccf_tools_df.loc[(ccf_tools_df['s'] == term), 'slabel'] = label
ccf_tools_df.loc[(ccf_tools_df['o'] == term), 'olabel'] = label

if row['o'] == term and row['olabel'].lower() != label.lower():
log_dict["diff_label"].append({"id": term, "label": label, "asct_label": row['olabel'], "user_label": row['user_olabel'], "row_number": int(row['row_number'])})
# logger.warning(f"Different labels found for {term}. Uberongraph: {label} ; ASCT+b table: {row['olabel']}")
ccf_tools_df.loc[(ccf_tools_df['o'] == term), 'olabel'] = label
ccf_tools_df.loc[(ccf_tools_df['s'] == term), 'slabel'] = label

# CREATE IMAGE REPORT
if len(terms_images) > 0:
Expand Down

0 comments on commit d483cb8

Please sign in to comment.