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

Fix off-by-one in chunk ranges #320

Closed
wants to merge 5 commits into from
Closed
Changes from all commits
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
11 changes: 6 additions & 5 deletions bin/generate_cram_csv.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,25 @@ chunk_cram() {
local cram=$1
local chunkn=$2
local outcsv=$3
local chunksize=10000
realcram=$(readlink -f ${cram})
realcrai=$(readlink -f ${cram}.crai)
local rgline=$(samtools view -H "${realcram}" | grep "@RG" | sed 's/\t/\\t/g' | sed "s/'//g")
local ncontainers=$(zcat "${realcrai}" | wc -l)
local base=$(basename "${realcram}" .cram)
local from=0
local to=10000

local to=$((chunksize - 1))

while [ $to -lt $ncontainers ]; do
echo "${realcram},${realcrai},${from},${to},${base},${chunkn},${rgline}" >> $outcsv
from=$((to + 1))
((to += 10000))
to=$((to + chunksize))
((chunkn++))
done

if [ $from -le $ncontainers ]; then
echo "${realcram},${realcrai},${from},${ncontainers},${base},${chunkn},${rgline}" >> $outcsv
if [ $from -lt $ncontainers ]; then
to=$((ncontainers - 1))
echo "${realcram},${realcrai},${from},${to},${base},${chunkn},${rgline}" >> $outcsv
((chunkn++))
fi

Expand Down
Loading