define alternative rules with snakemake












0















Hello I am new with snakemake and I need some help.



My goal is to index a genome (with bowtie2)
But I need some alternative steps depending of the files that are available



1> check if index already exist in storage (/storage/index)
2> if yes, copy index in local (/index)
3> if no, create index in local (/index)
4> then copy new index in storage (/storage/index)


I managed to setup a bash script to check the existing file and the alternative workflows. But I wish to use snakemake and I am not sure how to define the rules to obtain a similar behavior.










share|improve this question























  • I would suggest showing what you have tried so far and where you ran into problems.

    – JeeYem
    Jan 2 at 16:53
















0















Hello I am new with snakemake and I need some help.



My goal is to index a genome (with bowtie2)
But I need some alternative steps depending of the files that are available



1> check if index already exist in storage (/storage/index)
2> if yes, copy index in local (/index)
3> if no, create index in local (/index)
4> then copy new index in storage (/storage/index)


I managed to setup a bash script to check the existing file and the alternative workflows. But I wish to use snakemake and I am not sure how to define the rules to obtain a similar behavior.










share|improve this question























  • I would suggest showing what you have tried so far and where you ran into problems.

    – JeeYem
    Jan 2 at 16:53














0












0








0








Hello I am new with snakemake and I need some help.



My goal is to index a genome (with bowtie2)
But I need some alternative steps depending of the files that are available



1> check if index already exist in storage (/storage/index)
2> if yes, copy index in local (/index)
3> if no, create index in local (/index)
4> then copy new index in storage (/storage/index)


I managed to setup a bash script to check the existing file and the alternative workflows. But I wish to use snakemake and I am not sure how to define the rules to obtain a similar behavior.










share|improve this question














Hello I am new with snakemake and I need some help.



My goal is to index a genome (with bowtie2)
But I need some alternative steps depending of the files that are available



1> check if index already exist in storage (/storage/index)
2> if yes, copy index in local (/index)
3> if no, create index in local (/index)
4> then copy new index in storage (/storage/index)


I managed to setup a bash script to check the existing file and the alternative workflows. But I wish to use snakemake and I am not sure how to define the rules to obtain a similar behavior.







snakemake






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Jan 2 at 7:47









Maxime HebrardMaxime Hebrard

285




285













  • I would suggest showing what you have tried so far and where you ran into problems.

    – JeeYem
    Jan 2 at 16:53



















  • I would suggest showing what you have tried so far and where you ran into problems.

    – JeeYem
    Jan 2 at 16:53

















I would suggest showing what you have tried so far and where you ran into problems.

– JeeYem
Jan 2 at 16:53





I would suggest showing what you have tried so far and where you ran into problems.

– JeeYem
Jan 2 at 16:53












1 Answer
1






active

oldest

votes


















0














Your psedocode logic, as it is, seems to create cyclical dependency problem in snakemake. So to make it simpler, I changed step3 to if no, create new index in storage (/storage/index) and this allows step4 to be same as step1.



rule create_index:
input:
"/storage/index/a.fa"
output:
"/storage/index/a.idx"
message:
"Create index at source dir"
shell:
'''
index_tool {input} {output}
'''


rule copy_index:
input:
"/storage/index/a.idx"
output:
"/local/index/a.idx"
message:
"copy index to local dir"
shell:
'''
cp {input} {output}
'''





share|improve this answer
























  • I get your point. But in my setup I cannot create the index directly in storage. I need to create the index in local then copy into storage.

    – Maxime Hebrard
    Jan 3 at 9:45











  • I assumed this would be possible because of your step4. An ugly workaround is you exclude input:, just define output:, and let your bash script do the job for you. Of course, you will be missing out on snakemake's advantages.

    – JeeYem
    Jan 3 at 15:59











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54002881%2fdefine-alternative-rules-with-snakemake%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














Your psedocode logic, as it is, seems to create cyclical dependency problem in snakemake. So to make it simpler, I changed step3 to if no, create new index in storage (/storage/index) and this allows step4 to be same as step1.



rule create_index:
input:
"/storage/index/a.fa"
output:
"/storage/index/a.idx"
message:
"Create index at source dir"
shell:
'''
index_tool {input} {output}
'''


rule copy_index:
input:
"/storage/index/a.idx"
output:
"/local/index/a.idx"
message:
"copy index to local dir"
shell:
'''
cp {input} {output}
'''





