File: Repel.h

package info (click to toggle)
macromoleculebuilder 4.2%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 119,404 kB
  • sloc: cpp: 23,722; python: 5,098; ansic: 2,101; awk: 145; perl: 144; makefile: 40; sh: 38
file content (274 lines) | stat: -rw-r--r-- 8,587 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
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
#ifndef Repel_H_
#define Repel_H_

/* -------------------------------------------------------------------------- *
 *                           MMB (MacroMoleculeBuilder)                       *
 * -------------------------------------------------------------------------- *
 *                                                                            *
 * Copyright (c) 2011-12 by the Author.                                       *
 * Author: Samuel Flores                                                      *
 *                                                                            *
 * See RNABuilder.cpp for the copyright and usage agreement.                  *
 * -------------------------------------------------------------------------- */

//const int maxChiWelds = 1000;
//const int maxResidues = 3000;    // was maxChars

#include <iostream>
#include <vector>
#include <stdlib.h>// for MAX_PATH

#include "MMB_config.h"

#include "SimTKmolmodel.h"
#include "PeriodicScrubber.h"  
#include "BiopolymerClass.h"
#include "ParameterReader.h"
#include "PeriodicPdbAndEnergyWriter.h"
#include "BiopolymerClassTwoTransformForces.h"
#ifdef MMB_NTC_ENABLED
#include "NtCForces.h"
#endif // MMB_NTC_ENABLED
#include "TetherForce.h"
#include "Sterics.h" 
#include "AddNASTForces.h"
#include "WadleyKeatingDuartePyleTorsionForce.h"
#include "SetSingleBondMobility.h" 
#include "DensityForce.h"
#include "ConstraintContainer.h"

//using namespace SimTK;
//using namespace std;


/**
 * /brief This method sets the BondMobility for all bonds within each residue in a certain stretch of residues of any biopolymer   chain
 *
 * added by scf
 */
MMB_EXPORT void setBiopolymerResidueBondMobility (Biopolymer & myChain , BondMobility::Mobility  mobility, ResidueInfo::Index startResidue, ResidueInfo::Index endResidue);


/**
 * /brief This method sets the BondMobility for all bonds in a certain stretch of residues of a Protein        chain
 *
 * added by scf
 */
MMB_EXPORT void setProteinBondMobility (Biopolymer & myProteinChain , BondMobility::Mobility  mobility, ResidueInfo::Index startResidue, ResidueInfo::Index endResidue);



MMB_EXPORT double PointToPlaneDistance (Vec3 Point1, Vec3 Normal1, Vec3 Point2) ;


/**
 * /brief This utility is used to get the name of an atom involved in hydrogen bonding. It was written to help with the problem of pulling together two halves of an A-form double helix. 
 *
 * By convention the first atom of the first residue is a bond donor "H", the second atom of the first residue is an accepter "O".
 * the opposite convention holds for the second residue.
 *
 * /param PdbResidueName is the type of base (AUCG).  Based on this parameter we will determine the name of the appropriate hydrogen-bonding atom.
 * 
 */

// this polymorphism soon to be obsolete

// MMB_EXPORT String ReturnHBondingAtomName(String myPdbResidueName, int firstOrSecondResidue, int firstOrSecondBond );

/**
 * 
 * 
 * /param 
 * myPdbResidueName1,2 must be one of "A","C","G","U".
 * bondingEdge1,2 must be one of "WatsonCrick","Hoogsteen","Sugar","Bifurcated".
 * glycosidicBondOrientation must be either "Cis" or "Trans".
 *
 */

/**
 * /brief This utility is used for the Concentricity constraint.  In this constraint, a certain atom on residue 1 is connected by a LinearSpring to a certain point OUTSIDE of an atom on residue 2.  location2 is that point, in the body frame of the atom on residue 2.
 * 
 */
/*
class  SetPolynucleotideChiBondMobility  { public:

    SetPolynucleotideChiBondMobility (
        Biopolymer & myChain,
	int startResidueNumber,
	int endResidueNumber,
	LeontisWesthofClass  & myLeontisWesthofClass ,    
        SimbodyMatterSubsystem & matter,
        State& state,
        Constraint myWeld1[maxChiWelds],
        Constraint myWeld2[maxChiWelds],
        Constraint myWeld3[maxChiWelds]

	) ;  
    SetPolynucleotideChiBondMobility (
        Biopolymer & myChain,
	int startResidueNumber,
	int endResidueNumber,
	LeontisWesthofClass  & myLeontisWesthofClass ,    
	BondMobility::Mobility mobility = BondMobility::Free   
	)   ;
};       
*/
    //static bool compareUpper( const String& param, const char* symbol );


