Hi everyone, I am a very new user of Nextflow and am experimenting with using it with docker containers. I have a script I want to run inside a docker container with gdown installed to download some files, given a popmap file and a samples.json file containing the gdown ids for the samples.
However, my problem is that I keep running in an unexpected input error that doesn’t make sense to neither me or github copilot (which doesn’t mean much anyway).
The error is:
$ nextflow run main.nf --samples_json samples.json --popmap popmap
N E X T F L O W ~ version 24.04.0-edge
Launching `main.nf` [reverent_kowalevski] DSL2 - revision: 89ea171489
ERROR ~ Script compilation error
- file : /main.nf
- cause: Unexpected input: '{' @ line 12, column 26.
process download_samples {
^
1 error
NOTE: If this is the beginning of a process or workflow, there may be a syntax error in the body, such as a missing or extra comma, for which a more specific error message could not be produced.
-- Check '.nextflow.log' file for details`
The content of the main.nf file can be seen below:
params.samples_json = "samples.json"
params.popmap = "popmap"
Channel
.fromPath(params.samples_json)
.set { samples_json_ch }
Channel
.fromPath(params.popmap)
.set { popmap_ch }
process download_samples {
container 'ghcr.io/dennislarsson/download-image:refs-tags-1.0.0-e2e677d'
input:
file samples_json from samples_json_ch
file popmap from popmap_ch
output:
file(*.fq.gz) into samples_ch
script:
"""
while IFS= read -r line; do
sample_name=$(echo "$line" | cut -f1)
id=$(jq -r --arg key "${sample_name}.fq.gz" '.[$key]' $samples_json)
if [[ $id == "null" ]]; then
echo "Error: Sample ${sample_name}.fq.gz not found in samples.json" >&2
exit 1
else
gdown $id --output "${sample_name}.fq.gz"
fi
done < $popmap
"""
}
workflow {
download_samples
}
Does anyone know what is causing the syntax error?
For context this is the content of the .nextflow.log file:
Jun-19 14:27:08.602 [main] DEBUG nextflow.cli.Launcher - $> nextflow run main.nf --samples_json test_samples.json --popmap popmap_test
Jun-19 14:27:08.673 [main] DEBUG nextflow.cli.CmdRun - N E X T F L O W ~ version 24.04.0-edge
Jun-19 14:27:08.709 [main] DEBUG nextflow.plugin.PluginsFacade - Setting up plugin manager > mode=prod; embedded=false; plugins-dir=/root/.nextflow/plugins; core-plugins: nf-amazon@2.5.0,nf-azure@1.6.0,nf-cloudcache@0.4.1,nf-codecommit@0.2.0,nf-console@1.1.2,nf-ga4gh@1.3.0,nf-google@1.13.0,nf-tower@1.9.1,nf-wave@1.4.1
Jun-19 14:27:08.725 [main] INFO o.pf4j.DefaultPluginStatusProvider - Enabled plugins: []
Jun-19 14:27:08.726 [main] INFO o.pf4j.DefaultPluginStatusProvider - Disabled plugins: []
Jun-19 14:27:08.731 [main] INFO org.pf4j.DefaultPluginManager - PF4J version 3.10.0 in 'deployment' mode
Jun-19 14:27:08.754 [main] INFO org.pf4j.AbstractPluginManager - No plugins
Jun-19 14:27:08.834 [main] DEBUG n.secret.LocalSecretsProvider - Secrets store: /root/.nextflow/secrets/store.json
Jun-19 14:27:08.852 [main] DEBUG nextflow.secret.SecretsLoader - Discovered secrets providers: [nextflow.secret.LocalSecretsProvider@6d64b553] - activable => nextflow.secret.LocalSecretsProvider@6d64b553
Jun-19 14:27:08.912 [main] DEBUG nextflow.cli.CmdRun - Applied DSL=2 by global default
Jun-19 14:27:08.941 [main] DEBUG nextflow.cli.CmdRun - Launching `main.nf` [cheesy_perlman] DSL2 - revision: 188cdd7a95
Jun-19 14:27:08.943 [main] DEBUG nextflow.plugin.PluginsFacade - Plugins default=[]
Jun-19 14:27:08.943 [main] DEBUG nextflow.plugin.PluginsFacade - Plugins resolved requirement=[]
Jun-19 14:27:09.037 [main] DEBUG nextflow.Session - Session UUID: 2a54db1a-55dc-4e25-a0b5-529f38c77d5b
Jun-19 14:27:09.038 [main] DEBUG nextflow.Session - Run name: cheesy_perlman
Jun-19 14:27:09.038 [main] DEBUG nextflow.Session - Executor pool size: 12
Jun-19 14:27:09.051 [main] DEBUG nextflow.file.FilePorter - File porter settings maxRetries=3; maxTransfers=50; pollTimeout=null
Jun-19 14:27:09.059 [main] DEBUG nextflow.util.ThreadPoolBuilder - Creating thread pool 'FileTransfer' minSize=10; maxSize=36; workQueue=LinkedBlockingQueue[10000]; allowCoreThreadTimeout=false
Jun-19 14:27:09.099 [main] DEBUG nextflow.cli.CmdRun -
Version: 24.04.0-edge build 5911
Created: 13-05-2024 09:18 UTC (09:18 GMT)
System: Linux 5.15.153.1-microsoft-standard-WSL2
Runtime: Groovy 4.0.21 on OpenJDK 64-Bit Server VM 11.0.23+9-post-Ubuntu-1ubuntu122.04.1
Encoding: UTF-8 (ANSI_X3.4-1968)
Process: 11@ff40bb5f9452 [172.17.0.2]
CPUs: 12 - Mem: 7.6 GB (6.4 GB) - Swap: 2 GB (2 GB)
Jun-19 14:27:09.125 [main] DEBUG nextflow.Session - Work-dir: /work [overlayfs]
Jun-19 14:27:09.172 [main] DEBUG nextflow.executor.ExecutorFactory - Extension executors providers=[]
Jun-19 14:27:09.196 [main] DEBUG nextflow.Session - Observer factory: DefaultObserverFactory
Jun-19 14:27:09.233 [main] DEBUG nextflow.cache.CacheFactory - Using Nextflow cache factory: nextflow.cache.DefaultCacheFactory
Jun-19 14:27:09.247 [main] DEBUG nextflow.util.CustomThreadPool - Creating default thread pool > poolSize: 13; maxThreads: 1000
Jun-19 14:27:09.325 [main] DEBUG nextflow.Session - Session start
Jun-19 14:27:09.335 [main] DEBUG nextflow.Session - Using default localLib path: /lib
Jun-19 14:27:09.343 [main] DEBUG nextflow.Session - Adding to the classpath library: /lib
Jun-19 14:27:09.586 [main] DEBUG nextflow.script.ScriptRunner - Parsed script files:
Jun-19 14:27:09.595 [main] ERROR nextflow.cli.Launcher - Script compilation error
- file : /main.nf
- cause: Unexpected input: '{' @ line 12, column 26.
process download_samples {
^
1 error
NOTE: If this is the beginning of a process or workflow, there may be a syntax error in the body, such as a missing or extra comma, for which a more specific error message could not be produced.
nextflow.exception.ScriptCompilationException: Script compilation error
- file : /main.nf
- cause: Unexpected input: '{' @ line 12, column 26.
process download_samples {
^
1 error
NOTE: If this is the beginning of a process or workflow, there may be a syntax error in the body, such as a missing or extra comma, for which a more specific error message could not be produced.
at nextflow.script.ScriptParser.parse0(ScriptParser.groovy:196)
at nextflow.script.ScriptParser.parse(ScriptParser.groovy:206)
at nextflow.script.ScriptRunner.parseScript(ScriptRunner.groovy:229)
at nextflow.script.ScriptRunner.execute(ScriptRunner.groovy:136)
at nextflow.cli.CmdRun.run(CmdRun.groovy:368)
at nextflow.cli.Launcher.run(Launcher.groovy:503)
at nextflow.cli.Launcher.main(Launcher.groovy:657)
Caused by: org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
Script_fd9362748aaedef1: 12: Unexpected input: '{' @ line 12, column 26.
process download_samples {
^
1 error
at org.codehaus.groovy.control.ErrorCollector.failIfErrors(ErrorCollector.java:292)
at org.codehaus.groovy.control.ErrorCollector.addFatalError(ErrorCollector.java:148)
at org.apache.groovy.parser.antlr4.AstBuilder.collectSyntaxError(AstBuilder.java:4753)
at org.apache.groovy.parser.antlr4.AstBuilder.access$100(AstBuilder.java:169)
at org.apache.groovy.parser.antlr4.AstBuilder$3.syntaxError(AstBuilder.java:4764)
at groovyjarjarantlr4.v4.runtime.ProxyErrorListener.syntaxError(ProxyErrorListener.java:44)
at groovyjarjarantlr4.v4.runtime.Parser.notifyErrorListeners(Parser.java:543)
at groovyjarjarantlr4.v4.runtime.DefaultErrorStrategy.notifyErrorListeners(DefaultErrorStrategy.java:154)
at org.apache.groovy.parser.antlr4.internal.DescriptiveErrorStrategy.reportInputMismatch(DescriptiveErrorStrategy.java:104)
at org.apache.groovy.parser.antlr4.internal.DescriptiveErrorStrategy.recover(DescriptiveErrorStrategy.java:55)
at org.apache.groovy.parser.antlr4.internal.DescriptiveErrorStrategy.recoverInline(DescriptiveErrorStrategy.java:68)
at groovyjarjarantlr4.v4.runtime.Parser.match(Parser.java:213)
at org.apache.groovy.parser.antlr4.GroovyParser.compilationUnit(GroovyParser.java:368)
at org.apache.groovy.parser.antlr4.AstBuilder.buildCST(AstBuilder.java:243)
at org.apache.groovy.parser.antlr4.AstBuilder.buildCST(AstBuilder.java:221)
at org.apache.groovy.parser.antlr4.AstBuilder.buildAST(AstBuilder.java:262)
at org.apache.groovy.parser.antlr4.Antlr4ParserPlugin.buildAST(Antlr4ParserPlugin.java:58)
at org.codehaus.groovy.control.SourceUnit.buildAST(SourceUnit.java:256)
at java.base/java.util.Iterator.forEachRemaining(Iterator.java:133)
at java.base/java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1801)
at java.base/java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:658)
at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:663)
at groovy.lang.GroovyClassLoader.doParseClass(GroovyClassLoader.java:373)
at groovy.lang.GroovyClassLoader.lambda$parseClass$2(GroovyClassLoader.java:316)
at org.codehaus.groovy.runtime.memoize.StampedCommonCache.compute(StampedCommonCache.java:163)
at org.codehaus.groovy.runtime.memoize.StampedCommonCache.getAndPut(StampedCommonCache.java:154)
at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:314)
at groovy.lang.GroovyShell.parseClass(GroovyShell.java:572)
at groovy.lang.GroovyShell.parse(GroovyShell.java:585)
at groovy.lang.GroovyShell.parse(GroovyShell.java:639)
at groovy.lang.GroovyShell.parse(GroovyShell.java:643)
at nextflow.script.ScriptParser.parse0(ScriptParser.groovy:175)
... 6 common frames omitted
I should also mention that I have also tried using nextflow 23.01 and 21.01 and I still get the same error.