Xmipp  v3.23.11-Nereus
Classes | Functions
pdb.h File Reference
#include <vector>
#include "cif++.hpp"
#include "core/xmipp_error.h"
Include dependency graph for pdb.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  Matrix1D< T >
 
class  Matrix2D< T >
 
class  MultidimArray< T >
 
struct  pdbInfo
 
class  Atom
 
class  PDBPhantom
 
class  RichAtom
 
class  PDBRichPhantom
 
class  AtomInterpolator
 

Functions

int atomCharge (const std::string &atom)
 
double atomRadius (const std::string &atom)
 
double atomCovalentRadius (const std::string &atom)
 
void computePDBgeometry (const std::string &fnPDB, Matrix1D< double > &centerOfMass, Matrix1D< double > &limit0, Matrix1D< double > &limitF, const std::string &intensityColumn)
 
void applyGeometryToPDBFile (const std::string &fn_in, const std::string &fn_out, const Matrix2D< double > &A, bool centerPDB=true, const std::string &intensityColumn="occupancy")
 
void analyzePDBAtoms (const FileName &fn_pdb, const std::string &typeOfAtom, int &numberOfAtoms, pdbInfo &at_pos)
 
void atomDescriptors (const std::string &atom, Matrix1D< double > &descriptors)
 
double electronFormFactorFourier (double f, const Matrix1D< double > &descriptors)
 
double electronFormFactorRealSpace (double r, const Matrix1D< double > &descriptors)
 
void atomRadialProfile (int M, double T, const std::string &atom, Matrix1D< double > &profile)
 
void atomProjectionRadialProfile (int M, const Matrix1D< double > &profileCoefficients, Matrix1D< double > &projectionProfile)
 
void projectPDB (const PDBPhantom &phantomPDB, const AtomInterpolator &interpolator, Projection &proj, int Ydim, int Xdim, double rot, double tilt, double psi)
 
void distanceHistogramPDB (const PDBPhantom &phantomPDB, size_t Nnearest, double maxDistance, int Nbins, Histogram1D &hist)
 
const char * hy36encode (unsigned width, int value, char *result)
 
const char * hy36decode (unsigned width, const char *s, unsigned s_size, int *result)
 
void hy36encodeSafe (unsigned width, int value, char *result)
 
void hy36decodeSafe (unsigned width, const char *s, unsigned s_size, int *result)
 

Function Documentation

◆ hy36decode()

const char* hy36decode ( unsigned  width,
const char *  s,
unsigned  s_size,
int *  result 
)

hybrid-36 decoder: converts string s to integer result width: must be 4 (e.g. for residue sequence numbers) or 5 (e.g. for atom serial numbers) s: string to be converted does not have to be null-terminated s_size: size of s must be equal to width, or an error message is returned otherwise result: integer holding the conversion result return value: pointer to error message, if any, or 0 on success Example usage (from C++): int result; const char* errmsg = hy36decode(width, "A1T5", 4, &result); if (errmsg) throw std::runtime_error(errmsg);

Definition at line 1892 of file pdb.cpp.

1893 {
1894  static int first_call = 1;
1895  static int digits_values_upper[128U];
1896  static int digits_values_lower[128U];
1897  static const char*
1898  ie_range = "internal error hy36decode: integer value out of range.";
1899  unsigned i;
1900  int di;
1901  const char* errmsg;
1902  if (first_call) {
1903  first_call = 0;
1904  for(i=0;i<128U;i++) digits_values_upper[i] = -1;
1905  for(i=0;i<128U;i++) digits_values_lower[i] = -1;
1906  for(i=0;i<36U;i++) {
1907  di = digits_upper()[i];
1908  if (di < 0 || di > 127) {
1909  *result = 0;
1910  return ie_range;
1911  }
1912  digits_values_upper[di] = i;
1913  }
1914  for(i=0;i<36U;i++) {
1915  di = digits_lower()[i];
1916  if (di < 0 || di > 127) {
1917  *result = 0;
1918  return ie_range;
1919  }
1920  digits_values_lower[di] = i;
1921  }
1922  }
1923  if (s_size == width) {
1924  di = s[0];
1925  if (di >= 0 && di <= 127) {
1926  if (digits_values_upper[di] >= 10) {
1927  errmsg = decode_pure(digits_values_upper, 36U, s, s_size, result);
1928  if (errmsg == 0) {
1929  /* result - 10*36**(width-1) + 10**width */
1930  if (width == 4U) (*result) -= 456560;
1931  else if (width == 5U) (*result) -= 16696160;
1932  else {
1933  *result = 0;
1934  return unsupported_width();
1935  }
1936  return 0;
1937  }
1938  }
1939  else if (digits_values_lower[di] >= 10) {
1940  errmsg = decode_pure(digits_values_lower, 36U, s, s_size, result);
1941  if (errmsg == 0) {
1942  /* result + 16*36**(width-1) + 10**width */
1943  if (width == 4U) (*result) += 756496;
1944  else if (width == 5U) (*result) += 26973856;
1945  else {
1946  *result = 0;
1947  return unsupported_width();
1948  }
1949  return 0;
1950  }
1951  }
1952  else {
1953  errmsg = decode_pure(digits_values_upper, 10U, s, s_size, result);
1954  if (errmsg) return errmsg;
1955  if (!(width == 4U || width == 5U)) {
1956  *result = 0;
1957  return unsupported_width();
1958  }
1959  return 0;
1960  }
1961  }
1962  }
1963  *result = 0;
1964  return invalid_number_literal();
1965 }
double * di
#define i

