# Edit this file to introduce tasks to be run by cron.
# 
# Each task to run has to be defined through a single line
# indicating with different fields when the task will be run
# and what command to run for the task
# 
# To define the time you can provide concrete values for
# minute (m), hour (h), day of month (dom), month (mon),
# and day of week (dow) or use '*' in these fields (for 'any').# 
# Notice that tasks will be started based on the cron's system
# daemon's notion of time and timezones.
# 
# Output of the crontab jobs (including errors) is sent through
# email to the user the crontab file belongs to (unless redirected).
# 
# For example, you can run a backup of all your user accounts
# at 5 a.m every week with:
# 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/
# 
# For more information see the manual pages of crontab(5) and cron(8)
# 
# m h  dom mon dow   command

# update databases for HHSuite 
0 2 * * 4 cd /home/casp/SoftWare/HHSuite/my-scripts; ./updateDB_hhsuite.sh
30 4 * * 4 /home/casp/SoftWare/blast/updateDB_blast.sh
30 22 * * 6 cd /data0/db_pdb/ ; ./update.sh


####---COMMENTED ON JULY 30 2018; rsync predictions from predictioncenter.org
##30 3,7,10,16,23 * * * cd /home/casp/casp_related ; ./rsync_data_casp13.sh
##45 23 * * * cd /home/casp/casp_related ; ./rsync_from_p3.sh
##20 20 * * * cd /data/backup/db ; ./rsync_from_p3.sh 
##45 20 * * 1,3,5 cd /data/backup/db ; ./manage_update_db.sh



#### copy crontab  at predictioncenter.org
## After the target is closed for server predictions send them for evaluation; check the evaluation and creates tarballs for QA stage1 and stage2
#10 13 * * * cd /local/Projects/Perl/casp14/src/scripts/; ./evaluateForQAtarballs.pl >>evaluateForQAtarballs.pl.log 2>&1

## Patch for script ./evaluateForQAtarballs.pl: in order to avoid overflowing of requests to the database from the evaluation servers (malbecs)
## The script has to be scheduled before the ./evaluateForQAtarballs.pl
#05 13 * * * cd /local/Projects/Perl/casp14/src/scripts/; ./patchServerCodes.pl >>patchServerCodes.pl.log 2>&1

## Downloading tarballs for QA to /www/download_area/CASP14 and send requests to QA servers
#22 12 * * * cd /local/Projects/Perl/casp14/src/scripts/; ./createForQAtarballs.pl >>createForQAtarballs.pl.log 2>&1

## After the target is closed copy predictions TS and RR to directories from which the evaluation system fetches models
## This script also ctreates/updates the file /local/CASP11/predictions/closed_targets.list
## During the regular season when QA stuff is running the time should be set at 14:30
#30 14 * * * cd /local/Projects/Perl/casp14/src/scripts/; ./copy_4eval.pl >>copy_4eval.pl.log 2>&1
#35 14 * * * cd /local/Projects/Perl/caspcommons/src/scripts/; ./copy_4eval.pl >>copy_4eval.pl.log 2>&1

## After the target is closed create tarballs of selected RR predictions  for contact-guided targets
## The task has to be run after ./copy_4eval.pl
## OBSOLETE!
###05 15 * * * cd /local/Projects/Perl/casp12/src/scripts/; ./createForTCfiles.pl >>createForTCfiles.pl.log 2>&1

## During the server predict. season switch tarballs creation to 7:45, i.e. a few minutes, not hours, before sending QA quer$
#50 7 * * * cd /local/Projects/Perl/casp14/src/scripts/; ./create_tarballs.pl >> create_tarballs.pl.log 2>&1
##45 7 * * * cd /local/Projects/Perl/casprol/src/scripts/; ./create_tarballs.pl >> create_tarballs.pl.log 2>&1

