Xmipp  v3.23.11-Nereus
Public Member Functions | List of all members
ProgPdbSphDeform Class Reference

#include <pdb_sph_deform.h>

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

Public Member Functions

void defineParams () override
 
void readParams () override
 
void show () const override
 
void run () override
 
std::string readNthLine (int N) const
 
std::vector< double > string2vector (std::string const &s) const
 
void fillVectorTerms ()
 
void centerOfMass (PDBRichPhantom pdb, Matrix1D< double > &cm)
 
- 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 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 ()
 

Additional Inherited Members

- Public Attributes inherited from XmippProgram
bool doRun
 
bool runWithoutArgs
 
int verbose
 Verbosity level. More...
 
int debug
 
- 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

Definition at line 33 of file pdb_sph_deform.h.

Member Function Documentation

◆ centerOfMass()

void ProgPdbSphDeform::centerOfMass ( PDBRichPhantom  pdb,
Matrix1D< double > &  cm 
)

Compute center of mass of the PDB file

Definition at line 182 of file pdb_sph_deform.cpp.

183 {
184  size_t numAtoms = pdb.getNumberOfAtoms();
185  for (size_t a=0; a<numAtoms; a++)
186  {
187  RichAtom& atom_i=pdb.atomList[a];
188  auto z = atom_i.z;
189  auto y = atom_i.y;
190  auto x = atom_i.x;
191  VEC_ELEM(cm, 0) += x;
192  VEC_ELEM(cm, 1) += y;
193  VEC_ELEM(cm, 2) += z;
194 
195  }
196  VEC_ELEM(cm, 0) /= numAtoms;
197  VEC_ELEM(cm, 1) /= numAtoms;
198  VEC_ELEM(cm, 2) /= numAtoms;
199 }
#define VEC_ELEM(v, i)
Definition: matrix1d.h:245
static double * y
Definition: pdb.h:174
doublereal * x
double y
Position Y.
Definition: pdb.h:187
double z
double x
Position X.
Definition: pdb.h:184
std::vector< RichAtom > atomList
List of atoms.
Definition: pdb.h:257
size_t getNumberOfAtoms() const
Get number of atoms.
Definition: pdb.h:270
doublereal * a
double z
Position Z.
Definition: pdb.h:190

◆ defineParams()

void ProgPdbSphDeform::defineParams ( )
overridevirtual

Params definitions

Reimplemented from XmippProgram.

Definition at line 30 of file pdb_sph_deform.cpp.

31 {
32  addUsageLine("Deform a PDB according to a list of SPH deformation coefficients");
33  addParamsLine("--pdb <file> : PDB to deform");
34  addParamsLine("--clnm <metadata_file> : List of deformation coefficients");
35  addParamsLine("-o <file> : Deformed PDB");
36  addParamsLine("[--center_mass] : Center the PDB according with its center of mass");
37  addParamsLine("[--boxsize <b=0> ] : Box size of the volume where the PDB was fitted");
38  addParamsLine("[--sr <s=1> ] : Sampling rate of the volume where the PDB was fitted");
39  addExampleLine("xmipp_pdb_sph_deform --pdb 2tbv.pdb -o 2tbv_deformed.pdb --clnm coefficients.txt");
40 }
void addExampleLine(const char *example, bool verbatim=true)
void addUsageLine(const char *line, bool verbatim=false)
void addParamsLine(const String &line)

◆ fillVectorTerms()

void ProgPdbSphDeform::fillVectorTerms ( )

Fill degree and order vectors

Definition at line 156 of file pdb_sph_deform.cpp.

157 {
158  int idx = 0;
159  auto vecSize = (int)(clnm.size()/3);
160  vL1.initZeros(vecSize);
161  vN.initZeros(vecSize);
162  vL2.initZeros(vecSize);
163  vM.initZeros(vecSize);
164  for (int h=0; h<=basisParams[1]; h++)
165  {
166  int totalSPH = 2*h+1;
167  auto aux = (int)(std::floor(totalSPH/2));
168  for (int l=h; l<=basisParams[0]; l+=2)
169  {
170  for (int m=0; m<totalSPH; m++)
171  {
172  VEC_ELEM(vL1,idx) = l;
173  VEC_ELEM(vN,idx) = h;
174  VEC_ELEM(vL2,idx) = h;
175  VEC_ELEM(vM,idx) = m-aux;
176  idx++;
177  }
178  }
179  }
180 }
#define VEC_ELEM(v, i)
Definition: matrix1d.h:245
__host__ __device__ float2 floor(const float2 v)
void initZeros()
Definition: matrix1d.h:592
int m

◆ readNthLine()

std::string ProgPdbSphDeform::readNthLine ( int  N) const

Read Nth line of file

Definition at line 133 of file pdb_sph_deform.cpp.

134 {
135  std::ifstream in(fn_sph.getString());
136  std::string s;
137 
138  //skip N lines
139  for(int i = 0; i < N; ++i)
140  std::getline(in, s);
141 
142  std::getline(in,s);
143  return s;
144 }
#define i
int in
String getString() const

