{"id":20893221,"url":"https://github.com/keiserlab/autofragdiff","last_synced_at":"2025-06-27T17:34:47.281Z","repository":{"id":198097295,"uuid":"700021901","full_name":"keiserlab/autofragdiff","owner":"keiserlab","description":null,"archived":false,"fork":false,"pushed_at":"2024-05-23T11:32:54.000Z","size":36572,"stargazers_count":27,"open_issues_count":2,"forks_count":1,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-04-01T13:05:39.763Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/keiserlab.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2023-10-03T19:45:01.000Z","updated_at":"2025-03-20T12:14:01.000Z","dependencies_parsed_at":"2023-11-30T19:42:13.086Z","dependency_job_id":null,"html_url":"https://github.com/keiserlab/autofragdiff","commit_stats":null,"previous_names":["keiserlab/autofragdiff"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/keiserlab%2Fautofragdiff","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/keiserlab%2Fautofragdiff/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/keiserlab%2Fautofragdiff/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/keiserlab%2Fautofragdiff/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/keiserlab","download_url":"https://codeload.github.com/keiserlab/autofragdiff/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253833350,"owners_count":21971401,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-18T10:15:01.055Z","updated_at":"2025-05-12T22:32:25.839Z","avatar_url":"https://github.com/keiserlab.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# AutoFragDiff\n\nThis repository is the official implementation of Autoregressive fragment based diffusion model for target-aware ligand design\n\n\u003cimg src=\"assets/movie.gif\" width=500 height=400\u003e\n\n\n# Dependencies\n- RDKit\n- openbabel\n- PyTorch\n- biopython\n- biopandas\n- networkx\n- py3dmol\n- scikit-learn\n- tensorboard\n- wandb\n- pytorch-lightning\n\n## Create conda environment\n```\nconda create -n autofragdiff\npip install rdkit\nconda install -c conda-forge openbabel\npip3 install torch torchvision torchaudio \npip install biopython\npip install biopandas\npip install networkx\npip install py3dmol\npip install scikit-learn\npip install tensorboard\npip install wandb\npip install tqdm\npip install pytorch-lightning==1.6.0\n```\n\nThe model has been tested with the following software versions:\n\n| Software        | Version     |\n| --------------- | ----------- |\n| rdkit           | 2023.3.1    |\n| openbabel       | 3.1.1       |\n| pytorch         | 2.0.1       |\n| biopython       | 1.81        |\n| biopandas       | 0.4.1       |\n| networkx        | 3.1         |\n| py3dmol         | 2.0.1.      |\n| scikit-learn    | 1.2.2       |\n| tensorboard     | 2.13.0      |\n| wandb           | 0.15.2      |\n| pytorch-lightning | 1.6.0     |\n\n\n## QucikVina2\nFor Docking with qvina install QuickVina2:\n```\nwget https://github.com/QVina/qvina/raw/master/bin/qvina2.1\nchmod +x qvina2.1 \n```\nWe also need MGLTools for preparing the receptor for docking (pdb-\u003epdbqt) but it can mess up the conda environment, so make a new one.\n```\nconda create -n mgltools -c bioconda mgltools\n```\n\n# Data Preparation\n\n## CrossDock\nDownload and extract the dataset as described by the authors of Pocket2Mol: https://github.com/pengxingang/Pocket2Mol/tree/main/data\n\nprocess the molecule fragments using a custom fragmentation. \n```\npython process_crossdock.py --rootdir $CROSSDOCK_PATH --outdir $OUT_DIR \\\n      --dist_cutoff 7. --max-num-frags 8 --split test --max-atoms-single-fragment 22 \\\n      --add-Vina-score --add-QED-score --add-SA-score --n-cores 16\n```\n- For adding Vina you also need to generate pdbqt files for each receptor and crystallographic ligand.\n\n# Training\n\n## Training AutoFragdiff. \n```\npython train_frag_diffuser.py --data $CROSSDOCK_DIR  --exp_name CROSSDOCK_model_1 \\\n        --lr 0.0001 --n_layers 6  --nf 128  --diffusoin_steps 500 \\\n       --diffusion_loss_type l2 --n_epochs 1000 --batch_size 4\n```\n\n## Training anchor predictor\n```\npython train_anchor_predictor --data $CROSSDOCK_DIR --exp_name CROSDOCK_anchor_model_1 \\\n        --n_layers 4 --inv_sublayers 2 --nf 128 --dataset-type CrossDock\n```\n\n\n# Sampling:\n\nFirt download the trained models from the google drive in the following link\n\nhttps://drive.google.com/drive/folders/1DQwIfibHIoFPGJP6aHBGiYRp87bCZFA0?usp=share_link\n\n## CrossDock pocket-based molecule generation:\n\nTo generate molecules from trained pocket-based model, also use anchor-predictor model. fragment sizes are sampled from the data distribution.\n\n## CrossDock pocket-based molecule generation (with guidance):\n\nTo generate molecules for crossdock test set:\n```\npython sample_crossdock_mols.py --results-path results/ --data-path $(path-to-crossdock-dataset) --use-anchor-model --anchor-model anchor-model.ckpt --n-samples 20 --exp-name test-crossdock --diff-model pocket-gvp.ckpt --device cuda:0 \n```\n\nTo sample molecules from a pdb file:\nfirst run fpocket and identify the correct pocket using:\n```\nfpocket -f $pdb.pdb\n```\nfpocket gives multiple pockets, you can visualize the identify the right pocket and run sampling\n\n```\npython sample_from_pocket.py --result-path results --pdb $pdbname --anchor-model anchor-model.ckpt --n-samples 10 --device cuda:0 --pocket-number 1 \n```\n\n## Scaffold-based molecule property optimization\n\nFor scaffold-based optimization you need the pdb file of the pocket and the sdf file of the scaffold molecule (and the original molecule). \n\nScaffold-extension for crossdock test set\n```\npython extend_scaffold_crossdock.py --data-path $(path-to-crossdock) --results-path scaffold-gen --anchor-model anchor-model.ckpt --n-samples 20 --exp-name scaffold-gen --diff-model pocket-gvp.ckpt --device cuda:0 \n```\n\n- In order to select the anchor you can add the `--custom-anchors` argument and provide the ids of custom anchors (starts from 0 and based on atomic ids in the scaffold molecule).\n\u003cdiv align=\"center\"\u003e\n\u003cimg src=\"assets/scaffold_optim.png\" width=700\u003e\n\u003c/div\u003e\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkeiserlab%2Fautofragdiff","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkeiserlab%2Fautofragdiff","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkeiserlab%2Fautofragdiff/lists"}