functional¶
multimolecule.data.functional
¶
dot_bracket_to_contact_map
¶
dot_bracket_to_contact_map(dot_bracket: str) -> ndarray
Convert a dot-bracket notation string to a contact map.
This function parses a dot-bracket string representation of secondary structure and creates a binary contact map where 1 indicates paired bases.
Note
This function is the inverse of
contact_map_to_dot_bracket
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
|
str
|
A string in dot-bracket notation representing secondary structure. Can include various bracket types for representing pseudoknots. |
required |
Returns:
Type | Description |
---|---|
ndarray
|
A symmetric numpy array of shape (n, n) where n is the length of the input string. 1 indicates paired bases, 0 indicates unpaired bases. |
Raises:
Type | Description |
---|---|
ValueError
|
If the dot-bracket notation contains unmatched or invalid symbols. |
Examples:
Simple hairpin structure
Python Console Session | |
---|---|
Structure with pseudoknots using different bracket types
Python Console Session | |
---|---|
Unpaired sequence
Python Console Session | |
---|---|
Error case: unmatched bracket
Python Console Session | |
---|---|
Source code in multimolecule/data/functional.py
contact_map_to_dot_bracket
¶
Convert a contact map to dot-bracket notation.
This function takes a contact map (binary matrix where 1 indicates paired bases) and converts it to a dot-bracket notation string.
Note
This function is the inverse of
dot_bracket_to_contact_map
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
|
ndarray | list | Tensor
|
A square array where 1 indicates a base pair. Should be symmetric with zeros on the diagonal. |
required |
|
bool
|
If True, only use the upper triangular part of the matrix and issue a warning if the matrix is not symmetric. Useful for processing model outputs. |
False
|
Returns:
Type | Description |
---|---|
str
|
A string in dot-bracket notation representing the secondary structure. |
Raises:
Type | Description |
---|---|
ValueError
|
If the contact map contains invalid pairing information or if there are too many pseudoknots to represent with available bracket types. |
Examples:
Simple hairpin structure
Python Console Session | |
---|---|
Structure with pseudoknots using different bracket types
Unpaired sequence
Python Console Session | |
---|---|
Using unsafe mode with non-symmetric input
Python Console Session | |
---|---|
Source code in multimolecule/data/functional.py
Python | |
---|---|
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 |
|