share|improve this answer
























  • I get your point. But in my setup I cannot create the index directly in storage. I need to create the index in local then copy into storage.

    – Maxime Hebrard
    Jan 3 at 9:45











  • I assumed this would be possible because of your step4. An ugly workaround is you exclude input:, just define output:, and let your bash script do the job for you. Of course, you will be missing out on snakemake's advantages.

    – JeeYem
    Jan 3 at 15:59
















0














Your psedocode logic, as it is, seems to create cyclical dependency problem in snakemake. So to make it simpler, I changed step3 to if no, create new index in storage (/storage/index) and this allows step4 to be same as step1.



rule create_index:
input:
"/storage/index/a.fa"
output:
"/storage/index/a.idx"
message:
"Create index at source dir"
shell:
'''
index_tool {input} {output}
'''


rule copy_index:
input:
"/storage/index/a.idx"
output:
"/local/index/a.idx"
message:
"copy index to local dir"
shell:
'''
cp {input} {output}
'''





share|improve this answer
























  • I get your point. But in my setup I cannot create the index directly in storage. I need to create the index in local then copy into storage.

    – Maxime Hebrard
    Jan 3 at 9:45











  • I assumed this would be possible because of your step4. An ugly workaround is you exclude input:, just define output:, and let your bash script do the job for you. Of course, you will be missing out on snakemake's advantages.

    – JeeYem
    Jan 3 at 15:59














0












0








0







Your psedocode logic, as it is, seems to create cyclical dependency problem in snakemake. So to make it simpler, I changed step3 to if no, create new index in storage (/storage/index) and this allows step4 to be same as step1.



rule create_index:
input:
"/storage/index/a.fa"
output:
"/storage/index/a.idx"
message:
"Create index at source dir"
shell:
'''
index_tool {input} {output}
'''


rule copy_index:
input:
"/storage/index/a.idx"
output:
"/local/index/a.idx"
message:
"copy index to local dir"
shell:
'''
cp {input} {output}
'''





share|improve this answer













Your psedocode logic, as it is, seems to create cyclical dependency problem in snakemake. So to make it simpler, I changed step3 to if no, create new index in storage (/storage/index) and this allows step4 to be same as step1.



rule create_index:
input:
"/storage/index/a.fa"
output:
"/storage/index/a.idx"
message:
"Create index at source dir"
shell:
'''
index_tool {input} {output}
'''


rule copy_index:
input:
"/storage/index/a.idx"
output:
"/local/index/a.idx"
message:
"copy index to local dir"
shell:
'''
cp {input} {output}
'''






share|improve this answer












share|improve this answer



share|improve this answer










answered Jan 2 at 23:21









JeeYemJeeYem

1,227924




1,227924













  • I get your point. But in my setup I cannot create the index directly in storage. I need to create the index in local then copy into storage.

    – Maxime Hebrard
    Jan 3 at 9:45











  • I assumed this would be possible because of your step4. An ugly workaround is you exclude input:, just define output:, and let your bash script do the job for you. Of course, you will be missing out on snakemake's advantages.

    – JeeYem
    Jan 3 at 15:59



















  • I get your point. But in my setup I cannot create the index directly in storage. I need to create the index in local then copy into storage.

    – Maxime Hebrard
    Jan 3 at 9:45











  • I assumed this would be possible because of your step4. An ugly workaround is you exclude input:, just define output:, and let your bash script do the job for you. Of course, you will be missing out on snakemake's advantages.

    – JeeYem
    Jan 3 at 15:59

















I get your point. But in my setup I cannot create the index directly in storage. I need to create the index in local then copy into storage.

– Maxime Hebrard
Jan 3 at 9:45





I get your point. But in my setup I cannot create the index directly in storage. I need to create the index in local then copy into storage.

– Maxime Hebrard
Jan 3 at 9:45













I assumed this would be possible because of your step4. An ugly workaround is you exclude input:, just define output:, and let your bash script do the job for you. Of course, you will be missing out on snakemake's advantages.

– JeeYem
Jan 3 at 15:59





I assumed this would be possible because of your step4. An ugly workaround is you exclude input:, just define output:, and let your bash script do the job for you. Of course, you will be missing out on snakemake's advantages.

– JeeYem
Jan 3 at 15:59




















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54002881%2fdefine-alternative-rules-with-snakemake%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Monofisismo

Angular Downloading a file using contenturl with Basic Authentication

Olmecas