update_annotation_gene_i.sh 1.3 KB

1234567891011121314151617181920212223242526272829303132
  1. #!/bin/bash
  2. #update_annotation_gene.sh
  3. DB_USER='root' #'your_db_username'
  4. DB_PASS='root' #'your_password'
  5. DB='my_genie_sys_database' #'database_name'
  6. # USAGE sh update_annotation_gene_i.sh gene_go
  7. display_usage() {
  8. echo "\nUsage:\n$0 [table_name] \n"
  9. }
  10. #UPDATE $1 INNER JOIN transcript_info on transcript_info.transcript_id = $1.transcript_id SET $1.transcript_i = transcript_info.transcript_i;
  11. #update transcript_info,$1 set $1.transcript_i=transcript_info.transcript_i where transcript_info.transcript_id=$1.transcript_id;
  12. # if less than one arguments supplied, display usage
  13. if [ $# -le 0 ]
  14. then
  15. display_usage
  16. exit 1
  17. fi
  18. count=$(mysql --host=localhost --user=$DB_USER --password=$DB_PASS --database=$DB -sse "SHOW COLUMNS FROM $1 LIKE 'transcript_id';")
  19. if [ ${#count} -gt 0 ]
  20. then
  21. mysql --host=localhost --user=$DB_USER --password=$DB_PASS --local_infile=1 --database=$DB << EOFMYSQL
  22. UPDATE $1 INNER JOIN transcript_info on transcript_info.transcript_id = $1.transcript_id SET $1.transcript_i = transcript_info.transcript_i;
  23. EOFMYSQL
  24. else
  25. mysql --host=localhost --user=$DB_USER --password=$DB_PASS --local_infile=1 --database=$DB << EOFMYSQL
  26. UPDATE $1 INNER JOIN transcript_info on transcript_info.gene_id = $1.gene_id SET $1.gene_i = transcript_info.gene_i;
  27. EOFMYSQL
  28. fi