-
Notifications
You must be signed in to change notification settings - Fork 5
/
atgc2ATGC.sh
63 lines (54 loc) · 1.56 KB
/
atgc2ATGC.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/bin/bash
# Raymond Kiu [email protected]
#print the options
usage () {
echo ""
echo "This bash script converts atgc to ATGC in FASTA files"
echo ""
echo "Usage: $0 [options] FASTAFILE"
echo "Option:"
echo " -o output filename (default: FASTAFILE.converted.fasta)"
echo " -h print usage and exit"
echo " -a print author and exit"
echo " -v print version and exit"
echo ""
echo "Version 1.0"
echo "Author: Raymond Kiu [email protected] (2020)"
echo "";
}
version () { echo "version 1.0";}
author () { echo "Author: Raymond Kiu [email protected]";}
output=($1.converted.fasta)
while getopts ':o:hav' opt;
do
case $opt in
o) output=$OPTARG ;;
h) usage; exit;;
a) author; exit;;
v) version; exit;;
\?) echo "Invalid option: -$OPTARG" >&2; exit 1;;
:) echo "Missing option argument for -$OPTARG" >&2; exit 1;;
*) echo "Unimplemented option: -$OPTARG" >&2; exit 1;;
esac
done
# skip over the processed options
shift $((OPTIND-1))
#check for mandatory positional parameters
if [ $# -lt 1 ]; then
echo ""
echo "This bash script converts atgc to ATGC in FASTA files"
echo ""
echo "Usage: $0 [options] FASTAFILE"
echo "Option:"
echo " -o output filename (default: FASTAFILE.converted.fasta)"
echo " -h print usage and exit"
echo " -a print author and exit"
echo " -v print version and exit"
echo ""
echo "Version 1.0"
echo "Author: Raymond Kiu [email protected] (2020)"
echo "";
exit 1
fi
cat $1|awk 'BEGIN{FS=" "}{if(!/>/){print toupper($0)}else{print $1}}' > $output
exit 1;