OAT utilities documentation
Data structures
Dataclass to hold information about a chunk of a trajectory |
|
Dataclass to hold metadata about a single configuration |
|
Dataclass to hold metadata about a trajectory file |
|
Dataclass/numpy representation for oxDNA configurations |
|
Dataclass to hold metadata about a topology file |
|
Object hierarchy representation of an oxDNA configuration |
|
Object hierarchy representation of an oxDNA strand. |
|
A Dataclass containing information about oxDNA monomers. |
- class oxDNA_analysis_tools.UTILS.data_structures.Chunk(block: str, offset: int, is_last: bool, file_size: int)
Bases:
object
Dataclass to hold information about a chunk of a trajectory
- Parameters:
- class oxDNA_analysis_tools.UTILS.data_structures.ConfInfo(offset: int, size: int, id: int)
Bases:
object
Dataclass to hold metadata about a single configuration
- Parameters:
- class oxDNA_analysis_tools.UTILS.data_structures.TrajInfo(path: str, nconfs: int, idxs: List[ConfInfo], incl_v: bool)
Bases:
object
Dataclass to hold metadata about a trajectory file
- Parameters:
- class oxDNA_analysis_tools.UTILS.data_structures.Configuration(time: int, box: ndarray, energy: ndarray, positions: ndarray, a1s: ndarray, a3s: ndarray)
Bases:
object
Dataclass/numpy representation for oxDNA configurations
- Parameters:
time (int) – The time step of the configuration
box (numpy.ndarray) – The box size for the simulation
energy (numpy.ndarray) – The potential, kinetic and total energy for the configuration
positions (numpy.ndarray) – The positions of the nucleotides
a1s (numpy.ndarray) – the orientations of the base pairing sites
a3s (numpy.ndarray) – the orientations of the stacking sites
- class oxDNA_analysis_tools.UTILS.data_structures.TopInfo(path: str, nbases: int)
Bases:
object
Dataclass to hold metadata about a topology file
- Parameters:
- class oxDNA_analysis_tools.UTILS.data_structures.System(top_file: str = '', strands: List[Strand] = [])
Bases:
object
Object hierarchy representation of an oxDNA configuration
Can be accessed and modified using Python list syntax (implements __getitem__, __setitem__, and __iter__) for accessing Strand objects.
- Parameters:
- class oxDNA_analysis_tools.UTILS.data_structures.Strand(id, *initial_data, **kwargs)
Bases:
object
Object hierarchy representation of an oxDNA strand.
Can be accessed and modified using Python list syntax (implements __getitem__, __setitem__, and __iter__) for accessing Monomer objects.
- Parameters:
- append(monomer: Monomer)
Append a monomer to the strand.
Modifies this strand in-place.
- Parameters:
monomer (Monomer) – The monomer to append
- get_kwdata() Dict[str, str]
Returns all attributes of this object which do not begin with ‘__’
Used for writing out new-style topology files.
- is_old()
Returns whether this Strand came from an old-style topology file.
- set_old(from_old)
Sets the _from_old attribute read by is_old.
- class oxDNA_analysis_tools.UTILS.data_structures.Monomer(id: int, btype: str, strand: Strand | None = None, n3: int | None = None, n5: int | None = None, pair: int | None = None, pos: ndarray | None = None, a1: ndarray | None = None, a3: ndarray | None = None)
Bases:
object
A Dataclass containing information about oxDNA monomers.
Geometry utilities
Returns the axis of a RNA duplex |
|
Returns the axis of a DNA duplex |
- oxDNA_analysis_tools.UTILS.geom.fit_plane(points)
- oxDNA_analysis_tools.UTILS.geom.get_RNA_axis(particles, d)
Returns the axis of a RNA duplex
- Parameters:
particles (oxpy.config_info) – The positions/orientations of the particles
d (duplex_list) – A duplex_list object with members “start1”, “end1”, “end2”, “start2” containing integer values of the corresponding particle IDs.
- oxDNA_analysis_tools.UTILS.geom.get_DNA_axis(particles, d)
Returns the axis of a DNA duplex
- Parameters:
particles (oxpy.config_info) – The positions/orientations of the particles
d (duplex_list) – A duplex_list object with members “start1”, “end1”, “end2”, “start2” containing integer values of the corresponding particle IDs.
iPython oxView plugin
Generate an iframe displaying the provided files in oxview |
|
Display oxview frame based on the string path provided |
|
Display an oxDNA configuration in oxview |
|
Display a loro patchy configuration in oxview |
|
Display a flro patchy configuration in oxview |
- oxDNA_analysis_tools.UTILS.oxview.display_files(system_list, inbox_settings=['Monomer', 'Origin'], oxview_src='https://sulcgroup.github.io/oxdna-viewer/')
Generate an iframe displaying the provided files in oxview
- oxDNA_analysis_tools.UTILS.oxview.from_path(*args: List[str] | List[List[str]], **kwargs)
Display oxview frame based on the string path provided
- Parameters:
args (Union[List[str],List[List[str]]]) – contains the paths to the files or a list of lists of paths
kwargs (dict) – the properties to oxview defaults to = {“inbox_settings”:[“Monomer”, “Origin”], “oxview_src” : “https://sulcgroup.github.io/oxdna-viewer/”}
- Usage:
from_path(“conf.top”, “conf.dat”,**{“inbox_settings”:[“Monomer”, “Origin”]})
- oxDNA_analysis_tools.UTILS.oxview.oxdna_conf(top: TopInfo, conf: Configuration, overlay=None, forces_path=None, par_file_path=None, script_file_path=None, inbox_settings=['Monomer', 'Origin'], oxview_src='https://sulcgroup.github.io/oxdna-viewer/')
Display an oxDNA configuration in oxview
- Parameters:
top (TopInfo) – the top file data
conf (Configuration) – the configuration data
overlay (str) – (optional) the path to the overlay file
forces_path (str) – (optional) the path to the forces file
par_file_path (str) – (optional) the path to the par file
script_file_path (str) – (optional) the path to the script file (js)
inbox_settings (list[str]) – (optional) a list of strings, the inbox settings to use
oxview_src (str) – (optional) the url of the oxview source
- oxDNA_analysis_tools.UTILS.oxview.loro_patchy_conf(top_path: str, conf: Configuration, matrix_path: str, inbox_settings=['Monomer', 'Origin'], oxview_src='https://sulcgroup.github.io/oxdna-viewer/')
Display a loro patchy configuration in oxview
- oxDNA_analysis_tools.UTILS.oxview.flro_patchy_conf(top_path: str, conf: Configuration, particles_path: str, inbox_settings=['Monomer', 'Origin'], oxview_src='https://sulcgroup.github.io/oxdna-viewer/')
Display a flro patchy configuration in oxview
Multiprocesser
|
Runs a function on a trajectory by distributing chunks of the trajectory to each processor. |
- oxDNA_analysis_tools.UTILS.oat_multiprocesser.oat_multiprocesser(nconfs: int, ncpus: int, function: Callable, callback: Callable, ctx: NamedTuple)
Runs a function on a trajectory by distributing chunks of the trajectory to each processor. Accumulates the results with a callback function.
- Parameters:
nconfs (int) – The total number of configurations to process
ncpus (int) – The number of processors to use
function (function) – The function to run on each chunk
callback (function) – The function to call after each chunk is processed
ctx (NamedTuple) – A NamedTuple containing the arguments for the function
The callback function must use the nonlocal keyword to update a variable in the main thread.
Rye reader
Generator that yields chunks of a fixed number of bytes |
|
Read a trajecory without multiprocessing. |
|
Read a chunk of configurations from a trajectory file. |
|
Get data from topology file header |
|
Retrieve top and traj info without providing a topology. |
|
Get the information of a trajectory file |
|
retrieve top and traj info for a provided pair |
|
Retrieve all information from a topology file and return a System object which maps nucleotides to strands. |
|
Gets the value of a parameter in an oxDNA input file |
|
Modify the positions attribute such that all positions are inside the box. |
|
write the conf to a file |
|
Write configuration as a string |
|
Write topology file from system object. |
- oxDNA_analysis_tools.UTILS.RyeReader.Chunker(file, fsize, size=1000000) Iterator[Chunk]
Generator that yields chunks of a fixed number of bytes
- oxDNA_analysis_tools.UTILS.RyeReader.linear_read(traj_info: TrajInfo, top_info: TopInfo, chunk_size: int = -1) Iterator[List[Configuration]]
Read a trajecory without multiprocessing.
Produces an iterator that yields a list of <chunk_size> configurations.
- Parameters:
- Returns:
An iterator object which yields lists of <chunk_size> configurations.
- Return type:
iterator[Configuration]
- oxDNA_analysis_tools.UTILS.RyeReader.get_confs(top_info: TopInfo, traj_info: TrajInfo, start_conf: int, n_confs: int) List[Configuration]
Read a chunk of configurations from a trajectory file.
- Parameters:
- Returns:
A list of n_confs configurations starting from <start_conf>
- Return type:
List[Configuration]
- oxDNA_analysis_tools.UTILS.RyeReader.get_top_info(top: str) TopInfo
Get data from topology file header
- oxDNA_analysis_tools.UTILS.RyeReader.get_top_info_from_traj(traj: str) TopInfo
Retrieve top and traj info without providing a topology.
Note its not implemented, but if it were, this would not return the number of strands.
- oxDNA_analysis_tools.UTILS.RyeReader.get_traj_info(traj: str) TrajInfo
Get the information of a trajectory file
- oxDNA_analysis_tools.UTILS.RyeReader.describe(top: str | None, traj: str) Tuple[TopInfo, TrajInfo]
retrieve top and traj info for a provided pair
You can provide None as the topology and it will read the first conf of the traj to get the number of particles. The TopInfo will be missing the path parameter if no topology is provided.
- oxDNA_analysis_tools.UTILS.RyeReader.strand_describe(top: str) Tuple[System, list]
Retrieve all information from a topology file and return a System object which maps nucleotides to strands.
This is returned as two objects so that monomers can be indexed either via strand or via global index. This function will automatically detect whether the input topology file is new or old format.
- oxDNA_analysis_tools.UTILS.RyeReader.get_input_parameter(input_file, parameter) str
Gets the value of a parameter in an oxDNA input file
- oxDNA_analysis_tools.UTILS.RyeReader.inbox(conf: Configuration, center: bool = True, centerpoint: str | ndarray = 'bc') Configuration
Modify the positions attribute such that all positions are inside the box.
For cohesive structures, you almost always want center=True. For diffuse simulations, you probably want center=False.
- Parameters:
conf (Configuration) – The configuration to inbox
center (bool) – If True, center the configuration in the box (default True)
centerpoint (str|np.ndarray) – If ‘bc’, center in the box, if array, center on the array (default ‘bc’)
- Returns:
The inboxed configuration
- Return type:
- oxDNA_analysis_tools.UTILS.RyeReader.write_conf(path: str, conf: Configuration, append: bool = False, include_vel: bool = True) None
write the conf to a file
- Parameters:
path (str) – path to the file
conf (Configuration) – the configuration to write
append (bool) – if True, append to the file, if False, overwrite
include_vel (bool) – Include velocities in the output trajectory? Defaults to True.
- oxDNA_analysis_tools.UTILS.RyeReader.conf_to_str(conf: Configuration, include_vel: bool = True) str
Write configuration as a string
- Parameters:
conf (Configuration) – The configuration to write
include_vel (bool) – Include velocities in the output string? Defaults to True.
- Returns:
The configuration as a string
- Return type:
(str)