47 #ifndef IOTBX_PDB_HYBRID_36_C_H 48 #define IOTBX_PDB_HYBRID_36_C_H 54 #define HY36_WIDTH_4_MIN -999 55 #define HY36_WIDTH_4_MAX 2436111 56 #define HY36_WIDTH_5_MIN -9999 57 #define HY36_WIDTH_5_MAX 87440031 67 std::ifstream f2parse;
68 f2parse.open(fn_pdb.c_str());
76 pdbFile.
read(fn_pdb.c_str());
79 for (
auto& atom : pdbFile.
atomList) {
80 if (atom.name == typeOfAtom) {
84 at_pos.
x.push_back(atom.x);
85 at_pos.
y.push_back(atom.y);
86 at_pos.
z.push_back(atom.z);
87 at_pos.
chain.push_back(std::string(1, atom.chainid));
90 at_pos.
residue.push_back(atom.resseq);
93 at_pos.
b.push_back(atom.bfactor);
108 interpolatedElementBSpline1D(r*
M,3);
118 interpolatedElementBSpline1D(r*
M,3);
241 const std::string &intensityColumn)
249 double total_mass = 0;
258 bool useBFactor = intensityColumn==
"Bfactor";
259 for (
auto& atom : pdbFile.
atomList) {
270 if (atom.name ==
"EN")
273 weight = atom.bfactor;
275 weight = atom.occupancy;
279 if (atom.record ==
"HETATM")
283 total_mass += weight;
284 XX(centerOfMass) += weight * atom.x;
285 YY(centerOfMass) += weight * atom.y;
286 ZZ(centerOfMass) += weight * atom.z;
290 centerOfMass /= total_mass;
296 const std::string &intensityColumn)
305 limit0 -= centerOfMass;
306 limitF -= centerOfMass;
311 fh_in.open(fn_in.c_str());
314 std::ofstream fh_out;
315 fh_out.open(fn_out.c_str());
324 getline(fh_in, line);
330 std::string kind = line.substr(0,4);
331 if (kind !=
"ATOM" && kind !=
"HETA")
333 fh_out << line << std::endl;
348 y-
YY(centerOfMass),z-
ZZ(centerOfMass));
358 sprintf(aux,
"%8.3f",
XX(v));
359 line.replace(30,8,aux);
360 sprintf(aux,
"%8.3f",
YY(v));
361 line.replace(38,8,aux);
362 sprintf(aux,
"%8.3f",
ZZ(v));
363 line.replace(46,8,aux);
365 fh_out << line << std::endl;
384 bool checkExtension(
const std::filesystem::path &filePath,
const std::list<std::string> &acceptedExtensions,
const std::list<std::string> &acceptedCompressions) {
386 bool validExtension =
false;
389 if (
find(acceptedExtensions.begin(), acceptedExtensions.end(), filePath.extension()) != acceptedExtensions.end()) {
391 validExtension =
true;
393 if (
find(acceptedCompressions.begin(), acceptedCompressions.end(), filePath.extension()) != acceptedCompressions.end()) {
396 const std::filesystem::path shortedPath = filePath.parent_path().u8string() +
"/" + filePath.stem().u8string();
397 if (
find(acceptedExtensions.begin(), acceptedExtensions.end(), shortedPath.extension()) != acceptedExtensions.end()) {
399 validExtension =
true;
405 return validExtension;
408 template<
typename callable>
421 fh_in.open(fnPDB.c_str());
432 getline(fh_in, line);
435 kind = line.substr(0, 4);
436 if (kind !=
"ATOM" && kind !=
"HETA")
453 template<
typename callable>
463 void readCIF(
const std::string &fnCIF,
const callable &
addAtom, cif::datablock &dataBlock)
470 cif::datablock& db = cifFile.front();
475 cif::category& atom_site = db[
"atom_site"];
479 for (
const auto& [atom_id, x_pos, y_pos, z_pos]: atom_site.find
480 <std::string,
float,
float,
float>
482 cif::key(
"group_PDB") ==
"ATOM" || cif::key(
"group_PDB") ==
"HETATM",
516 int imax=atomList.size();
517 for (
int i=0;
i<imax;
i++)
525 template<
typename callable>
539 std::vector<std::string> &remarks,
const bool pseudoatoms,
const double threshold)
543 fh_in.open(fnPDB.c_str());
548 auto line = std::string(80,
' ');
555 getline(fh_in, line);
564 if (kind ==
"ATOM" || kind ==
"HETATM")
566 line.resize (80,
' ');
576 atom.
resname = line.substr(17, 3);
579 atom.
icode = line[26];
585 if (line.length() >= 76 &&
simplify(line.substr(72, 4)) !=
"")
586 atom.
segment = line.substr(72, 4);
587 if (line.length() >= 78 &&
simplify(line.substr(77, 1)) !=
"")
591 if (line.length() >= 80 &&
simplify(line.substr(79, 1)) !=
"")
595 intensities.push_back(atom.
bfactor);
597 if(!pseudoatoms && atom.
bfactor >= threshold)
600 }
else if (kind ==
"REMARK")
601 remarks.push_back(line);
608 template<
typename callable>
622 void readRichCIF(
const std::string &fnCIF,
const callable &
addAtom, std::vector<double> &intensities,
623 const bool pseudoatoms,
const double threshold, cif::datablock &dataBlock)
630 cif::datablock& db = cifFile.front();
633 cif::category& atom_site = db[
"atom_site"];
637 for (
const auto& [record, serialNumber, atomId, altId, resName, chain, resSeq, seqId, iCode, xPos, yPos, zPos,
638 occupancy, bFactor, charge, authSeqId, authCompId, authAsymId, authAtomId, pdbNum]:
639 atom_site.find<std::string,
int,std::string,std::string,std::string,std::string,
int,
int,std::string,
float,
640 float,
float,
float,
float,std::string,
int,std::string,std::string,std::string,
int>
643 cif::key(
"group_PDB") ==
"ATOM" || cif::key(
"group_PDB") ==
"HETATM",
658 "pdbx_formal_charge",
668 atom.
serial = serialNumber;
692 intensities.push_back(bFactor);
695 if (bFactor >= threshold)
714 template<
typename callable>
725 void writePDB(
const FileName &fnPDB,
bool renumber,
const std::vector<std::string> &remarks,
const callable &atomList)
727 FILE* fh_out=fopen(fnPDB.c_str(),
"w");
730 size_t imax=remarks.size();
731 for (
size_t i=0;
i<imax; ++
i)
732 fprintf(fh_out,
"%s\n",remarks[
i].c_str());
734 imax=atomList.size();
735 for (
size_t i=0;
i<imax; ++
i)
742 reportWarning(
"Failed to use atom.serial. Using i+1 instead.");
753 fprintf (fh_out,
"%-6s%5s %-4s%s%-4s%c%4s%s %8.3f%8.3f%8.3f%6.2f%6.2f %4s%2s%-2s\n",
756 resseq,atom.
icode.c_str(),
763 template<
typename callable>
773 void writeCIF(
const std::string &fnCIF,
const callable &atomList, cif::datablock &dataBlock)
776 std::ofstream cifFile(fnCIF);
779 cif::category atomSite(
"atom_site");
780 cif::row_initializer atomSiteInserter;
783 std::stringstream tempStream;
784 std::string occupancy;
793 tempStream << std::fixed << std::setprecision(2) << atom.occupancy;
794 occupancy = tempStream.str();
799 tempStream << std::fixed << std::setprecision(3) << atom.x;
800 xPos = tempStream.str();
805 tempStream << std::fixed << std::setprecision(3) << atom.y;
806 yPos = tempStream.str();
811 tempStream << std::fixed << std::setprecision(3) << atom.z;
812 zPos = tempStream.str();
817 tempStream << std::fixed << std::setprecision(2) << atom.bfactor;
818 bFactor = tempStream.str();
826 {
"group_PDB", atom.record.empty() ?
"." : atom.record},
828 {
"type_symbol", atom.name.empty() ?
'.' : atom.name[0]},
829 {
"label_atom_id", atom.name.empty() ?
"." : atom.name},
830 {
"label_alt_id", atom.altId.empty() ?
"." : atom.altId},
831 {
"label_comp_id", atom.resname.empty() ?
"." : atom.resname},
832 {
"label_asym_id", atom.altloc.empty() ?
"." : atom.altloc},
833 {
"label_entity_id", atom.resseq},
834 {
"label_seq_id", atom.seqId},
835 {
"pdbx_PDB_ins_code", atom.icode.empty() ?
"." : atom.icode},
839 {
"occupancy", occupancy},
840 {
"B_iso_or_equiv", bFactor},
841 {
"pdbx_formal_charge", atom.charge.empty() ?
"." : atom.charge},
842 {
"auth_seq_id", atom.authSeqId},
843 {
"auth_comp_id", atom.authCompId.empty() ?
"." : atom.authCompId},
844 {
"auth_asym_id", atom.authAsymId.empty() ?
"." : atom.authAsymId},
845 {
"auth_atom_id", atom.authAtomId.empty() ?
"." : atom.authAtomId},
846 {
"pdbx_PDB_model_num", atom.pdbNum}
850 atomSite.emplace(std::move(atomSiteInserter));
854 auto categoryInsertPosition = std::find_if(
855 dataBlock.cbegin(), dataBlock.cend(),
856 [](
const cif::category& cat) {
857 return cat.name() ==
"atom_site";
860 if (categoryInsertPosition != dataBlock.cend()) {
861 categoryInsertPosition = dataBlock.erase(categoryInsertPosition);
863 dataBlock.insert(categoryInsertPosition, atomSite);
866 dataBlock.write(cifFile);
878 writePDB(fnPDB, renumber, remarks, atomList);
889 descriptors( 1)= 0.0088;
890 descriptors( 2)= 0.0449;
891 descriptors( 3)= 0.1481;
892 descriptors( 4)= 0.2356;
893 descriptors( 5)= 0.0914;
894 descriptors( 6)= 0.1152;
895 descriptors( 7)= 1.0867;
896 descriptors( 8)= 4.9755;
897 descriptors( 9)=16.5591;
898 descriptors(10)=43.2743;
903 descriptors( 1)= 0.0489;
904 descriptors( 2)= 0.2091;
905 descriptors( 3)= 0.7537;
906 descriptors( 4)= 1.1420;
907 descriptors( 5)= 0.3555;
908 descriptors( 6)= 0.1140;
909 descriptors( 7)= 1.0825;
910 descriptors( 8)= 5.4281;
911 descriptors( 9)=17.8811;
912 descriptors(10)=51.1341;
917 descriptors( 1)= 0.0267;
918 descriptors( 2)= 0.1328;
919 descriptors( 3)= 0.5301;
920 descriptors( 4)= 1.1020;
921 descriptors( 5)= 0.4215;
922 descriptors( 6)= 0.0541;
923 descriptors( 7)= 0.5165;
924 descriptors( 8)= 2.8207;
925 descriptors( 9)=10.6297;
926 descriptors(10)=34.3764;
931 descriptors( 1)= 0.0365;
932 descriptors( 2)= 0.1729;
933 descriptors( 3)= 0.5805;
934 descriptors( 4)= 0.8814;
935 descriptors( 5)= 0.3121;
936 descriptors( 6)= 0.0652;
937 descriptors( 7)= 0.6184;
938 descriptors( 8)= 2.9449;
939 descriptors( 9)= 9.6298;
940 descriptors(10)=28.2194;
945 descriptors( 1)= 0.1005;
946 descriptors( 2)= 0.4615;
947 descriptors( 3)= 1.0663;
948 descriptors( 4)= 2.5854;
949 descriptors( 5)= 1.2725;
950 descriptors( 6)= 0.0977;
951 descriptors( 7)= 0.9084;
952 descriptors( 8)= 4.9654;
953 descriptors( 9)=18.5471;
954 descriptors(10)=54.3648;
959 descriptors( 1)= 0.0915;
960 descriptors( 2)= 0.4312;
961 descriptors( 3)= 1.0847;
962 descriptors( 4)= 2.4671;
963 descriptors( 5)= 1.0852;
964 descriptors( 6)= 0.0838;
965 descriptors( 7)= 0.7788;
966 descriptors( 8)= 4.3462;
967 descriptors( 9)=15.5846;
968 descriptors(10)=44.6365;
973 descriptors( 1)= 0.1929;
974 descriptors( 2)= 0.8239;
975 descriptors( 3)= 1.8689;
976 descriptors( 4)= 2.3694;
977 descriptors( 5)= 1.9060;
978 descriptors( 6)= 0.1087;
979 descriptors( 7)= 1.0806;
980 descriptors( 8)= 4.7637;
981 descriptors( 9)=22.8500;
982 descriptors(10)=76.7309;
987 descriptors( 1)= 0.2149;
988 descriptors( 2)= 0.8703;
989 descriptors( 3)= 2.4999;
990 descriptors( 4)= 2.3591;
991 descriptors( 5)= 3.0318;
992 descriptors( 6)= 0.1660;
993 descriptors( 7)= 1.6906;
994 descriptors( 8)= 8.7447;
995 descriptors( 9)=46.7825;
996 descriptors(10)=165.6923;
1001 descriptors( 1)= 0.0382;
1002 descriptors( 2)= 0.1822;
1003 descriptors( 3)= 0.5972;
1004 descriptors( 4)= 0.7707;
1005 descriptors( 5)= 0.2130;
1006 descriptors( 6)= 0.0613;
1007 descriptors( 7)= 0.5753;
1008 descriptors( 8)= 2.6858;
1009 descriptors( 9)= 8.8214;
1010 descriptors(10)=25.6668;
1012 else if (atom==
"Mg")
1015 descriptors( 1)= 0.1130;
1016 descriptors( 2)= 0.5575;
1017 descriptors( 3)= 0.9046;
1018 descriptors( 4)= 2.1580;
1019 descriptors( 5)= 1.4735;
1020 descriptors( 6)= 0.1356;
1021 descriptors( 7)= 1.3579;
1022 descriptors( 8)= 6.9255;
1023 descriptors( 9)=32.3165;
1024 descriptors(10)=92.1138;
1026 else if (atom==
"Cl")
1029 descriptors( 1)= 0.0799;
1030 descriptors( 2)= 0.3891;
1031 descriptors( 3)= 1.0037;
1032 descriptors( 4)= 2.3332;
1033 descriptors( 5)= 1.0507;
1034 descriptors( 6)= 0.0694;
1035 descriptors( 7)= 0.6443;
1036 descriptors( 8)= 3.5351;
1037 descriptors( 9)=12.5058;
1038 descriptors(10)=35.8633;
1040 else if (atom==
"Ca")
1043 descriptors( 1)= 0.2355;
1044 descriptors( 2)= 0.9916;
1045 descriptors( 3)= 2.3959;
1046 descriptors( 4)= 3.7252;
1047 descriptors( 5)= 2.5647;
1048 descriptors( 6)= 0.1742;
1049 descriptors( 7)= 1.8329;
1050 descriptors( 8)= 8.8407;
1051 descriptors( 9)=47.4583;
1052 descriptors(10)=134.9613;
1062 for (
int i=1;
i<=5;
i++)
1066 retval+=ai*exp(-bi*f*f);
1091 for (
int i=1;
i<=5;
i++)
1093 double ai=descriptors(
i);
1094 double bi=descriptors(
i+5);
1095 double b=bi/(4*
PI*
PI);
1096 retval+=ai*
sqrt(
PI/b)*exp(-r*r/(4*b));
1106 double ripple=0.01,
double deltaw=1.0/8.0)
1111 auto Nmax=(int)
CEIL(M/2.0);
1112 if (filterType==
"SimpleAveraging")
1116 filter(
i)=1.0/(2*Nmax+1);
1118 else if (filterType==
"SincKaiser")
1123 if (newLastIdx>3*lastIdx)
1125 filter/=filter.
sum();
1156 const double K2=
XSIZE(auxFilter);
1157 std::complex<double> aux;
1158 auto * ptrAux=(
double*)&aux;
1164 sincos(arg,ptrAux+1,ptrAux);
1183 double reductionFactor=p[1];
1187 if (reductionFactor<0.7 || reductionFactor>1.3)
1189 if (ripple<0 || ripple>0.2)
1191 if (deltaw<1e-3 || deltaw>0.2)
1198 hlpf(auxf,
globalM,
"SincKaiser", filter, reductionFactor,
1215 fhlpfCoarselySampled(
i)=
1225 aux=fhlpfCoarselySampled;
1234 double amplitudeFactor=fhlpfFinelySampled.
sum()/
1235 fhlpfCoarselySampled.
sum();
1252 double f2=
log10(iglobalT*
1255 double diff=(f1-f2);
1260 std::cout <<
"i=" <<
i <<
" wi=" <<
A1D_ELEM(freq,
i) <<
" f1=" << f1 <<
" f2=" << f2 <<
" diff=" << diff <<
" err2=" << diff*diff << std::endl;
1264 f1array.
write(
"PPPf1.txt");
1265 f2array.
write(
"PPPf2.txt");
1266 std::cout <<
"Error " << error/Npoints <<
" " << Npoints <<
" M=" <<
globalM <<
" T=" << globalT << std::endl;
1269 return error/Npoints;
1300 &
Hlpf_fitness,
nullptr, 0.05, fitness, iter, steps,
false);
1302 hlpf(f, M,
"SincKaiser", filter, bestPrm(0), bestPrm(1), bestPrm(2));
1310 double largestb1=76.7309/(4*
PI*
PI);
1311 double Rmax=4*
sqrt(2*largestb1);
1312 auto imax=(int)
CEIL(Rmax/T);
1317 for (
int i=-imax;
i<=imax;
i++)
1329 fhlpf(f, filter, M, profile);
1333 if (fabs(profile(ileft))<1e-3)
1334 for (ileft=
STARTINGX(profile)+1; ileft<=0; ileft++)
1335 if (fabs(profile(ileft))>1e-3)
1338 if (fabs(profile(iright))<1e-3)
1339 for (iright=
FINISHINGX(profile)-1; iright>=0; iright--)
1340 if (fabs(profile(iright))>1e-3)
1355 double r=M*
sqrt(r0_2+z*z);
1362 #define INTEGRATION 2 1370 double radius=(double)
FINISHINGX(profileCoefficients)/
M;
1371 double r2=radius*radius;
1373 projectionProfile.
initZeros(profileCoefficients);
1376 double r0=(double)
i/M;
1377 atomValue.
r0_2=r0*r0;
1378 if (atomValue.
r0_2>r2)
1381 double maxZ=
sqrt(r2-atomValue.
r0_2);
1387 for (atomValue.
z=-maxZ; atomValue.
z<=maxZ; atomValue.
z+=dz)
1389 projectionProfile(
i)+=atomValue();
1391 projectionProfile(
i)*=dz;
1394 Romberg Rom(atomValue, atomValue.
z,-maxZ,maxZ);
1395 projectionProfile(
i) = Rom();
1408 addAtom(
"H",computeProjection);
1409 addAtom(
"C",computeProjection);
1410 addAtom(
"N",computeProjection);
1411 addAtom(
"O",computeProjection);
1412 addAtom(
"P",computeProjection);
1413 addAtom(
"S",computeProjection);
1414 addAtom(
"Fe",computeProjection);
1415 addAtom(
"K",computeProjection);
1416 addAtom(
"F",computeProjection);
1417 addAtom(
"Mg",computeProjection);
1418 addAtom(
"Cl",computeProjection);
1419 addAtom(
"Ca",computeProjection);
1436 if (computeProjection)
1450 constexpr
float SUBSAMPLING = 2;
1453 constexpr
float SUBSTEP = 1/(SUBSAMPLING*2.0);
1475 std::cout <<
"Actual atom\n" << atom.
atomType <<
" (" 1476 << atom.
x <<
"," << atom.
y <<
"," << atom.
z <<
")\n";
1477 std::cout <<
"Center " << Center.
transpose() << std::endl;
1478 std::cout <<
"VP matrix\n" << VP << std::endl;
1480 std::cout <<
"direction " << direction.
transpose() << std::endl;
1481 std::cout <<
"P.euler matrix " << P.
euler << std::endl;
1482 std::cout <<
"max_distance " << max_distance << std::endl;
1483 std::cout <<
"origin " << origin.
transpose() << std::endl;
1489 VECTOR_R3(corner1, max_distance, max_distance, max_distance);
1490 VECTOR_R3(corner2, -max_distance, -max_distance, -max_distance);
1493 std::cout <<
"Corner1 : " << corner1.
transpose() << std::endl
1494 <<
"Corner2 : " << corner2.
transpose() << std::endl;
1500 std::cout <<
"Corner1 moves to : " << corner1.
transpose() << std::endl
1501 <<
"Corner2 moves to : " << corner2.
transpose() << std::endl;
1508 std::cout <<
"Corner1 finally is : " << corner1.
transpose() << std::endl
1509 <<
"Corner2 finally is : " << corner2.
transpose() << std::endl;
1524 std::cout <<
"corner1 " << corner1.
transpose() << std::endl;
1525 std::cout <<
"corner2 " << corner2.
transpose() << std::endl;
1530 if (
XX(corner1) ==
XX(corner2))
1532 if (
YY(corner1) ==
YY(corner2))
1537 for (
auto v = (
int)
YY(corner1); v <= (int)
YY(corner2); v++)
1538 for (
auto u = (
int)
XX(corner1);
u <= (int)
XX(corner2);
u++)
1542 #ifdef DEBUG_EVEN_MORE 1544 std::cout <<
"Studying point (" <<
u <<
"," << v <<
")\n";
1549 double u0 =
u - (int)(SUBSAMPLING / 2.0) * SUBSTEP;
1550 double v0 = v - (int)(SUBSAMPLING / 2.0) * SUBSTEP;
1552 for (
int subv = 0; subv < SUBSAMPLING; subv++)
1555 for (
int subu = 0; subu < SUBSAMPLING; subu++)
1568 double possible_length=interpolator.
1570 if (possible_length > 0)
1571 length += possible_length;
1573 #ifdef DEBUG_EVEN_MORE 1575 std::cout <<
"Averaging at (" << actu <<
"," << actv <<
")\n";
1576 std::cout <<
" which in univ. coords is " << act.
transpose() << std::endl;
1577 std::cout <<
" r=" << r << std::endl;
1578 std::cout <<
" intersection there " << possible_length << std::endl;
1582 actu += SUBSTEP * 2.0;
1584 actv += SUBSTEP * 2.0;
1586 length /= (SUBSAMPLING * SUBSAMPLING);
1590 std::cout <<
"Final value added at position (" <<
u <<
"," << v <<
")=" 1591 << length << std::endl;
1601 #undef DEBUG_EVEN_MORE 1605 int Ydim,
int Xdim,
double rot,
double tilt,
double psi)
1608 proj().initZeros(Ydim, Xdim);
1609 proj().setXmippOrigin();
1630 const std::vector<Atom> &atoms=phantomPDB.
atomList;
1631 int Natoms=atoms.size();
1633 NnearestDistances.
resize((Natoms-1)*Nnearest);
1634 for (
int i=0;
i<Natoms;
i++)
1636 std::vector<double> NnearestToThisAtom;
1637 const Atom& atom_i=atoms[
i];
1638 for (
int j=
i+1;
j<Natoms;
j++)
1640 const Atom& atom_j=atoms[
j];
1641 double diffx=atom_i.
x-atom_j.
x;
1642 double diffy=atom_i.
y-atom_j.
y;
1643 double diffz=atom_i.
z-atom_j.
z;
1644 double dist=
sqrt(diffx*diffx+diffy*diffy+diffz*diffz);
1645 if (maxDistance>0 && dist>maxDistance)
1648 size_t nearestSoFar=NnearestToThisAtom.size();
1649 if (nearestSoFar==0)
1651 NnearestToThisAtom.push_back(dist);
1657 while (idx<nearestSoFar && NnearestToThisAtom[idx]<dist)
1659 if (idx<nearestSoFar)
1661 NnearestToThisAtom.insert(NnearestToThisAtom.begin()+idx,1,dist);
1662 if (NnearestToThisAtom.size()>Nnearest)
1663 NnearestToThisAtom.erase(NnearestToThisAtom.begin()+Nnearest);
1665 if (idx==nearestSoFar && nearestSoFar<Nnearest)
1667 NnearestToThisAtom.push_back(dist);
1673 for (
size_t k=0;
k<Nnearest;
k++)
1674 NnearestDistances(
i*Nnearest+
k)=NnearestToThisAtom[
k];
1704 digits_upper() {
return "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"; }
1708 digits_lower() {
return "0123456789abcdefghijklmnopqrstuvwxyz"; }
1712 value_out_of_range() {
return "value out of range."; }
1715 const char* invalid_number_literal() {
return "invalid number literal."; }
1718 const char* unsupported_width() {
return "unsupported width."; }
1722 fill_with_stars(
unsigned width,
char* result)
1735 unsigned digits_size,
1750 rest = value / digits_size;
1751 buf[i++] = digits[value - rest * digits_size];
1752 if (rest == 0)
break;
1755 if (j) buf[i++] =
'-';
1756 for(j=i;j<width;j++) *result++ =
' ';
1757 while (i != 0) *result++ = buf[--
i];
1764 const int* digits_values,
1765 unsigned digits_size,
1772 int have_non_blank = 0;
1775 for(;i<s_size;i++) {
1777 if (si < 0 || si > 127) {
1779 return invalid_number_literal();
1782 if (!have_non_blank)
continue;
1783 value *= digits_size;
1785 else if (si ==
'-') {
1786 if (have_non_blank) {
1788 return invalid_number_literal();
1796 dv = digits_values[si];
1797 if (dv < 0 || dv >= digits_size) {
1799 return invalid_number_literal();
1801 value *= digits_size;
1805 if (have_minus) value = -value;
1830 encode_pure(digits_upper(), 10U, 4U, i, result);
1836 encode_pure(digits_upper(), 36U, 0U, i, result);
1842 encode_pure(digits_lower(), 36U, 0U, i, result);
1847 else if (width == 5U) {
1850 encode_pure(digits_upper(), 10U, 5U, i, result);
1854 if (i < 43670016 ) {
1856 encode_pure(digits_upper(), 36U, 0U, i, result);
1862 encode_pure(digits_lower(), 36U, 0U, i, result);
1868 fill_with_stars(width, result);
1869 return unsupported_width();
1871 fill_with_stars(width, result);
1872 return value_out_of_range();
1892 hy36decode(
unsigned width,
const char* s,
unsigned s_size,
int* result)
1894 static int first_call = 1;
1895 static int digits_values_upper[128U];
1896 static int digits_values_lower[128U];
1898 ie_range =
"internal error hy36decode: integer value out of range.";
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) {
1912 digits_values_upper[
di] =
i;
1914 for(i=0;i<36U;i++) {
1915 di = digits_lower()[
i];
1916 if (di < 0 || di > 127) {
1920 digits_values_lower[
di] =
i;
1923 if (s_size == width) {
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);
1930 if (width == 4U) (*result) -= 456560;
1931 else if (width == 5U) (*result) -= 16696160;
1934 return unsupported_width();
1939 else if (digits_values_lower[di] >= 10) {
1940 errmsg = decode_pure(digits_values_lower, 36U, s, s_size, result);
1943 if (width == 4U) (*result) += 756496;
1944 else if (width == 5U) (*result) += 26973856;
1947 return unsupported_width();
1953 errmsg = decode_pure(digits_values_upper, 10U, s, s_size, result);
1954 if (errmsg)
return errmsg;
1955 if (!(width == 4U || width == 5U)) {
1957 return unsupported_width();
1964 return invalid_number_literal();
1970 auto* errmsg =
hy36decode(width, s, s_size, result);
1979 const char* errmsg =
hy36encode(width, value, result);
void read(const FileName &fnPDB)
Read phantom from either a PDB of CIF file.
void selfWindow(int n0, int z0, int y0, int x0, int nF, int zF, int yF, int xF, T init_value=0)
T interpolatedElementBSpline1D(double x, int SplineDegree=3) const
void min(Image< double > &op1, const Image< double > &op2)
void read(const FileName &fnPDB, const bool pseudoatoms=false, const double threshold=0.0)
Read rich phantom from either a PDB of CIF file.
const char * hy36encode(unsigned width, int value, char *result)
void atomProjectionRadialProfile(int M, const MultidimArray< double > &profileCoefficients, MultidimArray< double > &projectionProfile)
void resize(size_t Ndim, size_t Zdim, size_t Ydim, size_t Xdim, bool copy=true)
double electronFormFactorRealSpace(double r, const Matrix1D< double > &descriptors)
double point_line_distance_3D(const Matrix1D< double > &p, const Matrix1D< double > &a, const Matrix1D< double > &v)
void reportWarning(const String &what)
void applyGeometryToPDBFile(const std::string &fn_in, const std::string &fn_out, const Matrix2D< double > &A, bool centerPDB, const std::string &intensityColumn)
void sortTwoVectors(Matrix1D< T > &v1, Matrix1D< T > &v2)
std::vector< MultidimArray< double > > projectionProfileCoefficients
void projectPDB(const PDBPhantom &phantomPDB, const AtomInterpolator &interpolator, Projection &proj, int Ydim, int Xdim, double rot, double tilt, double psi)
std::string segment
segment name
#define REPORT_ERROR(nerr, ErrormMsg)
void write(const FileName &fnPDB, const bool renumber=false)
Write rich phantom to PDB or CIF file.
void writeCIF(const std::string &fnCIF, const callable &atomList, cif::datablock &dataBlock)
Write rich phantom to CIF file.
void sqrt(Image< double > &op)
void hlpf(MultidimArray< double > &f, int M, const std::string &filterType, MultidimArray< double > &filter, double reductionFactor=0.8, double ripple=0.01, double deltaw=1.0/8.0)
std::string charge
2-char charge with sign 2nd (e.g. 1- or 2+)
std::vector< SelLine >::iterator find(std::vector< SelLine > &text, const std::string &img_name)
void readCIF(const std::string &fnCIF, const callable &addAtom, cif::datablock &dataBlock)
Read phantom from CIF.
Couldn't write to file.
std::string record
Record Type ("ATOM " or "HETATM")
MultidimArray< double > globalf
int serial
atom serial number
void inv(Matrix2D< T > &result) const
std::vector< std::string > chain
void addAtom(const Atom &atom)
Add Atom.
void InverseFourierTransform(const MultidimArray< std::complex< double > > &in, MultidimArray< double > &out)
std::string resname
Residue name.
std::string atomType
atom element type
double Hlpf_fitness(double *p, void *prm)
void hy36encodeSafe(unsigned width, int value, char *result)
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
void readRichCIF(const std::string &fnCIF, const callable &addAtom, std::vector< double > &intensities, const bool pseudoatoms, const double threshold, cif::datablock &dataBlock)
Read rich phantom from CIF.
int atomCharge(const std::string &atom)
Matrix1D< T > transpose() const
void setup(int m, double hights, bool computeProjection=false)
void threshold(double *phi, unsigned long nvox, double limit)
int resseq
Residue sequence.
void box_enclosing(const Matrix1D< double > &v0, const Matrix1D< double > &vF, const Matrix2D< double > &V, Matrix1D< double > &corner1, Matrix1D< double > &corner2)
const Atom & getAtom(int i) const
Get Atom at position i.
void compute_hist(const MultidimArrayGeneric &array, Histogram1D &hist, int no_steps)
size_t getNumberOfAtoms() const
Get number of atoms.
void distanceHistogramPDB(const PDBPhantom &phantomPDB, size_t Nnearest, double maxDistance, int Nbins, Histogram1D &hist)
double projectionAtDistance(char atom, double r) const
float textToFloat(const char *str)
double occupancy
Occupancy.
virtual double operator()()
String simplify(const String &str)
void resize(size_t Xdim, bool copy=true)
void atomRadialProfile(int M, double T, const std::string &atom, MultidimArray< double > &profile)
void computePDBgeometry(const std::string &fnPDB, Matrix1D< double > ¢erOfMass, Matrix1D< double > &limit0, Matrix1D< double > &limitF, const std::string &intensityColumn)
void write(const FileName &fn) const
void max(Image< double > &op1, const Image< double > &op2)
void sincos(const MultidimArray< double > &x, MultidimArray< double > &s, MultidimArray< double > &c)
__host__ __device__ float length(float2 v)
File or directory does not exist.
std::vector< MultidimArray< double > > volumeProfileCoefficients
void direction(const MultidimArray< double > &orMap, MultidimArray< double > &qualityMap, double lambda, int size, MultidimArray< double > &dirMap, int x, int y)
void log10(Image< double > &op)
const char * hy36decode(unsigned width, const char *s, unsigned s_size, int *result)
int getAtomIndex(char atom) const
Get atom index.
void shift(double x, double y, double z)
Apply a shift to all atoms.
void FourierTransform(const MultidimArray< double > &in, MultidimArray< std::complex< double > > &out)
double electronFormFactorFourier(double f, const Matrix1D< double > &descriptors)
void atomDescriptors(const std::string &atom, Matrix1D< double > &descriptors)
Matrix1D< double > direction
std::vector< int > residue
__device__ float FFT_IDX2DIGFREQ(int idx, int size)
void optimizeHlpf(MultidimArray< double > &f, int M, double T, const std::string &atom, MultidimArray< double > &filter, Matrix1D< double > &bestPrm)
void fhlpf(const MultidimArray< double > &f, const MultidimArray< double > &filter, int M, MultidimArray< double > &convolution)
#define M3x3_BY_V3x1(a, M, b)
void hy36decodeSafe(unsigned width, const char *s, unsigned s_size, int *result)
void addAtom(const std::string &atomType, bool computeProjection=false)
Add atom.
std::vector< RichAtom > atomList
List of atoms.
#define FOR_ALL_ELEMENTS_IN_ARRAY1D(v)
bool checkExtension(const std::filesystem::path &filePath, const std::list< std::string > &acceptedExtensions, const std::list< std::string > &acceptedCompressions)
Checks if the file uses a supported extension type.
double psi(const double x)
std::vector< Atom > atomList
List of atoms.
#define VECTOR_R3(v, x, y, z)
const MultidimArray< double > * profileCoefficients
void resizeNoCopy(int Xdim)
void analyzePDBAtoms(const FileName &fn_pdb, const std::string &typeOfAtom, int &numberOfAtoms, pdbInfo &at_pos)
void readRichPDB(const FileName &fnPDB, const callable &addAtom, std::vector< double > &intensities, std::vector< std::string > &remarks, const bool pseudoatoms, const double threshold)
Read rich phantom from either a PDB of CIF file.
Matrix1D< double > globalHlpfPrm(3)
double volumeAtDistance(char atom, double r) const
fprintf(glob_prnt.io, "\)
double atomRadius(char atom) const
std::vector< double > radii
std::vector< double > atomCovRad
void setAngles(double _rot, double _tilt, double _psi)
void initZeros(const MultidimArray< T1 > &op)
double atomCovalentRadius(const std::string &atom)
void projectAtom(const Atom &atom, Projection &P, const Matrix2D< double > &VP, const Matrix2D< double > &PV, const AtomInterpolator &interpolator)
void addAtom(const RichAtom &atom)
Add Atom.
void FFT_magnitude(const MultidimArray< std::complex< double > > &v, MultidimArray< double > &mag)
Incorrect value received.
void writePDB(const FileName &fnPDB, bool renumber, const std::vector< std::string > &remarks, const callable &atomList)
Write rich phantom to PDB file.
void getRow(size_t i, Matrix1D< T > &v) const
double fitness(double *p)
void readPDB(const FileName &fnPDB, const callable &addAtom)
Read phantom from PDB.
#define V3_PLUS_V3(a, b, c)
#define IMGPIXEL(I, i, j)
#define SPEED_UP_temps012
std::string altloc
Alternate location.
void SincKaiserMask(MultidimArray< double > &mask, double omega, double delta, double Deltaw)