Xmipp  v3.23.11-Nereus
Public Member Functions | Public Attributes | List of all members

#include <pdb_label_from_volume.h>

Inheritance diagram for ProgPdbValueToVol:
Inheritance graph
[legend]
Collaboration diagram for ProgPdbValueToVol:
Collaboration graph
[legend]

Public Member Functions

void defineParams ()
 
void readParams ()
 
void produceSideInfo ()
 
void show ()
 
void run ()
 
void computeProteinGeometry ()
 
- Public Member Functions inherited from XmippProgram
const char * getParam (const char *param, int arg=0)
 
const char * getParam (const char *param, const char *subparam, int arg=0)
 
int getIntParam (const char *param, int arg=0)
 
int getIntParam (const char *param, const char *subparam, int arg=0)
 
double getDoubleParam (const char *param, int arg=0)
 
double getDoubleParam (const char *param, const char *subparam, int arg=0)
 
float getFloatParam (const char *param, int arg=0)
 
float getFloatParam (const char *param, const char *subparam, int arg=0)
 
void getListParam (const char *param, StringVector &list)
 
int getCountParam (const char *param)
 
bool checkParam (const char *param)
 
bool existsParam (const char *param)
 
void addParamsLine (const String &line)
 
void addParamsLine (const char *line)
 
ParamDefgetParamDef (const char *param) const
 
virtual void quit (int exit_code=0) const
 
virtual int tryRun ()
 
void initProgress (size_t total, size_t stepBin=60)
 
void setProgress (size_t value=0)
 
void endProgress ()
 
void processDefaultComment (const char *param, const char *left)
 
void setDefaultComment (const char *param, const char *comment)
 
virtual void initComments ()
 
void setProgramName (const char *name)
 
void addUsageLine (const char *line, bool verbatim=false)
 
void clearUsage ()
 
void addExampleLine (const char *example, bool verbatim=true)
 
void addSeeAlsoLine (const char *seeAlso)
 
void addKeywords (const char *keywords)
 
const char * name () const
 
virtual void usage (int verb=0) const
 
virtual void usage (const String &param, int verb=2)
 
int version () const
 
virtual void show () const
 
virtual void read (int argc, const char **argv, bool reportErrors=true)
 
virtual void read (int argc, char **argv, bool reportErrors=true)
 
void read (const String &argumentsLine)
 
 XmippProgram ()
 
 XmippProgram (int argc, const char **argv)
 
virtual ~XmippProgram ()
 

Public Attributes

double Ts
 
double radius
 
StringVector origin
 
bool defOrig
 
bool withMask
 
FileName fn_pdb
 
FileName fnVol
 
FileName fnMask
 
MultidimArray< double > inputVol
 
MultidimArray< double > inputMask
 
FileName fn_out
 
FileName fnMD
 
int output_dim
 
int M
 
Matrix1D< double > centerOfMass
 
Matrix1D< double > limit
 
- Public Attributes inherited from XmippProgram
bool doRun
 
bool runWithoutArgs
 
int verbose
 Verbosity level. More...
 
int debug
 

Additional Inherited Members

- Protected Member Functions inherited from XmippProgram
void defineCommons ()
 
- Protected Attributes inherited from XmippProgram
int errorCode
 
ProgramDefprogDef
 Program definition and arguments parser. More...
 
std::map< String, CommentListdefaultComments
 
int argc
 Original command line arguments. More...
 
const char ** argv
 

Detailed Description

Parameter class for the PDB Phantom program

Definition at line 39 of file pdb_label_from_volume.h.

Member Function Documentation

◆ computeProteinGeometry()

void ProgPdbValueToVol::computeProteinGeometry ( )

Definition at line 125 of file pdb_label_from_volume.cpp.

