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

#include <volume_from_pdb.h>

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

Public Member Functions

 ProgPdbConverter ()
 
void defineParams ()
 
void readParams ()
 
void produceSideInfo ()
 
void show ()
 
void run ()
 
void blobProperties () const
 
void atomBlobDescription (const std::string &_element, double &weight, double &radius) const
 
void computeProteinGeometry ()
 
void createProteinAtHighSamplingRate ()
 
void createProteinAtLowSamplingRate ()
 
void createProteinUsingScatteringProfiles ()
 
- 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
 
FileName fn_pdb
 
FileName fn_out
 
FileName fn_outPDB
 
struct blobtype blob
 
int output_dim_x
 
int output_dim_y
 
int output_dim_z
 
int orig_x
 
int orig_y
 
int orig_z
 
bool origGiven
 
bool useBlobs
 
bool usePoorGaussian
 
bool useFixedGaussian
 
bool doCenter
 
bool noHet
 
double sigmaGaussian
 
std::string intensityColumn
 Column for the intensity (if any). Only valid for fixed_gaussians. More...
 
int M
 
double highTs
 
Matrix2D< double > periodicTable
 
AtomInterpolator atomProfiles
 
Matrix1D< double > centerOfMass
 
Matrix1D< double > limit
 
Image< double > Vhigh
 
Image< double > Vlow
 
- 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 37 of file volume_from_pdb.h.

Constructor & Destructor Documentation

◆ ProgPdbConverter()

ProgPdbConverter::ProgPdbConverter ( )

Empty constructor

Definition at line 35 of file volume_from_pdb.cpp.

36 {
37  blob.radius = 2; // Blob radius in voxels
38  blob.order = 2; // Order of the Bessel function
39  blob.alpha = 3.6; // Smoothness parameter
40  output_dim_x = -1;
41  output_dim_y = -1;
42  output_dim_z = -1;
43 
44  fn_pdb = "";
45  Ts = 1;
46  highTs = 1.0/12.0;
47  useBlobs=false;
48  usePoorGaussian=false;
49  useFixedGaussian=false;
50  doCenter=false;
51  noHet=false;
52 
53  // Periodic table for the blobs
54  periodicTable.resize(12, 2);
55  periodicTable(0, 0) = atomRadius("H");
56  periodicTable(0, 1) = atomCharge("H");
57  periodicTable(1, 0) = atomRadius("C");
58  periodicTable(1, 1) = atomCharge("C");
59  periodicTable(2, 0) = atomRadius("N");
60  periodicTable(2, 1) = atomCharge("N");
61  periodicTable(3, 0) = atomRadius("O");
62  periodicTable(3, 1) = atomCharge("O");
63  periodicTable(4, 0) = atomRadius("P");
64  periodicTable(4, 1) = atomCharge("P");
65  periodicTable(5, 0) = atomRadius("S");
66  periodicTable(5, 1) = atomCharge("S");
67  periodicTable(6, 0) = atomRadius("Fe");
68  periodicTable(6, 1) = atomCharge("Fe");
69  periodicTable(7, 0) = atomRadius("K");
70  periodicTable(7, 1) = atomCharge("K");
71  periodicTable(8, 0) = atomRadius("F");
72  periodicTable(8, 1) = atomCharge("F");
73  periodicTable(9, 0) = atomRadius("Mg");
74  periodicTable(9, 1) = atomCharge("Mg");
75  periodicTable(10, 0) = atomRadius("Cl");
76  periodicTable(10, 1) = atomCharge("Cl");
77  periodicTable(11, 0) = atomRadius("Ca");
78  periodicTable(11, 1) = atomCharge("Ca");
79 
80  // Correct the atom weights by the blob weight
81  for (size_t i = 0; i < MAT_YSIZE(periodicTable); i++)
82  {
83  periodicTable(i, 1) /=
85  }
86 }
struct blobtype blob
#define MAT_YSIZE(m)
Definition: matrix2d.h:124
double alpha
Smoothness parameter.
Definition: blobs.h:121
#define i
int atomCharge(const std::string &atom)
Definition: pdb.cpp:122
double atomRadius(const std::string &atom)
Definition: pdb.cpp:168
int order
Derivation order and Bessel function order.
Definition: blobs.h:118
Matrix2D< double > periodicTable
double radius
Spatial radius in Universal System units.
Definition: blobs.h:115
void resize(size_t Ydim, size_t Xdim, bool noCopy=false)
Definition: matrix2d.cpp:1022
double basvolume(double a, double alpha, int m, int n)
Definition: blobs.cpp:215

