Skip to content

Commit 572faa1

Browse files
committed
Merge branch 'lcms_metab_lipid_cicd' into 'lcms_metab'
Add CI/CD for lipidomics and makefile command for downloading lipidomics test data See merge request mass-spectrometry/metams!21
2 parents 872b0ae + 7c25ffc commit 572faa1

8 files changed

Lines changed: 103 additions & 29 deletions
Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Test GC/MS workflow
1+
name: Test workflows
22

33
on:
44
push:
@@ -22,20 +22,36 @@ jobs:
2222
curl -fsSL https://get.docker.com -o get-docker.sh
2323
sh get-docker.sh
2424
sudo usermod -aG docker $USER
25-
26-
- name: Build Docker Image
27-
run: |
28-
docker build -t local-metams:latest .
2925
3026
- name: Install MiniWDL
3127
run: |
3228
python -m pip install --upgrade pip
3329
pip install miniwdl
34-
30+
31+
- name: Download test data for lipidomics
32+
run: |
33+
make get-lipid-test-data
34+
35+
- name: Run Lipidomics WDL with lipidomics test data
36+
run: |
37+
miniwdl run wdl/metaMS_lcmslipidomics.wdl -i wdl/metams_input_lipidomics.json --verbose --no-cache --copy-input-files
38+
3539
- name: Run GCMS WDL with pushed Docker Image
3640
run: |
3741
miniwdl run wdl/metaMS_gcms.wdl -i wdl/metams_input_gcms.json --verbose --no-cache --copy-input-files
42+
43+
- name: Build Docker Image
44+
run: |
45+
docker build -t local-metams:latest .
3846
3947
- name: Run GCMS WDL with local Docker Image based on Dockerfile
4048
run: |
41-
miniwdl run wdl/metaMS_gcms.wdl -i wdl/metams_input_gcms_local_docker.json --verbose --no-cache --copy-input-files
49+
miniwdl run wdl/metaMS_gcms.wdl -i wdl/metams_input_gcms_local_docker.json --verbose --no-cache --copy-input-files
50+
51+
- name: Run Lipidomics WDL with local Docker Image based on Dockerfile
52+
run: |
53+
miniwdl run wdl/metaMS_lcmslipidomics.wdl -i wdl/metams_input_lipidomics_local_docker.json --verbose --no-cache --copy-input-files
54+
55+
- name: Remove lipidomics test data
56+
run: |
57+
rm -rf test_data

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,7 @@ share/python-wheels/
4444
*.token
4545

4646
# msp databases
47-
*.msp
47+
*.msp
48+
49+
# test_data
50+
test_data/

