Package: pyscreener
pyscreenerA pythonic interface to high-throughput virtual screening softwareOverviewThis repository contains the source of pyscreener, both a library and software for conducting HTVS via python callsTable of ContentsOverviewTable of ContentsRequirementsInstallationRay setupRunning pyscreenerUsing pyscreenerInstallationDockerIf docker is not installed already for your system then it can be installed fromthe official docker website.The providedDockerfilecan be used to create pyscreener instances containing the required docking software and python dependencies / code. Any of the four vina docking softwares -vina,qvina2,smina, andpsovina- can be specified for installation to the docker image.
All python dependencies and the pyscreener library are installed to a conda environment namedpyscreenerwhich must be activated once the docker image starts.The below commands can be run in the directory containing theDockerfileandenvironment.ymlfiles to build the desired image:docker build -t pyscreener:base --target base .: Creates a docker image containing all python dependencies and pyscreener library but no docking softwaredocker build -t pyscreener:vina --target vina .: Creates an image frompyscreener:basewithvinainstalleddocker build -t pyscreener:qvina --target qvina .: Creates an image frompyscreener:basewithqvinainstalleddocker build -t pyscreener:smina --target smina .: Creates an image frompyscreener:basewithsminainstalleddocker build -t pyscreener:psovina --target psovina .: Creates an image frompyscreener:basewithpsovinainstalledAsDOCK6software requires a license, it is not possible to include its installation within the associated docker image.
A compiled form ofsphgen_cppand the binary required for installation ofchimeraare both available within thedock6_utilsdirectory of the associated dock6 image:docker build -t pyscreener:dock6 --target base-dock6 .: Creates an image frompyscreener:basecontaining utility software needed forDOCK6to run once installedNotes :Within the docker container, the environmentbasewill be activated by default. This contains all the required python dependencies so there is no need to manually activate an environment once inside the containerIf installing using docker, then the below installation stages are not required for the corresponding vina-type software. However, the DOCK6 directions must still be followed.General requirementspython >= 3.8numpy,openbabel,openmm,pdbfixer,ray,rdkit,scikit-learn,scipy, andtqdmall corresponding software downloaded and located on your PATH or under the path of a specific environment variable (seeexternal softwarefor more details.)Setup(if necessary)install condaconda env create -f environment.ymlconda activate pyscreenerpip install pyscreener(or if installing from source,pip install .)follow the corresponding directions below for the intended softwareBefore runningpyscreener, be sure to first activate the environment:conda activate pyscreener(or whatever you've named your environment)external softwarevina-type softwareinstallADFR Suiteand addprepare_receptorto your PATH. If this step was successful, the commandwhich prepare_receptorshould outputpath/to/prepare_receptor. This can be done via either:adding the entirebindirectory to your path (you should see a command at the end of the installation process) oradding onlyprepare_receptorin thebindirectory to your PATH as detailedbelowinstall any of the following docking software:vina 1.1.2(note:pyscreener does not work with vina 1.2),qvina2,smina,psovinaandensure the desired software executable is in a folder that is located on your pathDOCK6obtain a license for DOCK6install DOCK6 from the download link and follow theinstallation directionsafter ensuring the installation was installed properly, specify the DOCK6 environment variable as the path of the DOCK6 parent directory as detailedbelow. This is the directory that was unzipped from the tarball and is usually nameddock6. It is the folder that contains thebin,install, etc. subdirectories.)installsphgen_cpp. On linux systems, this can be done:wget http://dock.compbio.ucsf.edu/Contributed_Code/code/sphgen_cpp.1.2.tar.gztar -xzvf sphgen_cpp.1.2.tar.gzcd sphgen_cpp.1.2makeplace the sphgen_cpp executable (it should besphgen_cpp) inside thebinsubdirectory of the DOCK6 parent directory. If you've configured the environment variable already, (on linux) you can run:mv sphgen_cpp $DOCK6/bininstall chimeraand place the file on your PATH as detailedbelowadding an executable to your PATHTo add an executable to your PATH, you have three options:create a symbolic link to the executable inside a directory that is already on your path:ln -s FILE -t DIR. Typically,~/binor~/.local/binare good target directories (i.e.,DIR). To see what directories are currently on your path, typeecho $PATH. There will typically be a lot of directories on your path, and it is best to avoid creating files in any directory above your home directory ($HOMEon most *nix-based systems)copy the software to a directory that is already on your path. Similar, though less preferred than the above:cp FILE DIRappend the directory containing the file to your PATH:export PATH=$PATH:DIR, whereDIRis the directory containing the file in question. As your PATH must be configured each time run pyscreener, this command should also be placed inside your~/.bashrcor~/.bash_profile(if using a bash shell) to avoid needing to run the command every time you log in.Note: if using a non-bash shell, the specific file will be different.specifying an environment variableTo set theDOCK6environment variable, run the following command:export DOCK6=path/to/dock6, wherepath/to/dock6is thefullpath of the DOCK6 parent directory mentioned above. As this this environment variable must always be set before running pyscreener, the command should be placed inside your~/.bashrcor~/.bash_profile(if using a bash shell) to avoid needing to run the command every time you log in.Note: if using a non-bash shell, the specific file will be different.Ray Setuppyscreener usesrayas its parallel backend. If you plan to parallelize the software only across your local machine, don't need to do anything . However, if you wish to either (a.) limit the number of cores pyscreener will be run over or (b.) run it over a distributed setup (e.g., an HPC with many distinct nodes), you must manually start a ray clusterbeforerunning pyscreener.Limiting the number of coresTo do this, simply typeray start --head --num-cpus Nbefore starting pyscreener (whereNis the total number of cores you wish to allow pyscreener to utilize). Not performing this step will give pyscreener access to all of the cores on your local machine, potentially slowing down other applications.Distributing across many nodesWhile the precise instructions for this will vary with HPC cluster architecture, the general idea is to establish a ray cluster between the nodes allocated to your job. We have provided a sample SLURM submission script (run_pyscreener_distributed_example.batch) to achieve this, but you may have to alter some commands depending on your system. For more information on this seehere. To allow pyscreener to connect to your ray cluster, you must set theip_headandredis_passwordenvironment variables appropriately, whereip_headis the address of the head of your ray cluster, i.e.,IP:PORTwhereIPis the IP address of the head node andPORTis the port that is running ray.pyscreener writes a lot of intermediate input and output files (due to the inherent specifications of the underlying docking software.) Given that the primary endpoint of pyscreener is a list of ligands and associated scores (rather than the specific binding poses,) these files are written to each node's temporary directory (determined bytempfile.gettempdir()) and discarded at the end. If you wish to collect these files, pass the--collect-allflag in the program arguments or run thecollect_files()method of yourVirtualScreenobject when your screen is complete.Note: theVirtualScreen.collect_files()method isslowdue to the need to send possibly abunchof files over the network. This method should only be runonceover the lifetime of aVirtualScreenobject, as several intermediate calls will yield the same result as a single, final call.Note:tempfile.gettempdir()returns a path that depends the values of specific environment variables (seehere). It is possible that the value returned on your system is not actually a valid path for you! In this case you will likely get file permissions errors and must ask your system administrator where this value should point to and set your environment variables accordingly before running pyscreener!Running pyscreener as a software!!please read the entire section before running pyscreener!!pyscreener was designed to have a minimal interface under the principal that a high-throughput virtual screen is intended to be a broad strokes technique to gauge ligand favorability. With that in mind, all one really needs to get going are the following:the type of screen (screen-type) you would like to run:vinaordockfor Vina-type or DOCK6 screens, respectivelythe PDB id(s) of your receptor(s) of interest or PDB file(s) of the specific structure(s)a file containing the ligands you would like to dock, in SDF, SMI, or CSV formatthe coordinates of your docking box (center + size) or a PDB format file containing the coordinates of a previously bound liganda metadata template containing screen-specific options in a JSON-format string. See themetadatasection below for more details.the number of CPUs you would like to parallellize each docking simulation over. This is 1 by default, but Vina-type software can leverage multiple CPUs for faster docking. A generally good value for this is between2and8depending on your compute setup. If you're docking molecule-by-molecule, e.g., reinforcement learning, then you will likely want this to be as many CPUs as are on your machine.There are a variety of other options you can specify as well (including how to score a ligand given that multiple scored conformations are output, how to score against an ensemble of structures, etc.) To see all of these options and what they do, use the following command:pyscreener --help. All of these options may be specified on the command line or in a configuration file that accepts YAML, INI, andargparsesyntaxes. Example configuration files are located inintegration-tests/configs.To check if everything is working and installed properly, first run pyscreener like so:pyscreener --config path/to/your/config --smoke-testMetadata TemplatesVina-type and DOCK6 docking simulations have a number of options unique to their preparation and simulation pipeline, and these options are termed simulation "metadata" inpyscreener. At present, only a few of these options are supported for both families of docking software, but future updates will add support for more of these options. These options may be specified via a JSON struct to the--metadata-templateargument. Below is a list of the supported options for both types of docking screen (default options provided in parentheses next to the parameter)Vina-typesoftware(="vina"): which Vina-type docking software you would like to use. Currently supported values:"vina","qvina","smina", and"psovina"extra(=""): all the extra command line options to pass to a Vina-type docking software. E.g. for a run of Smina,extra="--force_cap ARG"or for PSOVina,extra="-w ARG"DOCK6probe_radius(=1.4): the size of the probe to use for calculating the molecular surface (seeherefor more details)steric_clash_dist(=0.0): prevent the generation of large spheres with close surface contacts with larger valuesmin_radius(=1.4): the minimum radius of sphere to use for sphere generationmax_radius(=4.0): the maximum "..."sphere_mode(="box"): the method by which to select spheres for docking box construction. Accepted values:"largest", select the largest cluster of spheres;"box", select all spheres within a predefined docking box;"ligand", use the coordinates of a previously docked/bound ligand to select spheresdocked_ligand_file(=""): a MOL2 file containing the coordinates of a previously docked/bound ligandbuffer(=10.0): the amount of extra space (in Angstroms) to be added around the ligand when selecting spheresenclose_spheres(=True): whether to construct the docking box by enclosing all of the selected spheres or use only spheres within a predefined docking boxTesting your environment setupTo test whether your environment is setup correctly with respect to pathing and environment variables, runpyscreenerlike so:pyscreener --smoke-test --screen-type SCREEN_TYPE --metadata-template TEMPLATEwhereSCREEN_TYPEandMETADATA_TEMPLATEand values as described aboveIf the checks pass, then your environment is set up correctly.Using pyscreener as a libraryTo check ifpyscreeneris set up properly, you can run the following:>>>importpyscreenerasps>>>software="...">>>metadata={...}>>>ps.check_env(software,metadata)...where software is the name of the software you intend to use and metadata is a dictionary containing the metadata template. Please see themetadata templatessection for details on possible key-value pairs.The object model of pyscreener relies on four classes:CalculationData: a simple object containing the broadstrokes specifications of a docking calculation common to all types of docking calculations (e.g., Vina, DOCK6, etc.): the SMILES string, the target receptor, the center/size of a docking box, the metadata, and the result.CalculationMetadata: a nondescript object that contains software-specific fields. For example, a Vina-type calculation requires asoftwareparameter, whereas a DOCK6 calculation requires a number of different parameters for receptor preparation. Most importantly, the metadata will always contain two fields of abstract type:prepared_ligandandprepared_receptor.DockingRunner: a static object that takes defines an interface to prepare and run docking calculations. Each calculation type defines its ownDockingRunnerimplementation.DockingVirtualScreen: an object that organizes a virtual screen. At a high level, a virtual is a series of docking calculations with some template set of parameters performed for a collection of molecules and distributed over some set of computational resources. ADockingVirtualScreentakes as arguments aDockingRunner, a list of receptors (for possible ensemble docking) and a set of template values for aCalculationDatatemplate. It defines a__call__()method that takes an unzipped list of SMILES strings, builds theCalculationDataobjects for each molecule, and submits these objects for preparation and calculation to various resources in the ray cluster (seeray setup).To perform docking calls inside your python code usingpyscreener, you must first initialize aDockingVirtualScreenobject either through the factorypyscreener.virtual_screenfunction or manually initializing one. The following section will show an example of how to perform computational from inside a python interpreter.Examplesthe following code snippet will dock benzene (SMILES string"c1ccccc1") against the D4 dopamine receptor (PDB ID5WIU) using a predefined docking box and Autodock Vina>>>importray>>>ray.init()[...]>>>importpyscreenerasps>>>metadata=ps.build_metadata("vina")>>>virtual_screen=ps.virtual_screen("vina",["integration-tests/inputs/5WIU.pdb"],(-18.2,14.4,-16.1),(15.4,13.9,14.5),metadata,ncpu=8){...}>>>scores=virtual_screen("c1ccccc1")>>>scoresarray([-4.4])A few notes from the above example:the input PDB file must becleanprior to use. You can alternatively pass in a PDB ID (e.g.,pdbids=["5WIU"]) but you must know the coordinates of the docking box for the corresponding PDB file. This usually means downloading the PDB file and manually inspecting it for more reliable results, but it's there if you want it.you can construct a docking from the coordinates of a previously bound ligand by providing these coordinates in a PDB file, e.g.vs=ps.virtual_screen("vina",["integration-tests/inputs/5WIU.pdb"],None,None,metadata,ncpu=8,docked_ligand_file="path/to/DOCKED_LIGAND.pdb")ray handles task distribution in the backend of the library. You don't need to manually start it if you're just going to callray.init()like we did above. This was only done to highlight the ability to initialize ray according to your own needs (i.e., a distributed setup).to use an input file containing ligands, you must use theLigandSupplyclass and access the.ligandsattribute, e.g.,supply=ps.LigandSupply(['integration-tests/inputs/ligands.csv'])virtual_screen(supply.ligands)for more examples, check out theexamplesfolder!Testingpip install pytest-covpytestCopyrightCopyright (c) 2021, david graff