openvax / neoantigen-vaccine-pipeline

Bioinformatics pipeline for selecting patient-specific cancer neoantigen vaccines
Apache License 2.0
75 stars 25 forks source link

Relative path issue when running not in the repo directory #151

Open gongyixiao opened 2 years ago

gongyixiao commented 2 years ago

When running without docker ENTRYPOINT mode, when below command is used:

cd [some_dir]
python [path_to_neoantigen-vaccine-pipeline]/run_snakemake.py

The current working directory is some_dir

And this line: https://github.com/openvax/neoantigen-vaccine-pipeline/blob/d2af22c68a93a4b7b5e36d740fb16bdd84f5feb8/run_snakemake.py#L274 It will interpret the relative path from some_dir and think pipeline/reference_Snakefile is in [some_dir]/pipeline/reference_Snakefile, but in fact it is in [path_to_neoantigen-vaccine-pipeline]/pipeline/reference_Snakefile

It's not appropriate to assume people will run run_snakemake.py from the [path_to_neoantigen-vaccine-pipeline] all the time.

This is critical when running in singularity because you need to be able to run python [path_to_neoantigen-vaccine-pipeline] outside of the singularity container to for example submit a singularity job.

I purpose the following change which won't change any current behavior but at the same time fix the issue:

https://github.com/openvax/neoantigen-vaccine-pipeline/blob/d2af22c68a93a4b7b5e36d740fb16bdd84f5feb8/run_snakemake.py#L21 Change to:

from os.path import dirname, isfile, join, basename, splitext, exists, realpath

https://github.com/openvax/neoantigen-vaccine-pipeline/blob/d2af22c68a93a4b7b5e36d740fb16bdd84f5feb8/run_snakemake.py#L274 Change to:

dirname(realpath(__file__))+'/'+'pipeline/reference_Snakefile',

https://github.com/openvax/neoantigen-vaccine-pipeline/blob/d2af22c68a93a4b7b5e36d740fb16bdd84f5feb8/run_snakemake.py#L305 Change to:

dirname(realpath(__file__))+'/'+'pipeline/reference_Snakefile',