Skip to content

Commit

Permalink
Add functionality to authenticate via MetabRef API token
Browse files Browse the repository at this point in the history
  • Loading branch information
smcolby committed Dec 13, 2024
1 parent 6e884c3 commit a693d1b
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 3 deletions.
1 change: 1 addition & 0 deletions configuration/gcms_metams.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ nmdc_metadata_path = "configuration/nmdc_metadata.json"
output_directory = "output"
output_filename = "output"
output_type = "csv"
metabref_token_path = "configuration/metabref.token"
3 changes: 3 additions & 0 deletions metaMS/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ def cli():
@click.argument("output_type", required=True, type=str)
@click.argument("corems_toml_path", required=True, type=str)
@click.argument("nmdc_metadata_path", required=True, type=str)
@click.argument("metabref_token_path", required=True, type=str)
@click.option("--jobs", "-j", default=4, help="'cpu's'")
def run_gcms_wdl_workflow(
file_paths,
Expand All @@ -40,6 +41,7 @@ def run_gcms_wdl_workflow(
output_type,
corems_toml_path,
nmdc_metadata_path,
metabref_token_path,
jobs,
):
"""Run the GCMS workflow\n
Expand All @@ -56,6 +58,7 @@ def run_gcms_wdl_workflow(
output_filename,
output_type,
corems_toml_path,
metabref_token_path,
jobs,
)

Expand Down
14 changes: 11 additions & 3 deletions metaMS/gcmsWorkflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ class WorkflowParameters:
output_filename: str = "data/..."
output_type: str = "csv"

# Token
metabref_token_path: str = "configuration/..."


def worker(args):
"""
Expand All @@ -72,6 +75,7 @@ def run_gcms_metabolomics_workflow_wdl(
output_filename,
output_type,
corems_toml_path,
metabref_token_path,
jobs,
db_path=None,
):
Expand All @@ -92,6 +96,8 @@ def run_gcms_metabolomics_workflow_wdl(
Output extension.
corems_toml_path : str
CoreMS configuration.
metabref_token_path : str
Token to authenticate MetabRef database access.
jobs : int
Number of concurrent jobs.
[unused] db_path : str
Expand All @@ -109,6 +115,7 @@ def run_gcms_metabolomics_workflow_wdl(
workflow_params.output_filename = output_filename
workflow_params.output_type = output_type
workflow_params.corems_toml_path = corems_toml_path
workflow_params.metabref_token_path = metabref_token_path

# Load CoreMS settings
click.echo("Loading CoreMS settings from %s" % workflow_params.corems_toml_path)
Expand All @@ -128,6 +135,7 @@ def run_gcms_metabolomics_workflow_wdl(
)

# Load FAMEs calibration reference
MetabRefGCInterface().set_token(workflow_params.metabref_token_path)
fames_ref_sql = MetabRefGCInterface().get_fames(format="sql")

# Compute RT:RI pairs
Expand Down Expand Up @@ -183,9 +191,8 @@ def run_nmdc_metabolomics_workflow(workflow_params_file, jobs):
)

# Load FAMEs calibration reference
fames_ref_sql = EI_LowRes_SQLite(
url=workflow_params.calibration_reference_path
)
MetabRefGCInterface().set_token(workflow_params.metabref_token_path)
fames_ref_sql = MetabRefGCInterface().get_fames(format='sql')

# Compute RT:RI pairs
rt_ri_pairs = get_rt_ri_pairs(gcms_cal_obj, sql_obj=fames_ref_sql)
Expand Down Expand Up @@ -253,6 +260,7 @@ def run_gcms_metabolomics_workflow(workflow_params_file, jobs):
)

# Load FAMEs calibration reference
MetabRefGCInterface().set_token(workflow_params.metabref_token_path)
fames_ref_sql = MetabRefGCInterface().get_fames(format="sql")

# Compute RT:RI pairs
Expand Down
2 changes: 2 additions & 0 deletions wdl/metaMS_gcms.wdl
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ task runMetaMSGCMS {
String output_type
File corems_toml_path
File nmdc_metadata_path
File metabref_token_path
Int jobs_count
}
Expand All @@ -31,6 +32,7 @@ task runMetaMSGCMS {
${output_type} \
${corems_toml_path} \
${nmdc_metadata_path} \
${metabref_token_path} \
--jobs ${jobs_count}
}

Expand Down

0 comments on commit a693d1b

Please sign in to comment.