Running ChemSTEP: Difference between revisions

From DISI
Jump to navigation Jump to search
No edit summary
No edit summary
 
(80 intermediate revisions by 2 users not shown)
Line 1: Line 1:
written July 24 2025 by katie. These are directions to run a legacy version of ChemSTEP on Wynton.  
last update: dec 16 2025 katie. current ver = 0.3.1.5 (automatic resubmission of failed SGE jobs).  


What the user needs: SMILES file of every molecule in virtual library with unique molecule IDs (ranging from 1-size of library), dockfiles
ChemSTEP (Chemical Space Traversal and Exploration Procedure) is an open-source, transparent acceleration algorithm for molecular docking capable of dealing with virtual libraries of several trillion compounds. This wiki page is a guide for BKS lab members to run ChemSTEP on Wynton HPC, using a drug-like subset of ZINC (22B) or 13.3B library from Enamine REAL. '''for detailed instructions on the 13B space, see 'Running ChemSTEP on the 13B space' wiki page'''. For more general use directions, please refer to [ChemSTEP Read-the-Docs].


'''1. Copy all necessary scripts to your working directory'''
At a high-level, ChemSTEP is an iterative process that identifies molecules from the larger virtual library to prioritize for docking. First, we identify a random sample of the total library (termed "seed set", round zero) and dock those molecules to the target of interest. From this seed set, we can calculate total-library pProp values (-log rank percentages) and the number of "virtual hits" in the total library (high-scoring molecules). ChemSTEP will identify a set of maximally diverse molecules that score above the desired pProp threshold ("beacons") from the seed set. These beacons guide prioritization, where molecules chosen and output by ChemSTEP are close in chemical space to the beacons. Prioritized molecules are then built, docked, and returned to ChemSTEP for a second round of prioritization. This process is iterated until you reach desired virtual hit recovery, or you are no longer recovering virtual hits.  
    cp -r /wynton/group/bks/work/kholland/shared/chemstep/all_scripts .  
includes get_fingerprints.py, chemstep_params.txt, get_threshold.py, run_chemstep for initial and subsequent rounds, as well as a launch_chemstep.sh script for SGE job submission.


'''2. Source environment'''
    source /wynton/group/bks/work/kholland/shared/chemstep/venv/bin/activate


'''3. Edit get_fingerprints.py''' to reflect your input SMILES file and desired output directory. NOTE: is not set up to work at scale right now. i am working on a method for parallelization.
= Running ChemSTEP (Auto DOCK and Build) =
  if __name__ == "__main__":
    smi_file = '''"library.smi"'''  # Replace with your input file
    output_dir = '''"library_fingerprints"''' # Replace with your output directory


''' Run generation'''
ChemSTEP is configured to run on Wynton with libraries of '''13B''' and '''22B'''. This page covers the full workflow for running ChemSTEP with automatic submission of docking and building jobs.
for large libraries, submit as a job using submit_fp_gen.sh
    python3 get_fingerprints.py


'''4. Dock a random, representative subset of the total library to your POI.'''
__TOC__


'''5. Extract scores and respective molecule IDs''' (same ones used for FP generation) from step 4, assigning a score of 100 to any molecule that did not dock.
== 1. Source Environment ==
    mol0001884980 -17.41
    mol0001883931 -21.49
    mol0001883965 -27.51
    mol0001883247 100
    mol0001885445 -20.05
    mol0001884461 -14.55
    mol0001884565 -16.7
    mol0001885496 -18.01
    mol0001884345 -16.71


'''6. Edit parameter file''' to reflect desired step size, pProp goal, and number of beacons per step
<pre>
source /wynton/group/bks/work/shared/kholland/chemstep_auto_v02/bin/activate
</pre>


  seed_scores_file: dicts_810k/scoredict_2.pickle
