File: TestTorsionPartitioner.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 (218 lines) | stat: -rw-r--r-- 8,433 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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
/* -------------------------------------------------------------------------- *
 *                      SimTK Core: SimTK Molmodel                            *
 * -------------------------------------------------------------------------- *
 * This is part of the SimTK Core biosimulation toolkit originating from      *
 * Simbios, the NIH National Center for Physics-Based Simulation of           *
 * Biological Structures at Stanford, funded under the NIH Roadmap for        *
 * Medical Research, grant U54 GM072970. See https://simtk.org.               *
 *                                                                            *
 * Portions copyright (c) 2006-7 Stanford University and the Authors.         *
 * Authors: Christopher Bruns                                                 *
 * Contributors:                                                              *
 *                                                                            *
 * Permission is hereby granted, free of charge, to any person obtaining a    *
 * copy of this software and associated documentation files (the "Software"), *
 * to deal in the Software without restriction, including without limitation  *
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,   *
 * and/or sell copies of the Software, and to permit persons to whom the      *
 * Software is furnished to do so, subject to the following conditions:       *
 *                                                                            *
 * The above copyright notice and this permission notice shall be included in *
 * all copies or substantial portions of the Software.                        *
 *                                                                            *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,   *
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL    *
 * THE AUTHORS, CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,    *
 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR      *
 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE  *
 * USE OR OTHER DEALINGS IN THE SOFTWARE.                                     *
 * -------------------------------------------------------------------------- */

#include "SimTKmolmodel.h"

#include <iostream>
#include <vector>

using std::cout;
using std::endl;

using namespace SimTK;
using namespace std;

// define CREATE_VIZ_WINDOW to see animated window of simulation
// undefine for automated nightly builds
// #define CREATE_VIZ_WINDOW

