Xmipp  v3.23.11-Nereus
pdb_reduce_pseudoatoms.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  *
3  * Authors: Javier Mota Garcia (jmota@cnb.csic.es)
4  *
5  *
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 <iostream>
28 #include <algorithm>
29 #include "pdb_reduce_pseudoatoms.h"
30 #include "data/pdb.h"
31 
33 {
34  thresh = 0.0;
35  num = -1.0;
36 }
37 
39 {
40  addUsageLine("Reduce the number of pseudoatoms in a volume.");
41  addExampleLine(" xmipp_pdb_reduce_pseudoatoms -i 1o7d.vol -o 1o7dreduced.vol --threshold 0.15");
42 
43  addParamsLine(" -i <pdb_file> : File to process");
44  addParamsLine(" [-o <fn_root>] : Root name for output");
45  addParamsLine(" [--number <num=-1.0>] : Number of pseudoatoms to keep based on intensity");
46  addParamsLine(" [--threshold <thresh=0.0>] : Intensity threshold for removing pseudoatoms");
47 }
48 
50 {
51  fn_volume = getParam("-i");
52  fn_out = checkParam("-o") ? getParam("-o") : fn_volume.withoutExtension();
53  num = getDoubleParam("--number");
54  thresh = getDoubleParam("--threshold");
55 
56 }
57 
58 /* Show -------------------------------------------------------------------- */
60 {
61  std::cout << "PDB file: " << fn_volume << std::endl
62  << "Number: " << num << std::endl
63  << "Threshold: " << thresh << std::endl;
64 }
65 
67 {
68  PDBRichPhantom pdb;
69  if(thresh != 0.0)
70  pdb.read(fn_volume, false, thresh);
71  else
72  {
73  pdb.read(fn_volume, true);
74  std::sort(pdb.intensities.rbegin(), pdb.intensities.rend());
75  thresh = pdb.intensities.at(num);
76  pdb.atomList.clear();
77  pdb.remarks.clear();
78  pdb.read(fn_volume, false, thresh);
79  }
80  pdb.write(fn_out, true); // keep renumbering
81 }
82 
84 {
86 }
87 
88 
void read(const FileName &fnPDB, const bool pseudoatoms=false, const double threshold=0.0)
Read rich phantom from either a PDB of CIF file.
Definition: pdb.cpp:704
double getDoubleParam(const char *param, int arg=0)
void write(const FileName &fnPDB, const bool renumber=false)
Write rich phantom to PDB or CIF file.
Definition: pdb.cpp:872
std::vector< double > intensities
Definition: pdb.h:258
const char * getParam(const char *param, int arg=0)
void addExampleLine(const char *example, bool verbatim=true)
void sort(struct DCEL_T *dcel)
Definition: sorting.cpp:18
std::vector< RichAtom > atomList
List of atoms.
Definition: pdb.h:257
std::vector< std::string > remarks
List of remarks.
Definition: pdb.h:254
FileName withoutExtension() const
bool checkParam(const char *param)
void addUsageLine(const char *line, bool verbatim=false)
void addParamsLine(const String &line)