示例#1
0
def check_mmpbsa(checkjob, ligs_idxs):

    jobid = checkjob.jobid
    mmpbsa_settings = checkjob.mmpbsa_settings
    ressource = mmpbsa_settings['ressource']
    path = ssh.get_remote_path(jobid, ressource)

    scriptname = 'check_mmpbsa.sh'
    write_check_mmpbsa_script(scriptname, path, ligs_idxs, checkjob.nposes)
    output = subprocess.check_output(ssh.coat_ssh_cmd("ssh %s 'bash -s' < %s" %
                                                      (ressource, scriptname)),
                                     shell=True,
                                     executable='/bin/bash')
    status = ssh.get_status(output)

    ligs_done_idxs = [
        ligs_idxs[idx] + 1 for idx in range(len(ligs_idxs))
        if status[idx] == 'done'
    ]

    if ligs_done_idxs:
        if len(ligs_done_idxs) == 1:
            ligs_done_idxs_bash = str(ligs_done_idxs[0])
        else:
            ligs_done_idxs_bash = '{' + ','.join(map(str,
                                                     ligs_done_idxs)) + '}'

        subprocess.check_output(ssh.coat_ssh_cmd(
            "ssh -C %s \"cd %s; tar -cf - lig%s/{pbsa,gbsa}\" | `cd ../job_%s; tar -xf -` "
            % (ressource, path, ligs_done_idxs_bash, jobid)),
                                shell=True,
                                executable='/bin/bash')

    return status
示例#2
0
def submit_mmpbsa(checkjob, ligs_idxs):

    jobid = checkjob.jobid
    nposes = checkjob.nposes
    mmpbsa_settings = checkjob.mmpbsa_settings
    ressource = mmpbsa_settings['ressource']
    path = ssh.get_remote_path(jobid, ressource)

    # create job folder if does not exist
    status = subprocess.check_output(ssh.coat_ssh_cmd("ssh %s 'if [ ! -f %s/run_mmpbsa.sh ]; then if [ ! -d %s ]; then mkdir %s; fi; echo 1; else echo 0; fi'"\
                 %(ressource, path, path, path)), shell=True, executable='/bin/bash')
    isfirst = int(status)

    if isfirst == 1:
        write_mmpbsa_job_script(checkjob)
        achlysdir = os.path.realpath(__file__)
        analysis_script = '/'.join(
            achlysdir.split('/')[:-1]) + '/../tools/analysis.py'
        subprocess.check_output(
            ssh.coat_ssh_cmd("scp config.ini run_mmpbsa.sh %s %s:%s/." %
                             (analysis_script, ressource, path)),
            shell=True,
            executable='/bin/bash')
        os.remove('run_mmpbsa.sh')

    ligs_idxs_s = ' '.join(map(str, ligs_idxs))

    # Prepare mmpbsa
    with open('submit_mmpbsa.sh', 'w') as file:
        script = """source ~/.bash_profile
cd %(path)s

# submit jobs
for idx in %(ligs_idxs_s)s; do
  ligdir=lig$((idx+1))
  if [[ ! -d $ligdir ]]; then
    mkdir $ligdir
  fi
  for posedir in $ligdir/pose{1..%(nposes)s}; do
    cd $posedir
    sbatch ../../run_mmpbsa.sh # submit job
    cd ../..
  done
done""" % locals()
        file.write(script)

    subprocess.check_output(ssh.coat_ssh_cmd(
        "ssh %s 'bash -s' < submit_mmpbsa.sh" % ressource),
                            shell=True,
                            executable='/bin/bash')
    status = ['running' for idx in range(len(ligs_idxs))]

    return status
示例#3
0
def submit_md(checkjob, ligs_idxs):

    jobid = checkjob.jobid
    ressource = checkjob.md_settings['ressource']
    path = ssh.get_remote_path(jobid, ressource)

    nposes = checkjob.nposes

    status = subprocess.check_output(ssh.coat_ssh_cmd(
        "ssh %s 'if [ ! -d %s ]; then mkdir %s; echo 1; else echo 0; fi'" %
        (ressource, path, path)),
                                     shell=True,
                                     executable='/bin/bash')
    isfirst = int(status)

    if isfirst:
        write_md_job_script(checkjob)
        achlysdir = os.path.realpath(__file__)
        py_md_scripts = '/'.join(
            achlysdir.split('/')[:-1]) + '/{run_md.py,NAMD.py,amber.py}'
        subprocess.call(
            ssh.coat_ssh_cmd("scp config.ini run_md.sh %s %s:%s/." %
                             (py_md_scripts, ressource, path)),
            shell=True,
            executable='/bin/bash')

    # prepare md jobs
    ligs_idxs_s = ' '.join(map(str, ligs_idxs))
    scriptname = 'submit_md.sh'
    with open(scriptname, 'w') as file:
        script = """source ~/.bash_profile
cd %(path)s

for idx in %(ligs_idxs_s)s; do
  ligdir=lig$((idx+1))
  mkdir $ligdir
  for pose_id in `seq 1 %(nposes)s`; do
    posedir=$ligdir/pose${pose_id}
    mkdir $posedir
    cd $posedir
    llsubmit ../../run_md.sh
    cd ../..
  done
done""" % locals()
        file.write(script)

    subprocess.call(ssh.coat_ssh_cmd("ssh %s 'bash -s' < %s" %
                                     (ressource, scriptname)),
                    shell=True,
                    executable='/bin/bash')
    status = ['running' for idx in range(len(ligs_idxs))]
    return status
