Basepair

class rnamake.basepair.Basepair(res1, res2, r, bp_type='c...')[source]

Bases: object

Parameters:
  • res1 (residue.Residue) – First residue in basepair
  • res2 (residue.Residue) – Second residue in basepair
  • r (np.array) – Reference frame of basepair
  • bp_type (str) – X3dna basepair type, default “c...”
Attributes:
res1 : residue.Residue
First residue in basepair
res2 : residue.Residue
Second residue in basepair
bp_type: str
X3dna basepair type
atoms: list of atom.Atoms
All atoms from both res1 and res2. Grouped together for easy manipulation
bp_state: BasepairState
Contains the orientation, origin and sugar. This is all information required to align to this basepair and can be used independently from the reset of the basepair.
uuid: uuid.uuid1()
unique id to indentify this basepair when locating it in a motif or pose
Examples:
# build basepair from stratch
>>> from rnamake.unittests import instances
>>> from rnamake import basepair
>>> import numpy as np
>>> s = instances.structure()
>>> b = basepair.Basepair(s.get_residue(num=103),
                          s.get_residue(num=104),
                          np.eye(3))
>>> print b
<Basepair(A103-A104)>

# loading test basepair
>>> b = instances.basepair()
>>> print b
<Basepair(A13-A12)>

# primary axis of orientation, used to align to this basepair
>>> print b.r()
[[  1.00000001e+00   1.00000001e-04  -9.99999990e-09]
 [ -1.00000002e-04   1.00000001e+00  -9.99999990e-05]
 [ -1.99999995e-08   9.99999955e-05   1.00000000e+00]]

# center of mass of basepair
>>> print b.d()
[ 0.1956032   0.69256601  0.0930465 ]
c1_prime_coords()[source]

gets the c1’ atom coordinates for both residues. These coordinates are used to fine tune the alignment between basepairs

Returns:list of c1’ coords
Return type:list of np.arrays
copy()[source]

creates a deep copy of this basepair object

d()[source]

gets the center of the atoms in this basepair.

Returns:center of mass of basepair
Return type:np.array
flip()[source]

wrapper for BasepairState flip. There is probably no reasons to ever call this. See the implementation in BasepairState

Returns:None
name()[source]

get name of basepair: which is the combined name of both residues seperated by a “-”. The residue with the lower res number should come first

Returns:name of basepair
Return type:str
Examples:
# build basepair from stratch
>>> from rnamake.unittests import instances
>>> b = instances.basepair()
>>> print b.res1
<Residue('G13 chain A')>

>>> print b.res2
<Residue('C12 chain A')>

>>> print b.name()
A12-A13
partner(res)[source]

get the other basepairing partner of a residue will throw an error if the supplied residue is not contained within this basepair

Parameters:res (Residue object) – the residue that you want to get the partner of
r()[source]

gets the orientation matrix of this basepair which is stored in the the BasepairState instance.

Returns:orientation matrix of basepair
Return type:np.array
residues()[source]

returns both residues for easy iteration

Returns:both residues in base
Return type:list of residue.Residues
state()[source]

gets the state of this basepair and makes sure that the center and sugar positions are updated

to_pdb(fname='basepair.pdb')[source]

write basepair object to pdb file

:param fname” the file you want to write the basepair too :type fname: str

to_pdb_str(acount=1, return_acount=0)[source]

creates a PDB string formatted verision of this Basepair object.

Parameters:
  • acount (int) – current atom index, default: 1
  • return_acount (int) – final atom index after current atoms, default: 0
Returns:

str

to_str()[source]

stringify basepair object

class rnamake.basepair.BasepairState(r, d, sugars)[source]

Bases: object

A small container class to hold the “State” of a basepair for finding matches in the database. The critical features are:

Params r:Reference Frame of basepair
Params d:Center of mass of basepair
Params sugars:C1` atom coords for both residues in basepair
Attributes:
r : np.Matrix
Reference Frame of basepair
d : Np.Array
Center of mass of basepair
sugars : List of Np.Arrays
C1` atom coords for both residues in basepair
Examples:
>>> from rnamake.unittests import instances
>>> bp_state_1 = instances.basepairstate_random()
>>> bp_state_2 = instances.basepairstate_random()

# get rotation and translation defining the transformation between the
# two states
>>> r, t = bp_state_1.get_transforming_r_and_t_w_state(bp_state_2)
>>> t += bp_state_1.d

# align end2 to end1, notice this is two steps, this is done so
# r and t can be applied to many states at the same time so they can
# be all aligned together
>>> new_r, new_d, new_sug = bp_state_2.get_transformed_state(r, t)
>>> bp_state_2.set(new_r, new_d, new_sug)

# both the orientation matrix and origins are nearly indentical now
>>> print bp_state_1.r
[[-0.43155336  0.24291737  0.86876513]
 [-0.61066224 -0.78751428 -0.08314381]
 [ 0.66396787 -0.56640305  0.4881949 ]]
>>> print bp_state_2.r
[[-0.43155336  0.24291737  0.86876513]
 [-0.61066224 -0.78751428 -0.08314381]
 [ 0.66396787 -0.56640305  0.4881949 ]]

>>> print bp_state_1.d
[  5.45492979  45.17079568  43.80163295]
>>> print bp_state_2.d
[  5.45492979  45.17079568  43.80163295]
copy()[source]

returns a deep copy of this BasepairState object

diff(state)[source]

calculate the difference between this basepair and another. Difference is defined currently as euclidean distance between their origins and two times the matrix difference between the orientations of both states.

Parameters:state (BasepairState) – the other state to compare the difference too
Returns:difference between the states
Return type:float
get_transformed_state(r, t)[source]

get new orientation, origin and sugar coordinates after transforming with suplied rotation and translation.

Parameters:
  • r (np.array) – supplied rotation matrix
  • t (np.array) – supplied translation
Returns:

new orientation, origin and sugar coorindates of this basepair state after transformation

get_transforming_r_and_t(r, t, sugars)[source]

get a rotation matrix and translation that describes the tranformation between the rotation, translation to THIS BasepairState.

Parameters:
  • r (np.array) – Another orientation matrix from another basepair
  • t (np.array) – The origin of another basepair
  • sugars (list of two np.arrays) – the c1’ coords of another basepair
Returns:

rotation and translation that defines transformation betwen both states

get_transforming_r_and_t_w_state(state)[source]

wrapper for get_transforming_r_and_t using another basepair state instead of specifying each component explicitly.

Parameters:state (BasepairState) – the basepair state you would like to get a transformation to align to the basepair state calling this function
set(r, d, sug)[source]

sets a new orientation matrx, origin and new c1’ sugar coordinates, overriding the existing values stored in this instance.

Parameters:
  • r (np.array) – new orientation matrix
  • d (np.array) – new origin point
  • sug (list of 2 np.arrays) – new c1’ sugar coordinates
to_str()[source]

converts basepairstate into a string

rnamake.basepair.str_to_basepairstate(s)[source]

convert stringified basepair back to a basepair object see basepairstate.to_str()