sequence_color.sh 1.2 KB

123456789101112131415161718192021222324
  1. #!/bin/bash
  2. #sequence_color.sh
  3. #get the gene.gff3 file and loaded into database sequence_color table.
  4. #Usage: sh sequence_color.sh /mnt/spruce/www/demo/geniecms/data/Egrandis_297_v2.0.gene.gff3
  5. # if less than two arguments supplied, display error message
  6. if [ $# -le 0 ]
  7. then
  8. start='\033[0;33m'
  9. start_0='\033[0;33m'
  10. start_2='\033[0;31m'
  11. end='\033[0m'
  12. echo "\nUsage:\n$0 ${start}[file_name]${end}\nEx: ${start_2}sh sequence_color.sh gene.gff3${end}
  13. \nWhat it does?\n${start_0}This script will read input gff3 fil[file_name] and load feature coordinates to sequence_color table.${end}\n"
  14. exit 1
  15. fi
  16. awk '/mRNA/{split($2,a,"=");sub(/ID=./,a[2]";");print $1;next}/gene/{;next}{sub(/ID=./,a[2]";");print $1}' FS=\; OFS=\; $1 | awk '!/#/{print $9"\t"$1"\t"$3"\t"$4"\t"$5}' > tmp &&
  17. sed -i 's/five_prime_UTR/5UTR/' tmp && sed -i 's/three_prime_UTR/3UTR/' tmp &&
  18. /usr/bin/mysql --defaults-file="$(dirname "$0")"/.mysql.cnf --local_infile=1 <<EOFMYSQL
  19. TRUNCATE TABLE sequence_color;
  20. LOAD DATA LOCAL INFILE "tmp" INTO TABLE sequence_color fields terminated by '\t' LINES TERMINATED BY '\n' ignore 0 lines;
  21. EOFMYSQL
  22. rm tmp