126 {
127  PDBRichPhantom pdbIn;
128  PDBRichPhantom pdbOut;
129  pdbIn.read(fn_pdb);
130 
131  MetaDataVec mdmean;
132  size_t objId;
133  objId = mdmean.addObject();
134 
135  double suma=0, sumaP=0;
136  int numA=0;
137  for (const auto& atomIn : pdbIn.atomList)
138  {
139  const auto& x = atomIn.x;
140  const auto& y = atomIn.y;
141  const auto& z = atomIn.z;
142 
143  // Correct position
144  Matrix1D<double> r(3);
145  VECTOR_R3(r, x, y, z);
146  r *= 1/Ts;
147 
148  // Characterize atom
149  double radius2=radius*radius;
150 
151  // Find the part of the volume that must be updated
152  int k0 = XMIPP_MAX(FLOOR(ZZ(r) - radius), STARTINGZ(inputVol));
153  int kF = XMIPP_MIN(CEIL(ZZ(r) + radius), FINISHINGZ(inputVol));
154  int i0 = XMIPP_MAX(FLOOR(YY(r) - radius), STARTINGY(inputVol));
155  int iF = XMIPP_MIN(CEIL(YY(r) + radius), FINISHINGY(inputVol));
156  int j0 = XMIPP_MAX(FLOOR(XX(r) - radius), STARTINGX(inputVol));
157  int jF = XMIPP_MIN(CEIL(XX(r) + radius), FINISHINGX(inputVol));
158 
159  int ka = XMIPP_MAX(FLOOR(ZZ(r)), STARTINGZ(inputVol));
160  int ia = XMIPP_MAX(FLOOR(YY(r)), STARTINGZ(inputVol));
161  int ja = XMIPP_MAX(FLOOR(XX(r)), STARTINGZ(inputVol));
162 
163 
164  float atomS=0.0;
165  float atomP=0.0;
166  float value=0.0;
167  int cont=0;
168  for (int k = k0; k <= kF; k++)
169  {
170  double zdiff=ZZ(r) - k;
171  double zdiff2=zdiff*zdiff;
172  for (int i = i0; i <= iF; i++)
173  {
174  double ydiff=YY(r) - i;
175  double zydiff2=zdiff2+ydiff*ydiff;
176  for (int j = j0; j <= jF; j++)
177  {
178  double xdiff=XX(r) - j;
179  double rdiffModule2=zydiff2+xdiff*xdiff;
180  if (withMask)
181  {
182  if ( (rdiffModule2<radius2 || (k==ka && i==ia && j==ja)) && (inputMask(k, i , j)>0.00001) )
183  {
184  atomS += A3D_ELEM(inputVol,k, i, j);
185  ++cont;
186 
187  //Absolute
188  if (A3D_ELEM(inputVol,k, i, j) < 0)
189  {
190  value = -A3D_ELEM(inputVol,k, i, j);
191  atomP += value;
192  }
193  else
194  atomP += A3D_ELEM(inputVol,k, i, j);
195 
196  }
197  }
198  else
199  {
200  if ( (rdiffModule2<radius2) || (k==ka && i==ia && j==ja))
201  {
202  atomS+=A3D_ELEM(inputVol,k, i, j);
203  ++cont;
204 
205  //Absolute
206  if (A3D_ELEM(inputVol,k, i, j) < 0)
207  {
208  value = -A3D_ELEM(inputVol,k, i, j);
209  atomP += value;
210  }
211  else
212  atomP += A3D_ELEM(inputVol,k, i, j);
213 
214  }
215  }
216 
217  }
218  }
219  }
220 
221  if (atomS>=0)
222  atomS = atomP;
223  else
224  atomS = -atomP;
225 
226  if (atomS != 0)
227  atomS=atomS/cont;
228  else
229  atomS=0.00;
230 
231  if (atomP != 0)
232  atomP=atomP/cont;
233  else
234  atomP=0.00;
235 
236 
237  ++numA;
238  suma+=atomS;
239  sumaP+=atomP;
240 
241  auto atomOut = atomIn;
242  atomOut.occupancy = atomS;
243  pdbOut.addAtom(atomOut);
244  }
245 
246  double mean = suma/numA;
247  double meanA = sumaP/numA;
248  std::cout << "mean value: = " << mean << std::endl;
249  std::cout << "absolute mean value: = " << meanA << std::endl;
250 
251  mdmean.setValue(MDL_VOLUME_SCORE1, mean, objId);
252  mdmean.setValue(MDL_VOLUME_SCORE2, meanA, objId);
253  mdmean.write(fnMD);
254 
255  pdbOut.write(fn_out);
256 }
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
#define XMIPP_MAX(x, y)
Definition: xmipp_macros.h:193
#define FINISHINGX(v)
void write(const FileName &fnPDB, const bool renumber=false)
Write rich phantom to PDB or CIF file.
Definition: pdb.cpp:872
static double * y
void write(const FileName &outFile, WriteModeMetaData mode=MD_OVERWRITE) const
#define FINISHINGZ(v)
#define STARTINGX(v)
doublereal * x
#define i
ql0001_ & k(htemp+1),(cvec+1),(atemp+1),(bj+1),(bl+1),(bu+1),(x+1),(clamda+1), &iout, infoqp, &zero,(w+1), &lenw,(iw+1), &leniw, &glob_grd.epsmac
#define STARTINGY(v)
#define A3D_ELEM(V, k, i, j)
#define FLOOR(x)
Definition: xmipp_macros.h:240
#define XX(v)
Definition: matrix1d.h:85
bool setValue(const MDObject &mdValueIn, size_t id)
#define CEIL(x)
Definition: xmipp_macros.h:225
size_t addObject() override
MultidimArray< double > inputVol
double z
#define XMIPP_MIN(x, y)
Definition: xmipp_macros.h:181
#define j
MultidimArray< double > inputMask
#define YY(v)
Definition: matrix1d.h:93
std::vector< RichAtom > atomList
List of atoms.
Definition: pdb.h:257
#define FINISHINGY(v)
#define VECTOR_R3(v, x, y, z)
Definition: matrix1d.h:124
< Score 1 for volumes
void addAtom(const RichAtom &atom)
Add Atom.
Definition: pdb.h:264
#define STARTINGZ(v)
#define ZZ(v)
Definition: matrix1d.h:101

