Skip to content

Commit

Permalink
Merge pull request #158 from Knowledge-Graph-Hub/decomp_source
Browse files Browse the repository at this point in the history
Decompress phenio source
  • Loading branch information
caufieldjh authored Nov 26, 2024
2 parents 285f2fc + 76a6695 commit 1c7927b
Show file tree
Hide file tree
Showing 3 changed files with 418 additions and 405 deletions.
4 changes: 2 additions & 2 deletions download.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
# phenio.owl
#
-
url: https://github.com/monarch-initiative/phenio/releases/latest/download/phenio.owl
local_name: phenio.owl
url: https://github.com/monarch-initiative/phenio/releases/latest/download/phenio.owl.tar.gz
local_name: phenio.owl.tar.gz

#
# phenio.owl test file
Expand Down
13 changes: 9 additions & 4 deletions kg_phenio/transform_utils/phenio/phenio_transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def run(self, data_file: Optional[str] = None) -> None:
data_file = os.path.join(self.input_base_dir, data_file)
self.parse(k, data_file, k)
else:
# load all ontologies
# Load PHENIO
for k in ONTO_FILES.keys():
data_file = os.path.join(self.input_base_dir, ONTO_FILES[k])
self.parse(k, data_file, k)
Expand All @@ -82,10 +82,13 @@ def parse(self, name: str, data_file: str, source: str) -> None:
Returns:
None.
"""
# Check if it needs to be decompressed first,
# and it probably does.
if not os.path.exists(data_file):
if os.path.exists(data_file + ".tar.gz"):
print(f"Decompressing {data_file}")
with tarfile.open(data_file) as compfile:
comp_data_file = data_file + ".tar.gz"
print(f"Decompressing {comp_data_file}")
with tarfile.open(comp_data_file) as compfile:
compfile.extractall(self.input_base_dir)
else:
print(f"Found ontology at {data_file}")
Expand Down Expand Up @@ -145,7 +148,9 @@ def parse(self, name: str, data_file: str, source: str) -> None:
if not os.path.exists(data_file_tsv):
if self.config:
if name == "PhenioTransformTest":
print(f"Transforming to KGX TSV with test config in {self.test_config}...")
print(
f"Transforming to KGX TSV with test config in {self.test_config}..."
)
tx_config = self.test_config
else:
print(f"Transforming to KGX TSV with config in {self.config}...")
Expand Down
Loading

0 comments on commit 1c7927b

Please sign in to comment.