Victor
 All Data Structures Functions Variables Friends Pages
LoboTools.h
1 /* This file is part of Victor.
2 
3  Victor is free software: you can redistribute it and/or modify
4  it under the terms of the GNU General Public License as published by
5  the Free Software Foundation, either version 3 of the License, or
6  (at your option) any later version.
7 
8  Victor is distributed in the hope that it will be useful,
9  but WITHOUT ANY WARRANTY; without even the implied warranty of
10  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  GNU General Public License for more details.
12 
13  You should have received a copy of the GNU General Public License
14  along with Victor. If not, see <http://www.gnu.org/licenses/>.
15  */
22 #ifndef _LOBO_TOOLS_H_
23 #define _LOBO_TOOLS_H_
24 #include <string>
25 #include <LoopModel.h>
26 #include <GetArg.h>
27 #include <PdbLoader.h>
28 #include <PdbSaver.h>
29 #include <iostream>
30 using namespace Victor;
31 using namespace Victor::Lobo;
32 
33 bool silent = false;
34 
38 inline void fillLine() {
39  std::cout << "---------------------------------------------------\n";
40 }
41 
45 inline void showCommonOptions() {
46  char *victor = getenv("VICTOR_ROOT");
47  if (victor == NULL)
48  ERROR("Environment variable VICTOR_ROOT was not found.\n Use the command:\n export VICTOR_ROOT=......", exception);
49  string path = "data/aa";
50  std::cout << "\t[--sol1 <n-solutions>] \t Number of primary solutions"
51  << " (default= " << LoopModel::MAX_ITER_SOL << ")\n"
52  << "\t[--maxWrite <n-sol.>] \t Number of solutions to write out"
53  << " (default = sol1)\n"
54  << "\t[--scwrl <filename>] \t Sequence output file for SCWRL (-s option)\n"
55  << "\t[--table <name>] \t Path and basename of LUT files (default = "
56  << getenv("VICTOR_ROOT") + path << ") \n"
57  << "\t[--withOxygen] \t\t Include Oxygen atoms in RMSD calculation\n"
58  << "\t[--verbose] \t\t Verbose mode\n"
59  << "\t[--silent] \t\t Silent mode\n";
60 }
61 
65 inline void showSpecialOptions() {
66  LoopModel lm;
67  std::cout << "\t[--sol2 <n-solutions>] \t Number of secondary solutions"
68  << " (default= 1)\n"
69  << "\t[--endrmsWeigth] \t Choose weigthing of endrms"
70  << " (default= " << lm.getENDRMS_WEIGHT() << ")\n"
71  << "\t[--energyWeigth] \t Choose weigthing of energy"
72  << " (default= " << LoopModel::ENERGY_WEIGTH << ")\n"
73  << "\t[--secprefWeigth] \t Choose weigthing of secondary preference"
74  << " (default= " << LoopModel::SECPREF_WEIGTH << ")\n"
75  << "\t[--secprefTol] \t\t Choose tolerance for secondary preference"
76  << " (default= " << LoopModel::SECPREF_TOL << ")\n"
77  << "\t[--packingWeigth] \t Choose weigthing of packing density"
78  << " (default= " << LoopModel::PACKING_WEIGTH << ")\n"
79  << "\t[--weigthEP] \t\t Choose weigthing of EP compared to ED & EN"
80  << " (default= " << LoopTableEntry::LAMBDA_EP << ")\n"
81  << "\t[--maxSearch] \t\t Choose max fraction of tables to search "
82  << "for best result (default= " << LoopTable::MAX_FACTOR << ")\n"
83  << "\t[--vdwLimit] \t\t Choose threshold for VDW filter"
84  << " (default= " << LoopModel::VDW_LIMIT << ")\n"
85  << "\t[--energyLimit] \t Choose threshold for energy filter"
86  << " (default= " << LoopModel::ENERGY_LIMIT << ")\n"
87  << "\t[--simLimit] \t\t Choose threshold for clustering similarity"
88  << " (default= " << LoopModel::SIM_LIMIT << ")\n"
89  << "\t[--interpol] \t\t Use interpolated RAPDF energy\n"
90  << "\t[--scatter <filename>] \t Write a scatter plot file.\n";
91 }
92 
96 inline void showSpecialOptionsLobo() {
97  std::cout << "\t[--cluster] \t\t Cluster results.\n"
98  << "\t[--norank] \t\t Do not rank or filter results.\n"
99  << "\t[--norankRms] \t\t Do not rank or filter results according "
100  << "to end AA RMS.\n"
101  << "\t[--noFullModel] \t Do not write full model, write only"
102  << " loop instead.\n"
103  << "\t[--noWrite]\t\t Do not write output file.\n"
104  << "\t[--refine] \t\t Refines the solutions (ie. reduced endRms)\n"
105  << "\t[--optimize] \t\t Local optimization of the top solution\n"
106  << "\t[--optall] \t\t Local optimization of all solutions pre-ranking\n"
107  << "\t[--opt1] \t\t Number of outer iterations for optimization\n"
108  << "\t[--opt2] \t\t Number of inner iterations for optimization\n"
109  << "\t[--optnum] \t\t Number of solutions to optimize\n"
110  << "\t[--test] \t\t Test mode, no optimization\n";
111 }
112 
116 static inline void sLoboHelp() {
117  std::cout << "LOBO - LOop Building & Optimization\n"
118  << "This program generates a model for a single loop or indel.\n"
119  << " Options: \n"
120  << "\t-i <filename> \t\t Input file\n"
121  << "\t-c <chain> \t\t pdb chain\n"
122  << "\t-s <n-start> \t\t Aminoacid where loop starts\n"
123  << "\t-e <n-end> \t\t Aminoacid where loop ends\n"
124  << "\n"
125  << "\t[-o <filename>] \t Output file (default = test.pdb)\n"
126  << "\t[--seq <filename>] \t Sequence file (in one letter code)\n";
127 }
128 
132 inline void showLoboHelp() {
133  sLoboHelp();
134  showCommonOptions();
135  std::cout << "\n\t--help \t\t Get detailed help.\n"
136  << endl;
137 }
138 
142 inline void showMoreLoboHelp() {
143  sLoboHelp();
144  showCommonOptions();
145  showSpecialOptions();
146  showSpecialOptionsLobo();
147  std::cout << endl;
148 }
149 
153 static inline void sLoboAutoHelp() {
154  std::cout << "LOBO - LOop Building & Optimization\n"
155  << "This program generates an automatic model for a single indel.\n"
156  << " Options: \n"
157  << "\t-i <filename> \t\t Input pdb file\n"
158  << "\t-c <filename> \t\t pdb chain\n"
159  << "\t-s <n-start> \t\t N-terminal aminoacid where indel starts\n"
160  << "\t-l <length> \t\t Length of indel\n"
161  << "\t--del \t\t Modelling of deletion requested (default)\n"
162  << "\t--ins \t\t Modelling of insertion requested\n"
163  << "\t--seq <filename> \t Sequence file (in one letter code)\n"
164  << "\n"
165  << "\t[-o <filename>] \t Output file (default = test.pdb)\n";
166 }
167 
171 inline void showLoboAutoHelp() {
172  sLoboAutoHelp();
173  showCommonOptions();
174  std::cout << "\n\t--help \t\t Get detailed help.\n"
175  << endl;
176 }
177 
181 inline void showMoreLoboAutoHelp() {
182  sLoboAutoHelp();
183  showCommonOptions();
184  showSpecialOptions();
185  showSpecialOptionsLobo();
186  std::cout << endl;
187 }
188 
192 static inline void sLoboFullHelp() {
193  std::cout << "LOBO FULL - LOop Building & Optimization for full proteins\n"
194  << "This program generates all models for every k-mer fragment in "
195  << "a single protein over a sliding window.\n"
196  << " Options: \n"
197  << "\t-i <filename> \t\t Input file\n"
198  << "\t[-c <chain>] \t\t pdb chain\n"
199  << "\t[-o <filename>] \t Output file basename\n"
200  << "\t[-s <offset>] \t\t Size of *real* sliding window (default= 5)\n"
201  << "\n"
202  << "\t[--norankRms] \t\t Do not rank or filter results according "
203  << "to end AA RMS.\n"
204  << "\t[--fullRank] \t\t Write full ranking.\n";
205 }
206 
210 inline void showLoboFullHelp() {
211  sLoboFullHelp();
212  showCommonOptions();
213  std::cout << "\n\t--help \t\t Get detailed help.\n"
214  << endl;
215 }
216 
220 inline void showMoreLoboFullHelp() {
221  sLoboFullHelp();
222  showCommonOptions();
223  showSpecialOptions();
224  std::cout << endl;
225 }
226 
232 inline string sGetSequence(string sequenceFile, bool silent) {
233  if (!silent)
234  std::cout << "seqFile = " << sequenceFile << "\n";
235 
236  ifstream seqFile(sequenceFile.c_str());
237  if (!seqFile)
238  ERROR("Sequence file not found.", exception);
239 
240  string tmp;
241  seqFile >> tmp;
242  return tmp;
243 }
244 
250 inline void treatSpecialOptions(int nArgs, char* argv[]) {
251  getOption(LoopModel::ENERGY_WEIGTH, "-energyWeigth", nArgs, argv, true);
252  getOption(LoopModel::SECPREF_WEIGTH, "-secprefWeigth", nArgs, argv, true);
253  getOption(LoopModel::SECPREF_TOL, "-secprefTol", nArgs, argv, true);
254  getOption(LoopModel::PACKING_WEIGTH, "-packingWeigth", nArgs, argv, true);
255  getOption(LoopTableEntry::LAMBDA_EP, "-weigthEP", nArgs, argv, true);
256  getOption(LoopTableEntry::LAMBDA_ED, "-weigthED", nArgs, argv, true);
257  getOption(LoopTableEntry::LAMBDA_EN, "-weigthEN", nArgs, argv, true);
258  getOption(LoopTable::MAX_FACTOR, "-maxSearch", nArgs, argv, true);
259  getOption(LoopModel::VDW_LIMIT, "-vdwLimit", nArgs, argv, true);
260  getOption(LoopModel::ENERGY_LIMIT, "-energyLimit", nArgs, argv, true);
261  getOption(LoopModel::SIM_LIMIT, "-simLimit", nArgs, argv, true);
262 }
263 
269 inline void printSeqAndBfactors(unsigned int index1, unsigned int index2, Spacer& sp) {
270  fillLine();
271  std::cout << "Sequence & B-factors:\n";
272 
273  for (unsigned int i = index1 + 1; i < index2 + 1; i++) {
274  std::cout << " " << sp.getAmino(i).getType();
275  for (unsigned int j = 0; j < sp.getAmino(i).sizeBackbone(); j++)
276  std::cout << " " << setw(5) << setprecision(3)
277  << sp.getAmino(i)[j].getBFac();
278  std::cout << "\n";
279  }
280 }
281 
287 inline void treatProlineBug(unsigned int index1, unsigned int index2, Spacer& sp) {
288  // take care of PROline sidechain bug:
289  if (sp.getAmino(index1 + 1).getCode() == PRO) {
290  if (sp.getAmino(index1 + 1).getSideChain().isMember(CD))
291  sp.getAmino(index1 + 1).getSideChain().removeAtom(
292  sp.getAmino(index1 + 1).getSideChain()[CD]);
293  }
294  if (sp.getAmino(index2 + 1).getCode() == PRO) {
295  if (sp.getAmino(index2 + 1).getSideChain().isMember(CD))
296  sp.getAmino(index2 + 1).getSideChain().removeAtom(
297  sp.getAmino(index2 + 1).getSideChain()[CD]);
298  }
299 }
300 
306 inline void printSecStructureAndLoop(unsigned int index1, unsigned int index2, Spacer& sp) {
307  for (unsigned int i = 0; i < sp.sizeAmino(); i++) {
308  if (sp.getAmino(i).getState() == HELIX)
309  std::cout << "H";
310  else if (sp.getAmino(i).getState() == STRAND)
311  std::cout << "E";
312  else
313  std::cout << "-";
314  if ((i + 1) % 60 == 0)
315  std::cout << "\n";
316  }
317  std::cout << "\n";
318  for (unsigned int i = 0; i < sp.sizeAmino(); i++) {
319  if ((i >= index1) && (i <= index2))
320  std::cout << "#";
321  else
322  std::cout << ".";
323  if ((i + 1) % 60 == 0)
324  std::cout << "\n";
325  }
326  std::cout << "\n";
327  fillLine();
328 }
329 
337 inline void printResults(unsigned int index1, unsigned int index2,
338  LoopModel& lm, Spacer& sp, vector<Spacer>& vsp, bool withOxygen, unsigned int maxWrite = 9999) {
339  fillLine();
340  std::cout << " Results: \t\t\t\t\t\t 1.35 121 180\n";
341 
342  maxWrite = (maxWrite < vsp.size() ? maxWrite : vsp.size());
343  for (unsigned int i = 0; i < maxWrite; i++) {
344  std::cout << setw(3) << i << " ";
345  lm.calculateRms(sp, index1, index2, vsp[i], true, withOxygen);
346  }
347  std::cout << endl;
348 }
349 
357 inline void saveLoopEnsemble(unsigned int index1, unsigned int index2,
358  LoopModel& lm, Spacer& sp, vector<Spacer>& vsp, string outputFile,
359  unsigned int maxWrite, bool noFullModel) {
360  unsigned int maxW = vsp.size() < maxWrite ? vsp.size() : maxWrite;
361  for (unsigned int i = 0; i < maxW; i++) {
362  string tmpStr = outputFile + ".";
363 
364  if (i < 10)
365  tmpStr += "00";
366  else if (i < 100)
367  tmpStr += "0";
368 
369  tmpStr += itos(i);
370 
371  ofstream outFile(tmpStr.c_str());
372  if (!outFile)
373  ERROR("Could not create file.", exception);
374  PdbSaver ps(outFile);
375  ps.setWriteAtomOnly();
376 
377  if (!noFullModel) {
378  lm.setStructure(sp, vsp[i], index1, index2);
379  sp.save(ps);
380  } else {
381  vsp[i].save(ps);
382  }
383  }
384 
385 }
386 
387 #endif //_LOBOTOOLS_H_
AminoAcid & getAmino(unsigned int n)
Definition: Spacer.cc:962
void removeAtom(Atom &a)
Definition: Group.cc:85
virtual string getType() const
Definition: SimpleBond.h:114
const unsigned int sizeAmino() const
Definition: Spacer.cc:197
Saves components (Atoms, Groups, etc.) in standard PDB format.
Definition: PdbSaver.h:39
void save(Saver &s)
Definition: Spacer.h:241
Implements a "Spacer" for a protein chain. Includes methods to obtain values from the atoms and its p...
Definition: Spacer.h:42