Member Function Documentation

◆ atomBlobDescription()

void ProgPdbConverter::atomBlobDescription ( const std::string &  _element,
double &  weight,
double &  radius 
) const

Definition at line 129 of file volume_from_pdb.cpp.

131 {
132  int idx = -1;
133  weight = radius = 0;
134  switch (_element[0])
135  {
136  case 'H':
137  idx = 0;
138  break;
139  case 'C':
140  idx = 1;
141  break;
142  case 'N':
143  idx = 2;
144  break;
145  case 'O':
146  idx = 3;
147  break;
148  case 'P':
149  idx = 4;
150  break;
151  case 'S':
152  idx = 5;
153  break;
154  case 'E': //iron Fe
155  idx = 6;
156  break;
157  case 'K':
158  idx = 7;
159  break;
160  case 'F':
161  idx = 8;
162  break;
163  case 'G': // Magnesium Mg
164  idx = 9;
165  break;
166  case 'L': // Chlorine Cl
167  idx = 10;
168  break;
169  case 'A': // Calcium Ca
170  idx = 11;
171  break;
172  default:
173  if (verbose>0)
174  std::cout << "Unknown :" << _element << std::endl;
175  return;
176  }
177  radius = periodicTable(idx, 0);
178  weight = periodicTable(idx, 1);
179 }
int verbose
Verbosity level.
Matrix2D< double > periodicTable

◆ blobProperties()

void ProgPdbConverter::blobProperties ( ) const

Definition at line 437 of file volume_from_pdb.cpp.

438 {
439  std::ofstream fh_out;
440  fh_out.open((fn_out + "_Fourier_profile.txt").c_str());
441  if (!fh_out)
443  fh_out << "# Freq(1/A) 10*log10(|Blob(f)|^2) Ts=" << highTs << std::endl;
444 
445 
446  for(double w=0; w < 1.0 / (2*highTs); w += 1.0 / (highTs * 500))
447  {
448  double H = kaiser_Fourier_value(w * highTs, periodicTable(0, 0) / highTs,
449  blob.alpha, blob.order);
450  fh_out << w << " " << 10*log10(H*H) << std::endl;
451  }
452  fh_out.close();
453 }
struct blobtype blob
double alpha
Smoothness parameter.
Definition: blobs.h:121
#define REPORT_ERROR(nerr, ErrormMsg)
Definition: xmipp_error.h:211
Couldn&#39;t write to file.
Definition: xmipp_error.h:140
doublereal * w
void log10(Image< double > &op)
double kaiser_Fourier_value(double w, double a, double alpha, int m)
Definition: blobs.cpp:144
int order
Derivation order and Bessel function order.
Definition: blobs.h:118
Matrix2D< double > periodicTable

◆ computeProteinGeometry()

void ProgPdbConverter::computeProteinGeometry ( )

Definition at line 261 of file volume_from_pdb.cpp.

