This is a test version of Biostars. For the public version, visit https://www.biostars.org.
cutadapt not working when calling in a bash code with qsub

I am using a server that allows job submission via qsub. In the interactive mode, cutadapt works fine, but when I try to run a pipeline that uses cutadapt with qsub like : qsub -cwd run_script.sh I get the following error and trimming does not happen:

 Traceback (most recent call last):
  File "/mnt/storage/apps/Python-3.6.13/bin/cutadapt", line 8, in <module>
    sys.exit(main_cli())
  File "/mnt/storage/apps/Python-3.6.13/lib/python3.6/site-packages/cutadapt/__main__.py", line 965, in main_cli
    main(sys.argv[1:])
  File "/mnt/storage/apps/Python-3.6.13/lib/python3.6/site-packages/cutadapt/__main__.py", line 1028, in main
    args, default_outfile, file_opener, adapter_names, adapter_names2
  File "/mnt/storage/apps/Python-3.6.13/lib/python3.6/site-packages/cutadapt/__main__.py", line 508, in open_output_files
    out, out2 = file_opener.xopen_pair(args.output, args.paired_output, "wb")
  File "/mnt/storage/apps/Python-3.6.13/lib/python3.6/site-packages/cutadapt/utils.py", line 222, in xopen_pair
    file1 = self.xopen_or_none(path1, mode)
  File "/mnt/storage/apps/Python-3.6.13/lib/python3.6/site-packages/cutadapt/utils.py", line 214, in xopen_or_none
    return self.xopen(path, mode)
  File "/mnt/storage/apps/Python-3.6.13/lib/python3.6/site-packages/cutadapt/utils.py", line 205, in xopen
    xopen, path, mode, compresslevel=self.compression_level, threads=threads
  File "/mnt/storage/apps/Python-3.6.13/lib/python3.6/site-packages/cutadapt/utils.py", line 51, in open_raise_limit
    f = func(*args, **kwargs)
  File "/mnt/storage/apps/Python-3.6.13/lib/python3.6/site-packages/xopen/__init__.py", line 827, in xopen
    opened_file = open(filename, mode, **text_mode_kwargs)
FileNotFoundError: [Errno 2] No such file or directory: '${trimmed_dir}/r1.fq'

I have specified export PATH="/mnt/storage/apps/Python-3.6.13/bin:$PATH" at the beginning of my code, but still I get the same error.

cross posted here : https://stackoverflow.com/questions/79071046/cutadapt-not-working-when-calling-in-a-bash-code-with-qsub

qsub trim cutadpat

1 answer

no such file or directory: '${trimmed_dir}/r1.fq

it looks like you escaped a dollar sign in your script. The variable is not replaced (used in single quote ? an antislash before the '$' ? , etc...)

So,

no such file or directory: '${trimmed_dir}/r1.fq

refers to the output of the cutadapt. since cutadapt did not work , the script could not find the output either.

Please show full script and replace the single by double quotes so the variable can expand.

Log in to answer this question.