annotate sort_chromosomal_position.sh @ 0:e77c9484b2d0 draft default tip

Uploaded
author saskia-hiltemann
date Thu, 22 Oct 2015 09:18:30 -0400
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
e77c9484b2d0 Uploaded
saskia-hiltemann
parents:
diff changeset
1 #!/bin/bash
e77c9484b2d0 Uploaded
saskia-hiltemann
parents:
diff changeset
2
e77c9484b2d0 Uploaded
saskia-hiltemann
parents:
diff changeset
3 #sort_chromosomal_position.sh $infile $chrcol $startcol $endcol $num_headerlines
e77c9484b2d0 Uploaded
saskia-hiltemann
parents:
diff changeset
4
e77c9484b2d0 Uploaded
saskia-hiltemann
parents:
diff changeset
5
e77c9484b2d0 Uploaded
saskia-hiltemann
parents:
diff changeset
6 cp $1 inputfile.tsv
e77c9484b2d0 Uploaded
saskia-hiltemann
parents:
diff changeset
7 chrcol=$2
e77c9484b2d0 Uploaded
saskia-hiltemann
parents:
diff changeset
8 startcol=$3
e77c9484b2d0 Uploaded
saskia-hiltemann
parents:
diff changeset
9 endcol=$4
e77c9484b2d0 Uploaded
saskia-hiltemann
parents:
diff changeset
10 num_headerlines=$5
e77c9484b2d0 Uploaded
saskia-hiltemann
parents:
diff changeset
11 outfile=$6
e77c9484b2d0 Uploaded
saskia-hiltemann
parents:
diff changeset
12
e77c9484b2d0 Uploaded
saskia-hiltemann
parents:
diff changeset
13 #remember header
e77c9484b2d0 Uploaded
saskia-hiltemann
parents:
diff changeset
14 head -$num_headerlines inputfile.tsv > header.tsv
e77c9484b2d0 Uploaded
saskia-hiltemann
parents:
diff changeset
15
e77c9484b2d0 Uploaded
saskia-hiltemann
parents:
diff changeset
16 #remove header
e77c9484b2d0 Uploaded
saskia-hiltemann
parents:
diff changeset
17 sed -i "1,$num_headerlines d" inputfile.tsv
e77c9484b2d0 Uploaded
saskia-hiltemann
parents:
diff changeset
18
e77c9484b2d0 Uploaded
saskia-hiltemann
parents:
diff changeset
19 #sort file
e77c9484b2d0 Uploaded
saskia-hiltemann
parents:
diff changeset
20 sort -k ${chrcol},${chrcol}V -k${startcol},${startcol}n inputfile.tsv > tmpout.txt
e77c9484b2d0 Uploaded
saskia-hiltemann
parents:
diff changeset
21
e77c9484b2d0 Uploaded
saskia-hiltemann
parents:
diff changeset
22 cat header.tsv tmpout.txt > $outfile
e77c9484b2d0 Uploaded
saskia-hiltemann
parents:
diff changeset
23
e77c9484b2d0 Uploaded
saskia-hiltemann
parents:
diff changeset
24
e77c9484b2d0 Uploaded
saskia-hiltemann
parents:
diff changeset
25
e77c9484b2d0 Uploaded
saskia-hiltemann
parents:
diff changeset
26