- Rewrite params.json to match WES tool registry format - Update main.nf to use Harbor container image - Add k8s profile to nextflow.config for WES/Kubernetes execution - Use s3://omic/eureka paths for output
71 lines
2.0 KiB
Plaintext
71 lines
2.0 KiB
Plaintext
#!/usr/bin/env nextflow
|
|
|
|
nextflow.enable.dsl=2
|
|
|
|
// Default parameters
|
|
params.disease_name = null
|
|
params.outdir = null
|
|
params.population = 10
|
|
params.gender = 0.5
|
|
params.min_age = 0
|
|
params.max_age = 90
|
|
params.seed = null
|
|
|
|
// Validate required parameters
|
|
if (!params.disease_name) {
|
|
error "Disease name is required. Please specify with --disease_name"
|
|
}
|
|
|
|
if (!params.outdir) {
|
|
error "Output directory is required. Please specify with --outdir"
|
|
}
|
|
|
|
// Process to generate synthetic patients
|
|
process generatePatients {
|
|
container 'harbor.cluster.omic.ai/omic/synthea-alldiseases:latest'
|
|
publishDir params.outdir, mode: 'copy'
|
|
|
|
input:
|
|
val diseaseName
|
|
|
|
output:
|
|
path "fhir/*.json", optional: true, emit: fhir_output
|
|
path "run.log", emit: log_file
|
|
|
|
script:
|
|
def moduleBasename = diseaseName.toLowerCase().replaceAll(' ', '_')
|
|
def genderArg = params.gender < 0.5 ? "M" : (params.gender > 0.5 ? "F" : "B")
|
|
def seedArg = params.seed ? "-s ${params.seed}" : ""
|
|
"""
|
|
# Check if a custom module exists, otherwise use built-in Synthea modules
|
|
MODULE_FILE="/app/src/main/resources/modules/${moduleBasename}.json"
|
|
if [ -f "\${MODULE_FILE}" ]; then
|
|
echo "Found custom module: \${MODULE_FILE}" | tee run.log
|
|
else
|
|
echo "Using built-in Synthea modules for: ${diseaseName}" | tee run.log
|
|
fi
|
|
|
|
# Run Synthea patient generation
|
|
cd /app && ./run_synthea \
|
|
-p ${params.population} \
|
|
-g ${genderArg} \
|
|
-a ${params.min_age}-${params.max_age} \
|
|
${seedArg} \
|
|
-- ${diseaseName} 2>&1 | tee -a run.log
|
|
|
|
# Collect FHIR output
|
|
mkdir -p fhir
|
|
if [ -d /app/output/fhir ]; then
|
|
cp /app/output/fhir/*.json fhir/ 2>/dev/null || true
|
|
echo "Copied \$(ls fhir/*.json 2>/dev/null | wc -l) FHIR bundles" | tee -a run.log
|
|
else
|
|
echo "Warning: No FHIR output generated" | tee -a run.log
|
|
fi
|
|
"""
|
|
}
|
|
|
|
// Workflow
|
|
workflow {
|
|
generatePatients(params.disease_name)
|
|
}
|