Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dont append when splitting and clean-up gen-vcfs #180

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
dont append when splitting and clean-up gen-vcfs
  • Loading branch information
brentp committed Mar 23, 2017
commit a5fd36a7f54572dc0e84460ccbb719183b762ee2
2 changes: 1 addition & 1 deletion scripts/lumpy_smooth
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ fi
export -f BAM_PREP
echo -en $BAMS | xargs -I{} -P $THREADS bash -c "BAM_PREP {}"

export GLOBAL_LUMPY="$LUMPY_HOME/bin/lumpy -mw 4 -t $(mktemp) -tt 0 -P $EXCLUDE "
export GLOBAL_LUMPY="$LUMPY_HOME/bin/lumpy -mw 4 -t $(mktemp) -tt 0 $EXCLUDE "

for SAMPLE_CSV in ${OPTS[@]:$((OPTIND - 1))}; do
SAMPLE_ARRAY=(${SAMPLE_CSV//,/ })
Expand Down
45 changes: 24 additions & 21 deletions scripts/par-svtyper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,27 +20,29 @@ export -f svtpar

genvcfs() {
set -euo pipefail
bams=$1
nth=0
tmpvcf=$TMPDIR/tmp.$$.$nth.vcf
echo -e "$header" > $tmpvcf
k=0
lines=$1
vcf=$2
set +e
header="$(less $vcf | head -2000 | grep ^#)"
set -e
# run this once to force the calculation of the bam stats.
# this avoids a race condition.
svtpar <(echo -e "$header")
while read -r line || [[ -n "$line" ]]; do
k=$((k + 1))
echo -e "$line" >> $tmpvcf
if [[ "$k" -eq "$LINES" ]]; then
# echo the bam and the vcf so they can be sent to svtyper.
echo "$tmpvcf"
nth=$((nth + 1))
tmpvcf=$TMPDIR/tmp.$$.$nth.vcf
echo -e "$header" > $tmpvcf
k=0;
fi
done < "$vcf"
echo "$tmpvcf"

zless "$vcf" | awk -vtmp=$TMPDIR -vtmpvcf="$TMPDIR/0.tmp.$$.vcf" -vpid=$$ -v header="$header" -vLINES=$lines 'BEGIN{nth=1;} !((NR - 1) % LINES) {
# we print the tmpvcf and move onto the next.
if(NR > 1) {
print tmpvcf;
}
tmpvcf=tmp"/"nth".tmp."pid".vcf.gz"
print header > tmpvcf;
nth+=1;
}
{
print $0 > tmpvcf;
}
END {
print tmpvcf;
}'
}

vcfsort() {
Expand All @@ -56,7 +58,7 @@ fi
export mypid=$$

cleanup() {
rm -f $TMPDIR/tmp.$mypid.*.vcf
rm -f $TMPDIR/*.$mypid.vcf*
rm -f $TMPDIR/tmp.$mypid.*.lib
}

Expand All @@ -78,7 +80,8 @@ type gargs >/dev/null 2>&1 || {
psvtyper() {
set -euo pipefail
export header=$(head -2000 $vcf | grep ^#)
genvcfs $bams | gargs -p $THREADS "svtpar {}" | vcfsort
svtpar <(echo -e "$header")
genvcfs $LINES $vcf | gargs -p $THREADS "svtpar {}" | vcfsort
}

mkdir -p $TMPDIR
Expand Down