#!/bin/csh # NCBIUPDATE, Version 09/26/14 #csh script to download GenBank files # Example: {uses 'at' command to run a delayed batch job} # at 1am # at>gbupdate filelist & # at>ctrl-D {ends the command } # This assumes you are in the GenBank directory. The existing files will be # replaced with the new ones, and so must be writeable. # Remember to include the index and documentation files in filelist. # When disk space is tight, edit the 'filelist' file to download files in # order of decreasing size. In general, you need to have at least twice as # much empty space as is necessary to hold the largest file to be downloaded. # This can be circumvented by setting $tmpdir to /tmp, rather than ".". #----------------------- Set environment variables ------------- # RM_CMD - command to be used for removing files and directories if (-e /usr/bin/rm) then set RM_CMD = /usr/bin/rm else if (-e /bin/rm) then set RM_CMD = /bin/rm else set RM_CMD = rm endif endif #- - - - - - - - - directory to store temporary files - - - - - - - - - # Unless you are just scraping the last bytes of the # filesystem in which GenBank is to reside, then the current working # directory should be fine. set tmpdir = . # /tmp and /var/tmp are two alternatives, if you're running out of space # in the target filesystem. Beware! if you max out /tmp, you will be # interfering with the ability of everyone else on the system to # do business as usual. /tmp on some systems can be surprisingly small, # if it is taken from /swap. #set tmpdir = /tmp # On some systems, /var/tmp is an alternative place for temporary files #set tmpdir = /var/tmp #- - - - - - - - - - - - - - - - - - - - - - #----------------------- MAIN LOOP ------------- foreach file (`cat gbfiles`) echo '===> '$file if ($file:e == gz ) then set unzipname = $file:r echo '======> '$unzipname gunzip $file set basename = $unzipname:r if ($unzipname:e == tar ) then echo '=========> '$basename tar xvfp $unzipname set success = $status if ($success == 0) then $RM_CMD $unzipname else echo '!!! tar xvfp '$unzipname' failed' endif endif endif end #foreach