Skip to content

Core

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
  • filename is resolved first to an MDtraj trajectory (optionally using top and stride).
  • The resulting traj then takes precedence over frames and sequence when constructing Nucleic.
Example

Load a DNA structure from a trajectory

traj = md.load('dna.pdb')
dna = mdna.load(traj=traj, chainids=[0, 1])

Source code in mdna/nucleic.py
def 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.

    Args:
        traj (object, optional): MDtraj trajectory containing the DNA structure. If provided, the frames and sequence arguments are ignored. (default: None)
        frames (np.array, optional): 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)
        sequence (str, optional): DNA sequence. If provided, the traj and frames arguments are ignored. (default: None)
        chainids (list, optional): Chain IDs of the DNA structure. (default: [0,1])
        circular (bool, optional): Flag indicating if the DNA structure is circular/closed. If not provided, it will be determined based on the input data. (default: None)
        filename (str, optional): The filename or filenames of the trajectory. If provided, the traj and frames arguments are ignored. (default: None)
        top (str, optional): The topology file of the trajectory. (default: None)
        stride (int, optional): The stride of the trajectory. (default: None)

    Returns:
        Nucleic (object): DNA structure object.

    Notes:
        - `filename` is resolved first to an MDtraj trajectory (optionally using `top` and `stride`).
        - The resulting `traj` then takes precedence over `frames` and `sequence` when constructing `Nucleic`.

    Example:
        Load a DNA structure from a trajectory
        ```python
        traj = md.load('dna.pdb')
        dna = mdna.load(traj=traj, chainids=[0, 1])
        ```
    """
    # Load the trajectory directly using MDtraj from a file
    if filename is not None and top is None:
        traj = md.load(filename_or_filenames=filename, stride=stride)
    elif filename is not None and top is not None:
        traj = md.load(filename_or_filenames=filename, top=top, stride=stride)

    return Nucleic(sequence=sequence, n_bp=None, traj=traj, frames=frames, chainids=chainids, circular=None)