Ejemplo n.º 1
0
def print_hp(s):
    e = energy([
        Complex(
            strands=[Strand(name="hairpin", sequence="GTTCGGGCAAAAGCCCGAAC")],
            structure=s)
    ], o, Complex_Energy)[0]
    print(s + '  (%5.2f)' % e)
    return e
def print_trajectory(o):
    seqstring = ''
    for i in range(len(o.full_trajectory)
                   ):  # go through each output microstate of the trajectory
        time = o.full_trajectory_times[
            i]  # time at which this microstate is entered
        states = o.full_trajectory[
            i]  # this is a list of the complexes present in this tube microstate
        newseqs = []
        for state in states:
            newseqs += [
                state[3]
            ]  # extract the strand sequences in each complex (joined by "+" for multistranded complexes)
        newseqstring = ' '.join(
            newseqs
        )  # make a space-separated string of complexes, to represent the whole tube system sequence
        if not newseqstring == seqstring:
            print newseqstring
            seqstring = newseqstring  # because strand order can change upon association of dissociation, print it when it changes
        structs = []
        for state in states:
            structs += [
                state[4]
            ]  # similarly extract the secondary structures for each complex
        tubestruct = ' '.join(
            structs
        )  # give the dot-paren secondary structure for the whole test tube
        dG = 0
        for state in states:
            dG += state[5]
        print '%s t=%11.9f seconds, dG=%6.2f kcal/mol' % (tubestruct, time, dG)

        # Needlessly verify that the reported trajectory energies are the Tube_Energy values
        dGv = 0
        for state in states:
            cs = state[3].split('+')
            st = state[4]
            dGv += energy([
                Complex(strands=[Strand(sequence=s) for s in cs], structure=st)
            ], o, Tube_Energy)[0]
        if not dGv == dG: print "Energy Mismatch"
Ejemplo n.º 3
0
    o
)  # necessary if you want to use energy() without running a simulation first.
# see more about the energy model usage and initialization in threewaybm_trajectories.py

# More meaningful names for argument values to the energy() function call, below.
Loop_Energy = 0  # requesting no dG_assoc or dG_volume terms to be added.  So only loop energies remain.
Volume_Energy = 1  # requesting dG_volume but not dG_assoc terms to be added.  No clear interpretation for this.
Complex_Energy = 2  # requesting dG_assoc but not dG_volume terms to be added.  This is the NUPACK complex microstate energy, sans symmetry terms.
Tube_Energy = 3  # requesting both dG_assoc and dG_volume terms to be added.  Summed over complexes, this is the system state energy.

# Sequence is from Schaeffer's PhD thesis, chapter 7, figure 7.1

# Just for illustration, create a hairping strand with just the outermost 4 base pairs of the stem formed:
c = Complex(strands=[Strand(name="hairpin", sequence="GTTCGGGCAAAAGCCCGAAC")],
            structure='((((' + 12 * '.' + '))))')
energy([c], o, Complex_Energy)  # should be -1.1449...

# Note that energy() takes a *list* of complexes, and returns a tuple of energies.  Don't give it just a complex as input, else all hell may break loose.

# Try 'help(energy)' for a little more information.
# Similarly, 'help(initialize_energy_model)'  or  'help(Options)'  or  'help(Complex)'  or  'help(Strand)' .
# But beware that the help docs are not always complete or up-to-date, sorry.


# Using this sequence, find the energy for a particular secondar structure conformation.
def print_hp(s):
    e = energy([
        Complex(
            strands=[Strand(name="hairpin", sequence="GTTCGGGCAAAAGCCCGAAC")],
            structure=s)
    ], o, Complex_Energy)[0]