base¶
Utility functions for oxDNA systems, strands and nucleotides.
base.py includes the classes: System, Strand, Nucleotide
-
class
base.Nucleotide(cm_pos, a1, a3, base, btype=None, L=<mynumpy.mynumpy_core.array object>, v=<mynumpy.mynumpy_core.array object>, n3=-1)¶ Nucleotides compose Strands.
Parameters: - cm_pos – Center of mass position, e.g. [0, 0, 0]
- a1 – Unit vector indicating orientation of backbone with respect to base, e.g. [1, 0, 0]
- a3 – Unit vector indicating orientation (tilting) of base with respect to backbone, e.g. [0, 0, 1]
- base –
Identity of base, which must be designated with either numbers or letters (this is called type in the c++ code). Confusingly enough, this is similar to Particle.btype in oxDNA.
Number: {0,1,2,3} or any number in between (-inf,-7) and (10, inf). To use specific sequences (or an alphabet large than four) one should start from the complementary pair 10 and -7. Complementary pairs are such that base_1 + base_2 = 3
Letter: {A,G,T,C} (these will be translated to {0, 1, 3, 2}). These are set in the dictionaries: number_to_base, base_to_number
- btype – Identity of base. Unused at the moment.
- L – Angular velocity
- v – Velocity
-
cm_pos¶ Position of the center of mass.
-
index¶ Index of the nucleotide.
-
pos_back¶ Position of the backbone centroid.
-
pos_base¶ Position of the base centroid.
-
pos_stack¶ Position of the stacking site centroid.
-
copy(disp=None, rot=None)¶ Returns a copy of the nucleotide, with optional translation and/or rotation.
Parameters: - disp – displacement vector to translate the copied nucleotide
- rot – rotation matrix to rotate the copied nucleotide
-
distance(other, PBC=True, box=None)¶ Returns the distance to another nucleotide.
Parameters: - other – the other Nucleotide object
- PBC – boolean. If true, considers periodic boundary conditions and returns the minimum image distance.
- box – box dimensions in a numpy array
-
get_base()¶ Returns the base id. If the base is in [“A”, “G”, “C”, “T”, 0, 1, 2, 3], returns a string containing the letter of the base id. Otherwise, returns a string containing the number of the base id.
-
get_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.
-
rotate(R, origin=None)¶ Rotates the nucleotide.
Parameters: - R – rotation matrix to rotate the nucleotide
- origin – the point around which the nucleotide rotates; defaults to be self.cm_pos
-
translate(disp)¶ Translates the nucleotide.
Parameters: disp – displacement vector to translate the nucleotide
-
class
base.Strand¶ Strands are composed of Nucleotides. Access nucleotide objects of Strand strand1 by strand1._nucleotides[nucleotide_index]. Strands can be contained in a System.
-
N¶ Length of the strand (i.e. the number of nucleotides).
-
sequence¶ Sequence of the strand.
-
cm_pos¶ Center of mass of the strand.
-
index¶ Index of the strand.
-
add_nucleotide(n)¶ Adds a nucleotide to the strand.
Parameters: n – Nucleotide object to be added.
-
append(other)¶ Returns an extended strand which is formed by appending another strand to the current strand. Note that the current strand is not changed.
Parameters: other – the other Strand object
-
bring_in_box_nucleotides(box)¶ Brings nucleotides of the strand back into the box.
Parameters: box – box dimensions in a numpy array
-
copy()¶ Returns a copy of the strand.
-
get_slice(start=0, end=None)¶ Returns a slice of the strand.
Parameters: - start – starting point of the slice (default is 0)
- end – ending point of the slice (default is end of strand)
-
make_circular(check_join_len=False)¶ Connect the ends of the strand to make it circular.
Parameters: check_join_len – boolean. If true, checks whether the ends of the strand are close enough.
-
make_noncircular()¶ Disconnect the ends of a circular strand.
-
overlaps_with(other, box)¶ Returns True if this strand overlaps with the other strand, False otherwise.
Parameters: - other – the other Strand object
- box – box dimensions in a numpy array
-
rotate(R, origin=None)¶ Rotates the strand.
Parameters: - R – rotation matrix to rotate the system
- origin – the point around which the strand rotates; defaults to be self.cm_pos (NB this does not exist at the moment, perhaps a bug)
-
set_cm_pos(new_pos)¶ Sets the center of mass of the strand to a new position by moving all the nucleotides.
Parameters: new_pos – new center of mass position
-
set_sequence(seq)¶ Sets the sequence of the strand.
Parameters: seq – either a string of letters (A,T,C,G), or a list of ints (0,1,2,3). Should have the same length as the strand.
-
translate(amount)¶ Translates the strand.
Parameters: amount – displacement vector to translate the strand
-
-
class
base.System(box, time=0, E_pot=0, E_kin=0)¶ Object representing an oxDNA system. Contains strands. Access strand objects of System system1 by system1._strands[strand_index].
Parameters: - box – Box size of the system, e.g. box = [50, 50, 50]
- time – Time of the system
- E_pot – Potential energy
- E_kin – Kinetic energy
-
N¶ Number of nucleotides in the system.
-
N_strands¶ Number of strands in the system.
-
E_pot¶ Potential energy
-
E_kin¶ Kinetic energy
-
E_tot¶ Total energy
-
add_strand(s, check_overlap=True)¶ Adds a Strand to the System. Returns True if non-overlapping, False otherwise.
Parameters: - s – Strand object to be added
- check_overlap – boolean. If true, checks for overlap. Defaults to be true.
-
add_strands(ss, check_overlap=True)¶ Adds multiple Strands to the System. Returns True if non-overlapping, False otherwise.
Parameters: - ss – List of Strand objects to be added
- check_overlap – boolean. If true, checks for overlap. Defaults to be true.
-
contains_overlaps()¶ Returns True if the system contains strand overlaps, False otherwise.
-
copy()¶ Returns a copy of the system.
-
get_nucleotide_list()¶ Returns a list of Nucleotide objects in the system.
-
get_reduced(according_to, bbox=None, check_overlap=False)¶ Returns a reduced copy of the system with only strands set to be visible in the visibility file.
Parameters: - according_to – path to visibility file
- bbox – box size of the reduced system
- check_overlap – boolean. If true, checks for strand overlap.
-
get_sequences()¶ Returns the sequence of the system as a list of lists containing strand sequences.
-
get_unique_seq()¶ Returns the unique sequences in the system.
-
join(other, box=None)¶ Returns a system formed by joining this system with another system.
Parameters: - other – the other System object
- box – box size in a numpy array
-
map_nucleotides_to_strands()¶ Fills the nucl_id -> strand_id array self._nucleotide_to_strand
-
print_lorenzo_output(conf_name, top_name, visibility=None)¶ Outputs oxDNA configuration and topology files for the system.
Parameters: - conf_name – configuration file name
- top_name – topology file name
- visibility – path to visibility file (default is None - everything is visible)
-
rotate(amount, origin=None)¶ Rotates the system.
Parameters: - amount – rotation matrix
- origin – the point around which the system rotates
-
set_visibility(arg=None)¶ Sets visibility according to a visibility file.
Parameters: arg – visibility file
-
translate(amount)¶ Translates the system.
Parameters: amount – displacement vector to translate the system