Skip to content

Commit

Permalink
Merge pull request #39 from bmeg/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
teslajoy authored Jul 30, 2024
2 parents 601fe24 + 6d19d28 commit 4820c50
Show file tree
Hide file tree
Showing 29 changed files with 1,143 additions and 813 deletions.
8 changes: 2 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,17 +50,13 @@ Detailed step-by-step guide on FHIRizing data for a project's study can be found

Example run for patient - replace path's to ndjson files or directories.

```
fhirizer convert --name case --in_path ./projects/<my-project>/cases.ndjson --out_path ./projects/<my-project>/cases_key.ndjson --verbose True
```
fhirizer generate --name case --out_dir ./projects/<my-project>/META --entity_path ./projects/<my-project>/cases_key.ndjson
```

- to generate document reference for the patients

```
fhirizer convert --name file --in_path ./projects/<my-project>/files.ndjson --out_path ./projects/<my-project>/files_key.ndjson --verbose True
```
fhirizer generate --name file --out_dir ./projects/<my-project>/META --entity_path ./projects/<my-project>/files_key.ndjson
```

Expand Down
33 changes: 28 additions & 5 deletions fhirizer/cli.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from fhirizer import utils, mapping, entity2fhir
from fhirizer import icgc2fhir
import click
from pathlib import Path


class NotRequiredIf(click.Option):
Expand Down Expand Up @@ -31,7 +32,7 @@ def handle_parse_result(self, ctx, opts, args):

@click.group()
def cli():
"""GDC or Cellosaurus to FHIR Key and Content Mapping"""
"""GDC, Cellosaurus, ICGC to FHIR schema Key and Content Mapping"""
pass


Expand All @@ -41,6 +42,8 @@ def cli():
show_default=True,
help='Path to available GDC field json files in this repo')
def field_keys(input_path):
assert Path(input_path).is_file(), f"Path {input_path} is not a valid file path."

case_fields = utils._read_json(input_path)
print("reading from input_path: ", input_path)
print("case fields: ", case_fields)
Expand All @@ -56,6 +59,8 @@ def field_keys(input_path):
show_default=True,
help='Path to GDC project json schema')
def project_init(field_path, out_path):
assert Path(field_path).is_file(), f"Path {field_path} is not a valid file path."

mapping.initialize_project(field_path, out_path)


Expand All @@ -69,6 +74,8 @@ def project_init(field_path, out_path):
show_default=True,
help='Path to GDC case json schema')
def case_init(field_path, out_path):
assert Path(field_path).is_file(), f"Path {field_path} is not a valid file path."

mapping.initialize_case(field_path, out_path)


Expand All @@ -82,6 +89,8 @@ def case_init(field_path, out_path):
show_default=True,
help='Path to GDC file json schema')
def file_init(field_path, out_path):
assert Path(field_path).is_file(), f"Path {field_path} is not a valid file path."

mapping.initialize_file(field_path, out_path)


Expand All @@ -97,6 +106,9 @@ def file_init(field_path, out_path):
show_default=True,
help='Directory path to save generated resources')
def resource(name, path, out_dir):
assert Path(path).is_file(), f"Path {path} is not a valid file path."
assert Path(out_dir).is_dir(), f"Path {out_dir} is not a valid directory path."

if name in 'cellosaurus':
entity2fhir.cellosaurus_resource(path=path, out_dir=out_dir)

Expand All @@ -116,6 +128,10 @@ def resource(name, path, out_dir):
default=False,
show_default=True)
def convert(name, in_path, out_path, verbose):
name_list = ['project', 'case', 'file', 'cellosaurus', 'icgc']
assert name in ['project', 'case', 'file', 'cellosaurus', 'icgc'], f'--name is not in {name_list}.'
assert Path(in_path).is_file(), f"Path {in_path} is not a valid file path."

mapping.convert_maps(name=name, in_path=in_path, out_path=out_path, verbose=verbose)


Expand All @@ -134,13 +150,20 @@ def convert(name, in_path, out_path, verbose):
@click.option('--icgc', help='Name of the ICGC project to FHIRize.')
@click.option('--has_files', is_flag=True, help='Boolean indicating file metatda via new argo site is available @ '
'ICGC/{project}/data directory to FHIRize.')
def generate(name, out_dir, entity_path, icgc, has_files):
@click.option('--convert', is_flag=True, help='Boolean indicating to write converted keys to directory')
@click.option('--verbose', is_flag=True)
def generate(name, out_dir, entity_path, icgc, has_files, convert, verbose):
name_list = ['project', 'case', 'file', 'cellosaurus', 'icgc']
assert name in ['project', 'case', 'file', 'cellosaurus', 'icgc'], f'--name is not in {name_list}.'
assert Path(out_dir).is_dir(), f"Path {out_dir} is not a valid directory path."
assert Path(entity_path).is_file(), f"Path {entity_path} is not a valid file path."

if name in 'project':
entity2fhir.project_gdc_to_fhir_ndjson(out_dir=out_dir, projects_path=entity_path)
entity2fhir.project_gdc_to_fhir_ndjson(out_dir=out_dir, projects_path=entity_path, convert=convert, verbose=verbose)
if name in 'case':
entity2fhir.case_gdc_to_fhir_ndjson(out_dir=out_dir, cases_path=entity_path)
entity2fhir.case_gdc_to_fhir_ndjson(out_dir=out_dir, name=name, cases_path=entity_path, convert=convert, verbose=verbose)
if name in 'file':
entity2fhir.file_gdc_to_fhir_ndjson(out_dir=out_dir, files_path=entity_path)
entity2fhir.file_gdc_to_fhir_ndjson(out_dir=out_dir, name=name, files_path=entity_path, convert=convert, verbose=verbose)
if name in 'cellosaurus':
entity2fhir.cellosaurus2fhir(out_dir=out_dir, path=entity_path)
if name in 'icgc' and icgc:
Expand Down
Loading

0 comments on commit 4820c50

Please sign in to comment.