Skip to content
Snippets Groups Projects
Commit 906c4967 authored by Floreal Cabanettes's avatar Floreal Cabanettes
Browse files

Remove unused sh

parent 64e95457
No related branches found
No related tags found
Loading
#!/bin/bash
# see http://redsymbol.net/articles/unofficial-bash-strict-mode/
set -euo pipefail
echo "---"
echo "Running svtyper.sh $1 $2 $3"
echo "Starting "`date +%Y-%m-%d`" at "`date +%H:%M:%S`
echo "---"
svtyper=svtyper
root=/home/faraut/work/CapriSV/src/SVPipeline
export PATH=$root/bin:$PATH
PYTHONPATH=""
myname=`basename "$0"`
function usage() {
echo "
Program: lumpy wrapper
usage: $myname [options] <bamlist> <input> <outprefix>
positional args:
bamlist a file with the bamfiles
input the input vcf file (gzipped or not)
outprefix prefix of the output file
ncpus the number of cpus, optional [1]
"
}
get_bams( ) {
bams=""
for bamfile in $@; do
bams=$bams$bamfile","
done
bams=${bams%?}
echo $bams
}
function join_by {
local IFS="$1";
shift;
echo "$*"; }
bamlist=${1:-}
input=${2:-}
outprefix=${3:-}
ncpus=${4:-1} # If parameter is unset or null, the expansion of word is substituted (see https://www.gnu.org/software/bash/manual/bashref.html#Shell-Parameter-Expansion)
if [[ -z ${bamlist} || -z ${input} || -z ${outprefix} ]]
then
usage
echo "At least one argument is missing"
exit 1
fi
outprefix=`realpath -s $outprefix`
if [[ ! -s $input ]]
then
echo "$input is not and existing or non empty file.\nExiting!"
exit 1
fi
input=`realpath -s $input`
bamarray=()
while read line
do
if [[ ! -s $line ]]
then
echo "$line is not and existing or non empty file.\nExiting!"
exit 1
fi
path=`realpath -s $line`
bamarray+=("$path")
done < ${bamlist}
bams=`join_by ',' "${bamarray[@]}"`
origdir=`pwd`
tempdir=`mktemp -d`
cd $tempdir
echo "Working in $tempdir"
# genotype the Structural variants (and parallelize the job)
awk '{ if( !/^#/) { exit 0; }; print $0}' < <(zless ${input}) > header
success=1
zless ${input} | grep -v "^#" | split -l 100 - temp_ || success=0
if [ "${success}" -eq "1" ]; then
for i in temp_*;
do cat header $i > $i.raw.vcf
rm -f $i;done
ls *.raw.vcf | parallel --no-notice -P ${ncpus} ${svtyper} -i {} -B ${bams} '>' {.}.output
rm -f lumpy_temp_*.raw.vcf
vcf-concat *.raw.output | vcf-sort > ${outprefix}.vcf
bgzip -f ${outprefix}.vcf
tabix -f -p vcf ${outprefix}.vcf.gz
cd $origdir
rm -fr $tempdir
else
if [ -f ${input} ]; then
cp ${input} ${outprefix}.vcf.gz
tabix -f -p vcf ${outprefix}.vcf.gz
fi
fi
echo "Script svtyper.sh completed successfully "`date +%Y-%m-%d`" at "`date +%H:%M:%S`
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment