Uni-Fold: Training your own deep protein-folding models

Overview

Uni-Fold: Training your own deep protein-folding models.

This package provides an implementation of a trainable, Transformer-based deep protein folding model. We modified the open-source code of DeepMind AlphaFold v2.0 and provided code to train the model from scratch. See the reference and the repository of DeepMind AlphaFold v2.0. To train your own Uni-Fold models, please follow the steps below:

1. Install the environment.

Run the following code to install the dependencies of Uni-Fold:

  conda create -n unifold python=3.8.10 -y
  conda activate unifold
  ./install_dependencies.sh

Uni-Fold has been tested for Python 3.8.10, CUDA 11.1 and OpenMPI 4.1.1. We recommend using Conda >= 4.10 to install the environment: using Conda with lower versions may lead to some conflicts between packages.

2. Prepare data before training.

Before you start to train your own folding models, you shall prepare the features and labels of the training proteins. Features of proteins mainly include the amino acid sequence, MSAs and templates of proteins. These messages should be contained in a pickle file <name>/features.pkl for each training protein. Uni-Fold provides scripts to process input FASTA files, relying on several external databases and tools. Labels are CIF files containing the structures of the proteins.

2.1 Datasets and external tools.

Uni-Fold adopts the same data processing pipeline as AlphaFold2. We kept the scripts of downloading corresponding databases for searching sequence homologies and templates in the AlphaFold2 repo. Use the command

  bash scripts/download_all_data.sh /path/to/database/directory

to download all required databases of Uni-Fold.

If you successfully installed the Conda environment in Section 1, external tools of search sequence homologies and templates should be installed properly. As an alternative, you can customize the arguments of the feature preparation script (generate_pkl_features.py) to refer to your own databases and tools.

2.2 Run the preparation code.

An example command of running the feature preparation pipeline would be

  python generate_pkl_features.py \
    --fasta_dir ./example_data/fasta \
    --output_dir ./out \
    --data_dir /path/to/database/directory \
    --num_workers 1

This command automatically processes all FASTA files under fasta_dir, and dumps the results to output_dir. Note that each FASTA file should contain only one sequence. The default number of CPUs used in hhblits and jackhmmer are 4 and 8. You can modify them in unifold/data/tools/hhblits.py and unifold/data/tools/jackhmmer.py, respectively.

2.3 Organize your training data.

Uni-Fold uses the class DataSystem to automatically sample and load the training proteins. To make everything goes right, you shall pay attention to how the training data is organized. Two directories should be established, one with input features (features.pkl files, referred to as features_dir) and the other with labels (*.cif files, referred to as mmcif_dir). The feature directory should have its files named as <pdb_id>_<model_id>_<chain_id>/features.pkl, e.g. 1ak0_1_A/features.pkl, and the label directory should have its files named as <pdb_id>.cif, e.g. 1ak0.cif. See ./example_data/features and ./example_data/mmcif for instances of the two directories. Notably, users shall make sure that all proteins used for training have their corresponding labels. This is checked by DataSystem.check_completeness().

3. Train Uni-Fold.

3.1 Configuration.

Before you conduct any actual training processes, please make sure that you correctly configured the code. Modify the training configurations in unifold/train/train_config.py. We annotated the default configurations to reproduce AlphaFold in the script. Specifically, modify the configurations of data paths:

"data": {
  "train": {
    "features_dir": "where/training/protein/features/are/stored/",
    "mmcif_dir": "where/training/mmcif/files/are/stored/",
    "sample_weights": "which/specifies/proteins/for/training.json"
  },
  "eval": {
    "features_dir": "where/validation/protein/features/are/stored/",
    "mmcif_dir": "where/validation/mmcif/files/are/stored/",
    "sample_weights": "which/specifies/proteins/for/training.json"
  }
}

The specified data should be contained in two folders, namely a features_dir and a mmcif_dir. Organizations of the two directories are introduced in Section 2.3. Meanwhile, if you want to specify a subset of training data under the directories, or assign customized sample weights for each protein, write a json file and feed its path to sample_weights. This is optional, as you can leave it as None (and the program will attempt to use all entries under features_dir with uniform weights). The json file should be a dictionary containing the basenames of directories of protein features ([pdb_id]_[model_id]_[chain_id]) and the sample weight of each protein in the training process (integer or float), such as:

{"1am9_1_C": 82, "1amp_1_A": 291, "1aoj_1_A": 60, "1aoz_1_A": 552}

or for uniform sampling, simply using a list of protein entries suffices:

["1am9_1_C", "1amp_1_A", "1aoj_1_A", "1aoz_1_A"]

For users who want to customize their own folding models, configurations of model hyperparameters can be edited in unifold/model/config.py .

3.2 Run the training code!

To train the model on a single node without MPI, run

python train.py

You can also train the model with multiple GPUs using MPI (or workload managers that supports MPI, such as PBS or Slurm) by running:

mpirun -n <num_of_gpus> python train.py

In either way, make sure you properly configurate the option use_mpi and gpus_per_node in unifold/train/train_config.py.

4. Infer with trained models.

4.1 Infer from features.pkl.

We provide the run_from_pkl.py script to support inferring protein structures from features.pkl inputs. A demo command would be

python run_from_pkl.py \
  --pickle_dir ./example_data/features \
  --model_names unifold \
  --model_paths /path/to/unifold.npz \
  --output_dir ./out

or

python run_from_pkl.py \
  --pickle_paths ./example_data/features/1ak0_1_A/features.pkl \
  --model_names unifold \
  --model_paths /path/to/unifold.npz \
  --output_dir ./out

The command will generate structures (in PDB format) from input features predicted by different input models, the running time of each component, and corresponding residue-wise confidence score (predicted LDDT, or pLDDT).

4.2 Infer from FASTA files.

Essentially, inferring the structures from given FASTA files includes two steps, i.e. generating the pickled features and predicting structures from them. We provided a script, run_from_fasta.py, as a friendlier user interface. An example usage would be

