| | 66 | ##FUNCGEN |
| | 67 | export species_name="$species_name"; var=`echo "ls -l /pub/bacteria/release-${release}/mysql/" | ncftp ${ftp_site} | perl -ane 'if ( $_ =~ /$Logged in to/ ) { $go=1; next } if ( $go ) { @a=split; $fileName=$a[ scalar( @a ) - 1]; $compareStr=$ENV{ species_name }."_funcgen"; if ( $fileName =~/^$compareStr/) { print $fileName."\n"; } }'`; set -- $var; mysql_efg_name=$1 |
| | 68 | |
| | 69 | # check variable before proceeding |
| | 70 | if [[ $mysql_efg_name =~ 'species_list' || $mysql_efg_name == '' ]] |
| | 71 | then |
| | 72 | echo "Skip!: $species_name not found at $ftp_site. Please fix file: $species_list" |
| | 73 | continue |
| | 74 | fi |
| | 75 | |
| | 76 | echo "** $mysql_efg_name **" |
| | 77 | mkdir ./${mysql_efg_name} |
| | 78 | |
| | 79 | |
| | 80 | # get raw tables from ftp site |
| | 81 | ncftpget ${ftp_site} ./${mysql_efg_name} /pub/bacteria/release-${release}/mysql/${mysql_efg_name}/*.txt.gz |
| | 82 | for q in ./${mysql_efg_name}/*.txt.gz |
| | 83 | do |
| | 84 | gunzip $q |
| | 85 | done |
| | 86 | |
| | 87 | ncftpget ${ftp_site} ./ /pub/bacteria/release-${release}/mysql/${mysql_efg_name}/${mysql_efg_name}.sql.gz |
| | 88 | gunzip ./${mysql_efg_name}.sql.gz |
| | 89 | |
| | 90 | #rename 3-name databases |
| | 91 | mysql_efg_name_local=${mysql_efg_name/escherichia_shigella/escherichia} |
| | 92 | |
| | 93 | #create local mysql db |
| | 94 | echo "create database if not exists ${mysql_efg_name_local}" | ${mysql} -u genmapp -pfun4genmapp |
| | 95 | #create schema |
| | 96 | ${mysql} -u genmapp -pfun4genmapp ${mysql_efg_name_local} < ./${mysql_efg_name}.sql |
| | 97 | # place in own scope, due to "cd" command |
| | 98 | ( |
| | 99 | cd ./${mysql_efg_name}; for table_name in *.txt |
| | 100 | do |
| | 101 | ${mysqlimport} -u genmapp -pfun4genmapp ${mysql_efg_name_local} `pwd`/${table_name} |
| | 102 | done |
| | 103 | ) |
| | 104 | |
| | 105 | # zip, archive and clean up |
| | 106 | gzip ./${mysql_efg_name}.sql |
| | 107 | tar cvzf ./${mysql_efg_name}.txt.tgz ./${mysql_efg_name}/* |
| | 108 | rm -R ./${mysql_efg_name}/ |
| | 109 | |