Skip to content

Commit

Permalink
Fix handling of pre-corrected reads, always operate in HPC space
Browse files Browse the repository at this point in the history
  • Loading branch information
skoren committed Mar 12, 2024
1 parent fe736ea commit fc890f7
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 22 deletions.
14 changes: 3 additions & 11 deletions src/Snakefiles/1-buildGraph.sm
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def toFloat(val):

rule buildGraph:
input:
reads = {rules.correctHiFi.output.fasta} if config['correction_enabled'] == "True" else HIFI_READS,
reads = {rules.correctHiFi.output.fasta},
output:
graph = '1-buildGraph/hifi-resolved.gfa',
hificov = '1-buildGraph/hifi_nodecov.csv',
Expand All @@ -44,7 +44,6 @@ rule buildGraph:
err = '1-buildGraph/buildGraph.err'
params:
MBG = config['MBG'],
corenable = config['correction_enabled'],

baseK = config['mbg_baseK'],
maxK = config['mbg_maxK'],
Expand Down Expand Up @@ -77,15 +76,8 @@ iopt=""

echo "Building graph with reads:"

if [ "{params.corenable}" = "True" ] ; then
echo " ../{input.reads}"
iopt="-i ../{input.reads}"
else
for rf in {HIFI_READS} ; do
echo " \$rf"
iopt="\$iopt -i \$rf"
done
fi
echo " ../{input.reads}"
iopt="-i ../{input.reads}"

echo ""
echo ""
Expand Down
18 changes: 13 additions & 5 deletions src/Snakefiles/c4-findErrors.sm
Original file line number Diff line number Diff line change
Expand Up @@ -153,16 +153,17 @@ def fixErrorsP(wildcards):
rule fixErrors:
input:
seqstore = {rules.buildStore.output.seqstore},
ovlstore = {rules.combineOverlaps.output.ovlstore},
reds = fixErrorsI,
finished = {rules.configureFindErrors.output.finished}
ovlstore = {rules.combineOverlaps.output.ovlstore} if config['correction_enabled'] == "True" else {rules.emptyfile.output},
reds = fixErrorsI if config['correction_enabled'] == "True" else {rules.emptyfile.output},
finished = {rules.configureFindErrors.output.finished} if config['correction_enabled'] == "True" else {rules.emptyfile.output}
output:
red = '0-correction/red.red',
fasta = '0-correction/hifi-corrected.fasta.gz'
log:
err = "0-correction/fixErrors.err"
params:
paths = fixErrorsP
paths = fixErrorsP,
corenable = config['correction_enabled']
threads:
1
resources:
Expand All @@ -181,8 +182,15 @@ echo ""
echo Combine corrections.
echo ""

if [ "{params.corenable}" = "False" ] ; then
prefix=\\$(echo ../{output.fasta} | sed s/.fasta//)
{VERKKO}/bin/sqStoreDumpFASTQ -S ../{input.seqstore} -corrected -compressed -fasta -o \$prefix -nolibname
touch ../{output.red}
exit 0
fi

# red files MUST be in sorted order, which fixErrorsP doesn't return.
cat find-errors-jobs/*red > red.red
cat find-errors-jobs/*red > ../{output.red}

# Use those corrections to correct the reads.
{VERKKO}/bin/fixErrors \\\\
Expand Down
7 changes: 1 addition & 6 deletions src/Snakefiles/functions.sm
Original file line number Diff line number Diff line change
Expand Up @@ -105,12 +105,7 @@ def getMBGMemoryRequest(attempt): # Sum the input size, divide by
if mem < 2.0:
mem = 0

if config['correction_enabled'] == "True" and os.path.exists(rules.correctHiFi.output.fasta):
mem += getFileBP(rules.correctHiFi.output.fasta)
else:
for f in HIFI_READS:
mem += getFileBP(f)

mem += getFileBP(rules.correctHiFi.output.fasta)
mem = mem * 1.10 # Expand by 10%
mem = mem / 2 # MBG is expected to use 1 byte for each 2 bytes of input
mem = mem / gib # Convert to GB
Expand Down

0 comments on commit fc890f7

Please sign in to comment.