view sort_chromosomal_position.sh @ 0:e77c9484b2d0 draft default tip

Uploaded
author saskia-hiltemann
date Thu, 22 Oct 2015 09:18:30 -0400
parents
children
line wrap: on
line source

#!/bin/bash

#sort_chromosomal_position.sh $infile $chrcol $startcol $endcol $num_headerlines


cp $1 inputfile.tsv
chrcol=$2
startcol=$3
endcol=$4
num_headerlines=$5
outfile=$6

#remember header 
head -$num_headerlines inputfile.tsv > header.tsv

#remove header
sed -i "1,$num_headerlines d" inputfile.tsv

#sort file
sort -k ${chrcol},${chrcol}V -k${startcol},${startcol}n inputfile.tsv > tmpout.txt

cat header.tsv tmpout.txt > $outfile