Skip to content

Instantly share code, notes, and snippets.

@sambrightman
Created October 1, 2016 13:42
Show Gist options
  • Save sambrightman/29355936d0c254c978f8c9a9ce24054d to your computer and use it in GitHub Desktop.
Save sambrightman/29355936d0c254c978f8c9a9ce24054d to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
BASH_TAP_ROOT=bash-tap
source ./bash-tap/bash-tap-bootstrap
PATH=../bin:$PATH # for freebayes
plan tests 1
ref=$(basename $0).ref
bam=$(basename $0).bam
trap 'rm -f ${ref}* ${bam}*' EXIT
function make_ref() {
local bases=$1 && shift
cat >${ref} <<REF
>ref
${bases}
REF
samtools faidx ${ref}
}
samtools view -S -b - >${bam} <<SAM
@HD VN:1.5 SO:coordinate
@SQ SN:ref LN:19
alt 0 ref 1 30 1=1X1=12X1=1X1=1X * 0 0 AGTTAAAAAAAAAAAGGTT *
SAM
samtools index ${bam}
function run_freebayes() {
freebayes --haplotype-length 0 --min-alternate-count 1 \
--min-alternate-fraction 0 --pooled-continuous --report-monomorphic \
--ploidy 1 \
-f $ref $bam \
2>&1 \
| grep -vE "^#" | cut -f1-5
}
expected=$(cat <<END
ref 2 . A G
ref 4 . CNNNNNNNNNNN TAAAAAAAAAAA
ref 17 . C G
ref 19 . A T
END
)
make_ref "AATCNNNNNNNNNNNGCTA"
is "$(run_freebayes)" "${expected}" "freebayes calls after long haplotype"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment