#!/bin/bash # write_secondaries.sh # usage # ./write_secondaries.sh # e.g. # ./write_secondaries.sh input.cram ref.fa output.cram 16 2G THR=${4:-4} MEM=${5:-1G} samtools view -@$THR -h $1 -T $2 -f256 > sec.txt samtools view -@$THR -h $1 -T $2 -F256 | secondary_rewriter --generate-primary-loc-tag --secondaries sec.txt | samtools sort --reference $2 -@$THR -m $MEM - -o $3