262 {
263  Matrix1D<double> limit0(3), limitF(3);
265  if (doCenter)
266  {
267  limit0-=centerOfMass;
268  limitF-=centerOfMass;
269  }
270  limit.resize(3);
271  XX(limit) = XMIPP_MAX(ABS(XX(limit0)), ABS(XX(limitF)));
272  YY(limit) = XMIPP_MAX(ABS(YY(limit0)), ABS(YY(limitF)));
273  ZZ(limit) = XMIPP_MAX(ABS(ZZ(limit0)), ABS(ZZ(limitF)));
274 
275  // Update output size if necessary
276  if (output_dim_x == -1)
277  {
278  int max_dim = XMIPP_MAX(CEIL(ZZ(limit) * 2 / Ts) + 5, CEIL(YY(limit) * 2 / Ts) + 5);
279  max_dim = XMIPP_MAX(max_dim, CEIL(XX(limit) * 2 / Ts) + 5);
280  if (useBlobs)
281  {
282  output_dim_x = (int)NEXT_POWER_OF_2(max_dim);
285  }
286  else
287  {
288  output_dim_x = max_dim+10;
291  }
292  }
293  else
294  {
295  if (output_dim_y == -1)
296  {
299  }
300  }
301 }
#define XMIPP_MAX(x, y)
Definition: xmipp_macros.h:193
std::string intensityColumn
Column for the intensity (if any). Only valid for fixed_gaussians.
#define XX(v)
Definition: matrix1d.h:85
#define CEIL(x)
Definition: xmipp_macros.h:225
void resize(size_t Xdim, bool copy=true)
Definition: matrix1d.h:410
void computePDBgeometry(const std::string &fnPDB, Matrix1D< double > &centerOfMass, Matrix1D< double > &limit0, Matrix1D< double > &limitF, const std::string &intensityColumn)
Definition: pdb.cpp:238
Matrix1D< double > centerOfMass
#define ABS(x)
Definition: xmipp_macros.h:142
#define NEXT_POWER_OF_2(x)
Definition: xmipp_macros.h:374
#define YY(v)
Definition: matrix1d.h:93
Matrix1D< double > limit
#define ZZ(v)
Definition: matrix1d.h:101

◆ createProteinAtHighSamplingRate()

void ProgPdbConverter::createProteinAtHighSamplingRate ( )

Definition at line 304 of file volume_from_pdb.cpp.

305 {
306  // Create an empty volume to hold the protein
307  int finalDim_x, finalDim_y, finalDim_z;
308  if (highTs!=Ts)
309  {
310  finalDim_x=(int)NEXT_POWER_OF_2(output_dim_x / (highTs/Ts));
311  finalDim_y=(int)NEXT_POWER_OF_2(output_dim_y / (highTs/Ts));
312  finalDim_z=(int)NEXT_POWER_OF_2(output_dim_z / (highTs/Ts));
313  }
314  else
315  {
316  finalDim_x=output_dim_x;
317  finalDim_y=output_dim_y;
318  finalDim_z=output_dim_z;
319  }
320  Vhigh().initZeros(finalDim_x,finalDim_y,finalDim_z);
321  if (!origGiven)
322  Vhigh().setXmippOrigin();
323  else
324  {
325  STARTINGX(Vhigh()) = orig_x;
326  STARTINGY(Vhigh()) = orig_y;
327  STARTINGZ(Vhigh()) = orig_z;
328  }
329  if (verbose)
330  std::cout << "The highly sampled volume is of size " << XSIZE(Vhigh())
331  << std::endl;
332  std::cout << "Size: "; Vhigh().printShape(); std::cout << std::endl;
333 
334  // Declare centered PDB
335  PDBRichPhantom centered_pdb;
336 
337  // Read centered pdb
338  centered_pdb.read(fn_pdb.c_str());
339 
340  Matrix1D<double> r(3);
341  bool useBFactor = intensityColumn=="Bfactor";
342  // Iterate the list of atoms modifying data if needed
343  for (auto& atom : centered_pdb.atomList) {
344  if (doCenter) {
345  atom.x -= XX(centerOfMass);
346  atom.y -= YY(centerOfMass);
347  atom.z -= ZZ(centerOfMass);
348  }
349  VECTOR_R3(r, atom.x, atom.y, atom.z);
350  r /= highTs;
351 
352  // Characterize atom
353  double weight, radius;
354  if (!useFixedGaussian)
355  {
356  if (noHet && atom.record == "HETATM")
357  continue;
358  atomBlobDescription(atom.atomType, weight, radius);
359  }
360  else
361  {
362  radius=4.5*sigmaGaussian;
363  if (useBFactor)
364  weight=atom.bfactor;
365  else
366  weight=atom.occupancy;
367  }
368  blob.radius = radius;
369  if (usePoorGaussian)
370  radius=XMIPP_MAX(radius/Ts,4.5);
371  double GaussianSigma2=(radius/(3*sqrt(2.0)));
372  if (useFixedGaussian)
373  GaussianSigma2=sigmaGaussian;
374  GaussianSigma2*=GaussianSigma2;
375  double GaussianNormalization = 1.0/pow(2*PI*GaussianSigma2,1.5);
376 
377  // Find the part of the volume that must be updated
378  int k0 = XMIPP_MAX(FLOOR(ZZ(r) - radius), STARTINGZ(Vhigh()));
379  int kF = XMIPP_MIN(CEIL(ZZ(r) + radius), FINISHINGZ(Vhigh()));
380  int i0 = XMIPP_MAX(FLOOR(YY(r) - radius), STARTINGY(Vhigh()));
381  int iF = XMIPP_MIN(CEIL(YY(r) + radius), FINISHINGY(Vhigh()));
382  int j0 = XMIPP_MAX(FLOOR(XX(r) - radius), STARTINGX(Vhigh()));
383  int jF = XMIPP_MIN(CEIL(XX(r) + radius), FINISHINGX(Vhigh()));
384 
385  // Fill the volume with this atom
386  Matrix1D<double> rdiff(3);
387  for (int k = k0; k <= kF; k++)
388  for (int i = i0; i <= iF; i++)
389  for (int j = j0; j <= jF; j++)
390  {
391  VECTOR_R3(rdiff, XX(r) - j, YY(r) - i, ZZ(r) - k);
392  rdiff*=highTs;
393  if (useBlobs)
394  Vhigh(k, i, j) += weight * blob_val(rdiff.module(), blob);
395  else if (usePoorGaussian || useFixedGaussian)
396  Vhigh(k, i, j) += weight *
397  exp(-rdiff.module()*rdiff.module()/(2*GaussianSigma2))*
398  GaussianNormalization;
399  }
400  }
401 
402  // Save centered PDB
403  if (doCenter && !fn_outPDB.empty())
404  {
405  centered_pdb.write(fn_outPDB);
406  }
407 }
struct blobtype blob
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
void atomBlobDescription(const std::string &_element, double &weight, double &radius) const
void sqrt(Image< double > &op)
#define FINISHINGZ(v)
std::string intensityColumn
Column for the intensity (if any). Only valid for fixed_gaussians.
#define STARTINGX(v)
#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 FLOOR(x)
Definition: xmipp_macros.h:240
#define XX(v)
Definition: matrix1d.h:85
#define CEIL(x)
Definition: xmipp_macros.h:225
#define XSIZE(v)
Matrix1D< double > centerOfMass
int verbose
Verbosity level.
#define XMIPP_MIN(x, y)
Definition: xmipp_macros.h:181
#define NEXT_POWER_OF_2(x)
Definition: xmipp_macros.h:374
#define j
#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
#define blob_val(r, blob)
Definition: blobs.h:139
#define PI
Definition: tools.h:43
Image< double > Vhigh
#define STARTINGZ(v)
double radius
Spatial radius in Universal System units.
Definition: blobs.h:115
#define ZZ(v)
Definition: matrix1d.h:101

