update_gene_i.sh 694 B

12345678910111213141516
  1. #!/bin/bash
  2. #update_gene_i.sh
  3. #USAGE: sh update_gene_i.sh
  4. DB_USER='root' #'your_db_username'
  5. DB_PASS='root' #'your_password'
  6. DB='my_genie_sys_database' #'database_name'
  7. mysql --host=localhost --user=$DB_USER --password=$DB_PASS --local_infile=1 --database=$DB <<EOFMYSQL
  8. create temporary table add_gene_i(gene_i MEDIUMINT NOT NULL AUTO_INCREMENT PRIMARY KEY, genename VARCHAR(40));
  9. ALTER TABLE add_gene_i AUTO_INCREMENT = 1;
  10. INSERT INTO add_gene_i(genename) select DISTINCT(gene_id) from transcript_info;
  11. UPDATE transcript_info INNER join add_gene_i ON add_gene_i.genename = transcript_info.gene_id SET transcript_info.gene_i = add_gene_i.gene_i;
  12. drop temporary table add_gene_i;
  13. EOFMYSQL