def submit_docking(checkjob, ligs_idxs):

    jobid = checkjob.jobid
    nligs = checkjob.nligs
    ntargets = checkjob.ntargets
    ressource = checkjob.docking_settings['ressource']

    firstcommand = ssh.get_first_command(ressource)
    submitcommand = ssh.get_submit_command(ressource)
    path = ssh.get_remote_path(jobid, ressource)

    # create results directory on the remote machine
    status = subprocess.check_output(ssh.coat_ssh_cmd("ssh %s 'if [ ! -d %s ]; then mkdir %s; echo 1; else echo 0; fi'"%(ressource, path, path)), \
        shell=True, executable='/bin/bash')
    isfirst = int(status)

    if isfirst == 1:
        write_docking_script(checkjob)

        # secure copy ligand files
        subprocess.check_output(ssh.coat_ssh_cmd(
            "tar -cf - {config.ini,lig*/iso1,targets,run_docking.sh} | \
ssh -C %(ressource)s '(cd %(path)s; tar -xf -)'" % locals()),
                                shell=True,
                                executable='/bin/bash')
        os.remove('run_docking.sh')

    ligs_idxs_s = ' '.join(map(str, ligs_idxs))

    # prepare docking jobs
    scriptname = 'submit_docking.sh'
    with open(scriptname, 'w') as file:
        script = """source ~/.bash_profile
cd %(path)s

# submit jobs
for idx in %(ligs_idxs_s)s; do
  cd lig$((idx+1))
  %(submitcommand)s ../run_docking.sh # submit job
  cd ..
done""" % locals()
        file.write(script)

    subprocess.check_output(ssh.coat_ssh_cmd(
        "ssh %s '%s bash -s' < %s" % (ressource, firstcommand, scriptname)),
                            shell=True,
                            executable='/bin/bash')
    status = ['running' for idx in range(len(ligs_idxs))]

    return status
示例#5
0
def submit_startup(checkjob, ligs_idxs):

    jobid = checkjob.jobid
    ressource = checkjob.docking_settings['ressource']
    path = ssh.get_remote_path(jobid, ressource)

    submitcommand = ssh.get_submit_command(ressource)
    firstcommand = ssh.get_first_command(ressource)

    # create results directory on the remote machine (pharma)
    status = subprocess.check_output(ssh.coat_ssh_cmd("ssh %s 'if [ ! -f %s/run_startup.py ]; then echo 1; else echo 0; fi'"%(ressource,path)),\
        shell=True, executable='/bin/bash')
    isfirst = int(status)

    if isfirst == 1:
        write_startup_job_script(checkjob)
        subprocess.call(ssh.coat_ssh_cmd("scp run_startup.sh %s:%s/." %
                                         (ressource, path)),
                        shell=True,
                        executable='/bin/bash')
        os.remove('run_startup.sh')

    # prepare md startup jobs
    ligs_idxs_s = ' '.join(map(str, ligs_idxs))
    scriptname = 'submit_startup.sh'
    with open(scriptname, 'w') as file:
        script = """#!/bin/bash 
source ~/.bash_profile
cd %(path)s

for idx in %(ligs_idxs_s)s; do
  cd lig$((idx+1))
  %(submitcommand)s ../run_startup.sh # submit job
  cd ..
done""" % locals()
        file.write(script)

    # submit jobs
    subprocess.call(ssh.coat_ssh_cmd("ssh %s '%s bash -s' < %s" %
                                     (ressource, firstcommand, scriptname)),
                    shell=True,
                    executable='/bin/bash')
    status = ['running' for idx in range(len(ligs_idxs))]

    return status
示例#6
0
def check_startup(checkjob, ligs_idxs):

    jobid = checkjob.jobid
    ressource = checkjob.docking_settings['ressource']
    path = ssh.get_remote_path(jobid, ressource)
    firstcommand = ssh.get_first_command(ressource)

    scriptname = 'check_startup.sh'
    write_check_startup_script(scriptname, path, ligs_idxs, checkjob.nposes)

    output =  subprocess.check_output(ssh.coat_ssh_cmd("ssh %s '%s bash -s' < %s"%(ressource,firstcommand,scriptname)),\
        shell=True, executable='/bin/bash')
    status = ssh.get_status(output)

    return status
示例#7
0
def check_md(checkjob, ligs_idxs):

    jobid = checkjob.jobid
    ressource = checkjob.md_settings['ressource']
    path = ssh.get_remote_path(jobid, ressource)

    scriptname = 'check_md.sh'
    write_check_md_script(scriptname, path, ligs_idxs, checkjob.nposes)

    output = subprocess.check_output(ssh.coat_ssh_cmd("ssh %s 'bash -s' < %s" %
                                                      (ressource, scriptname)),
                                     shell=True,
                                     executable='/bin/bash')
    status = ssh.get_status(output)

    return status
def check_docking(checkjob, ligs_idxs):

    ntargets = checkjob.ntargets
    jobid = checkjob.jobid
    ressource = checkjob.docking_settings['ressource']
    firstcommand = ssh.get_first_command(ressource)

    path = ssh.get_remote_path(jobid, ressource)

    ligs_idxs_s = ' '.join(map(str, ligs_idxs))
    scriptname = 'check_docking.sh'

    with open(scriptname, 'w') as file:
        script = """source ~/.bash_profile
cd %(path)s

# check the status of each docking job
for idx in %(ligs_idxs_s)s; do
  status=0
  for dir in lig$((idx+1))/iso1/target*; do
    filename=$dir/status.out
    if [[ -f $filename ]]; then
      num=`cat $filename`
      if [ $num -ne 0 ]; then # job ended with an error
        status=1
      fi
    elif [ $status -ne 1 ]; then # job is still running
      status=-1
    fi
  done
  echo $status
done""" % locals()
        file.write(script)

    output =  subprocess.check_output(ssh.coat_ssh_cmd("ssh %s '%s bash -s' < %s"%(ressource,firstcommand,scriptname)),\
        shell=True, executable='/bin/bash')
    status = ssh.get_status(output)

    return status
示例#9
0
def write_mmpbsa_job_script(checkjob):

    jobid = checkjob.jobid
    nposes = checkjob.nposes

    ressource_md = checkjob.md_settings['ressource']
    path_md = ssh.get_remote_path(jobid, ressource_md)

    mmpbsa_settings = checkjob.mmpbsa_settings
    ressource = mmpbsa_settings['ressource']
    path = ssh.get_remote_path(jobid, ressource)

    ssh_cmd = ssh.coat_ssh_cmd(
        """ssh -C %(ressource_md)s \"cd %(path_md)s/lig${lig_id}/pose${pose_id}/ligand; tar -cf - md.dcd\" | tar -xf -"""
        % locals())

    with open('run_mmpbsa.sh', 'w') as file:
        script = """#!/bin/bash
#SBATCH --time=168-00:00
#SBATCH --partition=largemem
#SBATCH --nodes=1
#SBATCH --cpus-per-task=4

lig_id=`echo $PWD | grep -o 'lig.*' | sed -n s/lig//p | cut -d/ -f1`
pose_id=`echo $PWD | grep -o 'pose.*' | sed -n s/pose//p`

# (A) prepare files for mmpbsa
cd ligand
%(ssh_cmd)s

mkdir mmpbsa
cd mmpbsa

# (B) run mmpbsa
run_mmpbsa.py -nt 4 -s ':WAT,Cl-,Na+' -n ':LIG'
echo $? > status.out
""" % locals()
        file.write(script)
示例#10
0
def write_md_job_script(checkjob):

    jobid = checkjob.jobid
    ressource_startup = checkjob.docking_settings['ressource']
    path_startup = ssh.get_remote_path(jobid, ressource_startup)
    firstcommand_startup = ssh.get_first_command(ressource_startup)

    ressource = checkjob.md_settings['ressource']
    path = ssh.get_remote_path(jobid, ressource)

    ssh_cmd = ssh.coat_ssh_cmd(
        """ssh -C %(ressource_startup)s \"%(firstcommand_startup)s cd %(path_startup)s/lig${lig_id}; tar -cf - pose${pose_id} --exclude=\\\"status.out\\\"\" | `cd ..; tar -xf -`"""
        % locals())

    with open('run_md.sh', 'w') as file:
        script = """#!/bin/sh
# @ job_name           = md-achlys
# @ job_type           = bluegene
# @ error              = $(job_name).$(Host).$(jobid).err
# @ output             = $(job_name).$(Host).$(jobid).out
# @ bg_size            = 64
# @ wall_clock_limit   = 24:00:00
# @ bg_connectivity    = Torus
# @ queue 

# (A) prepare files for md
cd $PWD
lig_id=`echo $PWD | grep -o 'lig.*' | sed -n s/lig//p | cut -d/ -f1`
pose_id=`echo $PWD | grep -o 'pose.*' | sed -n s/pose//p`
%(ssh_cmd)s

# (B) run files for md
cd ligand
python ../../../run_md.py min equil md -f ../../../config.ini --ncpus 1024 --bgq --withlig
echo $? > status.out\n""" % locals()
        file.write(script)