DrugCLIP: Contrastive Protein-Molecule Representation Learning

repository·main·Indexed 42 days ago

https://github.com/bowen-gao/drugclip

A framework for contrastive protein-molecule representation learning designed for virtual screening, molecular retrieval, and screening. It includes HomoAug, a homology-based data augmentation tool for generating pseudo-pocket-ligand pairs, and utilizes the esl-reformat CLI for sequence file conversion. Requires rdkit version 2022.9.5 and ray 1.12.0.

Tokens
2.6K
Snippets
10
Records
16
Agent score
53%

What's inside DrugCLIP

  1. Understand the HomoAug output directory structure

    main

    The --homoaug_dir contains both the original data and the generated augmented pairs.

    Note: If a pocket-ligand pair is unsuitable (e.g., the pocket is composed of multiple chains), the program will skip it. Only valid results are saved in the extend/ directory.

    Directory Structure:

    homoaug_dir
    ├── PDBID
    │   ├── PDBID.fasta
    │   ├── PDBID.pdb
    │   ├── PDBID_pocket.pdb
    │   ├── PDBID_pocket_chain.pdb
    │   ├── PDBID_ligand.pdb
    │   ├── PDBID_pocket_position.txt
    │   ├── rotation_matrix
    │   │   └── (TMalign output files)
    │   └── *extend*
    │       ├── AugmentedPDBID1
    │       │   ├── AugmentedPDBID1_protein.pdb
    │       │   ├── AugmentedPDBID1_pocket.pdb
    │       └── ...
  2. Install requirements for HomoAug

    main

    To use HomoAug, you must install the ray Python package and ensure the following HMMER and alignment tools are available in your system's PATH:

    1. Python Package: Install ray version 1.12.0 via pip.
    2. HMMER Tools: jackhmmer and esl-reformat.
    3. Alignment Tool: TM-align.

    The executables for jackhmmer, esl-reformat, and TM-align are provided in the bin folder of the repository. You must add this bin directory to your environment's PATH variable.

    pip install ray==1.12.0
    # Ensure the 'bin' directory from the repo is in your PATH
    export PATH=$PATH:/path/to/drugclip/HomoAug/bin
  3. Run HomoAug to generate pseudo-pocket-ligand pairs

    main

    HomoAug generates pseudo-pocket-ligand pairs by leveraging the similarity of ligand binding sites in homologous proteins. Execute the augmentation process using the run_HomoAug.py script with the required input files and configuration parameters.

    python run_HomoAug.py \
        --id_file your_id_file \
        --homoaug_dir your_homoaug_dir \
        --fasta_file your_fasta_file \
        --protein_pdb_dir your_protein_pdb_dir \
        --pocket_pdbs_dir your_pocket_pdbs_dir \
        --jackhmmer_output_dir your_jackhmmer_output_dir \
        --n_thread your_n_thread \
        --database_fasta_path your_database_fasta_path \
        --database_pdb_dir your_database_pdb_dir \
        --max_extend_num your_max_extend_num \
        --TMscore_threshold your_TMscore_threshold \
        --Match_rate_threshold your_Match_rate_threshold
  4. Use esl-reformat to reformat sequence files

    main

    The esl-reformat CLI tool is used to convert sequence files between different formats (e.g., Stockholm, Pfam, A2M, FASTA, Clustal).

    Supported Input Formats

    Common input formats include:

    • .sto, .sth, .stk (Stockholm)
    • .pfam (Pfam)
    • .a2m (UCSC A2M)
    • .fasta, .fa (Aligned FASTA)
    • .clu, .clustal (Clustal)
    • .phy, .phylip (PHYLIP)
    • .selex (SELEX)
    • .afasta (Aligned FASTA)

    Common Operations

    • Convert Alphabet: Convert DNA to RNA (--rna), RNA to DNA (--dna), or remove DNA IUPAC codes and convert ambiguous characters to N.
    • Handle Gaps: Remove columns containing all gaps (--nogap) or columns containing any gaps (--mingap).
    • Sequence Manipulation: Rename and number sequences (--rename <s1>:<s2>), or replace specific characters in sequences.
    • Memory Optimization: Use --small to use minimal RAM. This requires the input format to be pfam and the output format to be either afa or pfam.
    # Example: Convert a Stockholm file to Pfam format using minimal RAM
    esl-reformat --small --informat pfam --oformat pfam input.sto output.pfam
  5. Read LMDB training data using py_scripts/lmdb_utils.py

    main

    The training datasets (train.lmdb and valid.lmdb) can be read using the utility script py_scripts/lmdb_utils.py. The LMDB files contain the following keys:

    • atoms: atom types for each atom in the ligand
    • coordinates: 3D coordinates for each atom in the ligand generated by RDKit (Max 10 conformations)
    • pocket_atoms: atom types for each atom in the pocket
    • pocket_coordinates: 3D coordinates for each atom in the pocket
    • mol: RDKit molecule object for the ligand
    • smi: SMILES string for the ligand
    • pocket: pdbid of the pocket
  6. Reference the HomoAug CLI arguments

    main

    The following arguments are used to configure the run_HomoAug.py execution:

    ArgumentDescription
    --id_fileFile containing IDs of real pocket-ligand pairs. Format: <pdb_id>_<chain_id>_<any_string>_<ligand_name_in_pdb>
    --homoaug_dirOutput directory for results. Valid augmented pairs are stored in the extend/ subfolder.
    --fasta_fileFASTA file corresponding to id_file. Titles must start with the pdb_id
    --protein_pdb_dirDirectory containing input protein CIF files (format: <pdb_id>.cif)
    --pocket_pdbs_dirDirectory containing input pocket PDB files (format: <pdb_id>.pdb)
    --jackhmmer_output_dirTemporary directory for jackhmmer output
    --n_threadNumber of threads for parallel execution
    --database_fasta_pathFASTA file of the augmentation database (e.g., AF2DB)
    --database_pdb_dirPDB directory of the augmentation database
    --max_extend_numMaximum number of extended pairs per real pair
    --TMscore_thresholdMinimum TMscore required to keep an extended pair
    --Match_rate_thresholdMinimum Match_rate required to keep an extended pair (ratio of matched residues to real pocket residues)
  7. Run DrugCLIP retrieval

    main

    To perform retrieval tasks, execute the provided bash script. Example files for pocket.lmdb and mols.lmdb are available in the retrieval directory within the provided Google Drive data folder.

    bash retrieval.sh
  8. Supported output formats for esl-reformat

    main

    The esl-reformat tool supports two main categories of output: Unaligned and Aligned formats.

    Unaligned formats

    • fasta
    • hmmpgmd

    Aligned formats

    • a2m
    • afa
    • clustal
    • clustallike
    • pfam
    • phylip
    • phylips
    • psiblast
    • selex
    • stockholm
    Output format choices:
    Unaligned:      fasta, hmmpgmd
    Aligned:        a2m, afa, clustal, clustallike, pfam, phylip, phylips, psiblast, selex, stockholm