Exemplo n.º 1
0
def get_fiber_dyad_frames(fiber_params, nuc_d, nuc_type=nuc_name):
    '''
    Convert the parameters that define a stacked fiber to the
    frame coordinates of the dyad basepairs

    Parameters
    ----------
    fiber_params : ndarray of (N, 6)
        The step paremeters of the stacked fiber

    Returns
    -------
    res : ndarray of (N, 4, 3)
        The coordinates of the dyad frames
    '''
    fiber = HelixPose(fiber_params)
    res = []

    for i in range(len(fiber.frames)):
        n_f = np.transpose(fiber.frames[i])
        n_o = fiber.coord[i]

        dna_params, dna_o, dna_f0, c = GetNuc(norigin=n_o,
                                              nframe=n_f,
                                              nuc_type=nuc_type)
        n_dna = HelixPose(dna_params, frame0=dna_f0)

        dyad_coords = nuc.of2coords(n_dna.coord[nuc_d] + dna_o,
                                    np.transpose(n_dna.frames[nuc_d]))
        res.append(dyad_coords)
    return res
Exemplo n.º 2
0
def GetNuc(
        norigin=np.zeros(3), nframe=np.eye(3), wrapped_bp=0,
        nuc_type=nuc_name):
    '''
    Obtain the coordinates of a nucleosome from a pdb file

    Parameters
    ----------
    norigin : ndarray of (3)
        center of mass of the nucleosome
    nframe : ndarray of (3,3)
        frame of the nucleosome (x points to dyad, z points along cylinder axis)
    wrapped_bp : int
        controls the amount of nucleosome wrapped DNA
        negative values indicate #bp unwrapped at each side
        positive values indicate total wrapped #bp distributed symetrically 
    Returns
    -------
     params2 : ndarray of (N, 6)
        The basepair step parameters of DNA
     o2 : ndarray of (3)
         start coordinate of DNA
     f2 : ndarray of (3, 3)
         start frame of DNA
     c_dyad : ndarray of (4, 3)
         coordinate frame of the dyad basepair
     
    '''
    n = nuc.NucPose()
    n.from_file(nuc_type)
    dna = HelixPose(n.params)
    i = 0
    n_bp = dna.n_bp

    o_nuc, f_nuc = nuc.get_nframe(dna.coord, n.d_index, fixed)
    P = nuc.of2coords(o_nuc, f_nuc)
    Q = nuc.of2coords(norigin, nframe)

    transform = nuc.get_transformation(P, Q)
    o_dyad = dna.coord[n.d_index]
    f_dyad = dna.frames[n.d_index]
    c_dyad = nuc.apply_transf_coords(nuc.of2coords(o_dyad, f_dyad), transform)

    c0 = nuc.of2coords(dna.coord[0], dna.frames[0])

    c1 = nuc.apply_transf_coords(c0, transform)
    o1, f1 = nuc.coords2of(c1)
    dna1 = HelixPose(n.params, frame0=np.transpose(f1))

    f2 = dna1.frames[i]
    o2 = o1 + dna1.coord[i]
    params2 = dna1.params[i:i + n_bp]

    return params2, o2, f2, c_dyad
Exemplo n.º 3
0
def GetPose(filename, drc = ''):
    '''
    Load a dinucleome HelixPose object from .npz file
    
    Parameters
    ----------
    filename : string
        name of the .npz file
    drc : string
        directory in which the file can be found (if it is not in the same 
        directory as this script)
    
    Returns
    -------
    DNA : HelixPose object
        the HelixPose of a dinucleosome
    dyads : ndarray
        numpy array with dyad indices
    nucl : NucPose object
        the NucPose of the used nucleosome
    '''
    fname = drc + '\\' + filename
    
    NRL = int(filename.split('NRL')[1].split('h')[0])
    nuctype = filename.split('NRL')[0]
    #h = int(filename.split('NRL')[1].split('h')[1].split('.')[0])
    
    DNA = HelixPose(params = np.load(fname)['params'] , frame0 = np.load(fname)['frame0'])
    n_bp = len(DNA.params)
    dyads = np.asarray(NRL*(np.arange(0, 2, 1)-(2-1)/2.0))
    dyads = (dyads+n_bp/2).astype(int)
    nucl = NMC.NucPose()
    nucl.from_file(nuctype+'.3DNA')
    return DNA, dyads, nucl
