DNA Models

FractalDNA provides a number of models for building DNA.

Example notebooks are available under Examples.

Base and Helper Classes

class fractaldna.dna_models.dnachain.PlottableSequence

This is an inheritable class that gives DNA chains plotting methods and output methods.

to_frame(suppress_hash=False)

Return the molecules as a pandas data frame

Parameters:

suppress_hash (bool) – Hide the hash in front of the ‘name’ column which is kept for compatibiilty with the Geant4 DNA simulation format

Return type:

DataFrame

Returns:

Pandas data frame with molecule information

to_line_plot(size=(400, 350))

Return a mayavi figure instance with histone and linkers shown

Parameters:

size (Tuple[int, int]) – Figure size (width, height)

Returns:

mayavi figure

Raises:

ImportError – MayaVi likely Not installed

to_plot(plot_p=True, plot_b=True, plot_s=True)

Return a matplotlib.Figure instance with molecules plotted

Parameters:
  • plot_p (bool) – Show Phosphates in plot

  • plot_b (bool) – Show Bases in plot

  • plot_s (bool) – Show sugars in plot

Return type:

Figure

Returns:

Matplotlib Figure

to_strand_plot(plot_p=True, plot_b=True, plot_s=True, plot_bp=False)

Return a mayavi figure instance with strands plotted

:param plot_p : plot phosphate strands :param plot_s : plot sugar strands :param plot_b : plot base strands :param plot_bp : join base pairs together

Returns:

Mayavi Figure

Raises:

ImportError – MayaVi not imported

to_surface_plot()

Plot the surfaces of each molecule in the chain. Avoid this with large chains, this assumes each molecule is an ellipse

Return type:

Figure

Returns:

Matplotlib figure (contour plot)

to_text(seperator=' ')

Return a description of the molecules in the chain as text

Parameters:

seperator (str) – column seperator

Return type:

str

class fractaldna.dna_models.dnachain.Histone(position, rotation, genome=None, chain=0, histone_index=0)

Inherits from PlottableSequence

This class defines a histone.

Parameters:
  • position (Union[List, array]) – 3-vector for histone position

  • rotation (Union[List, array]) – 3-vector for histone rotation (euler angles)

  • genome (Optional[str]) – string defining the genome for the histone

  • chain (int) – Chain index for histone and basepairs therein

  • histone_index (int) – An index for the histone (by default, order in the solenoid)

as_series()

Express the histone as a single molecule in a pandas series

Return type:

Series

Returns:

Pandas Series for Histone

setChain(chainIdx)

Set the Chain Index of all base pairs in the histone

Parameters:

chainIdx (int) – Index for Chain

Return type:

None

translate(translation)

Translate the histone spatially

Parameters:

translation (Union[List, array]) – 3-vector for translation

Return type:

None

class fractaldna.dna_models.dnachain.SplineLinker(bp1, bp2, bp3, bp4, curviness=1.0, zrot=None, startkey=None, stopkey=None, method='corrected_quaternion', chain=0)

Inherits from PlottableSequence

Link two histones together via a cubic spline

linker = SplineLinker(bp1, bp2, bp3, bp4, curviness=1., zrot=None)

Create base pairs that link to sections of DNA as follows: bp1 bp2 <==== LINKER =====> bp3 bp4 Two base pairs on either side of the linker are needed to build splines low curviness = straighter high_curviness = smoother

startkey and stopkey act as keyframes for rotations

Parameters:
  • zrot (Optional[float]) –

    Describes the twist of bp3 relative to bp2
    • None: Determine automatically (experimental)

    • double: rotation in radians (mod 2*pi)

  • startkey (Optional[int]) –

    Starting keyframe for rotations
    • key = i will start/stop rotations after the i-th base pair

    • key = -i will start/stop rotations after the i-th last base pair

  • stopkey (Optional[int]) –

    Ending keyframe for rotations
    • key = i will start/stop rotations after the i-th base pair

    • key = -i will start/stop rotations after the i-th last base pair

  • method (str) –

    Method to handle rotational interpolation
    • ”quaternion”: Full use of quaternions

    • ”corrected_quaternion”: Full use of quaternions, with a correction to check that the base pair is aligned. This method is recommended

    • ”matrix”: Experimental method that doesn’t use quaternions. Currently incorrect.

  • chain (int) – Chain index assigned to linker and basepairs created therein

setChain(chainIdx)

Set the Chain Index of all base pairs in the histone

Parameters:

chainIdx – Index for Chain

translate(translation)

Translate the histone spatially

Parameters:

translation – 3-vector for translation

Unpacked DNA

Single Strand

class fractaldna.dna_models.dnachain.DNAChain(genome, chain=0)

Inherits from PlottableSequence A single DNA Chain built from a genome specified.

Parameters:
  • genome (str) – A string specifying the genome, e.g. ‘AGTATC’

  • chain (int) – The Chain index to label this strand

center_in_z()

Center the molecule around the z=0 plane

class fractaldna.dna_models.dnachain.TurnedDNAChain(genome)

Inherits from DNAChain

TurnedDNAChain(genome) Construct a single turned, twisted DNA chaiun

Parameters:

genome – string of GATC specifying genome order

class fractaldna.dna_models.dnachain.TurnedTwistedDNAChain(genome)

Inherits from DNAChain

TurnedTwistedDNAChain(genome) Construct a single turned, twisted DNA chaiun

Parameters:

genome – string of GATC specifying genome order

Two Strands per Volume

class fractaldna.dna_models.dnachain.DoubleDNAChain(genome, separation)

Inherits from DNAChain

DoubleDNAChain(genome, separation) Construct four straight DNA chains Chain indices are assigned anticlockwise starting from the +y strand.

Parameters:
  • genome – string of GATC specifying genome order

  • separation – separation of each strand from the center in angstroms

class fractaldna.dna_models.dnachain.TurnedDoubleDNAChain(genome, separation)
class fractaldna.dna_models.dnachain.TurnedTwistedDoubleDNAChain(genome, separation)

Four Strands per Volume

class fractaldna.dna_models.dnachain.FourStrandDNAChain(genome, separation)

Inherits from DNAChain

FourStrandDNAChain(genome, separation) Construct four straight DNA chains Chain indices are assigned anticlockwise starting from the +y strand.

Parameters:
  • genome (str) – string of GATC specifying genome order

  • separation (float) – separation of each strand from the center in angstroms

class fractaldna.dna_models.dnachain.FourStrandTurnedDNAChain(genome, separation, twist=False)

Inherits from DNAChain

FourStrandTurnedDNAChain(genome, separation) Construct four DNA chains that turn 90 degrees. Chain indices are assigned anticlockwise starting from the +y strand.

Parameters:
  • genome (str) – string of GATC specifying genome order

  • separation (float) – separation of each strand from the center in angstroms

  • twist (bool) – boolean, add a 90 deg twist to each chain

Eight Strands per Volume

class fractaldna.dna_models.dnachain.EightStrandDNAChain(genome, sep1, sep2, turn=False, twist=False)

Construct eight DNA chains that can turn 90 degrees if turn=True

Chain indices are assigned anticlockwise starting from the +y strand, first to the inner four strands, then two the outer four strands. i.e.:

____________________
|                  |
|        4         |
|        0         |
|  5  1     3  7   |
|        2         |
|        6         |
|__________________|

Strands 1 and 3, 0 and 2 are separated by sep1 Strands 4 and 6, 5 and 7 are separated by sep2

Parameters:
  • genome (str) – string of GATC specifying genome order

  • sep1 (float) – separation of inner strands from the center in angstroms

  • sep2 (float) – separation of outer strands from the center in angstroms

  • turn (bool) – boolean, turn strands 90 degrees along box

  • twist (bool) – boolean, add a 90 deg twist to each chain

Solenoid-Packed DNA

class fractaldna.dna_models.dnachain.Solenoid(voxelheight=750, radius=100, nhistones=38, histone_angle=50, twist=False, chain=0)

Inherits from PlottableSequence

Define Solenoidal DNA in a voxel (basically a box).

This method works by placing histones around the z-axis (≈6 histones per rotation) and then joining them together using SplineLinkers

Parameters:
  • voxelheight (float) – Height of ‘voxel’ in angstrom

  • radius (float) – Radius from Solenoid centre to histone centre

  • nhistones (int) – Number of histones to place

  • histone_angle (float) – tilt of histones from axis in degrees

  • twist (bool) – whether the DNA exiting the final spine should be rotated an extra pi/2.

  • chain (int) – Chain index for solenoid and basepairs therein

histones_to_frame()

Get Histones in Solenoid as a dataframe of their positions

Return type:

DataFrame

Returns:

DataFrame of Histones

setChain(chainIdx)

Set the Chain Index of all base pairs in the solenoid

Parameters:

chainIdx (int) – Index for Chain

Return type:

None

translate(translation)

Translate the solenoid spatially

Parameters:

translation (Union[List, array]) – 3-vector for translation

Return type:

None

class fractaldna.dna_models.dnachain.TurnedSolenoid(voxelheight=750, radius=100, nhistones=38, histone_angle=50, twist=False, chain=0)

Inherits from Solenoid

Define Solenoidal DNA in a voxel (basically a box). This Solenoid will turn 90 degrees through the box

This method works by placing histones around the z-axis (≈6 histones per rotation) and then joining them together using SplineLinkers

Parameters:
  • voxelheight (float) – Height of ‘voxel’ in angstrom

  • radius (float) – Radius from Solenoid centre to histone centre

  • nhistones (int) – Number of histones to place

  • histone_angle (float) – tilt of histones from axis in degrees

  • twist (bool) – whether the DNA exiting the final spine should be rotated an extra pi/2.

  • chain (int) – Chain index for solenoid and basepairs therein

class fractaldna.dna_models.dnachain.MultiSolenoidVolume(voxelheight=1500.0, separation=400, twist=False, turn=False, chains=[0, 1, 2, 3, 4, 5, 6, 7, 8], nhistones=None, radius=100, histone_angle=50)

Class to build placement volumes that contain multiple solenoidal DNA strands.

Constructor:

MultiSolenoidVolume(voxelheight=1500., separation=400, twist=False,

turn=False)

voxelheight: size of placement volume separation: separation between DNA strands

The class can contain up to 9 strands with indices as follows

0: central strand 1: x = separation, y = 0 2: x = 0, y = separation 3: x = -separation, y = 0 4: x = separation, y = separation 5: x = separation, y = separation 6: x = -separation, y = separation 7: x = -separation, y = -separation 8: x = separation, y = -seperation

Try: dna = MultiSolenoidVolume() dna.to_line_plot() dna.to_text()

Parameters:
  • voxelheight (float) – Height of ‘voxel’ in angstrom

  • separation (float) – separation between DNA strands

  • twist (bool) – whether the DNA exiting the final spine should be rotated an extra pi/2.

  • turn (bool) – make a turned volume (turn strand 90°)

  • chains (List) – List of chains to plot, e.g. [0, 1, 2, 3, 4] for a central strand (0) and 4 strands along the X/Y axes.

  • radius (float) – Radius from Solenoid centre to histone centre

  • nhistones (Optional[int]) – Number of histones to place (if None, will default) to int(38 * voxelheight / 750.0)

  • histone_angle (float) – tilt of histones from axis in degrees

histones_to_frame()

Get Histones in Solenoid as a dataframe of their positions

Return type:

DataFrame

Returns:

DataFrame of Histones

to_frame()

Return the molecules as a pandas data frame

Return type:

DataFrame

Returns:

Pandas data frame with molecule information

translate(translation)

Translate the solenoid spatially

Parameters:

translation (Union[List, array]) – 3-vector for translation

Return type:

None