== 2. Dock the Seed Set ==
  novelty_set_file: known_binders_fps.npy
  novelty_dist_thresh: 0.5
  screen_novelty: False
  beacon_dist_thresh: 0.0
  diversity_dist_thresh: 0.5
  '''hit_pprop: 4''' #change this
  artefact_pprop: 6
  use_artefact_filter: False
  '''n_docked_per_round:''' 100 #change this
  '''max_beacons:''' 10 #change this
  '''max_n_rounds:''' 10 #change this


'''7. Edit run_chemstep_init.py''' to reflect library size (n_files= number of fp_*.npy files generated in step 3), scores_dict (file with dock scores and mol ID from step 5), and path to fingerprint library from step 3.
Copy the <code>.sdi</code> file for the library you want to use:
  if __name__ == "__main__":
  scores_dict = get_scores_dict(''''dock_scores_round_0.txt'''') #change this
  run_chemstep_first_round('chemstep_params.txt', ''''/wynton/group/bks/work/path/to/fingerprint/library'''', scores_dict,
                            'chemstep_log', 'chemstep_output') #update path


'''8. Make output directories'''
{| class="wikitable"
  mkdir chemstep_output
! Library !! Path
|-
| 13B || <code>/wynton/group/bks/work/shared/kholland/chemstep_auto_v02/scripts/libraries/13B/13M_seeds.sdi</code>
|-
| 22B || <code>/wynton/group/bks/work/shared/kholland/chemstep_auto_v02/scripts/libraries/22B/22M_seeds.sdi</code>
|}


  mkdir chemstep_log
Then dock the seed set. See the '''Large-Scale Docking (LSD)''' directions.


== 3. Gather Scores for the Seed Set ==


'''9. Launch ChemSTEP'''
Once docking is complete, run the following from the directory '''one level above''' your docking output (<code>MOLECULES_DIR_TO_BIND</code>).
note: this may take several hours
  qsub launch_chemstep_init.sh


'''22B library:'''
<pre>
python /wynton/group/bks/work/shared/kholland/chemstep_auto_v02/scripts/get_scores.py 0
</pre>


when the job is complete, a pickle file will be created in the working directory. within chemstep_output will be a dataframe containing assigned beacons, a file of calculated tanimoto distances, and an '''smi_round_1.smi''' file containing the SMILES strings and IDs of molecules prioritized for the next round of docking.  
'''13B library:'''
<pre>
python /wynton/group/bks/work/shared/kholland/chemstep_auto_v02/scripts/get_scores_13B.py 0 MOL
</pre>


'''10. View assigned pProp value'''
{{Note|You must specify the molecule ID prefix for the 13B library (<code>MOL</code>).}}
    python3 get_threshold.py


'''11. Build and dock prioritized molecules'''
Verify that <code>scores_round_0.txt</code> was correctly written:
<pre>
wc -l scores_round_0.txt
</pre>


When completed, extract scores and IDs as outlined in step 5.  
== 4. Convert Scores to .npy Files ==


'''12. Edit run_chemstep.py''' to reflect library size, new score_dict, and ChemSTEP round number (we are now on round 2).  
Convert scores to ChemSTEP-readable <code>.npy</code> files:
  if __name__ == "__main__":
  scores_dict = get_scores_dict(''''dockingscores_round_1.txt'''')
  run_chemstep_round(scores_dict, '''2''')


'''13. Launch ChemSTEP round 2'''
<pre>
note: this may take several hours
python /wynton/group/bks/work/shared/kholland/chemstep_auto_v02/scripts/convert_scores_to_npy.py 0 <mol_id_prefix>
  qsub launch_chemstep.sh
</pre>


Repeat steps 11-13 as needed for desired hit recovery, making sure to update the scored_dict and round number.
The <code>mol_id_prefix</code> should match the library:
 
{| class="wikitable"
! Library !! Prefix
|-
| 22B / 72B || <code>CSLB</code>
|-
| 13B || <code>MOL</code>
|}
 
== 5. Set Up the ChemSTEP Run Directory ==
 
Create and enter a new run directory, then copy in the necessary files:
 
<pre>
mkdir chemstep_run
cd chemstep_run
chemstep-run-new
</pre>
 
This will populate the directory with <code>params.txt</code>, <code>run_chemstep.py</code>, and <code>launch_chemstep_as_job.sh</code>.
 
=== Optional: Integrated IFP ===
 
If running with integrated IFP for beacon selection, also run:
 
<pre>
chemstep-run-ifp
</pre>
 
This copies in the additional files <code>ifp_acceptance_criteria.txt</code> and <code>interactions.txt</code>.
 
== 6. Edit params.txt ==
 
Add the absolute paths to the ChemSTEP-readable score and indices <code>.npy</code> arrays generated in Step 4.
 
<pre>
seed_indices_file:  /path/to/your/indices_round_0.npy
seed_scores_file:  /path/to/your/scores_round_0.npy
hit_pprop:          5.5
n_docked_per_round: 2000000
bundle_size:        1000
max_beacons:        100
max_n_rounds:      250
</pre>
 
=== Parameter Reference ===
 
{| class="wikitable"
! Parameter !! Description
|-
| <code>hit_pprop</code> || Defines a "virtual hit." pProp = −log(rank%) within the total library score distribution. E.g., pProp 4 in 13B space ≈ top 0.01% (~1.3M molecules); pProp 5 ≈ 0.001% (~132K). The seed set should contain at least 10<sup>(pProp+2)</sup> molecules.
|-
| <code>n_docked_per_round</code> || Number of molecules prioritized per round. All must be built and docked between rounds. Too many slows throughput and may reduce diversity; too few slows virtual hit recovery.
|-
| <code>max_beacons</code> || Diverse, well-scoring molecules used to guide prioritization. All molecules above the pProp threshold are candidates. Too many reduces inter-beacon diversity; too few hinders space exploration. Fewer beacons than specified may be assigned if insufficient molecules clear the threshold.
|-
| <code>bundle_size</code> || In auto docking mode, number of molecules submitted as a single build job.
|-
| <code>max_n_rounds</code> || No adjustment needed when running ChemSTEP prospectively as described here.
|}
 
== 7. Edit run_chemstep.py ==
 
'''Note:''' All paths must be '''absolute paths'''.
 
=== Required Settings ===
 
Set <code>lib_path</code> to the library pickle for your library:
 
{| class="wikitable"
! Library !! Path
|-
| 13B || <code>/wynton/group/bks/work/shared/kholland/chemstep_auto_v02/scripts/libraries/13B/boltz_fplib.pickle</code>
|-
| 22B || <code>/wynton/group/bks/work/shared/kholland/chemstep_auto_v02/scripts/libraries/22B/22B_fplib.pickle</code>
|}
 
<pre>
lib_path = '/full/path/to/library.pickle'
</pre>
 
Set <code>dockfiles_path</code>:
 
<pre>
dockfiles_path="/full/path/to/dockfiles"
</pre>
 
=== Optional: minTD Exclusion Zone ===
 
Molecules will not be prioritized from within a specified Tanimoto distance of beacons. Comment in the relevant lines and update the value. Consider also setting <code>enforce_n_docked_per_round = True</code> when using this option:
 
<pre>
min_td_search=0.5,
enforce_n_docked_per_round=True,
</pre>
 
=== Optional: Integrated IFP ===
 
Only selects beacons that satisfy user-defined interaction criteria. Comment in the following lines and update the paths to the necessary files (copied in Step 5 if you ran <code>chemstep-run-ifp</code>):
 
<pre>
use_IFP=True,
ifp_pdb_path='/full/path/to/rec.crg.pdb',
interactions_file='/full/path/to/interactions.txt',
ifp_acceptance_criteria_file='/full/path/to/ifp_acceptance_criteria.txt',
</pre>
 
'''<code>interactions.txt</code>''' — one interaction per line, comma-separated. Format: <code>interaction_type, residue_name_and_number</code>. Example:
 
<pre>
Hydrogen bond, GLY19
Ionic, ASP149
</pre>
 
Supported interaction types include: Proximal, Hydrogen bond, Ionic, Cation-pi, Hydrophobic, Halogen bond, and others. See LUNA and IFP documentation for the full list.
 
'''<code>ifp_acceptance_criteria.txt</code>''' — defines the number of unsatisfied donors/acceptors/specific interactions required for a molecule to pass IFP and be considered for beacon selection. Example:
 
<pre>
#_donors
#_acceptors
#_unstatisfied_donors == 0
#_unstatisfied_acceptors <= 4
Ionic/ASP-149 > 0
</pre>
 
=== Example: AmpC on 22B with minTD=0.50, No IFP ===
 
<pre>
lib_path = '/wynton/group/bks/work/shared/kholland/chemstep_auto_v02/scripts/libraries/22B/22B_fplib.pickle'
lib = load_library_from_pickle(lib_path)
algo = CSAlgo(lib, 'params.txt', 'output', 16, verbose=True,
    scheduler='sge', smi_id_prefix='CSLB',
    python_exec="/wynton/group/bks/work/shared/kholland/chemstep_auto_v02/bin/python",
    dockfiles_path="/wynton/group/bks/work/kholland/chemstep_ampc_22B/seed_docking/dockfiles",
    min_td_search=0.5,
    enforce_n_docked_per_round=True,
    #use_IFP=True,
    #ifp_pdb_path='/path/to/your/reference/rec.crg.pdb',
    #interactions_file='/path/to/your/interactions.txt',
    #ifp_acceptance_criteria_file='/path/to/your/ifp_acceptance_criteria.txt',
    docking_method="auto", track_beacon_orig=True)
</pre>
 
== 8. Launch the Job ==
 
Submit the main ChemSTEP job:
 
<pre>
qsub launch_chemstep_as_job.sh
</pre>
 
== 9. Monitor Job Status ==
 
Check job status with <code>qstat</code>. The main job will run for up to '''2 weeks''' given no errors. ChemSTEP will launch search, building, and docking jobs in successive rounds.
 
'''Note:''' If any building or docking subjobs hang, the main job will not proceed until those are canceled or finished. Monitor job statuses regularly and occasionally verify that docking output files (<code>scores_round_*.txt</code>) are being populated.
 
== 10. View Beacon SMILES and IDs ==
 
From the ChemSTEP running directory, run the following in a '''screen session on a dev node''':
 
<pre>
python /wynton/group/bks/work/shared/kholland/chemstep_auto_v02/scripts/get_beacon_smiles.py /path/to/library/pickle chemstep_algo.log
</pre>
 
Use the library pickle path from [[#7. Edit run_chemstep.py|Step 7]].
 
== 11. Get Poses After Docking ==
 
Make a list of <code>test.mol2.gz.0</code> files from docking:
 
<pre>
find /round_*_docking/bundle_paths -maxdepth 2 -name "test.mol2.gz.0" > docked_poses.txt
</pre>
 
Then extract top poses:
 
<pre>
python /wynton/group/bks/work/bwhall61/for_beau/top_poses.py \
    -t <pProp_threshold> \
    -s <num_poses_per_file> \
    -dock_results_path docked_poses.txt
</pre>

Latest revision as of 16:53, 16 March 2026

last update: dec 16 2025 katie. current ver = 0.3.1.5 (automatic resubmission of failed SGE jobs).

ChemSTEP (Chemical Space Traversal and Exploration Procedure) is an open-source, transparent acceleration algorithm for molecular docking capable of dealing with virtual libraries of several trillion compounds. This wiki page is a guide for BKS lab members to run ChemSTEP on Wynton HPC, using a drug-like subset of ZINC (22B) or 13.3B library from Enamine REAL. for detailed instructions on the 13B space, see 'Running ChemSTEP on the 13B space' wiki page. For more general use directions, please refer to [ChemSTEP Read-the-Docs].

At a high-level, ChemSTEP is an iterative process that identifies molecules from the larger virtual library to prioritize for docking. First, we identify a random sample of the total library (termed "seed set", round zero) and dock those molecules to the target of interest. From this seed set, we can calculate total-library pProp values (-log rank percentages) and the number of "virtual hits" in the total library (high-scoring molecules). ChemSTEP will identify a set of maximally diverse molecules that score above the desired pProp threshold ("beacons") from the seed set. These beacons guide prioritization, where molecules chosen and output by ChemSTEP are close in chemical space to the beacons. Prioritized molecules are then built, docked, and returned to ChemSTEP for a second round of prioritization. This process is iterated until you reach desired virtual hit recovery, or you are no longer recovering virtual hits.


Running ChemSTEP (Auto DOCK and Build)

ChemSTEP is configured to run on Wynton with libraries of 13B and 22B. This page covers the full workflow for running ChemSTEP with automatic submission of docking and building jobs.

1. Source Environment

source /wynton/group/bks/work/shared/kholland/chemstep_auto_v02/bin/activate

2. Dock the Seed Set

Copy the .sdi file for the library you want to use:

Library Path
13B /wynton/group/bks/work/shared/kholland/chemstep_auto_v02/scripts/libraries/13B/13M_seeds.sdi
22B /wynton/group/bks/work/shared/kholland/chemstep_auto_v02/scripts/libraries/22B/22M_seeds.sdi

Then dock the seed set. See the Large-Scale Docking (LSD) directions.

3. Gather Scores for the Seed Set

Once docking is complete, run the following from the directory one level above your docking output (MOLECULES_DIR_TO_BIND).

22B library:

python /wynton/group/bks/work/shared/kholland/chemstep_auto_v02/scripts/get_scores.py 0

13B library:

python /wynton/group/bks/work/shared/kholland/chemstep_auto_v02/scripts/get_scores_13B.py 0 MOL

Template:Note

Verify that scores_round_0.txt was correctly written:

wc -l scores_round_0.txt

4. Convert Scores to .npy Files

Convert scores to ChemSTEP-readable .npy files:

python /wynton/group/bks/work/shared/kholland/chemstep_auto_v02/scripts/convert_scores_to_npy.py 0 <mol_id_prefix>

The mol_id_prefix should match the library:

Library Prefix
22B / 72B CSLB
13B MOL

5. Set Up the ChemSTEP Run Directory

Create and enter a new run directory, then copy in the necessary files:

mkdir chemstep_run
cd chemstep_run
chemstep-run-new

This will populate the directory with params.txt, run_chemstep.py, and launch_chemstep_as_job.sh.

Optional: Integrated IFP

If running with integrated IFP for beacon selection, also run:

chemstep-run-ifp

This copies in the additional files ifp_acceptance_criteria.txt and interactions.txt.

6. Edit params.txt

Add the absolute paths to the ChemSTEP-readable score and indices .npy arrays generated in Step 4.

seed_indices_file:  /path/to/your/indices_round_0.npy
seed_scores_file:   /path/to/your/scores_round_0.npy
hit_pprop:          5.5
n_docked_per_round: 2000000
bundle_size:        1000
max_beacons:        100
max_n_rounds:       250

Parameter Reference

Parameter Description
hit_pprop Defines a "virtual hit." pProp = −log(rank%) within the total library score distribution. E.g., pProp 4 in 13B space ≈ top 0.01% (~1.3M molecules); pProp 5 ≈ 0.001% (~132K). The seed set should contain at least 10(pProp+2) molecules.
n_docked_per_round Number of molecules prioritized per round. All must be built and docked between rounds. Too many slows throughput and may reduce diversity; too few slows virtual hit recovery.
max_beacons Diverse, well-scoring molecules used to guide prioritization. All molecules above the pProp threshold are candidates. Too many reduces inter-beacon diversity; too few hinders space exploration. Fewer beacons than specified may be assigned if insufficient molecules clear the threshold.
bundle_size In auto docking mode, number of molecules submitted as a single build job.
max_n_rounds No adjustment needed when running ChemSTEP prospectively as described here.

7. Edit run_chemstep.py

Note: All paths must be absolute paths.

Required Settings

Set lib_path to the library pickle for your library:

Library Path
13B /wynton/group/bks/work/shared/kholland/chemstep_auto_v02/scripts/libraries/13B/boltz_fplib.pickle
22B /wynton/group/bks/work/shared/kholland/chemstep_auto_v02/scripts/libraries/22B/22B_fplib.pickle
lib_path = '/full/path/to/library.pickle'

Set dockfiles_path:

dockfiles_path="/full/path/to/dockfiles"

Optional: minTD Exclusion Zone

Molecules will not be prioritized from within a specified Tanimoto distance of beacons. Comment in the relevant lines and update the value. Consider also setting enforce_n_docked_per_round = True when using this option:

min_td_search=0.5,
enforce_n_docked_per_round=True,

Optional: Integrated IFP

Only selects beacons that satisfy user-defined interaction criteria. Comment in the following lines and update the paths to the necessary files (copied in Step 5 if you ran chemstep-run-ifp):

use_IFP=True,
ifp_pdb_path='/full/path/to/rec.crg.pdb',
interactions_file='/full/path/to/interactions.txt',
ifp_acceptance_criteria_file='/full/path/to/ifp_acceptance_criteria.txt',

interactions.txt — one interaction per line, comma-separated. Format: interaction_type, residue_name_and_number. Example:

Hydrogen bond, GLY19
Ionic, ASP149

Supported interaction types include: Proximal, Hydrogen bond, Ionic, Cation-pi, Hydrophobic, Halogen bond, and others. See LUNA and IFP documentation for the full list.

ifp_acceptance_criteria.txt — defines the number of unsatisfied donors/acceptors/specific interactions required for a molecule to pass IFP and be considered for beacon selection. Example:

#_donors
#_acceptors
#_unstatisfied_donors == 0
#_unstatisfied_acceptors <= 4
Ionic/ASP-149 > 0

Example: AmpC on 22B with minTD=0.50, No IFP

lib_path = '/wynton/group/bks/work/shared/kholland/chemstep_auto_v02/scripts/libraries/22B/22B_fplib.pickle'
lib = load_library_from_pickle(lib_path)
algo = CSAlgo(lib, 'params.txt', 'output', 16, verbose=True,
    scheduler='sge', smi_id_prefix='CSLB',
    python_exec="/wynton/group/bks/work/shared/kholland/chemstep_auto_v02/bin/python",
    dockfiles_path="/wynton/group/bks/work/kholland/chemstep_ampc_22B/seed_docking/dockfiles",
    min_td_search=0.5,
    enforce_n_docked_per_round=True,
    #use_IFP=True,
    #ifp_pdb_path='/path/to/your/reference/rec.crg.pdb',
    #interactions_file='/path/to/your/interactions.txt',
    #ifp_acceptance_criteria_file='/path/to/your/ifp_acceptance_criteria.txt',
    docking_method="auto", track_beacon_orig=True)

8. Launch the Job

Submit the main ChemSTEP job:

qsub launch_chemstep_as_job.sh

9. Monitor Job Status

Check job status with qstat. The main job will run for up to 2 weeks given no errors. ChemSTEP will launch search, building, and docking jobs in successive rounds.

Note: If any building or docking subjobs hang, the main job will not proceed until those are canceled or finished. Monitor job statuses regularly and occasionally verify that docking output files (scores_round_*.txt) are being populated.

10. View Beacon SMILES and IDs

From the ChemSTEP running directory, run the following in a screen session on a dev node:

python /wynton/group/bks/work/shared/kholland/chemstep_auto_v02/scripts/get_beacon_smiles.py /path/to/library/pickle chemstep_algo.log

Use the library pickle path from Step 7.

11. Get Poses After Docking

Make a list of test.mol2.gz.0 files from docking:

find /round_*_docking/bundle_paths -maxdepth 2 -name "test.mol2.gz.0" > docked_poses.txt

Then extract top poses:

python /wynton/group/bks/work/bwhall61/for_beau/top_poses.py \
    -t <pProp_threshold> \
    -s <num_poses_per_file> \
    -dock_results_path docked_poses.txt