Skip to content

Instantly share code, notes, and snippets.

@mtw
Last active December 26, 2015 08:19
Show Gist options
  • Save mtw/7121573 to your computer and use it in GitHub Desktop.
Save mtw/7121573 to your computer and use it in GitHub Desktop.
Wrapper for htseq-count
#!/bin/bash
samdir="./"
annotation="my.gtf"
htseqdir="./htseq-count"
htseqcount=`which htseq-count`
samtools=`which samtools`
feature="gene"
idattr="gene_name"
ss="reverse"
if [ -d "$htseqdir" ];
then
echo "$htseqdir available"
else
mkdir $htseqdir
fi
for BAM in $(ls $samdir/*.bam)
do
bn=$(basename $BAM .uniq.bam)
echo "processing $bn"
set -x
$samtools sort -n -o $BAM $bn | $samtools view -h - | $htseqcount -t $feature -i $idattr -s $ss - $annotation > $htseqdir/$bn.htseq.count 2> $htseqdir/$bn.htseq.count.err
set +x
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment