Skip to content

Commit

Permalink
TODOs and statuses
Browse files Browse the repository at this point in the history
  • Loading branch information
caufieldjh committed Sep 3, 2024
1 parent f57e1b9 commit e34fa5e
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions src/kg_bioportal/transformer.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
from kgx.transformer import Transformer as KGXTransformer

# TODO: Don't repeat steps if the products already exist

# TODO: Fix KGX hijacking logging
# TODO: Save KGX logs to a file for each ontology
# TODO: Address BNodes

class Transformer:

Expand Down Expand Up @@ -118,20 +120,29 @@ def transform(self, ontology: str) -> bool:

# Transform to KGX nodes + edges
txr = KGXTransformer(stream=True)
outfilename = os.path.join(self.output_dir, f"{ontology_name}")
nodefilename = outfilename + "_nodes.tsv"
edgefilename = outfilename + "_edges.tsv"
input_args = {
"format": "owl",
"filename": [relaxed_outpath],
}
output_args = {
"format": "tsv",
"filename": os.path.join(self.output_dir, f"{ontology_name}"),
"filename": outfilename,
"provided_by": ontology_name,
"aggregator_knowledge_source": "infores:bioportal",
}
logging.info("Doing KGX transform.")
txr.transform(
try:
txr.transform(
input_args=input_args,
output_args=output_args,
)
)
logging.info(f"Nodes and edges written to {nodefilename} and {edgefilename}.")
status = True
except Exception as e:
logging.error(f"Error transforming {ontology} to KGX nodes and edges: {e}")
status = False

return status

0 comments on commit e34fa5e

Please sign in to comment.