Skip to content

Instantly share code, notes, and snippets.

@ryanlayer
Created October 13, 2015 15:41
Show Gist options
  • Select an option

  • Save ryanlayer/f97ee434b06e1243eabe to your computer and use it in GitHub Desktop.

Select an option

Save ryanlayer/f97ee434b06e1243eabe to your computer and use it in GitHub Desktop.
Get splitters and discordants
BAM=$1
OUT_DIR=$2
LUMPY_HOME=$HOME/src/lumpy-sv
SAMBAMBA=$HOME/bin/sambamba
SAMBLASTER=$HOME/bin/samblaster
BAMLIBS=$LUMPY_HOME/scripts/bamkit/bamlibs.py
SAMTOBAM="$SAMBAMBA view -S -f bam -l 0"
SAMSORT="$SAMBAMBA sort -m 1G --tmpdir "
PAIREND_DISTRO=$LUMPY_HOME/scripts/pairend_distro.py
BAMGROUPREADS=$LUMPY_HOME/scripts/bamkit/bamgroupreads.py
BAMFILTERRG=$LUMPY_HOME/scripts/bamkit/bamfilterrg.py
MAX_SPLIT_COUNT=2
MIN_NON_OVERLAP=20
if [ ! -d "$OUT_DIR" ]; then
mkdir $OUT_DIR
fi
BAM_BASE=`basename $BAM .bam`
OUTPUT=`basename $BAM`.vcf
OUTBASE=`basename "$OUTPUT"`
# make pipes
TEMP_DIR=$OUT_DIR/$BAM_BASE
mkdir -p $TEMP_DIR/spl $TEMP_DIR/disc
mkfifo $TEMP_DIR/spl_pipe
mkfifo $TEMP_DIR/disc_pipe
echo "$PYTHON $BAMGROUPREADS \
-i $BAM \
| $SAMBLASTER \
--acceptDupMarks \
--excludeDups \
--addMateTags \
--maxSplitCount $MAX_SPLIT_COUNT \
--minNonOverlap $MIN_NON_OVERLAP \
--splitterFile $TEMP_DIR/spl_pipe \
--discordantFile $TEMP_DIR/disc_pipe "
$PYTHON $BAMGROUPREADS \
-i $BAM \
| $SAMBLASTER \
--acceptDupMarks \
--excludeDups \
--addMateTags \
--maxSplitCount $MAX_SPLIT_COUNT \
--minNonOverlap $MIN_NON_OVERLAP \
--splitterFile $TEMP_DIR/spl_pipe \
--discordantFile $TEMP_DIR/disc_pipe \
> /dev/null &
$SAMTOBAM $TEMP_DIR/spl_pipe \
| $SAMSORT $TEMP_DIR/spl \
-o $TEMP_DIR/$BAM_BASE.splitters.bam \
/dev/stdin &
$SAMTOBAM $TEMP_DIR/disc_pipe \
| $SAMSORT $TEMP_DIR/disc \
-o $TEMP_DIR/$BAM_BASE.discordants.bam \
/dev/stdin
wait
rm $TEMP_DIR/spl_pipe
rm $TEMP_DIR/disc_pipe
rmdir $TEMP_DIR/spl
rmdir $TEMP_DIR/disc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment