forked from albertwcheng/RNASeqMappingScripts3
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sortByCoordGeneric.sh
executable file
·45 lines (33 loc) · 899 Bytes
/
sortByCoordGeneric.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/bin/sh
origPath=`pwd`
if [ $# -lt 5 ]; then
echo $0 "wherefolder infilefilter sortedprefix sortedsuffix format[MAPVIEW|SAM]"
exit
fi
where=$1 #'../byChr/' ####
infilefilter=$2 #'*.mapview' ####
sortedprefix=$3
sortedsuffix=$4 #.s ##
format=$5
if [ $format == "MAPVIEW" ]; then
format=1
elif [ $format == "SAM" ]; then
format=2
else
echo "unknown format $format"
exit
fi
cd $where
for i in $infilefilter
do
fileoutname="$sortedprefix$i$sortedsuffix";
#sort coordinates
if [ $format -eq 1 ]; then
echo "sorting $i as MAPVIEW to $fileoutname";
cat $i | sort -k 2,2 -k 3,3n > $fileoutname #sort uses start0 end1. sort the chr name first then the coordinate
elif [ $format -eq 2 ]; then
echo "sorting $i as SAM to $fileoutname";
cat $i | sort -k 3,3 -k 4,4n > $fileoutname #sort uses start0 end1. sort the chr name first then the coordinate
fi
done
cd $origPath