UFold¶
Pre-trained model for RNA secondary structure prediction using an image-like sequence representation and a U-Net.
Disclaimer¶
This is an UNOFFICIAL implementation of UFold: fast and accurate RNA secondary structure prediction with deep learning by Laiyi Fu, Yingxin Cao, Jie Wu, Qinke Peng, Qing Nie, and Xiaohui Xie.
The OFFICIAL repository of UFold is at uci-cbcl/UFold.
Tip
The MultiMolecule implementation is a direct PyTorch port of the original U-Net architecture and feature construction.
The team releasing UFold did not write this model card for this model so this model card has been written by the MultiMolecule team.
Model Details¶
UFold predicts RNA base-pair contact maps from single RNA sequences. It represents a sequence as a 17-channel image: 16 channels are outer products of one-hot nucleotide indicators and one channel is a hand-crafted canonical/wobble pairing score. A U-Net predicts a symmetric contact score matrix, and the original constrained post-processing routine can be enabled to enforce base-pairing constraints.
Model Specification¶
| Num Parameters (M) | FLOPs (G) | MACs (G) |
|---|---|---|
| 8.64 | 188.29 | 93.81 |
FLOPs and MACs are computed with multimolecule.utils for one 600 nt sequence.
Links¶
- Code: multimolecule.ufold
- Weights: multimolecule/ufold
- Paper: UFold: fast and accurate RNA secondary structure prediction with deep learning
- Developed by: Laiyi Fu, Yingxin Cao, Jie Wu, Qinke Peng, Qing Nie, Xiaohui Xie
- Original Repository: uci-cbcl/UFold
Usage¶
The model file depends on the multimolecule library. You can install it using pip:
| Bash | |
|---|---|
RNA Secondary Structure Pipeline¶
| Python | |
|---|---|
PyTorch Inference¶
To run the original constrained post-processing loop:
| Python | |
|---|---|
Training Details¶
UFold was trained for RNA secondary structure prediction from annotated contact maps and base-pairing rules.
Training Data¶
- RNAStrAlign: 30,451 unique RNAs from eight RNA families; the paper reports a random split with 24,895 training RNAs and 2,854 test RNAs after redundancy filtering.
- bpRNA-1m: 102,318 RNAs from 2,588 families; CD-HIT was used to remove redundant sequences before splitting the data into TR0 and TS0.
- augmented data: synthetic training examples were generated from bpRNA-new sequences by random mutation and structure prediction.
- PDB training data: high-resolution RNA structures from bpRNA and the PDB were used for fine-tuning/evaluation experiments; test sets TS1, TS2, and TS3 were filtered at 80% sequence identity.
- evaluation data: ArchiveII, TS0, bpRNA-new, and PDB test data were used for benchmark evaluation.
Training Procedure¶
- input representation: 16 outer-product channels following the MultiMolecule tokenizer order plus one hand-crafted pairing-score channel.
- objective: weighted binary cross entropy over base-pair contact maps.
- optimizer: Adam.
- training epochs: 100.
- batch size: 1.
- positive-class weight: 300.
- post-processing: constrained optimization with canonical/wobble pairing rules, sparsity shrinkage, and a 0.5 threshold.
Citation¶
Note
The artifacts distributed in this repository are part of the MultiMolecule project. If you use MultiMolecule in your research, you must cite the MultiMolecule project as follows:
| BibTeX | |
|---|---|
Contact¶
Please use GitHub issues of MultiMolecule for any questions or comments on the model card.
Please contact the authors of the UFold paper for questions or comments on the paper/model.
License¶
This model implementation is licensed under the GNU Affero General Public License.
For additional terms and clarifications, please refer to our License FAQ.
| Text Only | |
|---|---|
multimolecule.models.ufold
¶
RnaTokenizer
¶
Bases: Tokenizer
Tokenizer for RNA sequences.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
Alphabet | str | List[str] | None
|
alphabet to use for tokenization.
|
None
|
|
int
|
Size of kmer to tokenize. |
1
|
|
bool
|
Whether to tokenize into codons. |
False
|
|
bool
|
Whether to replace T with U. |
True
|
|
bool
|
Whether to convert input to uppercase. |
True
|
Examples:
Source code in multimolecule/tokenisers/rna/tokenization_rna.py
UfoldConfig
¶
Bases: PreTrainedConfig
This is the configuration class to store the configuration of a
UfoldModel. It is used to instantiate a UFold model according to the
specified arguments, defining the model architecture. Instantiating a configuration with the defaults will yield a
similar configuration to that of the UFold uci-cbcl/UFold architecture.
Configuration objects inherit from PreTrainedConfig and can be used to
control the model outputs. Read the documentation from PreTrainedConfig
for more information.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
int
|
Token vocabulary size of the UFold model. Defaults to 5 for the |
5
|
|
int
|
Number of image-like input channels. The original UFold model uses 16 outer-product base-pair channels plus one hand-crafted pairing-score channel. |
17
|
|
int
|
Number of U-Net output channels. The original UFold model predicts one contact-score matrix. |
1
|
|
list[int] | None
|
U-Net channel sizes for the five original resolution levels. |
None
|
|
int
|
Minimum padded image size used before the U-Net. The original short-sequence dataset pads to 80. |
80
|
|
int
|
Spatial size multiple required by the four downsampling stages. |
16
|
|
float
|
Epsilon used by the BatchNorm2d layers. |
1e-05
|
|
float
|
Momentum used by the BatchNorm2d layers. |
0.1
|
|
float
|
Probability threshold for predicting base pairs during post-processing. |
0.5
|
|
bool
|
Whether to run the UFold constrained post-processing loop in |
False
|
|
int
|
Number of constrained post-processing iterations. |
100
|
|
float
|
Learning rate for the minimization step in UFold post-processing. |
0.01
|
|
float
|
Learning rate for the Lagrangian multiplier maximization step in UFold post-processing. |
0.1
|
|
float
|
L1 sparsity coefficient used by UFold post-processing. |
1.6
|
|
bool
|
Whether to apply L1 shrinkage in UFold post-processing. |
True
|
|
float
|
Logit cutoff used by UFold post-processing. Defaults to |
2.1972245773362196
|
|
bool
|
Whether post-processing should allow non-canonical base pairs. |
False
|
|
float
|
Positive-class weight used by the original weighted binary cross-entropy training loss. |
300.0
|
Examples:
| Python Console Session | |
|---|---|
Source code in multimolecule/models/ufold/configuration_ufold.py
| Python | |
|---|---|
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 | |
UfoldModel
¶
Bases: UfoldPreTrainedModel
Examples:
Source code in multimolecule/models/ufold/modeling_ufold.py
| Python | |
|---|---|
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 | |
UfoldModelOutput
dataclass
¶
Bases: ModelOutput
Output type for UFold.
Source code in multimolecule/models/ufold/modeling_ufold.py
| Python | |
|---|---|