◆ createProteinAtLowSamplingRate()

void ProgPdbConverter::createProteinAtLowSamplingRate ( )

Definition at line 410 of file volume_from_pdb.cpp.

411 {
412  // Compute the integer downsapling factor
413  int M = FLOOR(Ts / highTs);
414  double current_Ts = highTs;
415 
416  // Use Bsplines pyramid if possible
417  int levels = FLOOR(log10((double)M) / log10(2.0) + XMIPP_EQUAL_ACCURACY);
419  current_Ts *= pow(2.0, levels);
420  Vhigh.clear();
421 
422  // Now scale using Bsplines
423  int new_output_dim = CEIL(XSIZE(Vlow()) * current_Ts / Ts);
425  new_output_dim, new_output_dim, new_output_dim);
426  Vlow() = Vhigh();
427  if (!origGiven)
428  Vlow().setXmippOrigin();
429 
430  // Return to the desired size
434 }
void pyramidReduce(int SplineDegree, MultidimArrayGeneric &V2, const MultidimArrayGeneric &V1, int levels)
Image< double > Vlow
#define FLOOR(x)
Definition: xmipp_macros.h:240
#define CEIL(x)
Definition: xmipp_macros.h:225
#define XMIPP_EQUAL_ACCURACY
Definition: xmipp_macros.h:119
#define XSIZE(v)
void log10(Image< double > &op)
void scaleToSize(int SplineDegree, MultidimArrayGeneric &V2, const MultidimArrayGeneric &V1, int Xdim, int Ydim, int Zdim)
#define FIRST_XMIPP_INDEX(size)
Definition: xmipp_macros.h:439
#define LAST_XMIPP_INDEX(size)
Definition: xmipp_macros.h:448
Image< double > Vhigh
void clear()
Definition: xmipp_image.h:144