python run_from_pkl.py \
  --fasta_paths ./example_data/fasta/1ak0_1_A.fasta \
  --model_names model_2 \
  --model_paths /path/to/model_2.npz \
  --data_dir /path/to/database/directory
  --output_dir ./out

4.3 Generate MSAs with MMseqs2.

It may take hours and much memory to generate MSA for sequences, especially for long sequences. In this condition, MMseqs2 may be a more efficient way. It can be used in the following way after it is installed:

# download and build database
mkdir mmseqs_db && cd mmseqs_db
wget http://wwwuser.gwdg.de/~compbiol/colabfold/uniref30_2103.tar.gz
wget http://wwwuser.gwdg.de/~compbiol/colabfold/colabfold_envdb_202108.tar.gz
tar xzvf uniref30_2103.tar.gz
tar xzvf colabfold_envdb_202108.tar.gz
mmseqs tsv2exprofiledb uniref30_2103 uniref30_2103_db
mmseqs tsv2exprofiledb colabfold_envdb_202108 colabfold_envdb_202108_db
mmseqs createindex uniref30_2103_db tmp
mmseqs createindex colabfold_envdb_202108_db tmp
cd ..

# MSA search
./scripts/colabfold_search.sh mmseqs "query.fasta" "mmseqs_db/" "result/" "uniref30_2103_db" "" "colabfold_envdb_202108_db" "1" "0" "1"

5. Changes from AlphaFold to Uni-Fold.

  • We implemented classes and methods for training and inference pipelines by adding scripts under unifold/train and unifold/inference.
  • We added scripts for installing the environment, training and inferencing.
  • Files under unifold/common, unifold/data and unifold/relax are minimally altered for re-structuring the repository.
  • Files under unifold/model are slightly altered to allow mixed-precision training.
  • We removed some unused scripts in training AlphaFold model.

6. License and disclaimer.

6.1 Uni-Fold code license.

Copyright 2021 Beijing DP Technology Co., Ltd.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

6.2 Use of third-party software.

Use of the third-party software, libraries or code may be governed by separate terms and conditions or license provisions. Your use of the third-party software, libraries or code is subject to any such terms and you should check that you can comply with any applicable restrictions or terms and conditions before use.

6.3 Contributing to Uni-Fold.

Uni-Fold is an ongoing project. Our target is to design better protein folding models and to apply them in real scenarios. We welcome the community to join us in developing the repository together, including but not limited to 1) reports and fixes of bugs,2) new features and 3) better interfaces. Please refer to CONTRIBUTING.md for more information.

