Luni
lahuta.Luni ¶
The main class of the Lahuta package. It represents a universe of atoms and provides methods for computing various properties of the universe.
The Luni class is the entry point for all computations. It provides an interface for loading files, or for initializing the Luni from an existing MDAnalysis.AtomGroup instance. This way we can support both file-based loading and indicrectly support all MDAnalysis formats, as well as provide support for reading MD trajectories.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
*args |
LuniInputType
|
Either an MDAnalysis.AtomGroup instance or a list of file names. |
()
|
Attributes:
Name | Type | Description |
---|---|---|
atom_types |
csc_array
|
A sparse array containing the atom types of the universe. |
arc |
ARC
|
The ARC instance used to load the files. |
sequence |
str
|
The sequence of the universe. |
Raises:
Type | Description |
---|---|
ValueError
|
If no input is provided or if invalid types of inputs are provided. |
Source code in lahuta/core/luni.py
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 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 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 |
|
sequence
property
¶
sequence
Retrieve the sequence of the Luni.
This method retrieves the sequence of the Luni from the underlying MDA AtomGroup instance. It returns a NumPy array of shape (n_atoms,) containing the one-letter amino acid codes.
Returns:
Type | Description |
---|---|
str
|
NDArray[np.str_]: A NumPy array containing the one-letter amino acid codes of the Luni. |
arc
property
¶
arc
Retrieve the ARC instance used to load the files.
Returns:
Type | Description |
---|---|
None | ARC
|
None | ARC: The ARC instance used to load the files. |
ready ¶
ready()
Prepare instance for computations by transforming the molecule and assigning atom types.
Source code in lahuta/core/luni.py
158 159 160 161 162 163 164 165 166 167 168 169 170 171 |
|
compute_neighbors ¶
compute_neighbors(radius=5.0, res_dif=1)
Compute the neighbors of each atom in the Luni.
This method calculates the neighbors for each atom based on the given radius and residue difference parameters.
It returns an object of type NeighborPairs
where each row in the underlying NumPy array contains the indices
of the neighbors for the atom corresponding to that row.
Ensures that the Luni instance is ready for computations by calling the ready
method if needed.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
radius |
float
|
The cutoff radius for considering two atoms as neighbors. Default is 5.0. |
5.0
|
res_dif |
int
|
The minimum difference in residue numbers for two atoms to be considered neighbors. Default is 1. |
1
|
Returns:
Name | Type | Description |
---|---|---|
NeighborPairs |
NeighborPairs
|
An object containing a 2D NumPy array with shape (n_atoms, n_neighbors). Each row in the array contains the indices of the neighbors for the atom corresponding to that row. |
Source code in lahuta/core/luni.py
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 |
|
get_format
staticmethod
¶
get_format(file_name)
Retrieve the file format from a file name.
This static method checks the file extension of the provided file name against the list of formats
supported by GEMMI (stored in GEMMI_SUPPRTED_FORMATS
). If the extension matches a supported format,
it returns the format and a boolean indicating whether the format is 'pdb' or 'pdb.gz'. If the file
extension doesn't match any supported formats, it returns None and False.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
file_name |
str
|
The name of the file. |
required |
Returns:
Name | Type | Description |
---|---|---|
tuple |
tuple[str | None, bool]
|
A tuple containing the file format (str or None) and a boolean indicating if it is 'pdb' or 'pdb.gz'. |
Source code in lahuta/core/luni.py
229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 |
|
to ¶
to(fmt)
Convert the Luni to a different format.
This method converts the internal representation of the Luni to the specified format.
Currently, the supported formats are "mda" and "mol". If the desired format is "mol" and
the Luni already has a "mol" representation, it returns the existing representation.
Otherwise, it uses the to
method of the file loader to perform the conversion.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
fmt |
str
|
The format to convert to. Currently supported formats are "mda" and "mol". |
required |
Returns:
Type | Description |
---|---|
MolType | AtomGroupType
|
MolType | AtomGroupType: A new Luni instance in the specified format. |
Source code in lahuta/core/luni.py
259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 |
|