23 17 * * 2 wget -m -nv -nd -P /PDB ftp://ftp.wwpdb.org/pub/pdb/derived_data/pdb_seqres.txt -o /PDB/pdb_seqres.weeklog
35 17 * * 2 wget -m -nv --retr-symlinks -x -N -nH --cut-dirs=7 -P /PDB_compressed/structures ftp://ftp.wwpdb.org/pub/pdb/data/structures/divided/pdb -o /PDB_compressed/struct.weeklog
00 19 * * 2 cat /PDB_compressed/struct.weeklog | grep 'ent\.gz' | grep 'saved' | cut -d'/' -f5 | cut -c1-14 > /PDB_compressed/struct.weeklog_last
01 19 * * 2 cat /PDB_compressed/struct.weeklog | grep 'ent\.gz' | cut -d'"' -f2 | cut -d'/' -f4 >> /PDB_compressed/struct.weeklog_last
02 19 * * 2 cat /PDB_compressed/struct.weeklog_last | mailx -s "PDB update" casp@predictioncenter.org
03 19 * * 2 chgrp users /PDB_compressed/struct.weeklog_last; chmod g+w /PDB_compressed/struct.weeklog_last; cp -p /PDB_compressed/struct.weeklog_last  /PDB_compressed/struct.weeklog`date +\%Y_\%U`
04 19 * * 2 for i in `cat /PDB_compressed/struct.weeklog_last`; do cp -p /PDB_compressed/structures/$i /PDB/structures; done
05 19 * * 2 for i in `ls /PDB/structures | grep 'ent\.gz'`; do gunzip -Nf /PDB/structures/$i; done

35 19 * * 2 wget -m -nv --retr-symlinks -x -N -nH --cut-dirs=7 -P /PDB_compressed/mmCIF ftp://ftp.wwpdb.org/pub/pdb/data/structures/divided/mmCIF -o /PDB_compressed/struct_mmcif.weeklog
00 23 * * 2 cat /PDB_compressed/struct_mmcif.weeklog | grep 'cif\.gz' | grep 'saved' | cut -d'/' -f5 | cut -c1-14 > /PDB_compressed/struct_mmcif.weeklog_last
01 23 * * 2 cat /PDB_compressed/struct_mmcif.weeklog | grep 'cif\.gz' | cut -d'"' -f2 | cut -d'/' -f4 >> /PDB_compressed/struct_mmcif.weeklog_last
02 23 * * 2 cat /PDB_compressed/struct_mmcif.weeklog_last | mailx -s "PDB mmcif update" casp@predictioncenter.org
03 23 * * 2 chgrp users /PDB_compressed/struct_mmcif.weeklog_last; chmod g+w /PDB_compressed/struct_mmcif.weeklog_last; cp -p /PDB_compressed/struct_mmcif.weeklog_last  /PDB_compressed/struct_mmcif.weeklog`date +\%Y_\%U`
04 23 * * 2 for i in `cat /PDB_compressed/struct_mmcif.weeklog_last`; do cp -p /PDB_compressed/mmCIF/$i /PDB/mmCIF; done
05 23 * * 2 for i in `ls /PDB/mmCIF | grep 'cif\.gz'`; do gunzip -Nf /PDB/mmCIF/$i; done

## Refresh server status page
##01,31 * * * * cd /local/Projects/Perl/casprol/src/scripts/; ./recalculate_prediction_status.pl >> recalculate_prediction_status.log
#03,33 * * * * cd /local/Projects/Perl/casp14/src/scripts/; ./recalculate_prediction_status.pl >> recalculate_prediction_status.log

## Upload targets from the command line
##15 8 28 5 * cd /local/Projects/Perl/casp9/src/distribution;./manual.pl --target=T0556 --type=qa_only --debug=0

## notification new targets release and server distribution in CASPROL
##05 09 * * * cd /local/Projects/Perl/casprol/src/admin/; ./notify_new_target_release.pl

## automatic distribution of requests to servers
#05 09 * * * cd /local/Projects/Perl/casp13/src/admin/; ./bin_servers_distribution.pl

## notification CAPRI targets release in CASP11
###03 09 * * * cd /local/Projects/Perl/casp11/src/admin/; ./notify_CAPRI_target_release.pl



