Top-Level Functions¶
These functions are the main entry points to MDNA, available directly from import mdna.
mdna.nucleic.make(sequence=None, control_points=None, circular=False, closed=False, n_bp=None, dLk=None, bp_per_turn=10.5)
¶
Generate a DNA structure from a given DNA sequence and control points.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sequence
|
str
|
DNA sequence code. If not provided, the default sequence 'CGCGAATTCGCG' will be used. (default: None) |
None
|
control_points
|
ndarray
|
Control points of the DNA structure. Should be a numpy array of shape (n, 3) where n is the number of control points. If not provided, a straight line will be used as the default control points. (default: None) |
None
|
circular
|
bool
|
Flag indicating if the DNA structure is circular/closed. If True, the DNA structure will be closed. If False, the DNA structure will be open. (default: False) |
False
|
closed
|
bool
|
Flag indicating if the DNA structure is closed. If True, the DNA structure will be closed. If False, the DNA structure will be open. This argument is deprecated and will be removed in a future version. Please use the 'circular' argument instead. (default: False) |
False
|
n_bp
|
int
|
Number of base pairs to scale the shape with. If not provided, the number of base pairs will be determined based on the length of the control points or the sequence. (default: None) |
None
|
dLk
|
int
|
Change in twist in terms of Linking number of the DNA structure. If not provided, a neutral twist based on bp_per_turn = 10.5 will be used. (default: None) |
None
|
bp_per_turn
|
int
|
Number of base pairs per turn of the DNA structure. (default: 10.5) |
10.5
|
Returns:
| Name | Type | Description |
|---|---|---|
Nucleic |
object
|
DNA structure object. |
Decision matrix
- No
control_points,sequenceprovided: uses default shape (line/circle fromcircular) and setsn_bp = len(sequence). - No
control_points,n_bpprovided: uses default shape and generates a random sequence of lengthn_bp. control_pointsprovided,sequenceandn_bpboth omitted: infersn_bpfrom spline sampling, then generates a random sequence of that length.control_points+sequence: scales spline tolen(sequence).control_points+n_bp: scales spline ton_bpand generates a random sequence.sequence+n_bp: both are accepted only when lengths match.
Additional behavior
- For
control_points-only input (sequence=None,n_bp=None),n_bpis inferred from the spline frame count (shape-dependent), not from the default dodecamer.
Validation rules
n_bpmust be positive when provided.control_pointsmust have shape(n, 3)withn >= 4.closedis deprecated and treated as an alias ofcircular.
Example
Generate a DNA structure from a sequence
Source code in mdna/nucleic.py
mdna.nucleic.load(traj=None, frames=None, sequence=None, chainids=[0, 1], circular=None, filename=None, top=None, stride=None)
¶
Load DNA representation from either base step mean reference frames/spline frames or an MDtraj trajectory.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
traj
|
object
|
MDtraj trajectory containing the DNA structure. If provided, the frames and sequence arguments are ignored. (default: None) |
None
|
frames
|
array
|
Base step mean reference frames of shape (n_bp, n_timesteps, 4, 3) or (n_bp, 4, 3). If provided, the traj and sequence arguments are ignored. (default: None) |
None
|
sequence
|
str
|
DNA sequence. If provided, the traj and frames arguments are ignored. (default: None) |
None
|
chainids
|
list
|
Chain IDs of the DNA structure. (default: [0,1]) |
[0, 1]
|
circular
|
bool
|
Flag indicating if the DNA structure is circular/closed. If not provided, it will be determined based on the input data. (default: None) |
None
|
filename
|
str
|
The filename or filenames of the trajectory. If provided, the traj and frames arguments are ignored. (default: None) |
None
|
top
|
str
|
The topology file of the trajectory. (default: None) |
None
|
stride
|
int
|
The stride of the trajectory. (default: None) |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
Nucleic |
object
|
DNA structure object. |
Notes
filenameis resolved first to an MDtraj trajectory (optionally usingtopandstride).- The resulting
trajthen takes precedence overframesandsequencewhen constructingNucleic.
Example
Load a DNA structure from a trajectory
Source code in mdna/nucleic.py
mdna.nucleic.connect(Nucleic0, Nucleic1, sequence=None, n_bp=None, leader=0, frame=-1, margin=1, minimize=True, exvol_rad=0.0, temperature=300, control_points=None, index=0)
¶
Connect two DNA structures by creating a new DNA structure with a connecting DNA strand.
The 3' end of the first DNA structure is connected to the 5' end of the second DNA structure. To connect the two strands, a straight line is interpolated between the two ends, and the optimal number of base pairs is distributed to achieve a neutral twist.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
Nucleic0
|
Nucleic
|
First DNA structure to connect. |
required |
Nucleic1
|
Nucleic
|
Second DNA structure to connect. |
required |
sequence
|
str or List
|
DNA sequence of the connecting DNA strand. Default is None. |
None
|
n_bp
|
int
|
Number of base pairs of the connecting DNA strand. Default is None. |
None
|
leader
|
int
|
The leader of the DNA structure to connect. Default is 0. |
0
|
frame
|
int
|
The time frame to connect. Default is -1. |
-1
|
margin
|
int
|
Number of base pairs to fix at the end. Default is 1. |
1
|
minimize
|
bool
|
Whether to minimize the new DNA structure. Default is True. |
True
|
exvol_rad
|
float
|
Radius for excluded volume interactions during minimization. Default is 0.0. |
0.0
|
temperature
|
int
|
Temperature for minimization. Default is 300. |
300
|
Returns:
| Name | Type | Description |
|---|---|---|
Nucleic |
object
|
DNA structure with the two DNA structures connected. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If either of the DNA structures is circular. |
Notes
- The minimization does not use excluded volume interactions by default.This is because the excluded volume interactions require the EV beads to have no overlap. However, in the initial configuration, the EV beads are likely to have overlap. If desired, the resulting Nucleic object can be further minimized with the excluded volume interactions.
Source code in mdna/nucleic.py
mdna.nucleic.compute_rigid_parameters(traj, chainids=[0, 1], fit_reference=False)
¶
Compute the rigid base parameters of the DNA structure.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
traj
|
object
|
MDtraj trajectory containing the DNA structure. |
required |
chainids
|
list
|
List of chain IDs of the DNA structure. Default is [0, 1]. |
[0, 1]
|
fit_reference
|
bool
|
Fit each base to canonical reference bases before frame extraction. Default is False. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
NucleicFrames |
object
|
Object representing the rigid base parameters of the DNA structure. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the traj argument is not provided. |
Notes
- The returned NucleicFrames object contains information about the rigid base parameters of the DNA structure, such as the positions and orientations of the base steps.
Example
Compute the rigid base parameters of a DNA structure ```python traj = md.load('dna.pdb') rigid_params = mdna.compute_rigid_parameters(traj, chainids=[0, 1]) ````
Source code in mdna/nucleic.py
mdna.nucleic.sequence_to_pdb(sequence='CGCGAATTCGCG', filename='my_dna', save=True, output='GROMACS', shape=None, n_bp=None, circular=False, dLk=None, save_location='./')
¶
Generate a DNA structure from a DNA sequence code.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sequence
|
str
|
The DNA sequence code. Default is 'CGCGAATTCGCG'. |
'CGCGAATTCGCG'
|
filename
|
str
|
The filename for the pdb output. Default is 'my_dna'. |
'my_dna'
|
save
|
bool
|
Whether to save the pdb file. Default is True. |
True
|
output
|
str
|
The type of pdb DNA format. Default is 'GROMACS'. |
'GROMACS'
|
shape
|
ndarray
|
Control points of shape (n,3) with n > 3 that is used for spline interpolation to determine DNA shape. Default is None, which is a straight line. |
None
|
n_bp
|
int
|
Number of base pairs to scale shape with. Default is None, then the sequence is used to determine n_bp. |
None
|
circular
|
bool
|
Indicates if the structure is circular/closed. Default is False. |
False
|
dLk
|
int
|
Change in twist in terms of Linking number of DNA structure to output. Default is None, which corresponds to a neutral twist based on bp_per_turn = 10.5. |
None
|
save_location
|
str
|
Location to save the trajectory. Default is './'. |
'./'
|
Returns:
| Type | Description |
|---|---|
Trajectory
|
md.Trajectory: An MDtraj trajectory object of the DNA structure (containing only a single frame). |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the sequence is not provided. |
Notes
- The pdb file is saved in the current directory with the specified filename.
Example
Generate a DNA structure from a sequence
Source code in mdna/nucleic.py
mdna.nucleic.sequence_to_md(sequence=None, time=10, time_unit='picoseconds', temperature=310, solvated=False, filename='my_dna', save=True, output='GROMACS', shape=None, n_bp=None, circular=False, dLk=None, save_location='./')
¶
Simulate DNA sequence using OpenMM.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sequence
|
str
|
DNA sequence code. |
None
|
time
|
int
|
Simulation time. |
10
|
time_unit
|
str
|
Time unit (picoseconds or nanoseconds). |
'picoseconds'
|
temperature
|
int
|
Temperature in Kelvin. |
310
|
solvated
|
bool
|
Solvate DNA with water and ions. |
False
|
filename
|
str
|
Filename for pdb output. |
'my_dna'
|
save
|
bool
|
Save the trajectory. |
True
|
output
|
str
|
Output format for the trajectory (GROMACS or HDF5). |
'GROMACS'
|
shape
|
str
|
Shape of the DNA structure (linear or circular). |
None
|
n_bp
|
int
|
Number of base pairs in the DNA structure. |
None
|
circular
|
bool
|
Flag indicating if the DNA structure is circular. |
False
|
dLk
|
int
|
Change in linking number of the DNA structure. |
None
|
save_location
|
str
|
Location to save the trajectory. |
'./'
|
Returns:
| Name | Type | Description |
|---|---|---|
MDTraj |
object
|
MDtraj trajectory object of DNA structure. |
Notes
- This function uses the OpenMM library to simulate the behavior of a DNA sequence.
- The simulation can be performed for a specified time period at a given temperature.
- The DNA structure can be solvated with water and ions.
- The trajectory of the simulation can be saved in either GROMACS or HDF5 format.
Example
Simulate a linear DNA structure for 100 picoseconds at 300 K
Source code in mdna/nucleic.py
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 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 | |