Xmipp  v3.23.11-Nereus
pdb_analysis.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  *
3  * Authors:
4  *
5  * Carlos Oscar S. Sorzano (coss@cnb.csic.es)
6  * Unidad de Bioinformatica of Centro Nacional de Biotecnologia , CSIC
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
21  * 02111-1307 USA
22  *
23  * All comments concerning this program package may be sent to the
24  * e-mail address 'xmipp@cnb.csic.es'
25  ***************************************************************************/
26 
27 #include "pdb_analysis.h"
28 #include "core/histogram.h"
29 #include "data/pdb.h"
30 
32 {
33  addUsageLine("Analyze a PDB file and produce different statistics");
34  addParamsLine("-i <file> : PDB to study");
35  addParamsLine("--operation <op> : Operation to perform");
36  addParamsLine(" where <op>");
37  addParamsLine(" distance_histogram <fileOut> <Nnearest=3> <MaxDistance=-1>: Compute the distance histogram between");
38  addParamsLine(" : an atom and its N nearest neighbours");
39  addParamsLine(" : The maximum distance of the neighbours may be limited (in Angstroms)");
40  addExampleLine("Compute the histogram of interatomic distances",false);
41  addExampleLine("xmipp_pdb_analysis -i mypdb.pdb --operation distance_histogram distance.hist");
42 }
43 
45 {
46  fn_pdb=getParam("-i");
47  op=getParam("--operation");
48  if (op=="distance_histogram")
49  {
50  fn_hist=getParam("--operation",1);
51  Nnearest=getIntParam("--operation",2);
52  maxDistance=getDoubleParam("--operation",3);
53  }
54 }
55 
57 {
58  if (verbose==0)
59  return;
60  std::cout
61  << "PDB: " << fn_pdb << std::endl
62  << "Operation: " << op << std::endl;
63  if (op=="distance_histogram")
64  std::cout << "Output histogram: " << fn_hist << std::endl
65  << "Nnearest: " << Nnearest << std::endl
66  << "MaxDistance: " << maxDistance << std::endl;
67 }
68 
70 {
71  if (op=="distance_histogram")
72  {
73  PDBPhantom pdb; // It cannot be a PDBRichPhantom because it also has to work with pseudoatomic structures
74  pdb.read(fn_pdb);
75  Histogram1D hist;
77  hist.write(fn_hist);
78  }
79 }
void read(const FileName &fnPDB)
Read phantom from either a PDB of CIF file.
Definition: pdb.cpp:503
double getDoubleParam(const char *param, int arg=0)
double maxDistance
Definition: pdb_analysis.h:52
const char * getParam(const char *param, int arg=0)
void distanceHistogramPDB(const PDBPhantom &phantomPDB, size_t Nnearest, double maxDistance, int Nbins, Histogram1D &hist)
Definition: pdb.cpp:1627
void addExampleLine(const char *example, bool verbatim=true)
int verbose
Verbosity level.
void write(const FileName &fn, MDLabel=MDL_X, MDLabel=MDL_COUNT)
Definition: histogram.cpp:129
FileName fn_pdb
Definition: pdb_analysis.h:40
void addUsageLine(const char *line, bool verbatim=false)
int getIntParam(const char *param, int arg=0)
FileName fn_hist
Definition: pdb_analysis.h:46
void addParamsLine(const String &line)