// MMB_EXPORT void setLeontisWesthofBondRowIndex (ParameterReader & myParameterReader,LeontisWesthofClass myLeontisWesthofClass, vector <Biopolymer>  & myMolecule);


class MMB_EXPORT ConstrainedDynamics : public Compound {
public:
    // int setDefaults();  
    void constraintsAndRestraints  (ParameterReader & ,BiopolymerClassContainer & ,GeneralForceSubsystem &  ,SimbodyMatterSubsystem & , State & , CompoundSystem &  );
    // void setBondMobilities(ParameterReader & myParameterReader,vector<Biopolymer> & myMolecule );
    // void addContacts(ParameterReader & myParameterReader,vector<Biopolymer> & myMolecule, GeneralContactSubsystem & contacts, GeneralForceSubsystem & forces, SimbodyMatterSubsystem & matter,CompoundSystem & system );
     
    void runDynamics();

    /**
    * Constructor
    *
    * \param a parameter reader
    */
    ConstrainedDynamics(ParameterReader * myParameterReader);

    /**
    * Destructor
    */
    ~ConstrainedDynamics();

    // Getters
    /**
    * \return the compound system
    */
    CompoundSystem & getCompoundSystem() { return _system; }

    /**
    * \return next frame number
    */
    unsigned int getNextFrameNum() { return _nextFrame; }

    /**
    * \return remaining frames number
    */
    unsigned int getRemainingFramesNum() { return _parameterReader->numReportingIntervals - (_nextFrame - 1); }

    /**
    * \return current state
    */
    State & getCurrentState() { return _state; }



    // Initializers

    void initializeDumm();

    /**
    * Initialize Biopolymers starting position
    */
    int  initializeBiopolymersAndCustomMolecules();
    int  initializeBiopolymersAndCustomMolecules(CompoundSystem & system); 

    /**
    * Initialize one Biopolymer identified by its chain
    * If no input file is provided, initialize with default positions
    */
    void initializeBiopolymer(String chainID, String inputPDBFile="");

    /**
    * Initialize other molecules and Bonds mobilizers
    * Must be called after initializeBiopolymers()
    */
    void initializeMoleculesAndBonds();
    void initializeMoleculesAndBonds(CompoundSystem & system, DuMMForceFieldSubsystem & dumm, SimbodyMatterSubsystem & matter);
    void setInterfaceMobilizers();
    void setInterfaceMobilizers(CompoundSystem & system, SimbodyMatterSubsystem & matter, State & state);
    void setMobilizers();

    /**
    * Create Multibody Tree.
    * Must be called after initializedMoleculesAndBonds()
    */
    void createMultibodyTree();
    void createMultibodyTree(CompoundSystem & system, State & state);


    /**
    * Instantiate Custom and other forces and constraints.
    */
    void initializeCustomForcesConstraints();

    /** 
    * Create periodic event handlers and reporters.
    */
    void createEventHandlers();

    /**
    * Initialize integrator and time stepper.
    */
    void initializeIntegrator();


    /**
    * Initialize other molecules, bonds, 
    * the Mutltibody tree and create the state
    */
    void initializeBodies ();
    void forceAdjustmentsWithFinalMobilizers(); // Some adjustments are made here to forces depending on mobilizers,  the mobilizers in turn are set in initializeBodies().

    /**
    * Initialize everything
    */
    void initializeDynamics();


    // Dynamics operation
    /**
    * Post-dynamics operations
    * Close the trajectory file and delete pointers
    * If required, write the last frame in an independant file
    */
    void postDynamics();


    /**
    * Run dynamics from next frame to numReportingIntervals
    */
    void runAllSteps();

    /**
    * Execute one step of dynamics
    *
    * \return number of remaining frames
    */
    unsigned int runOneStep();

    /**
    * Write original coordinates to the specified file.
    * It uses a dummy CompoundSystem.
    * \param filestream Ouptput file
    */
    void writeMMBPDB(std::ofstream & filestream);

private:
    CompoundSystem          _system;
    SimbodyMatterSubsystem  _matter;
    GeneralForceSubsystem   _forces;
    GeneralContactSubsystem _contacts;
    DuMMForceFieldSubsystem _dumm;
    State                   _state;
    Integrator *            _study;
    TimeStepper*            _ts;

    ofstream                _output;

    ParameterReader *       _parameterReader;

    unsigned int            _nextFrame;  
    double                  _previousTimeStep;  
};   
#endif