#!/bin/sh # INSTALLATION: # change the parameters below # where we find the PDB structures hierarchy export PDBDIR=/DATA/PDB/PDB # <<<< <<<< <<<< # source GNUstep environment source /usr/local/GNUstep/System/Makefiles/GNUstep.sh # <<<< <<<< <<<< # PostgreSQL database export PGDATABASE=mydb # <<<< <<<< <<<< export PGHOST=localhost # <<<< <<<< <<<< export PGPORT=5432 # <<<< <<<< <<<< # The script export PDBCHAINSAWST=$HOME/PDBChainSaw.s # <<<< <<<< <<< $TMPPDBLIST find ${PDBDIR}/[0-9A-Z][0-9A-Z] -name "*.pdb" -type f | sed -ne 's/.*\([1-9][0-9A-Z]\{3\}\)\.pdb$/insert into t_pdbnew (code) values ('\''\1'\'');/p;' >> $TMPPDBLIST echo "END WORK;" >> $TMPPDBLIST psql -q < $TMPPDBLIST #### 2.2. create differences to table of known pdb codes psql -q << ENDSQL CREATE VIEW pdb_sneu as (SELECT code from t_pdbnew except SELECT code from chsaw_pdb); CREATE VIEW pdb_sgeloescht as (SELECT code from chsaw_pdb except SELECT code from t_pdbnew); ENDSQL #### 2.3. delete old structures (from table pdb_sgeloescht) psql -qt << ENDSQL SELECT 'total of removed structures: '||count(*) from pdb_sgeloescht; DELETE from chsaw_chain where (pdb IN (select code from pdb_sgeloescht)); DELETE from chsaw_pdb where (code IN (select code from pdb_sgeloescht)); ENDSQL #### 2.4. call program ChainSaw on every new structure which must be added to db psql -qt -c "SELECT 'total of new structures: '||count(*) from pdb_sneu;" for S in `psql -q -t -c 'select code from pdb_sneu' `; do echo "*******************************************************************************" echo "Running ChainSaw on PDB file $S.pdb" MolTalk $PDBCHAINSAWST -i $S done #### 2.5. remove temporary stuff if [ -e $TMPPDBLIST ]; then rm $TMPPDBLIST; fi psql -q << ENDSQL DROP VIEW pdb_sneu; DROP VIEW pdb_sgeloescht; DROP TABLE t_pdbnew; ENDSQL } > $LOGFILE # compress log file gzip $LOGFILE # dump tables chsaw_chain and chsaw_pdb psql -c 'copy chsaw_chain (pdb,code,chainid,chainid2,residues,aminoacids,heterogens,solvent,sequence,organism,compound,eccode) to stdout;' | gzip - > $FTABLE1 psql -c 'copy chsaw_pdb (code,deposited,lastrev,experiment,resolution,header,title) to stdout;' | gzip - > $FTABLE2 chmod 644 $FTABLE1 chmod 644 $FTABLE2 # dump sequences in FASTA format (short peptides are omitted) psql -qt -c "SELECT '>'||chainid||' ('||length(sequence)||')\n'||sequence from chsaw_chain where length(sequence)>=10;" | sed -ne 's/^ *\(.*\)$/\1/p;' > $FSEQUENCES echo "all done." exit 0;