MAINTAINERS.md

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@
33
## Table of Contents
44
1. [Introduction](#introduction)
55
2. [Setting Up the Development Environment](#setting-up-the-development-environment)
6-
3. [Releasing a new version](#releasing-a-new-version)
6+
3. [Testing a new or modified workflow](#testing-a-new-or-modified-workflow)
7+
4. [Releasing a new version](#releasing-a-new-version)
78
1. [Bump Version Numbers](#bump-version-numbers)
89
2. [Push Updated Docker Image](#push-updated-docker-image)
9-
4. [Generate Documentation](#generate-documentation)
10+
5. [Generate Documentation](#generate-documentation)
1011

1112
## Introduction
1213
This guide provides instructions for developers working on the project. It covers setting up the development environment, pushing Docker images, generating documentation, and bumping version numbers.
@@ -31,6 +32,14 @@ This guide provides instructions for developers working on the project. It cover
3132
pip install -r requirements-dev.txt
3233
```
3334

35+
## Testing a new or modified workflow
36+
37+
To test a workflow before an associated docker image is pushed, you can run the workflow locally using the docker image that is built locally according to the dockerfile in the workflow directory. To do this, your wdl must have the option to change the docker image in which the workflow is run, and this image must be specified in the input json file. For example, the following command will run the lipidomcis workflow using the docker image that is built locally. See the input file [here](wdl/metams_input_lipidomics_local_docker.json) for an example of how to specify the docker image in the input file.
38+
39+
```sh
40+
miniwdl run wdl/metaMS_lcmslipidomics.wdl -i wdl/metams_input_lipidomics_local_docker.json --verbose --no-cache --copy-input-files
41+
```
42+
3443
## Releasing a new version
3544

3645
The following steps should be followed in order
@@ -54,7 +63,7 @@ To bump the repo *and all workflows*, run one of the following commands. This w
5463
make patch
5564
```
5665
### Push Updated Docker Image
57-
Use the github action to push a docker image to the appropriate dockerhub repository.
66+
Use the github action to push a docker image to the appropriate dockerhub repository. This will use the version number that was set in the previous step and will build and push a docker image according to the dockerfile in the root of the repo. The docker image will be tagged with the version number and the latest tag.
5867

5968
## Generating Documentation
6069

Makefile

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,9 +119,21 @@ wdl-run-gcms-local:
119119
@make docker-build-local
120120
@miniwdl run wdl/metaMS_gcms.wdl -i wdl/metams_input_gcms_local_docker.json --verbose --no-cache --copy-input-files
121121

122+
get-lipid-test-data:
123+
@echo "Downloading test data for lipidomics"
124+
@mkdir -p test_data
125+
@curl -L -o test_data/test_lipid_data.zip https://nmdcdemo.emsl.pnnl.gov/lipidomics/test_data/metams_lipid_test_data/test_lipid_data.zip
126+
@unzip test_data/test_lipid_data.zip -d test_data/
127+
@rm test_data/test_lipid_data.zip
128+
@echo "Test data downloaded and unzipped"
129+
122130
wdl-run-lipid :
123131
miniwdl run wdl/metaMS_lcmslipidomics.wdl -i wdl/metams_input_lipidomics.json --verbose --no-cache --copy-input-files
124132

133+
wdl-run-lipid-local:
134+
@make docker-build-local
135+
miniwdl run wdl/metaMS_lcmslipidomics.wdl -i wdl/metams_input_lipidomics_local_docker.json --verbose --no-cache --copy-input-files
136+
125137
convert_lipid_rst_to_md:
126138
# convert the lipid documentation from rst to md and render it into html
127139
pandoc -f rst -t markdown -o docs/lcms_lipidomics/README_LCMS_LIPID.md docs/lcms_lipidomics/index.rst

metaMS/lcms_lipidomics_workflow.py

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -291,10 +291,6 @@ def export_results(myLCMSobj, out_path, molecular_metadata=None, final=False):
291291
exporter.to_hdf(overwrite=True)
292292
if final:
293293
exporter.report_to_csv(molecular_metadata=molecular_metadata)
294-
else:
295-
with warnings.catch_warnings():
296-
warnings.simplefilter("ignore")
297-
exporter.report_to_csv()
298294

299295
def run_lipid_sp_ms1(file_in, out_path, params_toml, scan_translator):
300296
"""Run signal processing and associated mass feature generation for a lipidomics LCMS file
@@ -336,7 +332,11 @@ def run_lipid_sp_ms1(file_in, out_path, params_toml, scan_translator):
336332
]
337333
)
338334
)
339-
mz_dict = {myLCMSobj.polarity: precursor_mz_list}
335+
mz_dict = {myLCMSobj.polarity: precursor_mz_list.copy()}
336+
myLCMSobj.spectra_parser = None
337+
del myLCMSobj
338+
gc.collect()
339+
340340
return mz_dict
341341

342342
def prep_metadata(mz_dicts, out_dir, db_location):
@@ -599,8 +599,6 @@ def run_lcms_lipidomics_workflow(
599599
scan_translator = lipid_workflow_params.scan_translator_path
600600

601601
click.echo("Starting lipidomics workflow for " + str(len(files_list)) + " file(s), using " + str(cores) + " core(s)")
602-
gc.collect()
603-
604602
# Run signal processing, get associated ms1, add associated ms2, do ms1 molecular search, and export intermediate results
605603
if cores == 1 or len(files_list) == 1:
606604
mz_dicts = []
@@ -624,13 +622,11 @@ def run_lcms_lipidomics_workflow(
624622
for file_in, file_out in zip(files_list, out_paths_list)
625623
]
626624
mz_dicts = pool.starmap(run_lipid_sp_ms1, args)
627-
gc.collect()
628-
625+
629626
# Prepare metadata for searching
630627
click.echo("Preparing metadata for ms2 spectral search")
631628
metadata = prep_metadata(mz_dicts, out_dir, lipid_workflow_params.db_location)
632629
del mz_dicts
633-
gc.collect()
634630

635631
# Run ms2 spectral search and export final results
636632
click.echo("Starting ms2 spectral search and exporting final results")
@@ -644,4 +640,4 @@ def run_lcms_lipidomics_workflow(
644640
args = [(file_out, metadata, scan_translator) for file_out in out_paths_list]
645641
pool.starmap(run_lipid_ms2, args)
646642

647-
gc.collect()
643+
click.echo("Lipidomics workflow complete")

wdl/metaMS_lcmslipidomics.wdl

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
11
version 1.0
22

33
workflow lcmsLipidomics {
4-
call runMetaMSLCMSLipidomics
4+
input {
5+
String? docker_image # Optional input for Docker image
6+
}
7+
8+
call runMetaMSLCMSLipidomics {
9+
input:
10+
docker_image = docker_image
11+
}
512
613
output {
714
String out = runMetaMSLCMSLipidomics.out
@@ -17,6 +24,7 @@ task runMetaMSLCMSLipidomics {
1724
File db_location
1825
File scan_translator_path
1926
Int cores
27+
String? docker_image
2028
}
2129

2230
command {
@@ -27,6 +35,24 @@ task runMetaMSLCMSLipidomics {
2735
-d ${db_location} \
2836
-s ${scan_translator_path} \
2937
-j ${cores}
38+
EXIT_CODE=$?
39+
num_inputs=$(echo ${sep=' ' file_paths} | wc -w)
40+
num_subdirs=$(find "${output_directory}" -mindepth 1 -maxdepth 1 -type d | wc -l)
41+
all_ok=1
42+
for subdir in "${output_directory}"/*/; do
43+
if [ -d "$subdir" ]; then
44+
if ! ls "$subdir"/*.csv 1> /dev/null 2>&1; then
45+
all_ok=0
46+
break
47+
fi
48+
fi
49+
done
50+
51+
if [ "$all_ok" -eq 1 ] && [ "$num_subdirs" -eq "$num_inputs" ]; then
52+
exit 0
53+
else
54+
exit $EXIT_CODE
55+
fi
3056
}
3157

3258
output {
@@ -35,6 +61,6 @@ task runMetaMSLCMSLipidomics {
3561
}
3662

3763
runtime {
38-
docker: "microbiomedata/metams:3.1.0"
64+
docker: "~{if defined(docker_image) then docker_image else 'microbiomedata/metams:3.1.0'}"
3965
}
4066
}

wdl/metams_input_lipidomics.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
{
22
"lcmsLipidomics.runMetaMSLCMSLipidomics.file_paths": [
3-
"/Users/heal742/Library/CloudStorage/OneDrive-PNNL/Documents/_DMS_data/_NMDC/_blanchard_lipidomics/raw/Blanch_Nat_Lip_C_4_AB_M_08_NEG_25Jan18_Brandi-WCSH5801.raw",
4-
"/Users/heal742/Library/CloudStorage/OneDrive-PNNL/Documents/_DMS_data/_NMDC/_blanchard_lipidomics/raw/Blanch_Nat_Lip_C_4_AB_M_08_POS_23Jan18_Brandi-WCSH5801.raw"
3+
"./test_data/test_lipid_data/Blanch_Nat_Lip_C_4_AB_M_08_NEG_25Jan18_Brandi-WCSH5801.raw",
4+
"./test_data/test_lipid_data/Blanch_Nat_Lip_C_4_AB_M_08_POS_23Jan18_Brandi-WCSH5801.raw"
55
],
66
"lcmsLipidomics.runMetaMSLCMSLipidomics.output_directory": "output",
7-
"lcmsLipidomics.runMetaMSLCMSLipidomics.corems_toml_path": "/Users/heal742/LOCAL/05_NMDC/02_MetaMS/data_processing/configurations/emsl_lipidomics_corems_params.toml",
8-
"lcmsLipidomics.runMetaMSLCMSLipidomics.db_location": "/Users/heal742/LOCAL/05_NMDC/00_Lipid_Databse/lipid_db/lipid_ref.sqlite",
9-
"lcmsLipidomics.runMetaMSLCMSLipidomics.scan_translator_path": "./configuration/lipid_configs/emsl_lipidomics_scan_translator.toml",
7+
"lcmsLipidomics.runMetaMSLCMSLipidomics.corems_toml_path": "./test_data/test_lipid_data/emsl_lipidomics_corems_params_test.toml",
8+
"lcmsLipidomics.runMetaMSLCMSLipidomics.db_location": "./test_data/test_lipid_data/lipid_ref.sqlite",
9+
"lcmsLipidomics.runMetaMSLCMSLipidomics.scan_translator_path": "./test_data/test_lipid_data/emsl_lipidomics_scan_translator.toml",
1010
"lcmsLipidomics.runMetaMSLCMSLipidomics.cores": 1
1111
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"lcmsLipidomics.docker_image": "local-metams:latest",
3+
"lcmsLipidomics.runMetaMSLCMSLipidomics.file_paths": [
4+
"./test_data/test_lipid_data/Blanch_Nat_Lip_C_4_AB_M_08_NEG_25Jan18_Brandi-WCSH5801.raw",
5+
"./test_data/test_lipid_data/Blanch_Nat_Lip_C_4_AB_M_08_POS_23Jan18_Brandi-WCSH5801.raw"
6+
],
7+
"lcmsLipidomics.runMetaMSLCMSLipidomics.output_directory": "output",
8+
"lcmsLipidomics.runMetaMSLCMSLipidomics.corems_toml_path": "./test_data/test_lipid_data/emsl_lipidomics_corems_params_test.toml",
9+
"lcmsLipidomics.runMetaMSLCMSLipidomics.db_location": "./test_data/test_lipid_data/lipid_ref.sqlite",
10+
"lcmsLipidomics.runMetaMSLCMSLipidomics.scan_translator_path": "./test_data/test_lipid_data/emsl_lipidomics_scan_translator.toml",
11+
"lcmsLipidomics.runMetaMSLCMSLipidomics.cores": 1
12+
}

0 commit comments

Comments
 (0)