File: ExampleSimpleRNA.cpp

package info (click to toggle)
molmodel 3.1.0-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 24,384 kB
  • sloc: cpp: 39,830; perl: 526; ansic: 107; makefile: 41
file content (82 lines) | stat: -rwxr-xr-x 2,860 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
/* -------------------------------------------------------------------------- *
 *                   SimTK Molmodel Example: Simple RNA                       *
 * -------------------------------------------------------------------------- *
 * This is the second example from the Molmodel User's Guide. It creates a    *
 * small RNA molecule, simulates it, generates a live animation while it is   *
 * running and generates a multi-frame pdb file to look at later.             *
 *                                                                            *
 * Authors: Christopher Bruns, Michael Sherman                                *
 * -------------------------------------------------------------------------- */

#include "Molmodel.h"

#include <iostream>
#include <fstream>
#include <exception>

using namespace SimTK;

// We'll create a file of this name in the current working directory.
const char* PdbFileName = "simpleRNA.pdb";

int main() {
try {
	// molecule-specialized Simbody System
    CompoundSystem         system; 
	SimbodyMatterSubsystem matter(system);
    GeneralForceSubsystem  forces(system); // for Nose-Hoover
    DecorationSubsystem    decorations(system);

	// molecular force field
    DuMMForceFieldSubsystem forceField(system); 
    forceField.loadAmber99Parameters();

    // This is adenine-uracil-guanine.
    RNA rna("AUG");
    rna.assignBiotypes();
    system.adoptCompound(rna);

    // Use a Nose-Hoover thermostat, which is a continuous force element
    // rather than a periodic discontinuous "disturbance" like the 
    // VelocityRescalingThermostat. We're using the default relaxation time.
    NoseHooverThermostat thermo(forces, matter, 293.15);

    // Show me a movie with a frame every 20fs.
    system.addEventReporter(new Visualizer::Reporter(system, 0.020) );

    // Generate a pdb file with a frame every 100fs.
    std::ofstream pdbFile; pdbFile.open(PdbFileName);
    system.addEventReporter(new PeriodicPdbWriter(system, pdbFile, 0.100));

	// finalize multibody system
    system.modelCompounds(); 

	// Instantiate simbody model
	system.realizeTopology();
	State state = system.getDefaultState();

	// Relax the structure before dynamics run
	LocalEnergyMinimizer::minimizeEnergy(system, state, 15.0);

    // Simulate it.
    VerletIntegrator integ(system);
    TimeStepper ts(system, integ);
    ts.initialize(state);
    ts.stepTo(10.0); // 10 ps

    pdbFile.close();
    std::cout << "\nWrote pdb file "
              << Pathname::getCurrentWorkingDirectory() << PdbFileName << "\n";
    return 0;
} 
catch(const std::exception& e) {
    std::cerr << "ERROR: " << e.what() << std::endl;
    return 1;
}
catch(...) {
    std::cerr << "ERROR: An unknown exception was raised" << std::endl;
    return 1;
}

}