Welcome to drawNA’s documentation!¶
drawNA¶
drawNA.polygons¶
-
class
drawNA.polygons.
BoundaryPolygon
(vertices: numpy.ndarray)[source]¶ A BoundaryPolygon is a cyclic combination of 3 or more edges, which result in a closed Polygon
The first vertex on the starting edge = the last vertex on the final edge
-
property
edges
¶ Iterate over all vertices and return a list of Edge instances
-
property
-
class
drawNA.polygons.
Edge
(vertex_1: list, vertex_2: list, edge_kind: int = 0)[source]¶ An Edge is a combination of two vertices and stores geometric information about this connection
drawNA.readers¶
-
class
drawNA.readers.
LAMMPSDumpReader
(fnames: List[str])[source]¶ LAMMPS DumpFile reader designed specifically for LAMMPS simulations that have used the oxDNA or oxDNA2 forcefields, and have data/dump files configured as per the literature (i.e. not customised)
LAMMPSDumpReader subclasses LAMMPSDataReader and is also a subclass of Reader, which LAMMPSDataReader also subclasses. This architecture is slightly confusing but results in very concise code for this class
The reason for subclassing LAMMPSDataReader is because the configuration data file is needed to generate the bonds, which cannot be stored in a dump file.
-
drawNA.readers.
quat_to_matrix
(row: pandas.core.series.Series) → numpy.ndarray[source]¶ - Converts a pd.Series which has entries:
[[‘qw’, ‘qi’, ‘qj’, ‘qk’]]
from a quaternion to a matrix rotation and returns it as a np.ndarray.
drawNA.tools¶
-
class
drawNA.tools.
DNAEdge
(vertex_1: numpy.ndarray, vertex_2: numpy.ndarray, theta: float = 0.0)[source]¶ Abstract class that allows subclasses to generate oxDNA Strand instances along a vector.
-
property
length
¶ The length of the edge in oxdna units (i think)
-
node
(node_3p: drawNA.tools.DNANode = None, node_5p: drawNA.tools.DNANode = None) → drawNA.tools.DNANode[source]¶ Returns a DNANode for the opposite end of the DNANode provided in parameters
-
property
nt_length
¶ The length of the edge in units of nucleotides
-
property
perp_vector
¶ Perpendicular vector which lies in the xy plane
-
segments
() → float[source]¶ There are 2.5 segments in every unit of oxDNA distance.
Each segment represents a Nucleotide
-
property
summary
¶ Extended equivalent of self.__repr__
-
property
-
class
drawNA.tools.
DNANode
(*args, **kwargs)[source]¶ Abstract class for use with DNAEdge that helps to determine angles and vectors needed to generate stable structures.
-
property
angle
¶ Returns the angle between the two vectors leaving the Node in radians
-
property
vector_3p
¶ Vector entering/leaving the node from the 3’ direction
vector_3p and vector_5p follow on from each other which means that they cannot start/finish at the same point
-
property
vector_5p
¶ Vector leaving/entering the node from the 5’ direction
vector_3p and vector_5p follow on from each other which means that they cannot start/finish at the same point
-
property
drawNA.oxdna¶
drawNA.oxdna.nucleotide¶
Management and Storage of oxDNA nucleotides
-
class
drawNA.oxdna.nucleotide.
Nucleotide
(base: str, pos_com: numpy.ndarray, a1: numpy.ndarray, a3: numpy.ndarray, v: numpy.ndarray = array([0.0, 0.0, 0.0]), L: numpy.ndarray = array([0.0, 0.0, 0.0]))[source]¶ A Nucleotide is a single oxDNA particle that forms a DNA strand Can be added to a strand using StrandObject.add_nucleotide
- Parameters
- 'A' (base) –
'T' –
or 'G' ('C') –
- Center of mass position vector (pos_com) –
- Unit vector indicating orientation of backbone with respect to base (a1) –
- Unit vector indicating orientation (a3) –
- Linear velocity vector (v) –
- Angular velocity vector (L) –
- Attributes/Properties:
_base - ‘A’, ‘T’, ‘C’ or ‘G’ _a1 - Unit vector indicating orientation of backbone with respect to base _a3 - Unit vector indicating orientation (tilting) of base with respect to backbone _v - Linear velocity vector _L - Angular velocity vector pos_com - centre of mass pos_back - backbone position pos_base - position of base pos_stack - stacking direction series - table entry for writing conf and top files
-
property
lammps
¶ Returns a list of Series containing the following information needed to write a LAMMPS configuration data file
-
make_5p
(base: str, angle: float = 0.626, rise: float = 0.39) → drawNA.oxdna.nucleotide.Nucleotide[source]¶ Returns a new Nucleotide in the 5’ direction. The angle used for rotating the a1 vector can be specified in radians.
Args:
- base
standard string base
- angle (0.626)
angle of a1 rotation around a3 axis in radians
- rise (0.390)
difference in a3 direction between nucleotides
Returns:
A new Nucleotide generated to be in the preferred orientation in the 5’ direction
-
make_across
() → drawNA.oxdna.nucleotide.Nucleotide[source]¶ Returns:
A Nucleotide across (aka complementary)
-
property
pos_back
¶ Returns the position of the backbone site
-
property
pos_back_rel
¶ Returns the position of the backbone centroid relative to the centre of mass i.e. it will be a vector pointing from the c.o.m. to the backbone
-
property
pos_base
¶ Returns the position of the base site
-
property
pos_stack
¶ Returns the position the stacking site
-
property
quaternion
¶ Returns the quaternion used to create a LAMMPS configuration
Taken from https://github.com/lorenzo-rovigatti/tacoxDNA/src/libs/oxDNA_LAMMPS.py
-
property
series
¶ Writes a pd.Series object containing the information needed for writing a row in pd.DataFrame that will be used for writing to file.
drawNA.oxdna.strand¶
Storage and Management of oxDNA strands via the Strand class
-
class
drawNA.oxdna.strand.
Strand
(nucleotides: list = None)[source]¶ Collection of nucleotides in the 3’ -> 5’ direction Can be added to the system using SystemObject.add_strand
- Parameters
nucleotides ([]) –
- Attributes/Properties:
index - strand_id sequence - string sequence of bases nucleotides - list of Nucleotides dataframe - table of values for top and conf files copy - get a copy of a Strand instance
-
property
bonds
¶ Returns a dataframe containing the information needed to write the bonds section of a LAMMPS configuration data file
-
property
dataframe
¶ Returns a pd.Dataframe which can be used to write the information for both the configuration and topology files.
-
property
lammps
¶ Returns a list of DataFrames containing the following information needed to write a LAMMPS configuration data file
-
property
nucleotides
¶ Returns the list of nucleotides, and allocates the strand index to each nucleotide for its Nucleotide.series property.
drawNA.oxdna.system¶
oxDNA system class - contains tools to manage, read and write oxDNA simulation configurations.
-
class
drawNA.oxdna.system.
System
(box: numpy.ndarray, time: int = 0, E_pot: float = 0.0, E_kin: float = 0.0)[source]¶ oxDNA simulation system, a container for strands which are composed of nucleotides.
- Parameters
- the box size of the system (box) –
- Time of the system (time) –
- Potential energy (E_pot) –
- Kinetic energy (E_kin) –
-
add_strand
(addition: drawNA.oxdna.strand.Strand, index: int = None)[source]¶ Method to add strand(s) to the system
- Parameters
- accepted as Strand objects or a List of Strands (addition) –
index (default = None) –
Strand inserted at location given (otherwise) –
-
add_strands
(strand_obj: list = None, index: int = None)[source]¶ Add multiple strands to the system. Use a list of strands with an index indicating where they start, or a dictionary where the key is an integer and the value is a strand.
strand_lists are added in reverse order to preserve original list order
strand_dicts are added in normal order to preserve dictionary keys
- Parameters
strand_obj (-) – list or dict of strands
index (-) – index to start adding list
-
property
bonds
¶ Returns the total number of bonds in the system, used for writing LAMMPS configuration data files.
-
property
lammps
¶ Returns a DataFrame containing the information needed to write a LAMMPS configuration data file
-
drawNA.oxdna.system.
lammps_string
(dataframe: pandas.core.frame.DataFrame) → str[source]¶ Formats the dataframes needed for writing the lammps dataframe to the appropriate file format.
-
drawNA.oxdna.system.
oxDNA_string
(dataframe: pandas.core.frame.DataFrame) → str[source]¶ Formats the dataframes needed for writing the topology and configuration dataframes to the appropriate file format
drawNA.oxdna.utils¶
-
drawNA.oxdna.utils.
get_rotation_matrix
(axis: numpy.ndarray, theta: float) → numpy.ndarray[source]¶ Returns a rotation matrix for rotating an angle theta (rad) around an axis vector
-
drawNA.oxdna.utils.
next_5p
(position: numpy.ndarray, a1: numpy.ndarray, a3: numpy.ndarray, angle: float, rise: float)[source]¶ Returns the pos_com for a new nucleotide in the 5’ direction
-
drawNA.oxdna.utils.
round_to_multiple
(n, mo=0.34, decimal_places=2)[source]¶ Function rounds to the nearest multiple of value given Returns output to (default) 2 decimal places
- Parameters
--- value (n) –
--- "multiple_of" is the value (mo) –
want to round to a multiple of (we) –
--- no. of decimals to return (decimal_places) –
drawNA.lattice¶
drawNA.lattice._lattice¶
-
drawNA.lattice._lattice.
modify_lattice_row
(grid: numpy.ndarray, difference: numpy.ndarray, change_side: str = 'yes')[source]¶ Modifies the lattice sites for a given row in the grid by adding or removing the number of sites equal to the value which is stored in difference for that row
- Parameters
--- (change_side) –
--- –
--- –
can be given (arguments) –
adjustments will only be made (where) –
the prescribed side (on) –
e.g. a difference of -5 or +11, remove (1 -> 0) or add (0 -> 1) to the lattice row, respectively. Each removal/addition occurs on the opposite side of the lattice than the previous removal/addition
-
drawNA.lattice._lattice.
side
(row_no: int, R: bool = None)[source]¶ Returns either ‘onlyleft’ or ‘onlyright’ depending on which row we are modifying, i.e. row0 will always be modified at its end so if R = True, then right is the end of row0, row1 will always be modified at the opposite side to row0
drawNA.lattice.edge¶
drawNA.lattice.node¶
drawNA.lattice.route¶
-
class
drawNA.lattice.route.
LatticeRoute
(nodes: List[drawNA.lattice.node.LatticeNode] = [])[source]¶ Strand which follows the path defined by a set of LatticeNodes which are joined by LatticeEdges
-
add_node
(addition: drawNA.lattice.node.LatticeNode, index: int = None, update: bool = False)[source]¶ Method to add strand(s) to the system
- Parameters
- accepted as Strand objects or a List of Strands (addition) –
index (default = None) –
Strand inserted at location given (otherwise) –
-
add_nodes
(node_obj: list = None, index: int = None)[source]¶ Add multiple strands to the system. Use a list of strands with an index indicating where they start, or a dictionary where the key is an integer and the value is a strand.
strand_lists are added in reverse order to preserve original list order
strand_dicts are added in normal order to preserve dictionary keys
- Parameters
node_obj (-) – list or dict of strands
index (-) – index to start adding list
-
drawNA.lattice.utils¶
-
drawNA.lattice.utils.
find_closest
(myList, myNumber)[source]¶ Credit: https://stackoverflow.com/questions/12141150 Assumes myList is sorted. Returns closest value to myNumber.
If two numbers are equally close, return the smallest number.
-
drawNA.lattice.utils.
find_crossover_locations
(max_size: int = 30, bp_per_turn: float = 10.45, kind: str = 'half', origin: int = 0) → dict[source]¶ Function which returns an array containing the best locations for half or whole turns of the DNA strand where the strand will stay in plane and have the least strain/stress build-up.
This is computed given the number of basepairs per turn & locations are given in no. of base pairs
Arguments: bp_per_turn - (default: 10.45) kind - either half turns or whole turns max_size - max no. of turns to base pairs to the list origin - what number crossovers start at, either 0 (python indexing) or 1