◆ defineParams()

void ProgPdbValueToVol::defineParams ( )
virtual

Params definitions

Reimplemented from XmippProgram.

Definition at line 38 of file pdb_label_from_volume.cpp.

39 {
40  addUsageLine("Put a volume value to PDB file.");
41  addExampleLine(" xmipp_pdb_label_from_volume --pdb 1o7d.pdb --vol volume.vol -o pdb_label.pdb --sampling 1.6");
42 
43  addParamsLine(" --pdb <pdb_file> : File to process");
44  addParamsLine(" --vol <vol_file=\"\"> : Input volume");
45  addParamsLine(" [--mask <vol_file=\"\">] : Input mask (to calculate inside mask)");
46  addParamsLine(" -o <file> : Modified output PDB");
47  addParamsLine(" --sampling <Ts=1> : Sampling rate (Angstroms/pixel)");
48  addParamsLine(" [--origin <...>] : Origin of the volume --origin x y z");
49  addParamsLine(" [--radius <radius=0.8>] : Considered as radius of the atom (Angstroms)");
50  addParamsLine(" [--md <output=\"params.xmd\">] : Save mean and absolute mean output");
51 }
void addExampleLine(const char *example, bool verbatim=true)
void addUsageLine(const char *line, bool verbatim=false)
void addParamsLine(const String &line)

◆ produceSideInfo()

void ProgPdbValueToVol::produceSideInfo ( )

Produce side information. Produce the atomic profiles.

Definition at line 84 of file pdb_label_from_volume.cpp.

85 {
86  Image<double> V, M;
87  V.read(fnVol);
88  V().setXmippOrigin();
89  inputVol = V();
91 
92  if (withMask)
93  {
94  M.read(fnMask);
95  inputMask = M();
97  }
98 
99  //Origin of the volume
100  if (defOrig)
101  {
105 
109  }
110 
111  else
112  {
113  STARTINGZ(inputVol) = 0;
114  STARTINGY(inputVol) = 0;
115  STARTINGX(inputVol) = 0;
116 
117  STARTINGZ(inputMask) = 0;
118  STARTINGY(inputMask) = 0;
119  STARTINGX(inputMask) = 0;
120  }
121 
122 }
#define STARTINGX(v)
#define STARTINGY(v)
MultidimArray< double > inputVol
MultidimArray< double > inputMask
int textToInteger(const char *str)
int read(const FileName &name, DataMode datamode=DATA, size_t select_img=ALL_IMAGES, bool mapData=false, int mode=WRITE_READONLY)
#define STARTINGZ(v)