◆ hy36decodeSafe()

void hy36decodeSafe ( unsigned  width,
const char *  s,
unsigned  s_size,
int *  result 
)

Definition at line 1968 of file pdb.cpp.

1969 {
1970  auto* errmsg = hy36decode(width, s, s_size, result);
1971  if (errmsg) {
1973  }
1974 }
#define REPORT_ERROR(nerr, ErrormMsg)
Definition: xmipp_error.h:211
const char * hy36decode(unsigned width, const char *s, unsigned s_size, int *result)
Definition: pdb.cpp:1892
Incorrect value received.
Definition: xmipp_error.h:195

◆ hy36encode()

const char* hy36encode ( unsigned  width,
int  value,
char *  result 
)

hybrid-36 encoder: converts integer value to string result width: must be 4 (e.g. for residue sequence numbers) or 5 (e.g. for atom serial numbers) value: integer value to be converted result: pointer to char array of size width+1 or greater on return result is null-terminated return value: pointer to error message, if any, or 0 on success Example usage (from C++): char result[4+1]; const char* errmsg = hy36encode(4, 12345, result); if (errmsg) throw std::runtime_error(errmsg);

Definition at line 1824 of file pdb.cpp.

1825 {
1826  int i = value;
1827  if (width == 4U) {
1828  if (i >= -999) {
1829  if (i < 10000) {
1830  encode_pure(digits_upper(), 10U, 4U, i, result);
1831  return 0;
1832  }
1833  i -= 10000;
1834  if (i < 1213056 /* 26*36**3 */) {
1835  i += 466560 /* 10*36**3 */;
1836  encode_pure(digits_upper(), 36U, 0U, i, result);
1837  return 0;
1838  }
1839  i -= 1213056;
1840  if (i < 1213056) {
1841  i += 466560;
1842  encode_pure(digits_lower(), 36U, 0U, i, result);
1843  return 0;
1844  }
1845  }
1846  }
1847  else if (width == 5U) {
1848  if (i >= -9999) {
1849  if (i < 100000) {
1850  encode_pure(digits_upper(), 10U, 5U, i, result);
1851  return 0;
1852  }
1853  i -= 100000;
1854  if (i < 43670016 /* 26*36**4 */) {
1855  i += 16796160 /* 10*36**4 */;
1856  encode_pure(digits_upper(), 36U, 0U, i, result);
1857  return 0;
1858  }
1859  i -= 43670016;
1860  if (i < 43670016) {
1861  i += 16796160;
1862  encode_pure(digits_lower(), 36U, 0U, i, result);
1863  return 0;
1864  }
1865  }
1866  }
1867  else {
1868  fill_with_stars(width, result);
1869  return unsupported_width();
1870  }
1871  fill_with_stars(width, result);
1872  return value_out_of_range();
1873 }
#define i

◆ hy36encodeSafe()

void hy36encodeSafe ( unsigned  width,
int  value,
char *  result 
)

Definition at line 1977 of file pdb.cpp.

1978 {
1979  const char* errmsg = hy36encode(width, value, result);
1980  if (errmsg) {
1982  }
1983 }
const char * hy36encode(unsigned width, int value, char *result)
Definition: pdb.cpp:1824
#define REPORT_ERROR(nerr, ErrormMsg)
Definition: xmipp_error.h:211
Incorrect value received.
Definition: xmipp_error.h:195