def test_results_warning(self, u):
        ags = [r.atoms.select_atoms('name C* N*') for r in u.residues]
        p = polymer.PersistenceLength(ags)

        msg = ("The structure of the `results` array will change in "
               "MDAnalysis version 2.0.")
        with pytest.warns(DeprecationWarning, match=msg):
            p.run()
Esempio n. 2
0
def PersistenceLengthDNA(u_):
    PH_beads = u_.select_atoms('name PH or name RB1 or name DB2 or name RB2')
    PB_beads = u_.select_atoms('name PB or name RB1 or name DB2 or name RB2')
    if PH_beads.n_atoms > 39:
        dnas = [PH_beads, PH_beads]
    elif PB_beads.n_atoms > 39:
        dnas = [PB_beads, PB_beads]
    else:
        print('I cant find backbone P beads!!')

    # Persistance
    per = polymer.PersistenceLength(dnas).run()
    return per.lp / 10.  # convert to nm
 def test_ag_ValueError(self, u):
     ags = [u.atoms[:10], u.atoms[10:110]]
     with pytest.raises(ValueError):
         polymer.PersistenceLength(ags)
    def p(u):
        ags = [r.atoms.select_atoms('name C* N*') for r in u.residues]

        p = polymer.PersistenceLength(ags)
        return p
Esempio n. 5
0
def PersistenceL(trajFile,
                 top,
                 backboneAtoms,
                 NP,
                 coef=1. / 10.,
                 stride=1.,
                 chain0Id=0,
                 firstpoint=2):
    """
    get persistence length of chains of indices from chain0Id to chain0Id+NP-1 
    coef: divide results by 10. to convert to nm since MDAnalysis uses Angstrom
"""
    from MDAnalysis.lib.mdamath import make_whole
    import MDAnalysis as mda
    from MDAnalysis.analysis import polymer

    u = mda.Universe(top, trajFile)
    for frag in u.atoms.fragments:
        make_whole(frag)
    molecules = u.atoms.fragments
    filter = 'name {}'.format(*backboneAtoms)
    backbones = [mol.select_atoms(filter)
                 for mol in molecules][chain0Id:chain0Id + NP]
    sorted_backbones = [polymer.sort_backbone(bb) for bb in backbones]

    persistence_length = polymer.PersistenceLength(sorted_backbones)
    persistence_length.run()
    LB = persistence_length.lb * coef
    if firstpoint == 0:
        LP = persistence_length.lp * coef
    else:
        LP = polymer.fit_exponential_decay(
            persistence_length.x[firstpoint:],
            persistence_length.results[firstpoint:])
        persistence_length.fit = np.exp(-persistence_length.x[firstpoint:] /
                                        LP)
        LP *= coef

    fig, ax = plt.subplots(nrows=1, ncols=1, figsize=[3, 2])
    ax.plot(persistence_length.x * coef,
            persistence_length.results,
            'ro',
            label='Result')
    ax.plot(persistence_length.x[firstpoint:] * coef,
            persistence_length.fit,
            label='Fit')
    ax.vlines(LP, 0., 1, ls=':', lw=0.75)
    plt.text(2. * LP,
             0.5 * max(persistence_length.fit),
             '$<cos\\theta> = exp(-n*{}/{})$'.format(round(LB, 3),
                                                     round(LP, 3)),
             size=7)
    ax.set_xlim(-0.1, 1.1 * max(persistence_length.x * coef))
    ax.set_xlabel(r'$n*l_b$')
    ax.set_ylabel(r'$C(n*l_b)$')
    plt.savefig('persistenceL.png',
                dpi=500,
                transparent=True,
                bbox_inches="tight")

    return LP, LB, len(sorted_backbones[0])
Esempio n. 6
0
    def _make_p(self):
        ags = [r.select_atoms('type C or type N') for r in self.u.residues]

        p = polymer.PersistenceLength(ags)
        return p
Esempio n. 7
0
    def _make_p(self):
        ags = [r.atoms.select_atoms('name C* N*')
               for r in self.u.residues]

        p = polymer.PersistenceLength(ags)
        return p