sanger-pathogens / seroba

k-mer based Pipeline to identify the Serotype from Illumina NGS reads
https://sanger-pathogens.github.io/seroba/
Other
19 stars 16 forks source link

let tempfile determine temp dir location #68

Open rpetit3 opened 2 years ago

rpetit3 commented 2 years ago

I ran into the following issue trying to use the Seroba docker container

docker run --rm -u $(id -u):$(id -g) -v ${PWD}:/data quay.io/biocontainers/seroba:1.0.2--pyhdfd78af_1 seroba runSerotyping /data/sample7_1.fq.gz /data/sample7_2.fq.gz /data/test7
Traceback (most recent call last):
  File "/usr/local/bin/seroba", line 88, in <module>
    args.func(args)
  File "/usr/local/lib/python3.8/site-packages/seroba/tasks/sero_run.py", line 19, in run
    sero.run()
  File "/usr/local/lib/python3.8/site-packages/seroba/serotyping.py", line 468, in run
    self._run_kmc()
  File "/usr/local/lib/python3.8/site-packages/seroba/serotyping.py", line 55, in _run_kmc
    temp_dir = tempfile.mkdtemp(prefix = 'temp.kmc', dir=os.getcwd())
  File "/usr/local/lib/python3.8/tempfile.py", line 358, in mkdtemp
    _os.mkdir(file, 0o700)
PermissionError: [Errno 13] Permission denied: '/temp.kmco4ebdaal'

This PR allows tempfile to figure out where to make the temp dir (see https://docs.python.org/3/library/tempfile.html#tempfile.gettempdir)

Python searches a standard list of directories to find one which the calling user can create files in. The list is:

The directory named by the TMPDIR environment variable.
The directory named by the TEMP environment variable.
The directory named by the TMP environment variable.
A platform-specific location:
    - On Windows, the directories C:\TEMP, C:\TMP, \TEMP, and \TMP, in that order
    - On all other platforms, the directories /tmp, /var/tmp, and /usr/tmp, in that order.

As a last resort, the current working directory.