1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170
|
rule all:
input: "simple_shallow.out", "simple_full.out",
"absolute_exists.out", "touched.out", "log_exists.out",
"protected.out", "benchmark_exists.out", "minimal_ok.out"
rule shallow:
input: "test.in"
output: "simple_shallow.out"
shadow: "shallow"
shell:
"""
echo 1 > junk.out
cat {input} >> {output}
echo simple_shallow >> {output}
test ! -f more_junk.out
"""
rule full:
input: "test.in"
output: "simple_full.out"
shadow: "full"
shell:
"""
echo 1 > more_junk.out
cat {input} > {output}
echo simple_full >> {output}
test ! -f junk.out
"""
rule absolute_link:
input: "test.in"
output: "absolute.out", "absolute_link.out"
shadow: "shallow"
shell:
"""
echo 1 > absolute.out
DIRNAME=$(perl -e 'use Cwd "abs_path"; print abs_path(shift)' .)
ln -s $DIRNAME/absolute.out absolute_link.out
"""
# Snakemake has check_broken_symlink so we just need to test existence
rule absolute_stat:
input: "absolute_link.out"
output: touch("absolute_exists.out")
shell:
"""
test -f {input}
"""
rule log_stat:
input: "touched.out"
output: touch("log_exists.out")
shell:
"""
test -f shadow.log
"""
rule touch:
output: touch("touched.out")
log: "shadow.log"
shadow: "shallow"
shell:
"""
echo 1 > {log}
"""
rule protected:
output: protected("protected.out")
shadow: "shallow"
shell:
"""
touch {output}
"""
rule benchmark:
output: touch("benchmark.out")
benchmark: "benchmark.txt"
shadow: "shallow"
shell:
"""
touch {output}
"""
rule benchmark_stat:
input: "benchmark.out"
output: touch("benchmark_exists.out")
shell:
"""
test -f benchmark.txt
"""
# Setup files for testing of shadow: "minimal"
rule minimal_setup:
input: "test.in"
output:
"subdir1/subdir2/test.in",
"subdir1/subdir2/test.symbolic.in"
shell:
"""
cp -P {input} {output[0]}
cd subdir1/subdir2
ln -s test.in test.symbolic.in
"""
# Tests relative inputs/outputs and in the current dir
rule minimal_rel_curdir:
input: "test.in"
output: protected("simple_minimal.out")
benchmark: "benchmark_minimal.txt"
log: "minimal.log"
shadow: "minimal"
shell:
"""
touch minimal_junk.out
cat {input} >> {output}
echo simple_minimal >> {output}
echo minimal_log > {log}
"""
# Tests relative inputs/outputs in subdirectories
rule minimal_rel_subdir:
input: "subdir1/subdir2/test.in"
output: "outdir/minimal.out"
shadow: "minimal"
shell:
"""
touch outdir/minimal_junk.out
touch {output}
"""
# Tests symbolic input/output
rule minimal_symbolic:
input: "subdir1/subdir2/test.symbolic.in"
output: "outdir/minimal_real.out",
"outdir/minimal_symbolic.out"
shadow: "minimal"
shell:
"""
touch outdir/minimal_real.out
cd outdir
ln -s minimal_real.out minimal_symbolic.out
"""
# Tests absolute input/output
rule minimal_absolute:
input:
os.path.join(os.getcwd(),"test.in")
output: os.path.join(os.getcwd(),"outdir/minimal_absolute.out")
shadow: "minimal"
shell:
"""
touch {output}
"""
# Aggregates tests for shadow: "minimal"
rule minimal_ok:
input: "simple_minimal.out",
"outdir/minimal.out",
"outdir/minimal_symbolic.out",
os.path.join(os.getcwd(),"outdir/minimal_absolute.out")
output: "minimal_ok.out"
shell:
"""
#test ! -w {input[0]}
test -f benchmark_minimal.txt
test -f minimal.log
test ! -f minimal_junk.out
test ! -f outdir/minimal_junk.out
touch {output}
"""
|