phac-nml / staramr

Scans genome contigs against the ResFinder, PlasmidFinder, and PointFinder databases.
Apache License 2.0
120 stars 26 forks source link

docker image v0.8.0 does not accept --user #204

Closed splaisan closed 1 year ago

splaisan commented 1 year ago

Hi,

When I run without --user "$(id -u):$(id -g)" the docker executes and I get results owned by root

image="staphb/staramr:latest"
docker pull ${image}
docker run -it --rm  -v $PWD:/data  ${image}   staramr search   -o /data/staramr_results   /data/bc${bc}_assembly.fasta`
2023-11-08 09:28:05 WARNING: Using non-default ResFinder/PointFinder. This may lead to differences in the detected AMR genes depending on how the database files are structured.
2023-11-08 09:28:05 INFO: No --pointfinder-organism specified. Will not search the PointFinder databases
2023-11-08 09:28:05 INFO: No --plasmidfinder-database-type specified. Will search the entire PlasmidFinder database
2023-11-08 09:28:05 INFO: --output-dir set. All files will be output to [/data/staramr_results]
2023-11-08 09:28:05 INFO: Will exclude ResFinder/PointFinder genes listed in [/usr/local/lib/python3.8/dist-packages/staramr/databases/exclude/data/genes_to_exclude.tsv]. Use --no-exclude-genes to disable
2023-11-08 09:28:05 INFO: Making BLAST databases for input files
2023-11-08 09:28:05 INFO: Scheduling blasts and MLST for bc01_assembly.fasta
2023-11-08 09:28:07 WARNING: No drug found for drug_class=disinfectant, gene=qacE_1, accession=X68232
2023-11-08 09:28:07 INFO: Finished. Took 0.04 minutes.
2023-11-08 09:28:07 INFO: Predicting AMR resistance phenotypes is enabled. The predictions are for microbiological resistance and *not* clinical resistance. These results are continually being improved and we welcome any feedback.
2023-11-08 09:28:07 INFO: Writing resfinder to [/data/staramr_results/resfinder.tsv]
2023-11-08 09:28:07 INFO: --output-dir or --output-pointfinder unset. No pointfinder file will be written
2023-11-08 09:28:07 INFO: Writing plasmidfinder to [/data/staramr_results/plasmidfinder.tsv]
2023-11-08 09:28:07 INFO: Writing summary to [/data/staramr_results/summary.tsv]
2023-11-08 09:28:07 INFO: Writing MLST summary to [/data/staramr_results/mlst.tsv]
2023-11-08 09:28:07 INFO: Writing detailed summary to [/data/staramr_results/detailed_summary.tsv]
2023-11-08 09:28:07 INFO: Writing settings to [/data/staramr_results/settings.txt]
2023-11-08 09:28:07 INFO: Writing Excel to [/data/staramr_results/results.xlsx]
2023-11-08 09:28:08 INFO: BLAST hits are stored in [/data/staramr_results/hits]

If I add --user to have results owned by me (much nicer for later cleanup)

docker run -it --rm --user "$(id -u):$(id -g)" -v $PWD:/data ${image} staramr search -o /data/staramr_results /data/bc${bc}_assembly.fasta

I get the error:

/data/bc${bc}_assembly.fasta
2023-11-08 09:23:48 ERROR: SHA could not be resolved, git returned: b''
Traceback (most recent call last):
  File "/usr/local/bin/staramr", line 68, in <module>
    args.run_command(args)
  File "/usr/local/lib/python3.8/dist-packages/staramr/subcommand/Search.py", line 363, in run
    if not AMRDatabasesManager.is_database_repos_default_commits(database_repos):
  File "/usr/local/lib/python3.8/dist-packages/staramr/databases/AMRDatabasesManager.py", line 89, in is_database_repos_default_commits
    return database_repos.is_at_commits(self.DEFAULT_COMMITS)
  File "/usr/local/lib/python3.8/dist-packages/staramr/databases/BlastDatabaseRepositories.py", line 118, in is_at_commits
    if name in commits and not repo.is_at_commit(commits[name]):
  File "/usr/local/lib/python3.8/dist-packages/staramr/databases/BlastDatabaseRepository.py", line 91, in is_at_commit
    return self.info()[self._get_info_name('commit')] == commit
  File "/usr/local/lib/python3.8/dist-packages/staramr/databases/BlastDatabaseRepository.py", line 102, in info
    repo_head = repo.commit('HEAD')
  File "/usr/local/lib/python3.8/dist-packages/git/repo/base.py", line 536, in commit
    return self.rev_parse(str(rev) + "^0")
  File "/usr/local/lib/python3.8/dist-packages/git/repo/fun.py", line 229, in rev_parse
    obj = cast(Commit_ish, name_to_object(repo, rev[:start]))
  File "/usr/local/lib/python3.8/dist-packages/git/repo/fun.py", line 166, in name_to_object
    return Object.new_from_sha(repo, hex_to_bin(hexsha))
  File "/usr/local/lib/python3.8/dist-packages/git/objects/base.py", line 85, in new_from_sha
    oinfo = repo.odb.info(sha1)
  File "/usr/local/lib/python3.8/dist-packages/git/db.py", line 43, in info
    hexsha, typename, size = self._git.get_object_header(bin_to_hex(binsha))
  File "/usr/local/lib/python3.8/dist-packages/git/cmd.py", line 1253, in get_object_header
    return self.__get_object_header(cmd, ref)
  File "/usr/local/lib/python3.8/dist-packages/git/cmd.py", line 1240, in __get_object_header
    return self._parse_object_header(cmd.stdout.readline())
  File "/usr/local/lib/python3.8/dist-packages/git/cmd.py", line 1198, in _parse_object_header
    raise ValueError("SHA could not be resolved, git returned: %r" % (header_line.strip()))
ValueError: SHA could not be resolved, git returned: b''

thanks for your help

apetkau commented 1 year ago

Hello @splaisan. Thanks so much for reporting the issue.

We do not maintain the staphb docker image. If I use the most recent version of staramr (0.10.0) through the Docker image on quay.io/biocontainers everything does work fine when specifying to run the command as my local user.

image="quay.io/biocontainers/staramr:0.10.0--pyhdfd78af_0"
docker pull ${image}
docker run -it --rm --user "$(id -u):$(id -g)" -v $PWD:/data ${image} staramr search -o /data/staramr_results /data/SRR1952908.fasta

I hope this helps.

splaisan commented 1 year ago

thanks a lot Aaron, I meanwhile used the dev version from the git but it is good to know that there is a better image out there

apetkau commented 1 year ago

You're welcome. Here's the list of all versions available on quay.io/biocontainers: https://quay.io/repository/biocontainers/staramr?tab=tags (biocontainers are automatically built for any software in bioconda).