Search code examples
tildesnakemake

Using '~' (A.K.A. tilde) in input directive does not seem to work?


This is the first time I've tried to use a "~" in my input. It works when I convert the "~" to an absolute path.

Proof they are the same file:

(CentOS5-Compatible) [tboyarski@login2 6-bamMetrics]$ ls ~/share/references/rRNA.ensg72.hg19.interval_list
-rw-rw-r-- 1 fcchan users 24K Dec 12  2013 /home/tboyarski/share/references/rRNA.ensg72.hg19.interval_list

(CentOS5-Compatible) [tboyarski@login2 6-bamMetrics]$ ls /genesis/extscratch/clc/references/rRNA.ensg72.hg19.interval_list
-rw-rw-r-- 1 fcchan users 24K Dec 12  2013 /genesis/extscratch/clc/references/rRNA.ensg72.hg19.interval_list

(CentOS5-Compatible) [tboyarski@login2 6-bamMetrics]$ ls /home/tboyarski/share/references/rRNA.ensg72.hg19.interval_list
-rw-rw-r-- 1 fcchan users 24K Dec 12  2013 /home/tboyarski/share/references/rRNA.ensg72.hg19.interval_list

Doesn't work:

rule intervalList:
    input:
       "~/share/references/rRNA.ensg72.hg19.interval_list"

Works:

rule intervalList:
    input:
       "/home/tboyarski/share/references/rRNA.ensg72.hg19.interval_list"

I've only tried using it in the input directive at this time. I might spend a moment to see if it works as an output directive (not something I need, just curious).

Thoughts?

EDIT

@alvits Was able to point out that ~ is converted by the shell to ${HOME} before it gets evaluated. It would seem that when providing ~ to snakemake, this conversion does not occurr. Easy alternative is to just always use ${HOME}, which works both on MacOSX and Linux :).

I was able to use the following successfully:

rule intervalList:
    input:
       "${HOME}/share/references/rRNA.ensg72.hg19.interval_list"

Second EDIT

User pointed out what I thought was a solution was in fact not. Solution is to not use either "~" or "${HOME}" in the input directive.


Solution

  • I'm going to close this question.

    I ended up going with @alvits suggestion.

    I chose it because that is what tilde represents, so it makes sense to provide it in an non-referenced form.

    expanduser wrapping, although a possibility, is overkill for what is required.

    Thank you everyone for your help!

    2017/06/09 - EDIT: Don't use "~" or "${HOME}" in Snakemake inputs.

    After seeing the comment by Johannes Köster, I double checked what I had done, and I was unable to reproduce it.

    I'm sorry for the confusion. Thank you so much for catching this error J.K.

    I'm not sure what I had setup prior. I ended up changing the way the file is being used, even with git, I cannot reproduce it.