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

Decompress phenio source #158

Merged
merged 3 commits into from
Nov 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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