◆ readParams()

void ProgPdbSphDeform::readParams ( )
overridevirtual

Read from a command line.

Reimplemented from XmippProgram.

Definition at line 42 of file pdb_sph_deform.cpp.

43 {
44  fn_pdb = getParam("--pdb");
45  fn_sph = getParam("--clnm");
46  fn_out = getParam("-o");
47  center = checkParam("--center_mass");
48  boxSize= 0.5 * getDoubleParam("--boxsize") * getDoubleParam("--sr");
49 }
double getDoubleParam(const char *param, int arg=0)
const char * getParam(const char *param, int arg=0)
bool checkParam(const char *param)

◆ run()

void ProgPdbSphDeform::run ( )
overridevirtual

Run.

Reimplemented from XmippProgram.

Definition at line 62 of file pdb_sph_deform.cpp.

63 {
64  PDBRichPhantom pdb;
65  pdb.read(fn_pdb);
66  std::string line;
67  line = readNthLine(0);
68  basisParams = string2vector(line);
69  line = readNthLine(1);
70  clnm = string2vector(line);
72  size_t idxY0=clnm.size()/3;
73  size_t idxZ0=2*idxY0;
75  cm.initZeros(3);
76  centerOfMass(pdb, cm);
77  for (size_t a=0; a<pdb.getNumberOfAtoms(); a++)
78  {
79  double gx=0.0;
80  double gy=0.0;
81  double gz=0.0;
82  RichAtom& atom_i=pdb.atomList[a];
83  auto k = atom_i.z;
84  auto i = atom_i.y;
85  auto j = atom_i.x;
86  if (center)
87  {
88  k -= VEC_ELEM(cm, 2);
89  i -= VEC_ELEM(cm, 1);
90  j -= VEC_ELEM(cm, 0);
91  }
92  else
93  {
94  k -= boxSize;
95  i -= boxSize;
96  j -= boxSize;
97  }
98  for (size_t idx=0; idx<idxY0; idx++)
99  {
100  double Rmax=basisParams[2];
101  double Rmax2=Rmax*Rmax;
102  double iRmax=1.0/Rmax;
103  double k2=k*k;
104  double kr=k*iRmax;
105  double k2i2=k2+i*i;
106  double ir=i*iRmax;
107  double r2=k2i2+j*j;
108  double jr=j*iRmax;
109  double rr=std::sqrt(r2)*iRmax;
110  double zsph=0.0;
111  if (r2<Rmax2)
112  {
113  int l1 = VEC_ELEM(vL1,idx);
114  int n = VEC_ELEM(vN,idx);
115  int l2 = VEC_ELEM(vL2,idx);
116  int m = VEC_ELEM(vM,idx);
117  zsph=ZernikeSphericalHarmonics(l1,n,l2,m,jr,ir,kr,rr);
118  if (rr>0 || l2==0)
119  {
120  gx += clnm[idx] *zsph;
121  gy += clnm[idx+idxY0] *zsph;
122  gz += clnm[idx+idxZ0] *zsph;
123  }
124  }
125  }
126  atom_i.x += gx;
127  atom_i.y += gy;
128  atom_i.z += gz;
129  }
130  pdb.write(fn_out);
131 }
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 VEC_ELEM(v, i)
Definition: matrix1d.h:245
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)
Definition: pdb.h:174
std::string readNthLine(int N) const
void centerOfMass(PDBRichPhantom pdb, Matrix1D< double > &cm)
#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
double y
Position Y.
Definition: pdb.h:187
std::vector< double > string2vector(std::string const &s) const
void initZeros()
Definition: matrix1d.h:592
double x
Position X.
Definition: pdb.h:184
#define j
int m
std::vector< RichAtom > atomList
List of atoms.
Definition: pdb.h:257
size_t getNumberOfAtoms() const
Get number of atoms.
Definition: pdb.h:270
double ZernikeSphericalHarmonics(int n, int m, double xr, double yr, double zr, double r)
float r2
int * n
doublereal * a
int ir
double z
Position Z.
Definition: pdb.h:190

◆ show()

void ProgPdbSphDeform::show ( ) const
overridevirtual

Show parameters.

Reimplemented from XmippProgram.

Definition at line 51 of file pdb_sph_deform.cpp.

52 {
53  if (verbose==0)
54  return;
55  std::cout
56  << "PDB: " << fn_pdb << std::endl
57  << "Coefficient list: " << fn_sph << std::endl
58  << "Output: " << fn_out << std::endl
59  ;
60 }
int verbose
Verbosity level.

◆ string2vector()

std::vector< double > ProgPdbSphDeform::string2vector ( std::string const &  s) const

Convert String to Vector

Definition at line 146 of file pdb_sph_deform.cpp.

147 {
148  std::stringstream iss(s);
149  double number;
150  std::vector<double> v;
151  while (iss >> number)
152  v.push_back(number);
153  return v;
154 }

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