60 VPRIVATE
char *Valist_whiteChars = " \t\r\n";
61 VPRIVATE
char *Valist_commChars = "
#%"; 62 VPRIVATE
char *Valist_xmlwhiteChars =
" \t\r\n<>";
64 #if !defined(VINLINE_VATOM) 69 Vnm_print(2,
"Valist_getCenterX: Found null pointer when getting the center of X coordinate!\n");
79 Vnm_print(2,
"Valist_getCenterY: Found null pointer when getting the center of Y coordinate!\n");
88 Vnm_print(2,
"Valist_getCenterZ: Found null pointer when getting the center of Z coordinate!\n");
98 Vnm_print(2,
"Valist_getAtomList: Found null pointer when getting the atom list!\n");
108 Vnm_print(2,
"Valist_getNumberAtoms: Found null pointer when getting the number of atoms!\n");
118 Vnm_print(2,
"Valist_getAtom: Found null pointer when getting atoms!\n");
122 Vnm_print(2,
"Valist_getAtom: Requested atom number (%d) outside of atom list range (%d)!\n", i, thee->
number);
125 return &(thee->
atoms[i]);
131 if (thee == NULL)
return 0;
132 return Vmem_bytes(thee->
vmem);
143 if ( thee == VNULL) {
144 Vnm_print(2,
"Valist_ctor: Got NULL pointer when constructing the atom list object!\n");
148 Vnm_print(2,
"Valist_ctor: Error in constructing the atom list object!\n");
161 thee->
vmem = Vmem_ctor(
"APBS:VALIST");
169 if ((*thee) != VNULL) {
171 Vmem_free(VNULL, 1,
sizeof(
Valist), (
void **)thee);
182 Vmem_dtor(&(thee->
vmem));
186 VPRIVATE Vrc_Codes Valist_readPDBSerial(
Valist *thee, Vio *sock,
int *serial) {
188 char tok[VMAX_BUFSIZE];
191 if (Vio_scanf(sock,
"%s", tok) != 1) {
192 Vnm_print(2,
"Valist_readPDB: Ran out of tokens while parsing serial!\n");
195 if (sscanf(tok,
"%d", &ti) != 1) {
196 Vnm_print(2,
"Valist_readPDB: Unable to parse serial token (%s) as int!\n",
206 VPRIVATE Vrc_Codes Valist_readPDBAtomName(
Valist *thee, Vio *sock,
207 char atomName[VMAX_ARGLEN]) {
209 char tok[VMAX_BUFSIZE];
211 if (Vio_scanf(sock,
"%s", tok) != 1) {
212 Vnm_print(2,
"Valist_readPDB: Ran out of tokens while parsing atom name!\n");
215 if (strlen(tok) < VMAX_ARGLEN) strcpy(atomName, tok);
217 Vnm_print(2,
"Valist_readPDB: Atom name (%s) too long!\n", tok);
224 VPRIVATE Vrc_Codes Valist_readPDBResidueName(
Valist *thee, Vio *sock,
225 char resName[VMAX_ARGLEN]) {
227 char tok[VMAX_BUFSIZE];
229 if (Vio_scanf(sock,
"%s", tok) != 1) {
230 Vnm_print(2,
"Valist_readPDB: Ran out of tokens while parsing residue name!\n");
233 if (strlen(tok) < VMAX_ARGLEN) strcpy(resName, tok);
235 Vnm_print(2,
"Valist_readPDB: Residue name (%s) too long!\n", tok);
242 VPRIVATE Vrc_Codes Valist_readPDBResidueNumber(
243 Valist *thee, Vio *sock,
int *resSeq) {
245 char tok[VMAX_BUFSIZE];
249 if (Vio_scanf(sock,
"%s", tok) != 1) {
250 Vnm_print(2,
"Valist_readPDB: Ran out of tokens while parsing resSeq!\n");
253 if (sscanf(tok,
"%d", &ti) != 1) {
262 if (strlen(tok) == 1) {
266 if (Vio_scanf(sock,
"%s", tok) != 1) {
267 Vnm_print(2,
"Valist_readPDB: Ran out of tokens while parsing resSeq!\n");
270 if (sscanf(tok,
"%d", &ti) != 1) {
271 Vnm_print(2,
"Valist_readPDB: Unable to parse resSeq token (%s) as int!\n",
284 if (sscanf(resstring,
"%d", &ti) != 1) {
286 Vnm_print(2,
"Valist_readPDB: Unable to parse resSeq token (%s) as int!\n",
298 VPRIVATE Vrc_Codes Valist_readPDBAtomCoord(
Valist *thee, Vio *sock,
double *coord) {
300 char tok[VMAX_BUFSIZE];
303 if (Vio_scanf(sock,
"%s", tok) != 1) {
304 Vnm_print(2,
"Valist_readPDB: Ran out of tokens while parsing atom coordinate!\n");
307 if (sscanf(tok,
"%lf", &tf) != 1) {
316 VPRIVATE Vrc_Codes Valist_readPDBChargeRadius(
Valist *thee, Vio *sock,
317 double *charge,
double *radius) {
319 char tok[VMAX_BUFSIZE];
322 if (Vio_scanf(sock,
"%s", tok) != 1) {
323 Vnm_print(2,
"Valist_readPQR: Ran out of tokens while parsing charge!\n");
326 if (sscanf(tok,
"%lf", &tf) != 1) {
331 if (Vio_scanf(sock,
"%s", tok) != 1) {
332 Vnm_print(2,
"Valist_readPQR: Ran out of tokens while parsing radius!\n");
335 if (sscanf(tok,
"%lf", &tf) != 1) {
344 VPRIVATE Vrc_Codes Valist_readPDB_throughXYZ(
348 char atomName[VMAX_ARGLEN],
349 char resName[VMAX_ARGLEN],
360 if (Valist_readPDBSerial(thee, sock, serial) ==
VRC_FAILURE) {
361 Vnm_print(2,
"Valist_readPDB: Error while parsing serial!\n");
365 if (Valist_readPDBAtomName(thee, sock, atomName) ==
VRC_FAILURE) {
366 Vnm_print(2,
"Valist_readPDB: Error while parsing atom name!\n");
371 if (Valist_readPDBResidueName(thee, sock, resName) ==
VRC_FAILURE) {
372 Vnm_print(2,
"Valist_readPDB: Error while parsing residue name!\n");
378 if (Valist_readPDBResidueNumber(thee, sock, resSeq) ==
VRC_FAILURE) {
379 Vnm_print(2,
"Valist_readPDB: Error while parsing residue number!\n");
389 for (i=0; i<(njunk+1); i++) {
390 if (Valist_readPDBAtomCoord(thee, sock, x) ==
VRC_SUCCESS) {
396 Vnm_print(2,
"Valist_readPDB: Can't find x!\n");
400 if (Valist_readPDBAtomCoord(thee, sock, y) ==
VRC_FAILURE) {
401 Vnm_print(2,
"Valist_readPDB: Can't find y!\n");
405 if (Valist_readPDBAtomCoord(thee, sock, z) ==
VRC_FAILURE) {
406 Vnm_print(2,
"Valist_readPDB: Can't find z!\n");
411 Vnm_print(1,
"Valist_readPDB: serial = %d\n", *serial);
412 Vnm_print(1,
"Valist_readPDB: atomName = %s\n", atomName);
413 Vnm_print(1,
"Valist_readPDB: resName = %s\n", resName);
414 Vnm_print(1,
"Valist_readPDB: resSeq = %d\n", *resSeq);
415 Vnm_print(1,
"Valist_readPDB: pos = (%g, %g, %g)\n",
424 VPRIVATE
Vatom* Valist_getAtomStorage(
432 Vatom *oldList, *newList, *theList;
433 Vatom *oldAtom, *newAtom;
434 int iatom, inext, oldLength, newLength, natoms;
439 if (*pnatoms >= *pnlist) {
443 newLength = 2*oldLength;
444 newList = (
Vatom*)Vmem_malloc(thee->
vmem, newLength,
sizeof(
Vatom));
448 if (newList == VNULL) {
449 Vnm_print(2,
"Valist_readPDB: failed to allocate space for %d (Vatom)s!\n", newLength);
455 for (iatom=0; iatom<natoms; iatom++) {
456 oldAtom = &(oldList[iatom]);
457 newAtom = &(newList[iatom]);
463 Vmem_free(thee->
vmem, oldLength,
sizeof(
Vatom), (
void **)plist);
474 newAtom = &(theList[inext]);
475 *pnatoms = inext + 1;
480 VPRIVATE Vrc_Codes Valist_setAtomArray(
Valist *thee,
486 Vatom *list, *newAtom, *oldAtom;
494 if (thee->
atoms == VNULL) {
495 Vnm_print(2,
"Valist_readPDB: Unable to allocate space for %d (Vatom)s!\n",
502 for (i=0; i<thee->
number; i++) {
503 newAtom = &(thee->
atoms[i]);
504 oldAtom = &(list[i]);
510 Vmem_free(thee->
vmem, nlist,
sizeof(
Vatom), (
void **)plist);
520 Vatom *atoms = VNULL;
521 Vatom *nextAtom = VNULL;
524 char tok[VMAX_BUFSIZE];
525 char atomName[VMAX_ARGLEN], resName[VMAX_ARGLEN];
527 int nlist, natoms, serial, resSeq;
529 double x, y, z, charge, radius, epsilon;
533 Vnm_print(2,
"Valist_readPDB: Got NULL pointer when reading PDB file!\n");
538 Vio_setWhiteChars(sock, Valist_whiteChars);
539 Vio_setCommChars(sock, Valist_commChars);
547 while (Vio_scanf(sock,
"%s", tok) == 1) {
554 if (Valist_readPDB_throughXYZ(thee, sock, &serial, atomName,
556 Vnm_print(2,
"Valist_readPDB: Error parsing atom %d!\n",
563 if (atomData == VNULL) {
564 Vnm_print(2,
"Valist_readPDB: Couldn't find parameters for \ 565 atom = %s, residue = %s\n", atomName, resName);
568 charge = atomData->
charge;
569 radius = atomData->
radius;
573 nextAtom = Valist_getAtomStorage(thee, &atoms, &nlist, &natoms);
574 if (nextAtom == VNULL) {
575 Vnm_print(2,
"Valist_readPDB: Error in allocating spacing for atoms!\n");
580 pos[0] = x; pos[1] = y; pos[2] = z;
592 Vnm_print(0,
"Valist_readPDB: Counted %d atoms\n", natoms);
596 if (Valist_setAtomArray(thee, &atoms, nlist, natoms) ==
VRC_FAILURE) {
597 Vnm_print(2,
"Valist_readPDB: unable to store atoms!\n");
612 Vatom *atoms = VNULL;
613 Vatom *nextAtom = VNULL;
616 char tok[VMAX_BUFSIZE];
617 char atomName[VMAX_ARGLEN], resName[VMAX_ARGLEN];
618 char chs[VMAX_BUFSIZE];
621 int nlist, natoms, serial, resSeq;
623 double x, y, z, charge, radius, epsilon;
629 Vnm_print(2,
"Valist_readPQR: Got NULL pointer when reading PQR file!\n");
634 Vio_setWhiteChars(sock, Valist_whiteChars);
635 Vio_setCommChars(sock, Valist_commChars);
642 if(params != VNULL) use_params = 1;
646 while (Vio_scanf(sock,
"%s", tok) == 1) {
653 if (Valist_readPDB_throughXYZ(thee, sock, &serial, atomName,
655 Vnm_print(2,
"Valist_readPQR: Error parsing atom %d!\n",serial);
656 Vnm_print(2,
"Please double check this atom in the pqr file, e.g., make sure there are no concatenated fields.\n");
661 if (Valist_readPDBChargeRadius(thee, sock, &charge, &radius) ==
VRC_FAILURE) {
662 Vnm_print(2,
"Valist_readPQR: Error parsing atom %d!\n",
664 Vnm_print(2,
"Please double check this atom in the pqr file, e.g., make sure there are no concatenated fields.\n");
671 if (atomData == VNULL) {
672 Vnm_print(2,
"Valist_readPDB: Couldn't find parameters for \ 673 atom = %s, residue = %s\n", atomName, resName);
676 charge = atomData->
charge;
677 radius = atomData->
radius;
682 nextAtom = Valist_getAtomStorage(thee, &atoms, &nlist, &natoms);
683 if (nextAtom == VNULL) {
684 Vnm_print(2,
"Valist_readPQR: Error in allocating spacing for atoms!\n");
689 pos[0] = x; pos[1] = y; pos[2] = z;
711 Vnm_print(0,
"Valist_readPQR: Counted %d atoms\n", natoms);
715 if (Valist_setAtomArray(thee, &atoms, nlist, natoms) ==
VRC_FAILURE) {
716 Vnm_print(2,
"Valist_readPDB: unable to store atoms!\n");
727 Vatom *atoms = VNULL;
728 Vatom *nextAtom = VNULL;
730 char tok[VMAX_BUFSIZE];
731 char endtag[VMAX_BUFSIZE];
734 int xset, yset, zset, chgset, radset;
736 double x, y, z, charge, radius, dtmp;
740 Vnm_print(2,
"Valist_readXML: Got NULL pointer when reading XML file!\n");
745 Vio_setWhiteChars(sock, Valist_xmlwhiteChars);
746 Vio_setCommChars(sock, Valist_commChars);
762 Vnm_print(1,
"\nValist_readXML: Warning Warning Warning Warning Warning\n");
763 Vnm_print(1,
"Valist_readXML: The use of XML input files with parameter\n");
764 Vnm_print(1,
"Valist_readXML: files is currently not supported.\n");
765 Vnm_print(1,
"Valist_readXML: Warning Warning Warning Warning Warning\n\n");
769 while (Vio_scanf(sock,
"%s", tok) == 1) {
775 Vio_scanf(sock,
"%s", tok);
776 if (sscanf(tok,
"%lf", &dtmp) != 1) {
777 Vnm_print(2,
"Valist_readXML: Unexpected token (%s) while \ 784 Vio_scanf(sock,
"%s", tok);
785 if (sscanf(tok,
"%lf", &dtmp) != 1) {
786 Vnm_print(2,
"Valist_readXML: Unexpected token (%s) while \ 793 Vio_scanf(sock,
"%s", tok);
794 if (sscanf(tok,
"%lf", &dtmp) != 1) {
795 Vnm_print(2,
"Valist_readXML: Unexpected token (%s) while \ 802 Vio_scanf(sock,
"%s", tok);
803 if (sscanf(tok,
"%lf", &dtmp) != 1) {
804 Vnm_print(2,
"Valist_readXML: Unexpected token (%s) while \ 805 reading charge!\n", tok);
811 Vio_scanf(sock,
"%s", tok);
812 if (sscanf(tok,
"%lf", &dtmp) != 1) {
813 Vnm_print(2,
"Valist_readXML: Unexpected token (%s) while \ 814 reading radius!\n", tok);
822 nextAtom = Valist_getAtomStorage(thee, &atoms, &nlist, &natoms);
823 if (nextAtom == VNULL) {
824 Vnm_print(2,
"Valist_readXML: Error in allocating spacing for atoms!\n");
828 if (xset && yset && zset && chgset && radset){
831 pos[0] = x; pos[1] = y; pos[2] = z;
844 Vnm_print(2,
"Valist_readXML: Missing field(s) in atom tag:\n");
845 if (!xset) Vnm_print(2,
"\tx value not set!\n");
846 if (!yset) Vnm_print(2,
"\ty value not set!\n");
847 if (!zset) Vnm_print(2,
"\tz value not set!\n");
848 if (!chgset) Vnm_print(2,
"\tcharge value not set!\n");
849 if (!radset) Vnm_print(2,
"\tradius value not set!\n");
855 Vnm_print(0,
"Valist_readXML: Counted %d atoms\n", natoms);
859 if (Valist_setAtomArray(thee, &atoms, nlist, natoms) ==
VRC_FAILURE) {
860 Vnm_print(2,
"Valist_readXML: unable to store atoms!\n");
875 Vnm_print(2,
"Valist_getStatistics: Got NULL pointer when loading up Valist with various statistics!\n");
888 atom = &(thee->
atoms[0]);
889 for (i=0; i<3; i++) {
895 for (i=0; i<thee->
number; i++) {
897 atom = &(thee->
atoms[i]);
898 for (j=0; j<3; j++) {
912 Vnm_print(0,
"Valist_getStatistics: Max atom coordinate: (%g, %g, %g)\n",
914 Vnm_print(0,
"Valist_getStatistics: Min atom coordinate: (%g, %g, %g)\n",
916 Vnm_print(0,
"Valist_getStatistics: Molecule center: (%g, %g, %g)\n",
Contains declarations for class Valist.
VPUBLIC void Vatom_setEpsilon(Vatom *thee, double epsilon)
Set atomic epsilon.
VPUBLIC void Vatom_setAtomID(Vatom *thee, int atomID)
Set atom ID.
VPUBLIC Vrc_Codes Valist_ctor2(Valist *thee)
FORTRAN stub to construct the atom list object.
VPUBLIC int Valist_getNumberAtoms(Valist *thee)
Get number of atoms in the list.
VPUBLIC unsigned long int Valist_memChk(Valist *thee)
Get total memory allocated for this object and its members.
VPUBLIC void Vatom_setPosition(Vatom *thee, double position[3])
Set the atomic position.
VPUBLIC void Vatom_setAtomName(Vatom *thee, char atomName[VMAX_RECLEN])
Set atom name.
VPUBLIC double Valist_getCenterX(Valist *thee)
Get x-coordinate of molecule center.
AtomData sub-class; stores atom data.
VPUBLIC Vrc_Codes Valist_readXML(Valist *thee, Vparam *params, Vio *sock)
Fill atom list with information from an XML file.
VPUBLIC double Valist_getCenterY(Valist *thee)
Get y-coordinate of molecule center.
VPUBLIC void Vatom_copyTo(Vatom *thee, Vatom *dest)
Copy information to another atom.
#define VEMBED(rctag)
Allows embedding of RCS ID tags in object files.
VPUBLIC int Vstring_strcasecmp(const char *s1, const char *s2)
Case-insensitive string comparison (BSD standard)
VPUBLIC Vatom * Valist_getAtom(Valist *thee, int i)
Get pointer to particular atom in list.
VPUBLIC Vparam_AtomData * Vparam_getAtomData(Vparam *thee, char resName[VMAX_ARGLEN], char atomName[VMAX_ARGLEN])
Get atom data.
Reads and assigns charge/radii parameters.
VPUBLIC void Vatom_setRadius(Vatom *thee, double radius)
Set atomic radius.
VPUBLIC Vrc_Codes Valist_getStatistics(Valist *thee)
Load up Valist with various statistics.
VPUBLIC Vrc_Codes Valist_readPDB(Valist *thee, Vparam *param, Vio *sock)
Fill atom list with information from a PDB file.
VPUBLIC Vatom * Valist_getAtomList(Valist *thee)
Get actual array of atom objects from the list.
Contains public data members for Vatom class/module.
VPUBLIC void Vatom_setResName(Vatom *thee, char resName[VMAX_RECLEN])
Set residue name.
Container class for list of atom objects.
VPUBLIC double Valist_getCenterZ(Valist *thee)
Get z-coordinate of molecule center.
VPUBLIC Vrc_Codes Valist_readPQR(Valist *thee, Vparam *params, Vio *sock)
Fill atom list with information from a PQR file.
VPUBLIC void Valist_dtor2(Valist *thee)
FORTRAN stub to destroy atom list object.
VPUBLIC void Vatom_dtor2(Vatom *thee)
FORTRAN stub object destructor.
VPUBLIC void Vatom_setCharge(Vatom *thee, double charge)
Set atomic charge.
VPUBLIC void Valist_dtor(Valist **thee)
Destroys atom list object.
VPUBLIC Valist * Valist_ctor()
Construct the atom list object.