int main() {
//try
//  {
    Element e;
    e = Element::Argon();
    // cout << "Element=" << e << endl;

    AliphaticCarbon ac;
    // cout << "AliphaticCarbon " << ac << endl;

    MethylGroup methyl;
    // cout << "Methyl " << methyl << endl;

    Methane methane1;
    // cout << "Methane=" << methane1 << endl;
    Methane methane2;

    Ethane ethane1;
    Ethane ethane2;
    Ethane ethane3;
    ethane1.setDefaultTorsionAngle(55*Deg2Rad);
    // cout << "Ethane=" << ethane << endl;
    // cout << "  default torsion angle=" << ethane.getDefaultTorsionAngle() << endl;

    AminoAcidResidue::Serine serine;


    AminoAcidResidue::Alanine alanine1;
    // AminoAcidResidue::Alanine alanine2;
    // cout << "Alanine = " << alanine1 << endl;

    //cout << "PROTEIN=" << protein << endl;

    CompoundSystem system;
	SimbodyMatterSubsystem matter(system);
    DuMMForceFieldSubsystem dumm(system);
    DecorationSubsystem decorations(system);

    // system.adoptCompound(methane1);
    // system.adoptCompound(ethane1);
    // system.adoptCompound(alanine1);

    // system.adoptCompound(alanine1);

    // system.adoptCompound(ethane2);
    // system.adoptCompound(ethane3);
    // system.adoptCompound(methane2);

    // system.adoptCompound(protein);

    // system.adoptCompound(alanine1);
    // system.adoptCompound(alanine2);

    dumm.loadAmber99Parameters();
    //ifstream tinkerStream("../../resources/tinker_amber99_clean.prm");
    //dumm.populateFromTinkerParameterFile(tinkerStream);
    //tinkerStream.close();

    dumm.defineChargedAtomType(DuMM::ChargedAtomTypeIndex(5000), "Methane C",   DuMM::AtomClassIndex(1),  0.04);
    dumm.defineChargedAtomType(DuMM::ChargedAtomTypeIndex(5001), "Methane H",  DuMM::AtomClassIndex(34),  -0.01);
    dumm.defineChargedAtomType(DuMM::ChargedAtomTypeIndex(5002), "Ethane C",   DuMM::AtomClassIndex(1),  0.03);
    dumm.defineChargedAtomType(DuMM::ChargedAtomTypeIndex(5003), "Ethane H",  DuMM::AtomClassIndex(34),  -0.01);
    dumm.setBiotypeChargedAtomType(DuMM::ChargedAtomTypeIndex(5000), Biotype::MethaneC().getIndex());
    dumm.setBiotypeChargedAtomType(DuMM::ChargedAtomTypeIndex(5001), Biotype::MethaneH().getIndex());
    dumm.setBiotypeChargedAtomType(DuMM::ChargedAtomTypeIndex(5002), Biotype::EthaneC().getIndex());
    dumm.setBiotypeChargedAtomType(DuMM::ChargedAtomTypeIndex(5003), Biotype::EthaneH().getIndex());

    // Complete C-terminal group
    // alanine1.bondAtom(UnivalentAtom("2OXT", Element::Oxygen()), "bondC", 0.1250);
    // alanine1.nameAtom("1OXT", "O");

    // Add one more hydrogen to nitrogen to create unnatural 3-body cluster
    // alanine1.convertInboardBondCenterToOutboard();
    // alanine1.bondAtom(UnivalentAtom("2HN", Element::Hydrogen()), "bondN", 0.1010);

    // build acetyl alanine
    //AminoAcidResidue::Alanine alanine1;
    alanine1.assignBiotypes();
    //AcetylResidue compound1;
    //compound1.assignBiotypes(Ordinality::Initial);
    //compound1.bondCompound("ala1", alanine1, "bondC", 0.13350);
    //system.adoptCompound(compound1);

    AcetylResidue acetyl1;
    acetyl1.assignBiotypes(Ordinality::Initial);
    acetyl1.bondCompound("ala1", alanine1, "bondC", 0.135);
    acetyl1.setBondMobility(BondMobility::Rigid, "C", "ala1/N");

    // Add some more alanines to make a peptide
    AminoAcidResidue::Alanine alanine2;
    AminoAcidResidue::Alanine alanine3;
    AminoAcidResidue::Alanine alanine4;
    alanine2.assignBiotypes();
    alanine3.assignBiotypes();
    alanine4.assignBiotypes(Ordinality::Final);
    acetyl1.bondCompound("ala2", alanine2, "ala1/bondC", 0.135);

    // system.adoptCompound(acetyl1);

    // serine.assignBiotypes();
    // system.adoptCompound();
    AminoAcidResidue::Threonine thr;
    thr.assignBiotypes();
    // system.adoptCompound(thr);

//    Protein protein("AAAAAAAAA");
    Protein protein("GPRFS");
    protein.writeDefaultPdb(cout);
    protein.assignBiotypes();
    system.adoptCompound(protein);

    // bool biotypesComplete = alanine1.assignBiotypes();
    // bool biotypesComplete = alanine1.assignBiotypes(Ordinality::ANY);
    // assert(biotypesComplete);
    // alanine2.assignBiotypes();

    cout << "Methane = " << methane1 << endl;
    cout << "Ethane = " << ethane1 << endl;
    cout << "Alanine = " << alanine1 << endl;

    // alanine1.writeDefaultPdb(cout);

    system.modelCompounds();
                

    State state = system.realizeTopology();

#ifdef CREATE_VIZ_WINDOW
    Visualizer display(system);
#endif

    RungeKuttaMersonIntegrator study(system);
    //CPodesIntegrator study(system);
    study.initialize(state);

#ifdef CREATE_VIZ_WINDOW
    display.report(study.getState());
#endif

    // getchar(); // for synchronizing movie capture

    // ethane.setDihedralAngle(state, "torsion", 60*DuMM::Deg2Rad);

    //cout << protein.getAtomLocation(state, "0/CA") << endl;

    Real timeInterval = 0.005;
    for (Real time=0.0; time < (10 * timeInterval); time += timeInterval) // picoseconds
    {

        // std::cout << "Ethane torsion angle = " << DuMM::Rad2Deg * ethane.getDihedralAngle(state, "torsion") << std::endl;

        // study.stepTo(time, Infinity);
        study.stepTo(time);

#ifdef CREATE_VIZ_WINDOW
        display.report(study.getState());
#endif

        //protein.writePdbCoordinates(state, fileName);
    }

//  }
//catch (const std::exception& e)
//  {
//    printf("EXCEPTION THROWN: %s\n", e.what());
//  }
//catch (...)
//  {
//    printf("UNKNOWN EXCEPTION THROWN\n");
//  }    return 0;
}