Comments
  • illegal character 0

    illegal character 0

    This is my output from docker container.

    root@c305fc365212:/home/unifold# bash run_unifold.sh /home/unifold/T1052.fasta /home/unifold/output /home/data 2020-05-01 model_2_ft /home/unifold/params/monomer.unifold.pt Starting homogeneous searching... I0808 22:00:42.066362 139658661553856 templates.py:945] Using precomputed obsolete pdbs /home/data/pdb_mmcif/obsolete.dat. I0808 22:00:42.070091 139658661553856 homo_search.py:160] searching homogeneous Sequences & structures for unifold... I0808 22:00:42.070847 139658661553856 jackhmmer.py:140] Launching subprocess "/usr/bin/jackhmmer -o /dev/null -A /tmp/tmpezbgmjgz/output.sto --noali --F1 0.0005 --F2 5e-05 --F3 5e-07 --incE 0.0001 -E 0.0001 --cpu 8 -N 1 /home/unifold/T1052.fasta /home/data/uniref90/uniref90.fasta" I0808 22:00:42.087588 139658661553856 utils.py:36] Started Jackhmmer (uniref90.fasta) query I0808 22:06:28.933336 139658661553856 utils.py:40] Finished Jackhmmer (uniref90.fasta) query in 346.845 seconds I0808 22:06:28.936954 139658661553856 jackhmmer.py:140] Launching subprocess "/usr/bin/jackhmmer -o /dev/null -A /tmp/tmp2phimc6z/output.sto --noali --F1 0.0005 --F2 5e-05 --F3 5e-07 --incE 0.0001 -E 0.0001 --cpu 8 -N 1 /home/unifold/T1052.fasta /home/data/mgnify/mgy_clusters_2018_12.fa" I0808 22:06:28.955174 139658661553856 utils.py:36] Started Jackhmmer (mgy_clusters_2018_12.fa) query I0808 22:12:37.104840 139658661553856 utils.py:40] Finished Jackhmmer (mgy_clusters_2018_12.fa) query in 368.149 seconds I0808 22:12:37.155930 139658661553856 hmmbuild.py:121] Launching subprocess ['/usr/bin/hmmbuild', '--hand', '--amino', '/tmp/tmpvx3aub12/output.hmm', '/tmp/tmpvx3aub12/query.msa'] I0808 22:12:37.172153 139658661553856 utils.py:36] Started hmmbuild query I0808 22:12:37.564175 139658661553856 hmmbuild.py:129] hmmbuild stdout:

    hmmbuild :: profile HMM construction from multiple sequence alignments

    HMMER 3.3 (Nov 2019); http://hmmer.org/

    Copyright (C) 2019 Howard Hughes Medical Institute.

    Freely distributed under the BSD open source license.

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

    input alignment file: /tmp/tmpvx3aub12/query.msa

    output HMM file: /tmp/tmpvx3aub12/output.hmm

    input alignment is asserted as: protein

    model architecture construction: hand-specified by RF annotation

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

    idx name nseq alen mlen eff_nseq re/pos description

    #---- -------------------- ----- ----- ----- -------- ------ ----------- 1 query 198 1290 832 5.75 0.590

    CPU time: 0.38u 0.00s 00:00:00.38 Elapsed: 00:00:00.39

    stderr:

    I0808 22:12:37.564431 139658661553856 utils.py:40] Finished hmmbuild query in 0.392 seconds I0808 22:12:37.566694 139658661553856 hmmsearch.py:117] Launching sub-process ['/usr/bin/hmmsearch', '--noali', '--cpu', '8', '--F1', '0.1', '--F2', '0.1', '--F3', '0.1', '--incE', '100', '-E', '100', '--domE', '100', '--incdomE', '100', '-A', '/tmp/tmpil8uqp24/output.sto', '/tmp/tmpil8uqp24/query.hmm', '/home/data/pdb_seqres/pdb_seqres.txt'] I0808 22:12:37.579384 139658661553856 utils.py:36] Started hmmsearch (pdb_seqres.txt) query I0808 22:12:49.915640 139658661553856 utils.py:40] Finished hmmsearch (pdb_seqres.txt) query in 12.336 seconds Traceback (most recent call last): File "unifold/homo_search.py", line 306, in app.run(main) File "/opt/conda/lib/python3.8/site-packages/absl/app.py", line 312, in run _run_main(main, args) File "/opt/conda/lib/python3.8/site-packages/absl/app.py", line 258, in _run_main sys.exit(main(argv)) File "unifold/homo_search.py", line 284, in main generate_pkl_features( File "unifold/homo_search.py", line 176, in generate_pkl_features feature_dict = data_pipeline.process( File "/home/unifold/unifold/msa/pipeline.py", line 193, in process pdb_templates_result = self.template_searcher.query(msa_for_templates) File "/home/unifold/unifold/msa/tools/hmmsearch.py", line 89, in query return self.query_with_hmm(hmm) File "/home/unifold/unifold/msa/tools/hmmsearch.py", line 128, in query_with_hmm raise RuntimeError( RuntimeError: hmmsearch failed: stdout:

    hmmsearch :: search profile(s) against a sequence database

    HMMER 3.3 (Nov 2019); http://hmmer.org/

    Copyright (C) 2019 Howard Hughes Medical Institute.

    Freely distributed under the BSD open source license.

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

    query HMM file: /tmp/tmpil8uqp24/query.hmm

    target sequence database: /home/data/pdb_seqres/pdb_seqres.txt

    MSA of all hits saved to file: /tmp/tmpil8uqp24/output.sto

    show alignments in output: no

    sequence reporting threshold: E-value <= 100

    domain reporting threshold: E-value <= 100

    sequence inclusion threshold: E-value <= 100

    domain inclusion threshold: E-value <= 100

    MSV filter P threshold: <= 0.1

    Vit filter P threshold: <= 0.1

    Fwd filter P threshold: <= 0.1

    number of worker threads: 8

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

    Query: query [M=832]

    stderr: Parse failed (sequence file /home/data/pdb_seqres/pdb_seqres.txt): Line 1360234: illegal character 0

    Starting prediction... start to load params /home/unifold/params/monomer.unifold.pt start to predict unifold Traceback (most recent call last): File "unifold/inference.py", line 232, in main(args) File "unifold/inference.py", line 103, in main batch = load_feature_for_one_target( File "unifold/inference.py", line 46, in load_feature_for_one_target batch, _ = load_and_process( File "/home/unifold/unifold/dataset.py", line 234, in load_and_process features, labels = load(**load_kwargs, is_monomer=is_monomer) File "/home/unifold/unifold/dataset.py", line 129, in load all_chain_features = [ File "/home/unifold/unifold/dataset.py", line 130, in load_single_feature(s, monomer_feature_dir, uniprot_msa_dir, is_monomer) File "/home/unifold/unifold/data/utils.py", line 33, in wrapper return copy_lib.copy(cached_func(*args, **kwargs)) File "/home/unifold/unifold/dataset.py", line 72, in load_single_feature monomer_feature = utils.load_pickle( File "/home/unifold/unifold/data/utils.py", line 33, in wrapper return copy_lib.copy(cached_func(*args, **kwargs)) File "/home/unifold/unifold/data/utils.py", line 67, in load_pickle ret = load(path) File "/home/unifold/unifold/data/utils.py", line 64, in load with open_fn(path, "rb") as f: File "/opt/conda/lib/python3.8/gzip.py", line 58, in open binary_file = GzipFile(filename, gz_mode, compresslevel) File "/opt/conda/lib/python3.8/gzip.py", line 173, in init fileobj = self.myfileobj = builtins.open(filename, mode or 'rb') FileNotFoundError: [Errno 2] No such file or directory: '/home/unifold/output/unifold/A.feature.pkl.gz'

    third-party tool 
    opened by superantichrist 16
  • Failed to load Uni-Fold checkpoints

    Failed to load Uni-Fold checkpoints

    i use run_unifold.sh get some erro,how to check it :

    start to load params /data/data/unifolddata/params/monomer.unifold.pt Traceback (most recent call last): File "unifold/inference.py", line 266, in main(args) File "unifold/inference.py", line 91, in main model.load_state_dict(state_dict) File "/data/miniconda3/envs/unifold/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1604, in load_state_dict raise RuntimeError('Error(s) in loading state_dict for {}:\n\t{}'.format( RuntimeError: Error(s) in loading state_dict for AlphaFold: Missing key(s) in state_dict: "aux_heads.experimentally_resolved.linear.weight", "aux_heads.experimentally_resolved.linear.bias".

    opened by maxshen29 10
  • OOM in multimer

    OOM in multimer

    Hi,

    I'm running into OOM errors in the template module during finetuning (in training and validation) of Uni-Fold-multimer. It happens with multimer_ft and multimer_af2. All targets have at most 3500AA (combined). I'm using a A100 80GB. BF16 is enabled. I'm even more confused that it also happens during training, where the cropping should limit the peak memory consumption. Is there anything I have to keep in mind? I see that you do chunking during inference shouldn't this be also done in eval? Was the 1536AA limit you imposed in the paper tailored to 40GB VRAM? Thanks in advance!

    The OOM error occurs here: unifold/modules/template.py", line 229, in forward self.tri_att_start(

    more specifically in attn = torch.matmul(q, k.transpose(-1, -2)) in attentions.py", line 69

    RuntimeError: CUDA out of memory. Tried to allocate 75.09 GiB (GPU 0; 79.17 GiB total capacity; 22.66 GiB already allocated; 51.26 GiB free; 26.60 GiB reserved in total by PyTorch)

    opened by lhatsk 8
  • Demo Case : RuntimeError  & ChildFailedError

    Demo Case : RuntimeError & ChildFailedError

    The following error occurred when I ran the demo case command: bash train_monomer_demo.sh .


    2022-12-23 10:48:24 | INFO | unicore_cli.train | task: AlphafoldTask
    2022-12-23 10:48:24 | INFO | unicore_cli.train | model: AlphafoldModel
    2022-12-23 10:48:24 | INFO | unicore_cli.train | loss: AlphafoldLoss
    2022-12-23 10:48:24 | INFO | unicore_cli.train | num. model params: 94,169,845 (num. trained: 94,169,845)
    2022-12-23 10:48:24 | INFO | unicore.utils | ***********************CUDA enviroments for all 1 workers***********************
    2022-12-23 10:48:24 | INFO | unicore.utils | rank   0: capabilities =  7.5  ; total memory = 14.756 GB ; name = Tesla T4
    2022-12-23 10:48:24 | INFO | unicore.utils | ***********************CUDA enviroments for all 1 workers***********************
    2022-12-23 10:48:24 | INFO | unicore_cli.train | training on 1 devices (GPUs)
    2022-12-23 10:48:24 | INFO | unicore_cli.train | batch size per device = 1
    2022-12-23 10:48:24 | INFO | unicore.trainer | Preparing to load checkpoint ./checkpoint_last.pt
    2022-12-23 10:48:24 | INFO | unicore.trainer | No existing checkpoint found ./checkpoint_last.pt
    2022-12-23 10:48:24 | INFO | unicore.trainer | loading train data for epoch 1
    2022-12-23 10:48:24 | INFO | unifold.dataset | load 2 chains (unique 1 sequences)
    2022-12-23 10:48:24 | INFO | unifold.dataset | load 1 self-distillation samples.
    2022-12-23 10:48:24 | INFO | unicore.tasks.unicore_task | get EpochBatchIterator for epoch 1
    2022-12-23 10:48:25 | INFO | unicore.optim.adam | using FusedAdam
    2022-12-23 10:48:25 | INFO | unicore.trainer | begin training epoch 1
    2022-12-23 10:48:25 | INFO | unicore_cli.train | Start iterating over samples
    
    Traceback (most recent call last):
      File "/home/unifold13/.conda/envs/unifold/bin/unicore-train", line 8, in <module>
        sys.exit(cli_main())
      File "/home/unifold13/.conda/envs/unifold/lib/python3.8/site-packages/unicore_cli/train.py", line 403, in cli_main
        distributed_utils.call_main(args, main)
      File "/home/unifold13/.conda/envs/unifold/lib/python3.8/site-packages/unicore/distributed/utils.py", line 190, in call_main
        distributed_main(args.device_id, main, args, kwargs)
      File "/home/unifold13/.conda/envs/unifold/lib/python3.8/site-packages/unicore/distributed/utils.py", line 164, in distributed_main
        main(args, **kwargs)
      File "/home/unifold13/.conda/envs/unifold/lib/python3.8/site-packages/unicore_cli/train.py", line 126, in main
        valid_losses, should_stop = train(args, trainer, task, epoch_itr, ckp_copy_thread)
      File "/home/unifold13/.conda/envs/unifold/lib/python3.8/contextlib.py", line 75, in inner
        return func(*args, **kwds)
      File "/home/unifold13/.conda/envs/unifold/lib/python3.8/site-packages/unicore_cli/train.py", line 216, in train
        log_output = trainer.train_step(samples)
      File "/home/unifold13/.conda/envs/unifold/lib/python3.8/contextlib.py", line 75, in inner
        return func(*args, **kwds)
      File "/home/unifold13/.conda/envs/unifold/lib/python3.8/site-packages/unicore/trainer.py", line 649, in train_step
        raise e
      File "/home/unifold13/.conda/envs/unifold/lib/python3.8/site-packages/unicore/trainer.py", line 613, in train_step
        loss, sample_size_i, logging_output = self.task.train_step(
      File "/home/unifold13/.conda/envs/unifold/lib/python3.8/site-packages/unicore/tasks/unicore_task.py", line 279, in train_step
        loss, sample_size, logging_output = loss(model, sample)
      File "/home/unifold13/.conda/envs/unifold/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1110, in _call_impl
        return forward_call(*input, **kwargs)
      File "/data/unifold13/applications/uniFold/Uni-Fold/unifold/loss.py", line 41, in forward
        out, config = model(batch)
      File "/home/unifold13/.conda/envs/unifold/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1110, in _call_impl
        return forward_call(*input, **kwargs)
      File "/data/unifold13/applications/uniFold/Uni-Fold/unifold/model.py", line 47, in forward
        outputs = self.model.forward(batch)
      File "/data/unifold13/applications/uniFold/Uni-Fold/unifold/modules/alphafold.py", line 437, in forward
        ) = self.iteration_evoformer_structure_module(
      File "/data/unifold13/applications/uniFold/Uni-Fold/unifold/modules/alphafold.py", line 364, in iteration_evoformer_structure_module
        m, z0, s0, msa_mask, m_1_prev_emb, z_prev_emb = self.iteration_evoformer(
      File "/data/unifold13/applications/uniFold/Uni-Fold/unifold/modules/alphafold.py", line 299, in iteration_evoformer
        self.embed_templates_pair(
      File "/data/unifold13/applications/uniFold/Uni-Fold/unifold/modules/alphafold.py", line 192, in embed_templates_pair
        t = self.embed_templates_pair_core(batch, z, pair_mask, tri_start_attn_mask, tri_end_attn_mask, templ_dim, multichain_mask_2d)
      File "/data/unifold13/applications/uniFold/Uni-Fold/unifold/modules/alphafold.py", line 163, in embed_templates_pair_core
        single_templates = [
      File "/data/unifold13/applications/uniFold/Uni-Fold/unifold/modules/alphafold.py", line 164, in <listcomp>
        self.template_pair_embedder(x, z)
      File "/home/unifold13/.conda/envs/unifold/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1110, in _call_impl
        return forward_call(*input, **kwargs)
      File "/data/unifold13/applications/uniFold/Uni-Fold/unifold/modules/embedders.py", line 257, in forward
        x = self.linear(x.type(self.linear.weight.dtype))
      File "/home/unifold13/.conda/envs/unifold/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1110, in _call_impl
        return forward_call(*input, **kwargs)
      File "/home/unifold13/.conda/envs/unifold/lib/python3.8/site-packages/torch/nn/modules/linear.py", line 103, in forward
        return F.linear(input, self.weight, self.bias)
    RuntimeError: at::cuda::blas::gemm: not implemented for N3c108BFloat16E
    ERROR:torch.distributed.elastic.multiprocessing.api:failed (exitcode: 1) local_rank: 0 (pid: 66840) of binary: /home/unifold13/.conda/envs/unifold/bin/python
    Traceback (most recent call last):
      File "/home/unifold13/.conda/envs/unifold/lib/python3.8/runpy.py", line 194, in _run_module_as_main
        return _run_code(code, main_globals, None,
      File "/home/unifold13/.conda/envs/unifold/lib/python3.8/runpy.py", line 87, in _run_code
        exec(code, run_globals)
      File "/home/unifold13/.conda/envs/unifold/lib/python3.8/site-packages/torch/distributed/launch.py", line 193, in <module>
        main()
      File "/home/unifold13/.conda/envs/unifold/lib/python3.8/site-packages/torch/distributed/launch.py", line 189, in main
        launch(args)
      File "/home/unifold13/.conda/envs/unifold/lib/python3.8/site-packages/torch/distributed/launch.py", line 174, in launch
        run(args)
      File "/home/unifold13/.conda/envs/unifold/lib/python3.8/site-packages/torch/distributed/run.py", line 715, in run
        elastic_launch(
      File "/home/unifold13/.conda/envs/unifold/lib/python3.8/site-packages/torch/distributed/launcher/api.py", line 131, in __call__
        return launch_agent(self._config, self._entrypoint, list(args))
      File "/home/unifold13/.conda/envs/unifold/lib/python3.8/site-packages/torch/distributed/launcher/api.py", line 245, in launch_agent
        raise ChildFailedError(
    torch.distributed.elastic.multiprocessing.errors.ChildFailedError:
    ============================================================
    /home/unifold13/.conda/envs/unifold/bin/unicore-train FAILED
    ------------------------------------------------------------
    Failures:
      <NO_OTHER_FAILURES>
    
    ------------------------------------------------------------
    Root Cause (first observed failure):
    [0]:
      time      : 2022-12-23_10:48:29
      host      : unfold-1
      rank      : 0 (local_rank: 0)
      exitcode  : 1 (pid: 66840)
      error_file: <N/A>
      traceback : To enable traceback see: https://pytorch.org/docs/stable/elastic/errors.html
    
    opened by showlrr2 4
  • HMMSearch Failure reading  pdb_seqres.txt for Inference

    HMMSearch Failure reading pdb_seqres.txt for Inference

    The error appears to take issue with a specific line in the file but I download it using the provided scripts from AlphaFold2.

    Traceback (most recent call last):
      File "unifold/homo_search.py", line 313, in <module>
        app.run(main)
      File "/opt/conda/lib/python3.8/site-packages/absl/app.py", line 312, in run
        _run_main(main, args)
      File "/opt/conda/lib/python3.8/site-packages/absl/app.py", line 258, in _run_main
        sys.exit(main(argv))
      File "unifold/homo_search.py", line 291, in main
        generate_pkl_features(
      File "unifold/homo_search.py", line 177, in generate_pkl_features
        feature_dict = data_pipeline.process(
      File "/Uni-Fold/unifold/msa/pipeline.py", line 193, in process
        pdb_templates_result = self.template_searcher.query(msa_for_templates)
      File "/Uni-Fold/unifold/msa/tools/hmmsearch.py", line 89, in query
        return self.query_with_hmm(hmm)
      File "/Uni-Fold/unifold/msa/tools/hmmsearch.py", line 128, in query_with_hmm
        raise RuntimeError(
    RuntimeError: hmmsearch failed:
    stdout:
    # hmmsearch :: search profile(s) against a sequence database
    # HMMER 3.3 (Nov 2019); http://hmmer.org/
    # Copyright (C) 2019 Howard Hughes Medical Institute.
    # Freely distributed under the BSD open source license.
    # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    # query HMM file:                  /tmp/tmprvyby0zh/query.hmm
    # target sequence database:        /database/pdb_seqres/pdb_seqres.txt
    # MSA of all hits saved to file:   /tmp/tmprvyby0zh/output.sto
    # show alignments in output:       no
    # sequence reporting threshold:    E-value <= 100
    # domain reporting threshold:      E-value <= 100
    # sequence inclusion threshold:    E-value <= 100
    # domain inclusion threshold:      E-value <= 100
    # MSV filter P threshold:       <= 0.1
    # Vit filter P threshold:       <= 0.1
    # Fwd filter P threshold:       <= 0.1
    # number of worker threads:        8
    # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    
    Query:       query  [M=117]
    
    
    stderr:
    Parse failed (sequence file /database/pdb_seqres/pdb_seqres.txt):
    Line 1360658: illegal character 0
    
    
    
    Starting prediction...
    start to load params /database/monomer.unifold.pt
    start to predict T1104
    Traceback (most recent call last):
      File "unifold/inference.py", line 266, in <module>
        main(args)
      File "unifold/inference.py", line 118, in main
        batch = load_feature_for_one_target(
      File "unifold/inference.py", line 61, in load_feature_for_one_target
        batch, _ = load_and_process(
      File "/Uni-Fold/unifold/dataset.py", line 233, in load_and_process
        features, labels = load(**load_kwargs, is_monomer=is_monomer)
      File "/Uni-Fold/unifold/dataset.py", line 129, in load
        all_chain_features = [
      File "/Uni-Fold/unifold/dataset.py", line 130, in <listcomp>
        load_single_feature(s, monomer_feature_dir, uniprot_msa_dir, is_monomer)
      File "/Uni-Fold/unifold/data/utils.py", line 33, in wrapper
        return copy_lib.copy(cached_func(*args, **kwargs))
      File "/Uni-Fold/unifold/dataset.py", line 72, in load_single_feature
        monomer_feature = utils.load_pickle(
      File "/Uni-Fold/unifold/data/utils.py", line 33, in wrapper
        return copy_lib.copy(cached_func(*args, **kwargs))
      File "/Uni-Fold/unifold/data/utils.py", line 67, in load_pickle
        ret = load(path)
      File "/Uni-Fold/unifold/data/utils.py", line 64, in load
        with open_fn(path, "rb") as f:
      File "/opt/conda/lib/python3.8/gzip.py", line 58, in open
        binary_file = GzipFile(filename, gz_mode, compresslevel)
      File "/opt/conda/lib/python3.8/gzip.py", line 173, in __init__
        fileobj = self.myfileobj = builtins.open(filename, mode or 'rb')
    FileNotFoundError: [Errno 2] No such file or directory: '/data/output/T1104/A.feature.pkl.gz'
    
    opened by bernym12 4
  • loading state_dict

    loading state_dict

    I run the code in Running Uni-Fold( I change some paths)as this: bash run_unifold.sh /home/input_fasta/1.fasta /home/output /path/to/database/directory 2020-05-01 multimer_ft /home/Uni-Fold/all_model/multimer.unifold.pt model name is : multimer_ft model parameters file is:multimer.unifold.pt(in section 'Downloading the pre-trained model parameters')

    but I meet this bug: 截屏2022-08-12 下午8 40 16

    could u help me?

    opened by rabbit-0001 4
  • dataset down load error

    dataset down load error

    when i download the training dataset, i got the error: requests.exceptions.ConnectionError: HTTPConnectionPool(host='www.modelscope.cn', port=80): Max retries exceeded with url: /api/v1/datasets/DPTech/Uni-Fold-Data/oss/tree/?MaxLimit=-1&Revision=master&Recursive=True&FilterDir=True (Caused by ReadTimeoutError("HTTPConnectionPool(host='www.modelscope.cn', port=80): Read timed out. (read timeout=60)"))

    opened by maowayne123 3
  • CUDA OOM error when inference long protein sequence

    CUDA OOM error when inference long protein sequence

    Hi, thanks for sharing the work. I tried to run a long protein sequence(4022AA) with the provided monomer pretrained model and the model_name is "model_2_ft". I have tried to reduce the chunk size and switch to bf16 but it still failed. My machine is A100 40G. And the error log is as below.

    {'aatype': torch.Size([1, 1, 4022]), 'residue_index': torch.Size([1, 1, 4022]), 'seq_length': torch.Size([1, 1]), 'template_aatype': torch.Size([1, 1, 4, 4022]), 'template_all_atom_mask': torch.Size([1, 1, 4, 4022, 37]), 'template_all_atom_positions': torch.Size([1, 1, 4, 4022, 37, 3]), 'num_recycling_iters': torch.Size([1, 1]), 'is_distillation': torch.Size([4, 1]), 'seq_mask': torch.Size([1, 1, 4022]), 'msa_mask': torch.Size([4, 1, 508, 4022]), 'msa_row_mask': torch.Size([4, 1, 508]), 'template_mask': torch.Size([1, 1, 4]), 'template_pseudo_beta': torch.Size([1, 1, 4, 4022, 3]), 'template_pseudo_beta_mask': torch.Size([1, 1, 4, 4022]), 'template_torsion_angles_sin_cos': torch.Size([1, 1, 4, 4022, 7, 2]), 'template_alt_torsion_angles_sin_cos': torch.Size([1, 1, 4, 4022, 7, 2]), 'template_torsion_angles_mask': torch.Size([1, 1, 4, 4022, 7]), 'residx_atom14_to_atom37': torch.Size([1, 1, 4022, 14]), 'residx_atom37_to_atom14': torch.Size([1, 1, 4022, 37]), 'atom14_atom_exists': torch.Size([1, 1, 4022, 14]), 'atom37_atom_exists': torch.Size([1, 1, 4022, 37]), 'target_feat': torch.Size([1, 1, 4022, 22]), 'extra_msa': torch.Size([4, 1, 1024, 4022]), 'extra_msa_mask': torch.Size([4, 1, 1024, 4022]), 'extra_msa_row_mask': torch.Size([4, 1, 1024]), 'bert_mask': torch.Size([4, 1, 508, 4022]), 'true_msa': torch.Size([4, 1, 508, 4022]), 'extra_msa_has_deletion': torch.Size([4, 1, 1024, 4022]), 'extra_msa_deletion_value': torch.Size([4, 1, 1024, 4022]), 'msa_feat': torch.Size([4, 1, 508, 4022, 49])}
    Traceback (most recent call last):
      File "unifold/inference.py", line 269, in <module>
        main(args)
      File "unifold/inference.py", line 143, in main
        raw_out = model(batch)
      File "/root/paddlejob/workspace/env_run/openfold/lib/conda/envs/openfold_venv/lib/python3.7/site-packages/torch/nn/modules/module.py", line 1130, in _call_impl
        return forward_call(*input, **kwargs)
      File "/root/paddlejob/workspace/env_run/Uni-Fold/unifold/modules/alphafold.py", line 444, in forward
        num_ensembles=num_ensembles,
      File "/root/paddlejob/workspace/env_run/Uni-Fold/unifold/modules/alphafold.py", line 365, in iteration_evoformer_structure_module
        feats, m_1_prev, z_prev, x_prev
      File "/root/paddlejob/workspace/env_run/Uni-Fold/unifold/modules/alphafold.py", line 305, in iteration_evoformer
        templ_dim=-4,
      File "/root/paddlejob/workspace/env_run/Uni-Fold/unifold/modules/alphafold.py", line 192, in embed_templates_pair
        t = self.embed_templates_pair_core(batch, z, pair_mask, tri_start_attn_mask, tri_end_attn_mask, templ_dim, multichain_mask_2d)
      File "/root/paddlejob/workspace/env_run/Uni-Fold/unifold/modules/alphafold.py", line 161, in embed_templates_pair_core
        **self.config.template.distogram,
      File "/root/paddlejob/workspace/env_run/Uni-Fold/unifold/modules/featurization.py", line 123, in build_template_pair_feat
        act = torch.cat(to_concat, dim=-1)
    RuntimeError: CUDA out of memory. Tried to allocate 21.21 GiB (GPU 0; 39.59 GiB total capacity; 24.58 GiB already allocated; 13.62 GiB free; 24.82 GiB reserved in total by PyTorch) If reserved memory is >> allocated memory try setting max_split_size_mb to avoid fragmentation.  See documentation for Memory Management and PYTORCH_CUDA_ALLOC_CONF
    

    Thanks

    opened by SuperXiang 3
  • Predict from A3M directly ?

    Predict from A3M directly ?

    Hi!

    Is it possible to use a MSA directly for the prediction ? I already configured colabfold which takes a lot of space in my hard drive and I would like to avoid creating another database (if possible :))

    THanks! Best regards, THibault Tubiana.

    opened by tubiana 3
  • Questions regarding Uni-Fold multimer evaluation

    Questions regarding Uni-Fold multimer evaluation

    Thanks for presenting the great work of Uni-Fold on Protein Structure Prediction. I have a few questions regarding the multimer evaluation part.

    1. As for multimer evaluation, it's said in the paper that you merge all chains into one before scoring. Do you predict the multimers with all chains and then remove the TER symbol in the output pdb files before using the TMscore/lDDT tool? Or do you just use the command $ TMscore -c model.pdb native.pdb with -ter <= 1? Would you share more details or the scripts of the evaluation part since I haven't found it within the GitHub repo?

    2. Since the order of different chains might be a problem in the predicted multimers, it's said in the paper that you iterate over all possible permutation alignments during evaluation. Would you share any related codes of this part so that I can align my experiment results with yours?

    3. I think It's common to use DockQ during the multimer evaluation. May I know any reason for not using this metric besides leading to confusion which is said in the paper?

    opened by SuperXiang 2
  • URL for pre-trained Uni-Fold model parameters not working

    URL for pre-trained Uni-Fold model parameters not working

    The URL to download the Uni-Fold model parameters in the README instructions does not work:

    wget https://github.com/dptech-corp/Uni-Fold/releases/download/v2.2.0/unifold_params_2022-08-01.tar.gz

    opened by ajbordner 2
  • Using Template PDB files

    Using Template PDB files

    Hi,

    In AlphaFold you have a the possibility to provide a template (or decoy) protein structure, this way skipping the MSA search, leading to faster predictions. Is this with Uni-Fold also possible, or planned to be implemented? It would be of great use in some applications.

    opened by babaid 0
  • training error

    training error

    after i download the training dataset and start training. there is an error: Traceback (most recent call last): File "/home/wayne/miniconda3/envs/unifold/lib/python3.9/runpy.py", line 197, in _run_module_as_main return _run_code(code, main_globals, None, File "/home/wayne/miniconda3/envs/unifold/lib/python3.9/runpy.py", line 87, in _run_code exec(code, run_globals) File "/home/wayne/.vscode-server/extensions/ms-python.python-2022.20.1/pythonFiles/lib/python/debugpy/adapter/../../debugpy/launcher/../../debugpy/main.py", line 39, in cli.main() File "/home/wayne/.vscode-server/extensions/ms-python.python-2022.20.1/pythonFiles/lib/python/debugpy/adapter/../../debugpy/launcher/../../debugpy/../debugpy/server/cli.py", line 430, in main run() File "/home/wayne/.vscode-server/extensions/ms-python.python-2022.20.1/pythonFiles/lib/python/debugpy/adapter/../../debugpy/launcher/../../debugpy/../debugpy/server/cli.py", line 284, in run_file runpy.run_path(target, run_name="main") File "/home/wayne/.vscode-server/extensions/ms-python.python-2022.20.1/pythonFiles/lib/python/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_runpy.py", line 321, in run_path return _run_module_code(code, init_globals, run_name, File "/home/wayne/.vscode-server/extensions/ms-python.python-2022.20.1/pythonFiles/lib/python/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_runpy.py", line 135, in _run_module_code _run_code(code, mod_globals, init_globals, File "/home/wayne/.vscode-server/extensions/ms-python.python-2022.20.1/pythonFiles/lib/python/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_runpy.py", line 124, in _run_code exec(code, run_globals) File "/home/wayne/project/folding/uni/train.py", line 431, in cli_main() File "/home/wayne/project/folding/uni/train.py", line 427, in cli_main distributed_utils.call_main(args, main) File "/home/wayne/miniconda3/envs/unifold/lib/python3.9/site-packages/unicore-0.0.1-py3.9-linux-x86_64.egg/unicore/distributed/utils.py", line 193, in call_main main(args, **kwargs) File "/home/wayne/project/folding/uni/train.py", line 79, in main task.load_dataset(valid_sub_split, combine=False, epoch=1) File "/home/wayne/project/folding/uni/unifold/task.py", line 72, in load_dataset dataset = data_class( File "/home/wayne/project/folding/uni/unifold/dataset.py", line 257, in init sample_weight = load_json( File "/home/wayne/project/folding/uni/unifold/dataset.py", line 255, in load_json return json.load(open(filename, "r")) FileNotFoundError: [Errno 2] No such file or directory: '/media/HDD/dataset/protein1/modelscope/hub/datasets/downloads/DPTech/Uni-Fold-Data/master/eval_sample_weight.json'

    opened by maowayne123 0
  • finetuning unifold

    finetuning unifold

    Hi all! I'd like to finetune unifold multimer with new cases. In the git readme file, it mentions that I need a data structure similar to the one in example_data, with features pickle files and labels (please correct me if I'm wrong). However, it is not clear to me how to generate this data structure. Could you provide additional information on that, please? Thank you!

    opened by helder-ribeiro 3
  • support branch parallel for evoformer

    support branch parallel for evoformer

    opened by GuoxiaWang 0
Releases(v2.2.0)
Owner
DP Technology
DP Technology
Implementation of the GVP-Transformer, which was used in the paper "Learning inverse folding from millions of predicted structures" for de novo protein design alongside Alphafold2

GVP Transformer (wip) Implementation of the GVP-Transformer, which was used in the paper Learning inverse folding from millions of predicted structure

Phil Wang 19 May 6, 2022
A graph neural network (GNN) model to predict protein-protein interactions (PPI) with no sample features

A graph neural network (GNN) model to predict protein-protein interactions (PPI) with no sample features

null 2 Jul 25, 2022
Using this codebase as a tool for my own research. Making some modifications to the original repo for my own purposes.

For SwapNet Create a list.txt file containing all the images to process. This can be done with the GNU find command: find path/to/input/folder -name '

Andrew Jong 2 Nov 10, 2021
Predicting lncRNA–protein interactions based on graph autoencoders and collaborative training

Predicting lncRNA–protein interactions based on graph autoencoders and collaborative training Code for our paper "Predicting lncRNA–protein interactio

zhanglabNKU 1 Nov 29, 2022
Generative Models for Graph-Based Protein Design

Graph-Based Protein Design This repo contains code for Generative Models for Graph-Based Protein Design by John Ingraham, Vikas Garg, Regina Barzilay

John Ingraham 159 Dec 15, 2022
Codes and models for the paper "Learning Unknown from Correlations: Graph Neural Network for Inter-novel-protein Interaction Prediction".

GNN_PPI Codes and models for the paper "Learning Unknown from Correlations: Graph Neural Network for Inter-novel-protein Interaction Prediction". Lear

Ursa Zrimsek 2 Dec 14, 2022
RITA is a family of autoregressive protein models, developed by LightOn in collaboration with the OATML group at Oxford and the Debora Marks Lab at Harvard.

RITA: a Study on Scaling Up Generative Protein Sequence Models RITA is a family of autoregressive protein models, developed by a collaboration of Ligh

LightOn 69 Dec 22, 2022
A colab notebook for training Stylegan2-ada on colab, transfer learning onto your own dataset.

Stylegan2-Ada-Google-Colab-Starter-Notebook A no thrills colab notebook for training Stylegan2-ada on colab. transfer learning onto your own dataset h

Harnick Khera 66 Dec 16, 2022
A geometric deep learning pipeline for predicting protein interface contacts.

A geometric deep learning pipeline for predicting protein interface contacts.

null 44 Dec 30, 2022
Unofficial TensorFlow implementation of Protein Interface Prediction using Graph Convolutional Networks.

[TensorFlow] Protein Interface Prediction using Graph Convolutional Networks Unofficial TensorFlow implementation of Protein Interface Prediction usin

YeongHyeon Park 9 Oct 25, 2022
A denoising diffusion probabilistic model (DDPM) tailored for conditional generation of protein distograms

Denoising Diffusion Probabilistic Model for Proteins Implementation of Denoising Diffusion Probabilistic Model in Pytorch. It is a new approach to gen

Phil Wang 108 Nov 23, 2022
7th place solution of Human Protein Atlas - Single Cell Classification on Kaggle

kaggle-hpa-2021-7th-place-solution Code for 7th place solution of Human Protein Atlas - Single Cell Classification on Kaggle. A description of the met

null 8 Jul 9, 2021
Implementation and replication of ProGen, Language Modeling for Protein Generation, in Jax

ProGen - (wip) Implementation and replication of ProGen, Language Modeling for Protein Generation, in Pytorch and Jax (the weights will be made easily

Phil Wang 71 Dec 1, 2022
Graph-based community clustering approach to extract protein domains from a predicted aligned error matrix

Using a predicted aligned error matrix corresponding to an AlphaFold2 model , returns a series of lists of residue indices, where each list corresponds to a set of residues clustering together into a pseudo-rigid domain.

Tristan Croll 24 Nov 23, 2022
A package to predict protein inter-residue geometries from sequence data

trRosetta This package is a part of trRosetta protein structure prediction protocol developed in: Improved protein structure prediction using predicte

Ivan Anishchenko 185 Jan 7, 2023
A Protein-RNA Interface Predictor Based on Semantics of Sequences

PRIP PRIP:A Protein-RNA Interface Predictor Based on Semantics of Sequences installation gensim==3.8.3 matplotlib==3.1.3 xgboost==1.3.3 prettytable==2

李优 0 Mar 25, 2022
Official implementation of "Generating 3D Molecules for Target Protein Binding"

Generating 3D Molecules for Target Protein Binding This is the official implementation of the GraphBP method proposed in the following paper. Meng Liu

DIVE Lab, Texas A&M University 74 Dec 7, 2022
Implementation of a protein autoregressive language model, but with autoregressive infilling objective (editing subsequences capability)

Protein GLM (wip) Implementation of a protein autoregressive language model, but with autoregressive infilling objective (editing subsequences capabil

Phil Wang 17 May 6, 2022