Ligand preparation - 20170424: Difference between revisions

From DISI
Jump to navigation Jump to search
No edit summary

Revision as of 23:14, 24 April 2017

3 ways to build ligands:

1. Source the dock environment and run the stand-alone script to build ligands for a given smiles file:

  setenv DOCKBASE /nfs/soft/dock/versions/dock37/DOCK-3.7-trunk     
  source /nfs/soft/dock/versions/dock37/DOCK-3.7-trunk/env.csh
  sh $DOCKBASE/ligand/generate/build_database_ligand.sh mysmiles.smi

2. Source the dock environment and submits jobs to build ligands for a given smiles file:

a. create a file with following commands (in this example, the file's name is cmd ):
     setenv DOCKBASE /nfs/soft/dock/versions/dock37/DOCK-3.7-trunk 
     setenv BUILD_ENVIRONMENT /nfs/soft/dock/versions/dock37/DOCK-3.7-trunk/env.sh
     /nfs/soft/tools/utils/qsub-slice/qsub-mr-meta -tc 10 --map-instance-script \
     "/nfs/soft/tools/utils/qsub-slice/qsub-mr-map.sh" -s $BUILD_ENVIRONMENT \
     -l 100 $1 $DOCKBASE/ligand/generate/build_database_ligand.sh


b. run the script with a smiles file:
     csh cmd mysmiles.smi

What does the qsub submit script exactly do?

     -l 100 --> submit slices of 100 lines per task to run the script build_database_ligand.sh.   
     -tc 10 --> run only 10 tasks at any given time. 
     -s $BUILD_ENVIRONMENT --> source the dock environment before each task is run.


3. the following is a wrapper script (wrapper_queue_build_smiles_ligand_corina.csh) which breaks up the smiles file and submits it to the queue. Users may find this script gives more control over the "qsub-mr-meta" way although it is less polished.

#! /bin/csh

# source enviorment. 
source ~tbalius/.cshrc_dbgen_corina

#set number_per_db2 = 1000
#set number_per_db2 = 5
set number_per_db2 = 10
set ph = 7.4

set file = $1
set fileprefix = ${file:r}


set pwd = `pwd`
set pathdir = $pwd
set workdir = $pwd/${fileprefix}

echo ${workdir}
echo ${file} ${fileprefix}

if (-e ${workdir}) then
 echo "${workdir} exists"
 exit
endif

#exit
#rm -rf ${workdir}
mkdir ${workdir}
cd ${workdir}

ln -s ../${file} .

echo "split --lines=$number_per_db2 --suffix-length=6  ${file} ${fileprefix}_split"

split --lines=$number_per_db2 --suffix-length=6  ${file} ${fileprefix}_split


foreach splitfile ( ` ls ${fileprefix}_split* | grep -v db2.gz ` ) 
echo ${splitfile}

# make sure that the link is pointing to something.  
#set lsoutput = `ls -l sgejob_*/${splitfile}.db2.gz`
#echo "WHAT:: $lsoutput"
#if ("$lsoutput" == "") then
#    rm ${splitfile}.db2.gz
#endif

if (-e ${splitfile}.db2.gz) then
   echo "${splitfile} has been submitted for generations." 
   continue
endif 

cat << EOF >! script_qsub_${splitfile}.csh
#\$ -S /bin/csh
#\$ -cwd
#\$ -q all.q
#\$ -o stdout_${splitfile}
#\$ -e stderr_${splitfile}

# source enviorment. 
source ~tbalius/.cshrc_dbgen_corina

hostname
date

set SCRATCH_DIR = /scratch
if ! (-d \$SCRATCH_DIR ) then
    SCRATCH_DIR=/tmp
endif
set username = `whoami`

set TASK_DIR = "\$SCRATCH_DIR/\${username}/\$JOB_ID"
echo \$TASK_DIR

mkdir -p \${TASK_DIR}
cd \${TASK_DIR}
pwd

cp ${workdir}/${splitfile} .

# note that the pining script's inputs should not be in quotes ( or "").
/nfs/home/tbalius/zzz.github/DOCK/common/on-one-core - ${DOCKBASE}/ligand/generate/build_database_ligand.sh -H $ph ${splitfile}

cd ${workdir}
mkdir sgejob_\${JOB_ID}_${splitfile}

echo copying
ls -l \${TASK_DIR}/finished/*/*.db2.gz
ls -l \${TASK_DIR}/finished/*/*.db.gz 

# copy finshed directory
mv \${TASK_DIR}/finished/ sgejob_\${JOB_ID}_${splitfile}
rm -r \${TASK_DIR}

EOF

while ( `qstat -u tbalius | wc -l ` > 10 )
  sleep 10
end


qsub script_qsub_${splitfile}.csh

#exit

end

set up environment: jchem mitools, DOCK3.7, ZINC, corina

source /nfs/soft/jchem/current/env.csh
source /nfs/soft/mitools/env.csh
source /nfs/soft/dock/versions/dock37/DOCK-3.7-trunk/env.csh
deactivate
source /nfs/soft/www/apps/zinc15/envs/edge/env.csh
source /nfs/soft/corina/current/env.csh
setenv EMBED_PROTOMERS_3D_EXE $DOCKBASE/ligand/3D/embed3d_corina.sh 
setenv ZINC_CONFIG_ENV admin
setenv ZINC_CONFIG_SETUP_SKIP blueprints 


step 2. csh cmd mysmiles.ism

# put any change in the BUILD_ENVIRONMENT
source /nfs/soft/dock/versions/dock37/DOCK-3.7-trunk/env.csh
source /nfs/soft/corina/current/env.csh
setenv EMBED_PROTOMERS_3D_EXE $DOCKBASE/ligand/3D/embed3d_corina.sh
setenv BUILD_ENVIRONMENT /nfs/home/xyz/bin/dockenvNS.sh
#
/nfs/soft/tools/utils/qsub-slice/qsub-mr-meta -tc 10 -L 100000 --map-instance-script \
"/nfs/scratch/A/xyz/protomer/qsub-mr-map.sh" -s $BUILD_ENVIRONMENT \
-l 300 $1 $DOCKBASE/ligand/generate/build_database_ligand.sh

If you have any trouble using this (which the procedure used to build ZINC between July 14, 2016 and Nov 14, 2016 (ongoing), please contact me. I would be happy to help debug, as it will help us to make this procedure more robust.