Exemplo n.º 4
0
def insert_nucs(dna, dyads, pdb='1KX5'):
    '''
    Fix basepair parameters for nucleosomes in DNA at dyad positions

    Parameters
    ----------
    dna: HelixMC pose
    dyads : dyad positions in DNA (bp)
    Returns
    -------
    dna : HelixMC pose
    nucl : NucleosomeMC pose
    '''
    #    # Get nucleosome
    nucl = nMC.NucPose()
    nucl.from_file(fileio.change_extension(pdb, '3DNA'))

    params = dna.params
    length = len(nucl.dna.params)
    new_dyads = []
    for dyad in dyads:
        start = dyad - nucl.dyad
        end = start + length
        if (start >= 0 and (end < len(params))):
            params[start:end] = nucl.dna.params
            new_dyads.append(dyad)
    dna = HelixPose(params)
    return dna, nucl, np.asarray(new_dyads)
Exemplo n.º 5
0
def create_nuc_array(p=None):
    '''
    Create DNA configuration, including nucleosomes

    '''
    if p is None:
        p = Parameters()
        p.add('L_bp', value=500)
        p.add('n_nuc', value=2)
        p.add('NRL', value=197)
    p = p.valuesdict()

    n_bp = p['L_bp']
    n_nucs = p['n_nuc']
    NRL = p['NRL']

    dyads = np.asarray(NRL * (np.arange(0, n_nucs, 1) - (n_nucs - 1) / 2.0))
    dyads = (dyads + n_bp // 2).astype(int)

    random_step = RandomStepSimple.load_gaussian_params('DNA_gau.npy')
    params = np.tile(random_step.params_avg, (n_bp - 1, 1))

    dna = HelixPose(params)
    dna, nuc, dyads = insert_nucs(dna, dyads)

    return dna, dyads, nuc
Exemplo n.º 6
0
def create_fiber(l_handle,
                 n_nuc,
                 NRL,
                 dna_file='DinucleosomePoses\\4qlcNRL167.npz',
                 CL=True):
    '''    
    Create a chromatin fiber with prespecified handle lengths from a dinucleosome
    DNA pose file
    
    Parameters
    ----------
    l_handle : int
        lenght of DNA handle in basepairs
    n_nuc : int
        number of nucleosomes in the fiber
    NRL : int
        nucleosome repeat length in basepairs
    dna_file : string
        name of the saved HelixPose file
        
    Returns
    -------
    dna : instance of HelixPose
    
    dyads : list

    nucl : instance of NucPose
    '''
    dna = HelixPose(params=np.load(dna_file)['params'],
                    frame0=np.load(dna_file)['frame0'])
    n_bp = len(dna.coord)
    dna2, dyads, nucl = create_dna(
        n_bp,
        2,
        NRL,
        unwrap=-20,
        nuc_file=(dna_file.split('\\')[1]).split('N')[0] + '.3DNA')

    if CL == True:
        n_bp_new = NRL + 147
        diff = n_bp - n_bp_new
        newpars = dna.params[diff / 2 - 1:-(diff / 2)]
        for i in range(len(dyads)):
            dyads[i] = nucl.d_index + NRL * i - 1
        dna.set_params(newpars)
    dyads = CreateFiber(dna, dyads[0], dyads[1], n_nuc)
    #    for i in range(len(dyads)):
    #        dyads[i] = dyads[i] + l_handle
    dyads = dyads + l_handle
    handles = np.tile(random_step.params_avg, (l_handle, 1))
    newpars = dna.params

    newpars = np.concatenate((handles, newpars, handles))
    dna.set_params(newpars)

    return dna, dyads, nucl
Exemplo n.º 7
0
def create_dna(n_bp,
               n_nucs,
               NRL,
               unwrap=None,
               compute_tw_wr=False,
               nuc_file=nuc_name):
    '''
    Create random DNA configuration, including nucleosomes

    Parameters
    ----------
    n_bp : number of basepairs
    n_nucs : number of nucleosomes
    NRL : nucleosome repeat length
    unwrap : number of basepaires wrapped on the nucleosome. Negative numbers
        define number of unwrapped basepairs on each side
    
    Returns
    ----------
    DNA : instance of HelixMC
    dyads : bp position of dyads
    nucl : instance of NucleosomeMC
    '''
    dyads = np.asarray(NRL * (np.arange(0, n_nucs, 1) - (n_nucs - 1) / 2.0))
    dyads = (dyads + n_bp / 2).astype(int)

    random_step = RandomStepSimple.load_gaussian_params('DNA_gau.npy')
    params = np.tile(random_step.params_avg, (n_bp, 1))

    # Get nucleosome
    nucl = nuc.NucPose()
    nucl.from_file(nuc_file)

    # Insert nucleosomes in DNA
    params, free_dna = insert_nucs(params,
                                   nucl.params,
                                   dna_dyads=dyads,
                                   nuc_dyad=nucl.d_index,
                                   wrapped_bp=unwrap)
    DNA = HelixPose(params, compute_tw_wr=compute_tw_wr)

    return DNA, dyads, nucl
Exemplo n.º 8
0
def replace_linker(dna, dyads, linker_params):
    '''
    Replace basepair parameters for linker DNA

    Parameters
    ----------
    dna : basepair step parameters for DNA
    dyads : dyad index in DNA (bp)
    free_bps : array of bps; 0 = nucleosomal DNA, 1 = free DNA
    linker_params : basepair step parameters for linker DNA
    Returns
    -------
    dna_params : ndarray of (N, 6)
        The basepair step parameters of DNA
    free_bps : array of bps; 0 = nucleosomal DNA, 1 = free DNA
    '''
    params = dna.params
    for d1, d2 in zip(dyads, dyads[1:]):
        linker_mid = d1 + (d2 - d1) // 2
        linker_start = linker_mid - len(linker_params) // 2 - 1
        params[linker_start:linker_start + len(linker_params)] = linker_params
    dna = HelixPose(params)
    return dna
Exemplo n.º 9
0
def create_folded_fiber(par, nucl):
    dna, dyads, _ = create_nuc_array(p=par)
    params = np.zeros_like(dna.params)
    w = np.zeros(len(dna.coords))
    n_ofs = get_fiber_frames(par)
    origin_of = np.concatenate(([np.zeros(3)], np.eye(3)))
    unwrapped = int(par['Unwrapped_bp'])
    length = len(nucl.dna.params) - 2 * unwrapped
    for n_of, dyad in zip(n_ofs, dyads):
        tf = nMC.get_transformation(nucl.of, target=n_of)
        start_bp = dyad - nucl.dyad + unwrapped
        w[start_bp:start_bp + length] = np.ones(length)
        params[start_bp:start_bp +
               length] = nucl.dna.params[unwrapped:unwrapped + length]
        params[start_bp - 1] = \
            nMC.ofs2params(origin_of, nMC.apply_transformation(nMC.get_of(nucl.dna, unwrapped), tf))
        params[start_bp + length] = \
            nMC.ofs2params(nMC.apply_transformation(nMC.get_of(nucl.dna, len(nucl.dna.params) - unwrapped), tf),
                           origin_of)
    fiber_dna = HelixPose(params)

    w = np.transpose(np.asarray([w, w, w]))
    return fiber_dna, dyads, w
Exemplo n.º 10
0
def ribbon(r, cg, theta0, N, ld, h0):
    '''
    Creates dyad frames for nucleosomes in a ribbon    
    
    Parameters 
    ----------
    r : float 
        fiber radius
    theta0 : float
        starting angle
    N : int
        number of nucleosomes
    ld : float
        distance between two nucleosomes in the same ribbon
    h0: float
        beginning height of the spiral
    
    Returns
    -------
    coords : list
        list of nucleosome coords
    '''
    def theta(s):
        return s / r + theta0

    def znuc(s):
        return 1.0/np.sqrt(1+cg**2)*np.array([-np.sin(theta(s)),\
                np.cos(theta(s)), cg])

    def xnuc(s):
        return np.array([-np.cos(theta(s)), -np.sin(theta(s)), 0])

    def ynuc(s):
        return np.cross(znuc(s), xnuc(s))

    def fnuc(s):
        return np.array([xnuc(s), ynuc(s), znuc(s)])

    def onuc(s):
        x = r * np.cos(theta(s))
        y = r * np.sin(theta(s))
        z = s * cg + h0
        return np.array([x, y, z])

    ss = np.arange(0, N * ld, ld) + h0 / cg
    onucs = []
    fnucs = []
    cnucs = []
    for s in ss:
        o = onuc(s)
        f = fnuc(s)
        onucs.append(o)
        fnucs.append(f)
        cnucs.append(nuc.of2coords(o, f))

    dfs = []
    for i in range(len(onucs)):

        dna_params, dna_o, dna_f0, c = FMC.GetNuc(norigin=onucs[i],
                                                  nframe=fnucs[i])
        n_dna = HelixPose(dna_params, frame0=dna_f0)

        dyad_coords = nuc.of2coords(n_dna.coord[nucl.d_index] + dna_o,
                                    np.transpose(n_dna.frames[nucl.d_index]))
        dfs.append(dyad_coords)

    return dfs, cnucs
file_name = 'simulations\\' + date + '_' + str(NRL)

read_from_file = False

n_nuc = 2
n_bp = 147 + NRL
dna, dyads, nucl = FMC.create_dna(n_bp, n_nuc, NRL)
# end = FMC.nuc_get_ends(dna, dyads[1], nucl)[0]
start = dyads[0] + (147 - nucl.d_index)
end = dyads[1] - nucl.d_index
# start = FMC.nuc_get_ends(dna, dyads[0], nucl)[1]

if read_from_file == True:

    dna_file = 'simulations\\180215_197_0_unwrap.npz'
    dna = HelixPose(params=np.load(dna_file)['params'], frame0=np.load(dna_file)['frame0'])

else:

    # 197
    a = np.array([11.617, 0.329, 3.672, 0.965, 0.800])  # 15/02/18 197 solenoid --> unwrap 0-10
    # a = np.loadtxt('simulations\\180215_197_0_unwrap.dat')

    unwrap = 0

    link_len = end - start

    CurveDNA(a, unwrap, dna, nucl, start, end, n_nuc, dyads)
    print start
    print end
    se = np.linalg.norm(dna.coord[start] - dna.coord[end])
Exemplo n.º 12
0
    def from_file(self, input_file):
        '''
        Load pose data from an input file.

        Parameters
        ----------
        input_file : str
        input file (.txt) obtained from w3DNA.

        '''
        self.nuc_type = input_file.split('.')[0]
        if input_file == None:
            input_file = "3LZ0.3DNA"
            print('Default file: ' + input_file)
        #   read protein coords from pdb file
        filename = pdb_source_dir + input_file
        filename = fileio.change_extension(filename, 'pdb')
        chains = read_pdb(filename)

        #   read 3DNA file
        filename = fileio.change_extension(filename, '3DNA')
        with open(filename) as f:
            lines = f.read().splitlines()

        #   Basepair step parameters
        i = find(
            lines, lambda x:
            '    step       Shift     Slide      Rise      Tilt      Roll     Twist'
            in x) + 1

        j = find(lines[i:], lambda x: '~~~~~~~~~~~' in x)

        params = np.zeros((j, 6))
        for k in range(0, j):
            if not ('----' in lines[i + k]):
                tmp = np.asarray(map(float, lines[i + k].split()[2:]))
            params[k:] = np.append(tmp[0:3], np.radians(tmp[3:6]))

        #   get fixed frames
        B_factor = chains['DNA'][3]
        fixed = []
        for i in range(14):
            j = np.argmin(B_factor)
            fixed.append(j)
            B_factor[j - 6:j + 6] = np.max(B_factor)

        fixed = np.sort(fixed)
        self.dyad = int(round(np.mean(fixed)))
        self.fixed = fixed - self.dyad

        #   Centers of basepairs
        i = find(
            lines, lambda x:
            '      bp        Ox        Oy        Oz        Nx        Ny        Nz'
            in x) + 1

        coords = np.zeros((j, 3))
        frames = np.zeros((j, 3, 3))
        for k in range(0, j):
            tmp = np.asarray(map(float, lines[i + k].split()[2:]))
            coords[k, :] = tmp[0:3]
            frames[k][0] = tmp[3:6] / np.linalg.norm(tmp[3:6])
        chains['DNA'][2] = np.asarray(coords)

        # rotate all coords, such that frame0 = origin
        self.dna = HelixPose(params)
        tm = get_transformation(chains['DNA'][2][0:100],
                                self.dna.coords[0:100])
        for chain in chains:
            chains[chain][2] = apply_transformation(chains[chain][2], tm)
        self.chains = chains

        # remove non-nucleosomal DNA
        if len(self.dna.coords) > 147:
            loose_ends = 147 - (self.fixed_i[-1] - self.fixed_i[0] + 1)
            if loose_ends % 2 == 1:
                l1 = loose_ends / 2
                l2 = l1 + 1
            else:
                l1 = loose_ends / 2
                l2 = l1
            start = self.fixed_i[0] - l1 + self.d_index
            end = self.fixed_i[-1] + l2 + self.d_index
            self.d_index = self.d_index - start
            params = params[start:end]
            self.dna = HelixPose(params)

        # get origin and frame of nucleosome
        cm = np.mean(self.dna.coords[self.fixed], axis=0)
        Nx = self.dna.coords[self.dyad] - cm
        Nx = Nx / np.linalg.norm(Nx)
        Nz = np.mean(self.dna.coords[self.fixed[:7], :], axis=0) - np.mean(
            self.dna.coords[self.fixed[7:], :], axis=0)
        Nz = Nz / np.linalg.norm(Nz)

        Ny = np.cross(Nx, Nz)
        Ny = Ny / np.linalg.norm(Nz)

        Nz = np.cross(Nx, Ny)
        Nz = Nz / np.linalg.norm(Nz)
        origin = cm
        frame = np.array([Nx, Ny, Nz])
        self.of = join_o_f(origin, np.transpose(frame))
Exemplo n.º 13
0
    def from_file(self, input_file):
        '''
        Load pose data from an input file.

        Parameters
        ----------
        input_file : str
        input file (.txt) obtained from w3DNA.

        '''
        
        if input_file == None:
            input_file = "3LZ0.3DNA"
            
            print('Default file: ' + input_file)
        directory = "N:\\Chromatin\\Software\\ChromatinMC\\PDBs"
#   read protein coords from pdb file

        chains = ReadPdb(directory+ input_file.replace('3DNA','pdb'))
#   get fixed frames
        B = chains['DNA'][3]

        acids = chains['DNA'][1]
        self.step_list = []
        for i in range(len(acids)-1):
            self.step_list.append(acids[i]+acids[i+1])
      
        fixed = []
        for i in range(14):
            j = np.argmin(B)
            fixed.append(j)
            B[j-6:j+6]=np.max(B)

        fixed = np.sort(fixed)
        self.d_index = int(round(np.mean(fixed)))
        self.fixed_i = fixed - self.d_index


        
#   get link coordinates Glu61 (H2A) and Asp24 (H4)
        int_dict={'H2A':60, 'H2A*':60, 'H4':23, 'H4*':23}
        self.l_coords = []
        for locus in int_dict:
            self.l_coords.append(chains[locus][2][int_dict[locus]])
        self.l_coords = np.asarray(self.l_coords)
        
#   read 3DNA file         
        with open(directory+input_file) as f:
            lines = f.read().splitlines()
            
#   Basepair step parameters            
        i=find(lines, lambda x: 
        '    step       Shift     Slide      Rise      Tilt      Roll     Twist'
        in x)+1

        j=find(lines[i:], lambda x: '~~~~~~~~~~~' in x)

        self.params=np.zeros((j,6))
        for k in range (0,j):
            if not('----' in lines[i+k]):
                tmp = np.asarray(map(float,lines[i+k].split()[2:]))
            self.params[k:]= np.append(tmp[0:3], np.radians(tmp[3:6]))
        self.n_bp = len(self.params[:,0])+1
        
        
        
#        self.origins, self.frames = util.params2coords(self.params)
#        self.d_origin =self.origins[self.d_index]
#        self.d_frame = self.frames[self.d_index]
        
        
        

#   Centers of basepairs
        i=find(lines, lambda x: 
        '      bp        Ox        Oy        Oz        Nx        Ny        Nz'
        in x)+1

        coords = np.zeros((j,3))
        frames = np.zeros((j,3,3))
        for k in range (0,j):
            tmp = np.asarray(map(float,lines[i+k].split()[2:]))
            coords[k,:] = tmp[0:3]
            frames[k][0] = tmp[3:6]/np.linalg.norm(tmp[3:6])
            if k is self.d_index:
                self.d_origin = tmp[0:3]
                self.d_frame = tmp[3:6]/np.linalg.norm(tmp[3:6])
        chains['DNA'][2] = coords
        self.chains = chains
        
        
#   Dyad frame coords
        nucDNA = HelixPose(self.params)
        self.nucDNAcopy = HelixPose(self.params)
        Qn = coords
        P = nucDNA.coord[0:len(Qn)]
        transform = get_transformation(P, Q = Qn)
        
        
        Pn = of2coords(nucDNA.coord[self.d_index], nucDNA.frames[self.d_index])
        self.d_of = Pn

        self.d_coords = of2coords(nucDNA.coord[self.d_index], np.transpose(nucDNA.frames[self.d_index]))
        self.DNAcoords = nucDNA.coord
        self.DNApose = nucDNA
#   Nucleosome frame
        self.n_origin, self.n_frame = get_nframe(self.DNAcoords, self.d_index, self.fixed_i)
        #self.n_frame = np.transpose(self.n_frame)
        self.n_coords = of2coords(self.n_origin, self.n_frame)
        
        #com frame to dyad_frame transform
        self.com_d_transform = get_transformation(self.n_coords,self.d_coords)
        
#   origin of nucleosomal DNA
        transform = get_transformation(nucDNA.coord[0:len(coords)], Q = coords)   
        framecoords = of2coords(np.zeros(3), np.eye(3))
        framecoords = apply_transf_coords(framecoords, transform)
        self.origin0, self.frame0 = coords2of(framecoords)

#   fixed coordinates of nucleosome
        self.fixed_coord = get_fixed_coord(nucDNA, self.d_index-1, self.fixed_i)
        self.fixed_coord2 = []
        for i in range(0,14):
            self.fixed_coord2.append(get_fixed_coord2(nucDNA, self.d_index-1, \
            self.fixed_i, i))
        
#   stiffnes of fixed basepairs          
        sd_pos = 0.5 # (A)
        k_pos = kBT / sd_pos**2
        self.fixed_k = k_pos
        self.fixed_g = 10*kBT
        
        if self.n_bp > 147:
            loose_ends = self.fixed_i[-1]-self.fixed_i[0]+1
            if loose_ends%2 == 1:
                l1 = loose_ends/2
                l2 = l1 + 1
            else:
                l1 = loose_ends/2
                l2 = l1
            self.DNAcoords = self.DNAcoords[self.d_index-l1+self.fixed_i[0]:self.d_index+self.fixed_i[-1]+l2]

        #return self.params
Exemplo n.º 14
0
    def from_file(self, input_file):
        '''
        Load pose data from an input file.

        Parameters
        ----------
        input_file : str
        input file (.txt) obtained from w3DNA.

        '''
        self.nuc_type = input_file.split('.')[0]
        if input_file == None:
            input_file = "3LZ0.3DNA"
            print('Default file: ' + input_file)
#        directory = "C:\\Users\\lion\\Desktop\\ChromatinMC\\PDBs\\"
        directory = "PDBs\\3LZ0.3DNA"

#   read protein coords from pdb file

        chains = ReadPdb(directory+ input_file.replace('3DNA','pdb'))
#   get fixed frames
        B = chains['DNA'][3]

        acids = chains['DNA'][1]
        self.step_list = []
        for i in range(len(acids)-1):
            self.step_list.append(acids[i]+acids[i+1])
      
        fixed = []
        for i in range(14):
            j = np.argmin(B)
            fixed.append(j)
            B[j-6:j+6]=np.max(B)

        fixed = np.sort(fixed)
        self.d_index = int(round(np.mean(fixed)))
        self.fixed_i = fixed - self.d_index

        
#   get link coordinates Glu61 (H2A) and Asp24 (H4)
        int_dict={'H2A':60, 'H2A*':60, 'H4':23, 'H4*':23}
        self.l_coords = []
        for locus in int_dict:
            self.l_coords.append(chains[locus][2][int_dict[locus]])
        self.l_coords = np.asarray(self.l_coords)
        
#   read 3DNA file         
#        with open(directory+input_file) as f:
        with open(directory) as f:
            lines = f.read().splitlines()
            
#   Basepair step parameters            
        i=find(lines, lambda x:
        '    step       Shift     Slide      Rise      Tilt      Roll     Twist'
        in x)+1

        j=find(lines[i:], lambda x: '~~~~~~~~~~~' in x)

        self.params=np.zeros((j,6))
        for k in range (0,j):
            if not('----' in lines[i+k]):
                tmp = np.asarray(map(float,lines[i+k].split()[2:]))
            self.params[k:]= np.append(tmp[0:3], np.radians(tmp[3:6]))
        self.n_bp = len(self.params[:,0])+1
        

        
 
        
            
            
        
        

#   Centers of basepairs
        i=find(lines, lambda x: 
        '      bp        Ox        Oy        Oz        Nx        Ny        Nz'
        in x)+1

        coords = np.zeros((j,3))
        frames = np.zeros((j,3,3))
        for k in range (0,j):
            tmp = np.asarray(map(float,lines[i+k].split()[2:]))
            coords[k,:] = tmp[0:3]
            frames[k][0] = tmp[3:6]/np.linalg.norm(tmp[3:6])
            if k is self.d_index:
                self.d_origin = tmp[0:3]
                self.d_frame = tmp[3:6]/np.linalg.norm(tmp[3:6])
        chains['DNA'][2] = coords
        self.chains = chains
        
        
        if self.n_bp > 147:
            loose_ends = 147 - (self.fixed_i[-1]-self.fixed_i[0]+1)
            if loose_ends%2 == 1:
                l1 = loose_ends/2
                l2 = l1 + 1
            else:
                l1 = loose_ends/2
                l2 = l1
            start = self.fixed_i[0] - l1 + self.d_index
            end = self.fixed_i[-1] + l2 +self.d_index
            self.params = self.params[start:end]
            coords = coords[start:end]
            self.d_index = self.d_index-start
#   Dyad frame coords
        nucDNA = HelixPose(self.params)        
        self.d_coords = of2coords(nucDNA.coord[self.d_index], np.transpose(nucDNA.frames[self.d_index]))
        self.coords = nucDNA.coord
        self.frames = nucDNA.frames
#   Nucleosome frame
        self.n_origin, self.n_frame = get_nframe(self.coords, self.d_index, self.fixed_i)
        self.n_coords = of2coords(self.n_origin, self.n_frame)
        

        
#   origin of nucleosomal DNA
        transform = get_transformation(nucDNA.coord[0:len(coords)], Q = coords)   
        framecoords = of2coords(np.zeros(3), np.eye(3))
        framecoords = apply_transf_coords(framecoords, transform)
        self.origin0, self.frame0 = coords2of(framecoords)

#   fixed coordinates of nucleosome
        self.fixed_coord = get_fixed_coord(nucDNA, self.d_index-1, self.fixed_i)
        self.fixed_coord2 = []
        for i in range(0,14):
            self.fixed_coord2.append(get_fixed_coord2(nucDNA, self.d_index-1, \
            self.fixed_i, i))
            
#   create lists of linear transforms of fixed basepair to center of mass
        self.tvs = []
        self.mats = []
        for i in range(0,14):
            index = self.d_index + self.fixed_i[i]
            #multiply those with the frame of the fixed basepair of the dna to get the 
            #frame and position of the nucleosome center of mass
            self.tvs.append(np.dot(np.transpose(self.frames[index]), self.n_coords[0]-self.coords[index]))
            
            self.mats.append(np.dot(np.transpose(self.frames[index]),np.transpose(self.n_frame)))
        
#   stiffnes of fixed basepairs          
        sd_pos = 0.5 # (A)
        k_pos = kBT / sd_pos**2
        self.fixed_k = k_pos
        self.fixed_g = 10*kBT