r3fang / SnapTools

A module for working with snap files in Python
Apache License 2.0
35 stars 21 forks source link

Cyclic dependency for make bmat #7

Open Zepeng-Mu opened 5 years ago

Zepeng-Mu commented 5 years ago

Hi, I think it makes sense to put the binary matrix in the same snap file as input. However, this can create a "cyclic dependency" when using tools like snakemake, because the input name and the output name are the same.

Is there any way to circumvent this?

Many thanks

r3fang commented 5 years ago

Hi Zepeng,

Thanks for trying! I don't use snalemake myself but one of my labmate does and he has figured this out, i will ask him tomorrow and get you back tomorrow.

R

r3fang commented 5 years ago

Hi Zepeng,

I get back from my lab mate, he just create another file as output {dissection}/{dataset}/{dataset}.snap.add_bmat.ok

rule snap_add_bmat:
    input:
        snap="{dissection}/{dataset}/{dataset}.snap"
    output:
        "{dissection}/{dataset}/{dataset}.snap.add_bmat.ok"
    params:
        jobname = "{dataset}.snap_add_bmat"
    benchmark:
        "benchmarks/{dissection}/{dataset}.snap_add_bmat.benchmark"
    log:
        "log/{dissection}/{dataset}.snap_add_bmat.log"
    shell:
        """
        /home/yangli1/apps/anaconda2/bin/snaptools snap-add-bmat \
        --snap-file={input.snap} \
        --bin-size-list 1000 5000 10000 \
        --verbose=True &> {log}
        echo "Done" > {output}
        """

Let me know if this does not solve your question

Zepeng-Mu commented 5 years ago

Yeah, I actually also thought about this, this seems to be the only way. Thanks!