Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optional: Improve: code for adding labels to robot template #14

Open
joeflack4 opened this issue Apr 28, 2024 · 0 comments
Open

Optional: Improve: code for adding labels to robot template #14

joeflack4 opened this issue Apr 28, 2024 · 0 comments
Assignees

Comments

@joeflack4
Copy link
Contributor

Overview

Recently in #12 we created an ad hoc robot template for Mondo-->ORDO-->ICD11.foundation mappings.

During this process, we needed labels added to the template, and quickly. So I used a quick and dirty method. I had an existing components/icd11.foundation.db in mondo-ingest. So I queried that, then copy/pasted the icd11foundation_labels.tsv to the root of this repository, committed that, and then pulled it in via a static reference constant (not the CLI) into the robot template script.

If we need another robot template in the future, or feel there is any other advantage to setting this up, we'd want to do this:

  1. Delete: icd11foundation_labels.tsv
  2. Add a make goal for a SemanticSQL .db
  3. Add a goal to makeicd11foundation_labels.tsv in the temp dir
  • This could be a CLI command probably, but I've also already written a Python script (see additioanl details).
  1. Add that goal as a prerequisite to the goal for making the robot template, and pass it as an arg to the Python script.
  2. Add a CLI param for that in the Python script, and do the rest needed to wire that up correctly.

Additional details

Python script for getting labels

The one change I'd make here to add a CLI and use args for the input and output paths.

from typing import List, Union

import pandas as pd
from oaklib import get_implementation_from_shorthand
from oaklib.types import CURIE, URI

DB_PATH = 'icd11foundation.db'
OUTPATH = 'icd11foundation_labels.tsv'


def labels(db_path: str = DB_PATH, outpath: str = OUTPATH) -> pd.DataFrame:
    """Create mapping status tables"""
    oi = get_implementation_from_shorthand(db_path)

    # Get all terms and labels
    ids_all: List[Union[CURIE, URI]] = [x for x in oi.entities(filter_obsoletes=False)]
    id_labels_all: List[tuple] = [x for x in oi.labels(ids_all)]
    df = pd.DataFrame(id_labels_all, columns=['id', 'label'])

    df.to_csv(outpath, sep='\t', index=False)
    return df

@joeflack4 joeflack4 changed the title Improve: code for adding labels to robot template Optional: Improve: code for adding labels to robot template Apr 28, 2024
@joeflack4 joeflack4 self-assigned this Apr 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant