view rbdock.py @ 7:7e5c2e4bc227 draft default tip

"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/rdock commit 944ea4bb8a9cd4244152a4a4fecd0485fabc2ad0"
author bgruening
date Tue, 28 Jul 2020 08:44:40 -0400
parents d52d6ee95cf2
children
line wrap: on
line source

import subprocess
import argparse

def main():
    parser = argparse.ArgumentParser(description='Simple wrapper for rbdock')
    parser.add_argument('-n', '--num', type=int, help='Number of docking poses to generate')
    parser.add_argument('-s', '--seed', type=int, help='Random seed')
    args = parser.parse_args()

    cmd = ['rbdock', '-i', 'ligands.sdf', '-r', 'receptor.prm', '-p', 'dock.prm', '-n', str(args.num), '-o', 'rdock_output']
    if args.seed != None:
        cmd += ['-s', str(args.seed)]

    ps = subprocess.Popen(cmd, stdout=subprocess.PIPE)

    error_counter = 0
    for stdout_line in iter(ps.stdout.readline, ''):
        if 'RBT_DOCKING_ERROR' in str(stdout_line):
                error_counter += 1
                if error_counter == 10:
                    print(ps.stdout)
                    exit(23)
        if ps.poll() != None:
            print(ps.stdout)
            exit(int(ps.poll()))

if __name__ == "__main__":
    main()