◆ createProteinUsingScatteringProfiles()

void ProgPdbConverter::createProteinUsingScatteringProfiles ( )

Definition at line 456 of file volume_from_pdb.cpp.

457 {
458  // Create an empty volume to hold the protein
460  if (!origGiven) {
461  Vlow().setXmippOrigin();
462  }
463  else
464  {
465  STARTINGX(Vlow()) = orig_x;
466  STARTINGY(Vlow()) = orig_y;
467  STARTINGZ(Vlow()) = orig_z;
468  }
469 
470  //Save centered PDB
471  PDBRichPhantom centered_pdb;
472 
473  // Read centered pdb
474  centered_pdb.read(fn_pdb.c_str());
475 
476  Matrix1D<double> r(3);
477  bool useBFactor = intensityColumn=="Bfactor";
478  // Iterate the list of atoms modifying data if needed
479  for (auto& atom : centered_pdb.atomList) {
480  // Check if heteroatoms are allowed and current atom is one of them
481  if (noHet && atom.record == "HETATM")
482  continue;
483 
484  if (doCenter) {
485  atom.x -= XX(centerOfMass);
486  atom.y -= YY(centerOfMass);
487  atom.z -= ZZ(centerOfMass);
488  }
489  VECTOR_R3(r, atom.x, atom.y, atom.z);
490  r /= Ts;
491 
492  // Characterize atom
493  try
494  {
495  double radius=atomProfiles.atomRadius(atom.atomType[0]);
496  double radius2=radius*radius;
497 
498  // Find the part of the volume that must be updated
499  const MultidimArray<double> &mVlow=Vlow();
500  int k0 = XMIPP_MAX(FLOOR(ZZ(r) - radius), STARTINGZ(mVlow));
501  int kF = XMIPP_MIN(CEIL(ZZ(r) + radius), FINISHINGZ(mVlow));
502  int i0 = XMIPP_MAX(FLOOR(YY(r) - radius), STARTINGY(mVlow));
503  int iF = XMIPP_MIN(CEIL(YY(r) + radius), FINISHINGY(mVlow));
504  int j0 = XMIPP_MAX(FLOOR(XX(r) - radius), STARTINGX(mVlow));
505  int jF = XMIPP_MIN(CEIL(XX(r) + radius), FINISHINGX(mVlow));
506 
507  // Fill the volume with this atom
508  for (int k = k0; k <= kF; k++)
509  {
510  double zdiff=ZZ(r) - k;
511  double zdiff2=zdiff*zdiff;
512  for (int i = i0; i <= iF; i++)
513  {
514  double ydiff=YY(r) - i;
515  double zydiff2=zdiff2+ydiff*ydiff;
516  for (int j = j0; j <= jF; j++)
517  {
518  double xdiff=XX(r) - j;
519  double rdiffModule2=zydiff2+xdiff*xdiff;
520  if (rdiffModule2<radius2)
521  {
522  double rdiffModule=sqrt(rdiffModule2);
524  atom.atomType[0],rdiffModule);
525  }
526  }
527  }
528  }
529  }
530  catch (XmippError XE)
531  {
532  if (verbose)
533  std::cerr << "Ignoring atom of type *" << atom.atomType << "*" << std::endl;
534  }
535  }
536 
537  // Save centered PDB
538  if (doCenter && !fn_outPDB.empty())
539  {
540  centered_pdb.write(fn_outPDB);
541  }
542 }
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
void sqrt(Image< double > &op)
#define FINISHINGZ(v)
std::string intensityColumn
Column for the intensity (if any). Only valid for fixed_gaussians.
#define STARTINGX(v)
#define i
Image< double > Vlow
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
#define CEIL(x)
Definition: xmipp_macros.h:225
Matrix1D< double > centerOfMass
int verbose
Verbosity level.
#define XMIPP_MIN(x, y)
Definition: xmipp_macros.h:181
#define j
#define YY(v)
Definition: matrix1d.h:93
AtomInterpolator atomProfiles
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
double volumeAtDistance(char atom, double r) const
Definition: pdb.cpp:101
double atomRadius(char atom) const
Definition: pdb.h:414
#define STARTINGZ(v)
#define ZZ(v)
Definition: matrix1d.h:101

◆ defineParams()

void ProgPdbConverter::defineParams ( )
virtual

Params definitions

Reimplemented from XmippProgram.

Definition at line 181 of file volume_from_pdb.cpp.

182 {
183  addUsageLine("Covert a PDB file to a volume.");
184  addExampleLine("Sample at 1.6A and limit the frequency to 10A",false);
185  addExampleLine(" xmipp_volume_from_pdb -i 1o7d.pdb --sampling 1.6");
186  addExampleLine(" xmipp_transform_filter -i 1o7d.vol -o 1o7dFiltered.vol --fourier low_pass 10 raised_cosine 0.05 --sampling 1.6");
187 
188  addParamsLine(" -i <pdb_file> : File to process");
189  addParamsLine(" [-o <fn_root>] : Root name for output");
190  addParamsLine(" [--sampling <Ts=1>] : Sampling rate (Angstroms/pixel)");
191  addParamsLine(" [--high_sampling_rate <highTs=0.08333333>]: Sampling rate before downsampling");
192  addParamsLine(" [--size <output_dim_x=-1> <output_dim_y=-1> <output_dim_z=-1>]: Final size in pixels (must be a power of 2, if blobs are used)");
193  addParamsLine(" [--orig <orig_x=0> <orig_y=0> <orig_z=0>]: Define origin of the output volume");
194  addParamsLine(" : If just one dimension is introduced dim_x = dim_y = dim_z");
195  addParamsLine(" [--centerPDB] : Center PDB with the center of mass");
196  addParamsLine(" [--oPDB] : Save centered PDB");
197  addParamsLine(" [--noHet] : Heteroatoms are not converted");
198  addParamsLine(" [--blobs] : Use blobs instead of scattering factors");
199  addParamsLine(" [--poor_Gaussian] : Use a simple Gaussian adapted to each atom");
200  addParamsLine(" [--fixed_Gaussian <std=-1>] : Use a fixed Gausian for each atom with");
201  addParamsLine(" : this standard deviation");
202  addParamsLine(" : If not given, the standard deviation is taken from the PDB file");
203  addParamsLine(" [--intensityColumn <intensity_type=occupancy>] : Where to write the intensity in the PDB file");
204  addParamsLine(" where <intensity_type> occupancy Bfactor : Valid values: occupancy, Bfactor");
205 }
void addExampleLine(const char *example, bool verbatim=true)
void addUsageLine(const char *line, bool verbatim=false)
void addParamsLine(const String &line)

◆ produceSideInfo()

void ProgPdbConverter::produceSideInfo ( )

Produce side information. Produce the atomic profiles.

Definition at line 89 of file volume_from_pdb.cpp.

90 {
92  {
93  // Check if it is a pseudodensity volume
94  std::ifstream fh_pdb;
95  fh_pdb.open(fn_pdb.c_str());
96  if (!fh_pdb)
98  while (!fh_pdb.eof())
99  {
100  // Read an ATOM line
101  std::string line;
102  getline(fh_pdb, line);
103  if (line == "")
104  continue;
105  std::string kind = line.substr(0,6);
106  if (kind!="REMARK")
107  continue;
108  std::vector< std::string > results;
109  splitString(line," ",results);
110  if (useFixedGaussian && results[1]=="fixedGaussian")
111  sigmaGaussian=textToFloat(results[2]);
112  if (useFixedGaussian && results[1]=="intensityColumn")
113  intensityColumn=results[2];
114  }
115  fh_pdb.close();
116  }
117 
119  {
120  // Compute the downsampling factor
121  M=(int)ROUND(Ts/highTs);
122 
123  // Atom profiles for the electron scattering method
124  atomProfiles.setup(M,highTs,false);
125  }
126 }
#define REPORT_ERROR(nerr, ErrormMsg)
Definition: xmipp_error.h:211
std::string intensityColumn
Column for the intensity (if any). Only valid for fixed_gaussians.
void setup(int m, double hights, bool computeProjection=false)
Definition: pdb.cpp:1402
float textToFloat(const char *str)
int splitString(const String &input, const String &delimiter, StringVector &results, bool includeEmpties)
#define ROUND(x)
Definition: xmipp_macros.h:210
File or directory does not exist.
Definition: xmipp_error.h:136
AtomInterpolator atomProfiles

◆ readParams()

void ProgPdbConverter::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 207 of file volume_from_pdb.cpp.

208 {
209  fn_pdb = getParam("-i");
210  fn_out = checkParam("-o") ? getParam("-o") : fn_pdb.withoutExtension();
211  Ts = getDoubleParam("--sampling");
212  highTs = getDoubleParam("--high_sampling_rate");
213  output_dim_x = getIntParam("--size", 0);
214  output_dim_y = getIntParam("--size", 1);
215  output_dim_z = getIntParam("--size", 2);
216  if (checkParam("--orig"))
217  {
218  orig_x = getIntParam("--orig", 0);
219  orig_y = getIntParam("--orig", 1);
220  orig_z = getIntParam("--orig", 2);
221  origGiven=true;
222  }
223  else
224  {
225  origGiven=false;
226  orig_x=orig_y=orig_z=0;
227  }
228  useBlobs = checkParam("--blobs");
229  usePoorGaussian = checkParam("--poor_Gaussian");
230  useFixedGaussian = checkParam("--fixed_Gaussian");
231  if (useFixedGaussian)
232  sigmaGaussian = getDoubleParam("--fixed_Gaussian");
233  doCenter = checkParam("--centerPDB");
234  fn_outPDB = checkParam("--oPDB") ? (fn_out + "_centered.pdb") : FileName();
235  noHet = checkParam("--noHet");
236  intensityColumn = getParam("--intensityColumn");
237 }
double getDoubleParam(const char *param, int arg=0)
std::string intensityColumn
Column for the intensity (if any). Only valid for fixed_gaussians.
const char * getParam(const char *param, int arg=0)
bool checkParam(const char *param)
int getIntParam(const char *param, int arg=0)

◆ run()

void ProgPdbConverter::run ( )
virtual

Run.

Reimplemented from XmippProgram.

Definition at line 545 of file volume_from_pdb.cpp.

546 {
547  produceSideInfo();
548  show();
550  if (useBlobs)
551  {
554  blobProperties();
555  }
556  else if (usePoorGaussian || useFixedGaussian)
557  {
558  highTs=Ts;
560  Vlow=Vhigh;
561  Vhigh.clear();
562  }
563  else
564  {
566  }
567  if (Vlow().sum()<0)
568  REPORT_ERROR(ERR_NUMERICAL,"The output volume has a negative average. This could be caused by a too large voxel size.");
569  if (fn_out!="")
570  Vlow.write(fn_out + ".vol");
571 }
#define REPORT_ERROR(nerr, ErrormMsg)
Definition: xmipp_error.h:211
void write(const FileName &name="", size_t select_img=ALL_IMAGES, bool isStack=false, int mode=WRITE_OVERWRITE, CastWriteMode castMode=CW_CAST, int _swapWrite=0)
void createProteinAtLowSamplingRate()
Image< double > Vlow
Error related to numerical calculation.
Definition: xmipp_error.h:179
void createProteinUsingScatteringProfiles()
void createProteinAtHighSamplingRate()
void blobProperties() const
Image< double > Vhigh
void clear()
Definition: xmipp_image.h:144

◆ show()

void ProgPdbConverter::show ( )

Show parameters.

Definition at line 240 of file volume_from_pdb.cpp.

241 {
242  if (verbose==0)
243  return;
244  std::cout << "PDB file: " << fn_pdb << std::endl
245  << "Sampling rate: " << Ts << std::endl
246  << "High sampling rate: " << highTs << std::endl
247  << "Size: " << output_dim_x << " " << output_dim_y << " " << output_dim_z << std::endl
248  << "Origin: " << orig_x << " " << orig_y << " " << orig_z << std::endl
249  << "Center PDB: " << doCenter << std::endl
250  << "Do not Hetatm: " << noHet << std::endl
251  << "Use blobs: " << useBlobs << std::endl
252  << "Use poor Gaussian: " << usePoorGaussian << std::endl
253  << "Use fixed Gaussian: " << useFixedGaussian << std::endl
254  ;
255  if (useFixedGaussian)
256  std::cout << "Intensity Col: " << intensityColumn << std::endl
257  << "Sigma: " << sigmaGaussian << std::endl;
258 }
std::string intensityColumn
Column for the intensity (if any). Only valid for fixed_gaussians.
int verbose
Verbosity level.

Member Data Documentation

◆ atomProfiles

AtomInterpolator ProgPdbConverter::atomProfiles

Definition at line 114 of file volume_from_pdb.h.

◆ blob

struct blobtype ProgPdbConverter::blob

Blob

Definition at line 53 of file volume_from_pdb.h.

◆ centerOfMass

Matrix1D<double> ProgPdbConverter::centerOfMass

Definition at line 117 of file volume_from_pdb.h.

◆ doCenter

bool ProgPdbConverter::doCenter

Center the PDB

Definition at line 71 of file volume_from_pdb.h.

◆ fn_out

FileName ProgPdbConverter::fn_out

Output fileroot

Definition at line 47 of file volume_from_pdb.h.

◆ fn_outPDB

FileName ProgPdbConverter::fn_outPDB

Output file for centered PDB

Definition at line 50 of file volume_from_pdb.h.

◆ fn_pdb

FileName ProgPdbConverter::fn_pdb

PDB file

Definition at line 44 of file volume_from_pdb.h.

◆ highTs

double ProgPdbConverter::highTs

Definition at line 107 of file volume_from_pdb.h.

◆ intensityColumn

std::string ProgPdbConverter::intensityColumn

Column for the intensity (if any). Only valid for fixed_gaussians.

Definition at line 80 of file volume_from_pdb.h.

◆ limit

Matrix1D<double> ProgPdbConverter::limit

Definition at line 117 of file volume_from_pdb.h.

◆ M

int ProgPdbConverter::M

Definition at line 104 of file volume_from_pdb.h.

◆ noHet

bool ProgPdbConverter::noHet

not HETATM

Definition at line 74 of file volume_from_pdb.h.

◆ orig_x

int ProgPdbConverter::orig_x

Definition at line 56 of file volume_from_pdb.h.

◆ orig_y

int ProgPdbConverter::orig_y

Definition at line 56 of file volume_from_pdb.h.

◆ orig_z

int ProgPdbConverter::orig_z

Definition at line 56 of file volume_from_pdb.h.

◆ origGiven

bool ProgPdbConverter::origGiven

Orig is set

Definition at line 59 of file volume_from_pdb.h.

◆ output_dim_x

int ProgPdbConverter::output_dim_x

Final size and origin in pixels

Definition at line 56 of file volume_from_pdb.h.

◆ output_dim_y

int ProgPdbConverter::output_dim_y

Definition at line 56 of file volume_from_pdb.h.

◆ output_dim_z

int ProgPdbConverter::output_dim_z

Definition at line 56 of file volume_from_pdb.h.

◆ periodicTable

Matrix2D<double> ProgPdbConverter::periodicTable

Definition at line 111 of file volume_from_pdb.h.

◆ sigmaGaussian

double ProgPdbConverter::sigmaGaussian

Fixed Gaussian standard deviation

Definition at line 77 of file volume_from_pdb.h.

◆ Ts

double ProgPdbConverter::Ts

Sampling rate

Definition at line 41 of file volume_from_pdb.h.

◆ useBlobs

bool ProgPdbConverter::useBlobs

Use blobs instead of scattering factors

Definition at line 62 of file volume_from_pdb.h.

◆ useFixedGaussian

bool ProgPdbConverter::useFixedGaussian

Use fixed Gaussian instead of scattering factors

Definition at line 68 of file volume_from_pdb.h.

◆ usePoorGaussian

bool ProgPdbConverter::usePoorGaussian

Use poor Gaussian instead of scattering factors

Definition at line 65 of file volume_from_pdb.h.

◆ Vhigh

Image<double> ProgPdbConverter::Vhigh

Definition at line 121 of file volume_from_pdb.h.

◆ Vlow

Image<double> ProgPdbConverter::Vlow

Definition at line 124 of file volume_from_pdb.h.


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