Loaders
lahuta.core._loaders ¶
Classes to load and manage biological structure data.
The two main classes are GemmiLoader
and TopologyLoader
, each designed to work with a
specific library, Gemmi and MDAnalysis respectively, to load and handle structure data.
Both loaders extend from an abstract base class BaseLoader
which outlines the necessary
methods and properties all loader classes should have.
The module also provides a unified way to manage atoms, residues, and chains information through the ARC class instance. It includes various methods for querying the data and converting them into other common bioinformatics and chemoinformatics formats.
Classes:
Name | Description |
---|---|
BaseLoader |
Abstract base class that provides a template for the loader classes. |
GemmiLoader |
Class to load and manage biological structure data using the Gemmi library. |
TopologyLoader |
Class to load and manage biological structure data using the MDAnalysis library. |
BaseLoader ¶
Bases: ABC
Abstract base class providing a blueprint for loading and handling biological structure data.
BaseLoader
forms the basis for other loader classes in the lahuta library, dedicated
to handling different formats of biological structural data. It includes the initialization
of atomic, residue, and chain data as well as their transformation into different formats.
The class takes a file path as an input and reads the biological structure data. It offers various properties to access the data, as well as methods to convert the loaded data into different output formats. It also provides an iterator to iterate over atoms, residues, and chains.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
file_path |
str
|
The file path from which to load the biological structure data. |
required |
Attributes:
Name | Type | Description |
---|---|---|
file_path |
str
|
The file path from which the biological structure data is loaded. |
_chains |
Optional[Chains]
|
An instance of Chains class containing chain data. |
_residues |
Optional[Residues]
|
An instance of Residues class containing residue data. |
_atoms |
Optional[Atoms]
|
An instance of Atoms class containing atom data. |
structure |
A structure object containing biological structure data, currently initialized to None. |
|
arc |
Optional[ARC]
|
An instance of ARC class providing combined access to atoms, residues, and chains data. |
Source code in lahuta/core/_loaders.py
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 |
|
to ¶
to(fmt)
Convert the loaded biological structure data into a different format.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
fmt |
str
|
The format to which the biological structure data should be converted. |
required |
Returns:
Type | Description |
---|---|
MolType | AtomGroupType
|
MolType | AtomGroupType: The biological structure data in the specified format. |
Raises:
Type | Description |
---|---|
ValueError
|
If the specified format is not supported. |
Source code in lahuta/core/_loaders.py
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 |
|
to_mda
abstractmethod
¶
to_mda()
Convert the loaded biological structure data into an MDAnalysis AtomGroup object.
Source code in lahuta/core/_loaders.py
121 122 123 |
|
to_mol
abstractmethod
¶
to_mol()
Convert the loaded biological structure data into an OpenBabel Mol object.
Source code in lahuta/core/_loaders.py
125 126 127 |
|
GemmiLoader ¶
Bases: BaseLoader
Class for loading biological structure data using the gemmi library.
GemmiLoader
is a subclass of BaseLoader
and provides the implementation to read,
convert, and manage biological structure data specifically from the gemmi library.
The class takes a file path as an input and reads the biological structure data either
in PDB format or in the format specified in the file. It also offers methods to convert
the loaded data into different output formats.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
file_path |
str
|
The file path from which to load the biological structure data. |
required |
is_pdb |
bool
|
A flag to indicate whether the file is in PDB format. Defaults to False. |
False
|
Attributes:
Name | Type | Description |
---|---|---|
structure |
A gemmi structure object containing biological structure data. |
|
arc |
Optional[ARC]
|
An instance of ARC class providing combined access to atoms, residues, and chains data. |
ag |
AtomGroupType
|
An MDAnalysis AtomGroup object created from the loaded data. |
Source code in lahuta/core/_loaders.py
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 |
|
extract_positions ¶
extract_positions(atom_site_data)
Extract the coordinates from the atom_site data.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
atom_site_data |
dict[str, Any]
|
The atom_site data from the gemmi structure object. |
required |
Returns:
Type | Description |
---|---|
NDArray[float32]
|
NDArray[np.float32]: The coordinates of the atoms in the structure. |
Raises:
Type | Description |
---|---|
ValueError
|
If the atom_site data does not contain the required information. |
Source code in lahuta/core/_loaders.py
173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 |
|
to_mda ¶
to_mda()
Convert the loaded biological structure data into an MDAnalysis AtomGroup object.
Source code in lahuta/core/_loaders.py
233 234 235 |
|
to_mol ¶
to_mol()
Convert the loaded biological structure data into an OpenBabel Mol object.
Source code in lahuta/core/_loaders.py
237 238 239 240 241 242 243 244 245 246 247 |
|
TopologyLoader ¶
Bases: BaseLoader
Class for loading and managing biological structure data using the MDAnalysis library.
TopologyLoader
is a subclass of BaseLoader
and provides the implementation to read,
convert, and manage biological structure data specifically from the MDAnalysis library.
This class accepts one or more file paths and loads the structure data into an
MDAnalysis Universe. It also offers methods to convert the loaded data into different output formats.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
*paths |
str
|
One or more file paths from which to load the biological structure data. |
()
|
Attributes:
Name | Type | Description |
---|---|---|
ag |
AtomGroupType
|
An MDAnalysis AtomGroup object created from the loaded data. |
arc |
Optional[ARC]
|
An instance of ARC class providing combined access to atoms, residues, and chains data. |
Source code in lahuta/core/_loaders.py
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 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 |
|
to_mda ¶
to_mda()
Convert the loaded biological structure data into an MDAnalysis AtomGroup object.
Source code in lahuta/core/_loaders.py
279 280 281 |
|
to_mol ¶
to_mol()
Convert the loaded biological structure data into an OpenBabel Mol object.
Source code in lahuta/core/_loaders.py
283 284 285 286 287 288 289 290 291 292 |
|
from_mda
classmethod
¶
from_mda(ag)
Create a new instance of the TopologyLoader class from an MDAnalysis AtomGroup object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ag |
AtomGroupType
|
An MDAnalysis AtomGroup object. |
required |
Returns:
Name | Type | Description |
---|---|---|
TopologyLoader |
TopologyLoader
|
A new instance of the TopologyLoader class with the AtomGroup data copied. |
Source code in lahuta/core/_loaders.py
294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 |
|