Skip to content

Commit cb52845

Browse files
committed
New repeatLibrary config file param for skipping SpecialMaskContig rule.
1 parent cd3c38a commit cb52845

File tree

1 file changed

+26
-19
lines changed

1 file changed

+26
-19
lines changed

RepeatMaskGenome.snakefile

Lines changed: 26 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ configfile: "sd_analysis.json"
1010
if "asm" not in config and "assembly" in config:
1111
config["asm"] = config["assembly"]
1212

13-
asmFai=config["asm"] + ".fai"
13+
assembly="assembly.orig.fasta"
14+
asmFai="assembly.orig.fasta.fai"
15+
#asmFai=config["asm"] + ".fai"
1416
asmFaiFile=open(asmFai)
1517
contigs=[l.split()[0] for l in asmFaiFile]
1618
strIdx=[str(i) for i in range(0,len(contigs))]
@@ -27,7 +29,7 @@ rule all:
2729

2830
rule SplitContig:
2931
input:
30-
asm=config["asm"]
32+
asm=assembly
3133
output:
3234
contig="split/to_mask.{index}.fasta",
3335
params:
@@ -78,26 +80,31 @@ rule SpecialMaskContig:
7880
tmpdir=tempDir,
7981
sd=SD
8082
shell:"""
81-
mkdir -p t2t
82-
TEMP="$TMPDIR/$$_$RANDOM/"
83-
mkdir -p $TEMP
84-
#
85-
# Copy input file to temp dir that should have fast IO
86-
#
87-
{params.sd}/hardmask {input.mask} $TEMP/to_mask.{wildcards.index}.fasta && \
88-
pushd $TEMP && \
89-
RepeatMasker -nolow -libdir /home1/mchaisso/miniconda3/share/RepeatMasker/Libraries/Appended -species human -pa 8 -s -xsmall \"to_mask.{wildcards.index}.fasta\" && \
90-
popd && \
83+
if [ {params.repeatLibrary} != "na" ]
84+
then
85+
mkdir -p t2t
86+
TEMP="$TMPDIR/$$_$RANDOM/"
87+
mkdir -p $TEMP
88+
#
89+
# Copy input file to temp dir that should have fast IO
90+
#
91+
{params.sd}/hardmask {input.mask} $TEMP/to_mask.{wildcards.index}.fasta && \
92+
pushd $TEMP && \
93+
RepeatMasker -nolow -libdir /home1/mchaisso/miniconda3/share/RepeatMasker/Libraries/Appended -species human -pa 8 -s -xsmall \"to_mask.{wildcards.index}.fasta\" && \
94+
popd && \
9195
92-
if [ ! -e $TEMP/to_mask.\"{wildcards.index}\".fasta.masked ]; then
93-
ls -l masked/to_mask.\"{wildcards.index}\".fasta.masked
94-
cp masked/to_mask.\"{wildcards.index}\".fasta.masked t2t/to_mask.\"{wildcards.index}\".fasta.masked
95-
head -3 masked/to_mask.\"{wildcards.index}\".fasta.out > t2t/to_mask.\"{wildcards.index}\".fasta.out
96+
if [ ! -e $TEMP/to_mask.\"{wildcards.index}\".fasta.masked ]; then
97+
ls -l masked/to_mask.\"{wildcards.index}\".fasta.masked
98+
cp masked/to_mask.\"{wildcards.index}\".fasta.masked t2t/to_mask.\"{wildcards.index}\".fasta.masked
99+
head -3 masked/to_mask.\"{wildcards.index}\".fasta.out > t2t/to_mask.\"{wildcards.index}\".fasta.out
100+
else
101+
cp $TEMP/to_mask.\"{wildcards.index}\".fasta.* t2t/ || true
102+
fi
103+
rm -rf $TEMP
96104
else
97-
cp $TEMP/to_mask.\"{wildcards.index}\".fasta.* t2t/ || true
105+
echo "*** rule SpecialMaskContig made no change (skipped) ***" > t2t/to_mask.\"{wildcards.index}\".fasta.out
106+
cp {input.mask} t2t/to_mask.\"{wildcards.index}\".fasta.masked >> t2t/to_mask.\"{wildcards.index}\".fasta.out || true
98107
fi
99-
rm -rf $TEMP
100-
101108
"""
102109

103110
rule MergeMaskerRuns:

0 commit comments

Comments
 (0)