sidbdri / cookiecutter-de_analysis_skeleton

Skeleton for new differential expression analysis project.
3 stars 1 forks source link

use post-hook to record project setup parameter #151

Closed hxin closed 3 years ago

hxin commented 3 years ago

We want to be able to re-create the project using cookie-cutter with the init parameter.

This can be done using post-hook

hxin commented 3 years ago

It seems that the dictionary parameter cannot be passed via the command line...?

hxin commented 3 years ago

so there are a few approach for this I guess...

from cookiecutter.main import cookiecutter
cookiecutter('/home/xinhe/Projects/cookiecutter-de_analysis_skeleton',
             no_input=True,
             extra_context={
                 "project_name": 'name',
                 "projects_base": 'Projects',
                 "gtf_files": {
                     "mouse": "Mus_musculus.GRCm38.95.gtf",
                     "human": "Homo_sapiens.GRCh38.95.gtf",
                     "rat": "Rattus_norvegicus.Rnor_6.0.95.gtf"
                 }
             })

Since this is a new feature already in the cookie-cutter master branch, should we update cookie-cutter to use this, or should we try the python approach which a similar task? @lweasel

lweasel commented 3 years ago

So weirdly, although I couldn't actually find it in the documentation, it seems that you can supply extra context on the command line, e.g.,

> cookiecutter https://github.com/sidbdri/cookiecutter-de_analysis_skeleton
You've cloned /home/odando/.cookiecutters/cookiecutter-de_analysis_skeleton before. Is it okay to delete and re-clone it? [yes]: 
project_name [newproject]:

but...

cookiecutter https://github.com/sidbdri/cookiecutter-de_analysis_skeleton project_name=hello
You've cloned /home/odando/.cookiecutters/cookiecutter-de_analysis_skeleton before. Is it okay to delete and re-clone it? [yes]: 
project_name [hello]:

So, perhaps we could use a post-hook to take a JSON file that has been created with {{ cookiecutter | jsonify }} and turn it into a command with all the option choices as these key=value pairs (and record that command in a bash script)? What do you think @hxin ?

hxin commented 3 years ago

yes you can provide extra context in commandline options but I don't think it is possible to pass those dictionary parameter in commandlline, i.e you WON'T be able to do this: cookiecutter https://github.com/sidbdri/cookiecutter-de_analysis_skeleton gtf_files= { "mouse": "Mus_musculus.GRCm38.95.gtf", "human": "Homo_sapiens.GRCh38.95.gtf", "rat": "Rattus_norvegicus.Rnor_6.0.95.gtf" }

lweasel commented 3 years ago

Oh, right, sorry - I understand now. Hmm.

lweasel commented 3 years ago

However @hxin ...I can't remember a time when I've actually changed any of those dictionary parameters, I pretty much always use the defaults (which themselves depend on the Ensembl version). Could we get 90% of the way there by just creating a command which passes in the non-dictionary parameters?

hxin commented 3 years ago

yes

lweasel commented 3 years ago

So perhaps let's not worry about the dict parameters for now? I think we can get nearly all the useful functionality from creating a bash command for the non-dict parameters.

hxin commented 3 years ago

we can use the python way to re-create the project tho, which can handle the dictionary parameter?

lweasel commented 3 years ago

✔️