<commit_before>#!/usr/bin/env bash

if hash module 2>/dev/null; then
   if [ -n "$CLUSTER_IS_PBS" ]; then
      module add gnuplot/5.0.0
      module add preseq/1.0.2
   else
      module add preseq
   fi
   module add samtools/1.2
fi

# takes unsorted bam file as input. this file should include duplicates
if [ -n "$1" ]; then
   infile=$1
fi

sortedInfile="${infile/.bam/.sort.bam}"

# preseq needs sorted input
samtools sort -Ttmp -l0 -Obam "$infile" -o "${sortedInfile}"

# run preseq
preseq lc_extrap -B -o "${sortedInfile}.preseq.dat" "${sortedInfile}" -v 2> "${sortedInfile}.preseq.log"
rm sortedInfile

# plot the results
# maximum number of reads on x axis in plot (in millions)
XMAX=500

titleName=$(basename $infile) 

cat > preseq.gnu <<EOF
set terminal png 
set output '$infile.preseq.png'
set nokey
set style line 1 linewidth 5
set mxtics 2
set grid ytics xtics mxtics
set xrange [0:${XMAX}]
set xlabel "Number of Reads [millions]"
set ylabel "Expected Distinct Reads [millions]"
set title "PRESEQ Results for $titleName"
plot '$infile.sort.bed.preseq.dat' using (\$1/1000000):(\$2/1000000) with lines linestyle 1
EOF

gnuplot preseq.gnu
<commit_msg>PRESEQ bug fix<commit_after>#!/usr/bin/env bash

if hash module 2>/dev/null; then
   if [ -n "$CLUSTER_IS_PBS" ]; then
      module add gnuplot/5.0.0
      module add preseq/1.0.2
   else
      module add preseq
   fi
   module add samtools/1.2
fi

# takes unsorted bam file as input. this file should include duplicates
if [ -n "$1" ]; then
   infile=$1
fi

sortedInfile="${infile/.bam/.sort.bam}"

# preseq needs sorted input
samtools sort -Ttmp -l0 -Obam "$infile" -o "${sortedInfile}"

# run preseq
preseqData="${sortedInfile}.preseq.dat"
preseq lc_extrap -B -o "${preseqData}" "${sortedInfile}" -v 2> "${sortedInfile}.preseq.log"
rm $sortedInfile

# plot the results
# maximum number of reads on x axis in plot (in millions)
XMAX=500

titleName=$(basename $infile) 

cat > preseq.gnu <<EOF
set terminal png 
set output '$infile.preseq.png'
set nokey
set style line 1 linewidth 5
set mxtics 2
set grid ytics xtics mxtics
set xrange [0:${XMAX}]
set xlabel "Number of Reads [millions]"
set ylabel "Expected Distinct Reads [millions]"
set title "PRESEQ Results for $titleName"
plot '${preseqData}' using (\$1/1000000):(\$2/1000000) with lines linestyle 1
EOF

gnuplot preseq.gnu
rm preseq.gnu
{'fraction_non_alphanumeric': 0.12213740458015267, 'fraction_numerical': 0.031382527565733676, 'mean_word_length': 3.87396694214876, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4288412', 'n_tokens_mistral': 922, 'n_tokens_neox': 860, 'n_words': 291}