◆ readParams()

void ProgPdbValueToVol::readParams ( )
virtual

Read from a command line. An exception might be thrown by any of the internal conversions, this would mean that there is an error in the command line and you might show a usage message.

Reimplemented from XmippProgram.

Definition at line 53 of file pdb_label_from_volume.cpp.

54 {
55  fn_pdb = getParam("--pdb");
56  fnVol = getParam("--vol");
57  fnMask = getParam("--mask");
58  fn_out=getParam("-o");
59  fnMD = getParam("--md");
60  Ts = getDoubleParam("--sampling");
61  radius = getDoubleParam("--radius");
62  withMask = checkParam("--mask");
63  defOrig = checkParam("--origin");
64  getListParam("--origin", origin);
65 
66 }
double getDoubleParam(const char *param, int arg=0)
void getListParam(const char *param, StringVector &list)
const char * getParam(const char *param, int arg=0)
bool checkParam(const char *param)

◆ run()

void ProgPdbValueToVol::run ( )
virtual

Run.

Reimplemented from XmippProgram.

Definition at line 260 of file pdb_label_from_volume.cpp.

◆ show()

void ProgPdbValueToVol::show ( )

Show parameters.

Definition at line 69 of file pdb_label_from_volume.cpp.

70 {
71  if (verbose==0)
72  return;
73  std::cout << "PDB file: " << fn_pdb << std::endl
74  << "Output: " << fn_out << std::endl
75  << "Sampling rate: " << Ts << std::endl
76  << "Origin: ";
77  for (size_t i=0; i<origin.size(); ++i)
78  std::cout << origin[i] << " ";
79  std::cout << std::endl
80  << "Radius: " << radius << std::endl;
81 }
#define i
int verbose
Verbosity level.

Member Data Documentation

◆ centerOfMass

Matrix1D<double> ProgPdbValueToVol::centerOfMass

Definition at line 96 of file pdb_label_from_volume.h.

◆ defOrig

bool ProgPdbValueToVol::defOrig

Origin by user

Definition at line 52 of file pdb_label_from_volume.h.

◆ fn_out

FileName ProgPdbValueToVol::fn_out

Output fileroot

Definition at line 65 of file pdb_label_from_volume.h.

◆ fn_pdb

FileName ProgPdbValueToVol::fn_pdb

PDB file

Definition at line 58 of file pdb_label_from_volume.h.

◆ fnMask

FileName ProgPdbValueToVol::fnMask

Definition at line 61 of file pdb_label_from_volume.h.

◆ fnMD

FileName ProgPdbValueToVol::fnMD

Definition at line 65 of file pdb_label_from_volume.h.

◆ fnVol

FileName ProgPdbValueToVol::fnVol

Volume file

Definition at line 61 of file pdb_label_from_volume.h.

◆ inputMask

MultidimArray<double> ProgPdbValueToVol::inputMask

Definition at line 62 of file pdb_label_from_volume.h.

◆ inputVol

MultidimArray<double> ProgPdbValueToVol::inputVol

Definition at line 62 of file pdb_label_from_volume.h.

◆ limit

Matrix1D<double> ProgPdbValueToVol::limit

Definition at line 96 of file pdb_label_from_volume.h.

◆ M

int ProgPdbValueToVol::M

Definition at line 93 of file pdb_label_from_volume.h.

◆ origin

StringVector ProgPdbValueToVol::origin

Definition at line 49 of file pdb_label_from_volume.h.

◆ output_dim

int ProgPdbValueToVol::output_dim

Final size in pixels

Definition at line 69 of file pdb_label_from_volume.h.

◆ radius

double ProgPdbValueToVol::radius

Radius

Definition at line 46 of file pdb_label_from_volume.h.

◆ Ts

double ProgPdbValueToVol::Ts

Sampling rate

Definition at line 43 of file pdb_label_from_volume.h.

◆ withMask

bool ProgPdbValueToVol::withMask

Use Mask

Definition at line 55 of file pdb_label_from_volume.h.


The documentation for this class was generated from the following files: