NAMD
Enumerations | Functions
FreeEnergyParse.h File Reference

Go to the source code of this file.

Enumerations

enum  item_t {
  kAtom, kResidue, kAtomName, kAtomNameList,
  kResidueRange, kStartGroup, kEndGroup, kUnknownItem
}
 
enum  restr_t {
  kPosi, kDist, kAngle, kDihe,
  kPosiBound, kDistBound, kAngleBound, kDiheBound,
  kPosiPMF, kDistPMF, kAnglePMF, kDihePMF,
  kUnknownRestr
}
 
enum  pmf_t {
  kTask, kTime, kLambda, kLambdaT,
  kPrint, kNoPrint, kEquilTime, kAccumTime,
  kNumRepeats, kUnknownPmf
}
 
enum  TimeUnits_t { k_fs, k_ps, k_ns, kUnknownTime }
 

Functions

void ReadInput (char *Str, ARestraintManager &RMgr, ALambdaManager &LMgr, GlobalMasterFreeEnergy &CFE, double dT)
 
int ReadRestraints (char *Str, ARestraintManager &RMgr, GlobalMasterFreeEnergy &CFE)
 
ARestraintGetRestraint (char *Str, int &NumChars, GlobalMasterFreeEnergy &CFE)
 
int ReadPmfBlock (char *Str, ALambdaControl &PmfBlock, double dT)
 
int ReadNextPmfSpec (char *Str, pmf_t &PmfSpec)
 
int ReadTaskType (char *Str, feptask_t &Task)
 
int ReadTimeUnits (char *Str, TimeUnits_t &Units, TimeUnits_t DefaultUnits)
 
double GetTime (double Val, TimeUnits_t Units)
 
void CheckParentheses (const char *Str)
 
void ProblemParsing (const char *Message, const char *Str, Bool_t Terminate=kTrue)
 
void ToLower (char *Str)
 
int ReadWhite (const char *Str)
 
int ReadAlphaNum (const char *Str)
 
int ReadAlpha (const char *Str)
 
int ReadDigits (const char *Str)
 
int ReadParentheses (const char *Str)
 
int IsStartGroup (char *Str)
 
int IsEndGroup (char *Str)
 
int IsAtomName (char *Str)
 
int IsAtomNameList (char *Str)
 
int IsAtom (char *Str)
 
int IsAResidue (char *Str)
 
int IsResidue (char *Str)
 
int IsResidueRange (char *Str)
 
int ReadWord (const char *Str, const char *Word, Bool_t ErrMsg=kFalse)
 
int ReadChar (char *Str, char Char, Bool_t ErrMsg=kFalse)
 
int ReadAValue (char *Str, double &Value, Bool_t ErrMsg=kFalse)
 
int ReadBound (char *Str, Bound_t &Bound)
 
item_t ReadNextItem (char *Str, int &NumChars)
 
restr_t ReadNextRestraintType (char *Str, int &NumChars)
 
int AddAtoms (AGroup &Group, char *Str, GlobalMasterFreeEnergy &CFE)
 
void AddAtom (AGroup &Group, char *Atom, GlobalMasterFreeEnergy &CFE)
 
void AddResidues (AGroup &Group, char *ResRange, GlobalMasterFreeEnergy &CFE)
 
void AddAtomsInResidues (AGroup &Group, char *AtomNames, char *ResRange, GlobalMasterFreeEnergy &CFE)
 
void AddAtom (AGroup &Group, char *ResRange, char *AtomName, GlobalMasterFreeEnergy &CFE)
 
void GetResRange (char *ResRange, int &ResNum1, int &ResNum2)
 
int GetSegName (char *Str, char *SegName)
 
int GetResNum (char *Str, int &ResNum)
 
int GetAtomName (char *Str, char *AtomName)
 

Enumeration Type Documentation

enum item_t

Copyright (c) 1995, 1996, 1997, 1998, 1999, 2000 by The Board of Trustees of the University of Illinois. All rights reserved.

Enumerator
kAtom 
kResidue 
kAtomName 
kAtomNameList 
kResidueRange 
kStartGroup 
kEndGroup 
kUnknownItem 

Definition at line 12 of file FreeEnergyParse.h.

enum pmf_t
Enumerator
kTask 
kTime 
kLambda 
kLambdaT 
kPrint 
kNoPrint 
kEquilTime 
kAccumTime 
kNumRepeats 
kUnknownPmf 

Definition at line 17 of file FreeEnergyParse.h.

enum restr_t
Enumerator
kPosi 
kDist 
kAngle 
kDihe 
kPosiBound 
kDistBound 
kAngleBound 
kDiheBound 
kPosiPMF 
kDistPMF 
kAnglePMF 
kDihePMF 
kUnknownRestr 

Definition at line 14 of file FreeEnergyParse.h.

Enumerator
k_fs 
k_ps 
k_ns 
kUnknownTime 

Definition at line 19 of file FreeEnergyParse.h.

Function Documentation

void AddAtom ( AGroup Group,
char *  Atom,
GlobalMasterFreeEnergy CFE 
)

Definition at line 1011 of file FreeEnergyParse.C.

References AddAtom(), and GetAtomName().

Referenced by AddAtom(), AddAtoms(), and AddAtomsInResidues().

1011  {
1012 //-------------------------------------------------------------------
1013 // Group contains a list of int's representing AtomID's.
1014 // Atom should be "(segname, resnum, atomname)"
1015 // get the atomID for Atom, and add it to Group.
1016 //-------------------------------------------------------------------
1017  char AtomName[21];
1018 
1019  GetAtomName(Atom, AtomName);
1020  AddAtom(Group, Atom, AtomName, CFE);
1021 }
int GetAtomName(char *Str, char *AtomName)
void AddAtom(AGroup &Group, char *Atom, GlobalMasterFreeEnergy &CFE)
void AddAtom ( AGroup Group,
char *  ResRange,
char *  AtomName,
GlobalMasterFreeEnergy CFE 
)

Definition at line 1024 of file FreeEnergyParse.C.

References AGroup::Add(), GlobalMasterFreeEnergy::getAtomID(), GetResRange(), GetSegName(), ProblemParsing(), and GlobalMasterFreeEnergy::requestAtom().

1025  {
1026 //-------------------------------------------------------------------
1027 // Group contains a list of int's representing AtomID's.
1028 // ResRange should be "(segname, resnum) to (segname, resnum)"
1029 // or "(segname, resnum)"
1030 // AtomName is specified separately.
1031 // get the atomID, and add it to Group.
1032 //-------------------------------------------------------------------
1033  char SegName[21];
1034  int ResNum, ResNum1, ResNum2, AtomID, RetVal;
1035 
1036  // convert "(segname, resnum1) to (segname, resnum2)"
1037  // -> SegName, ResNum1, ResNum2
1038  GetSegName(ResRange, SegName);
1039  GetResRange(ResRange, ResNum1, ResNum2);
1040 
1041  // get atomID for each atom in the specified residue range
1042  // register it, add it to Group
1043  for (ResNum=ResNum1; ResNum<=ResNum2; ResNum++) {
1044  AtomID = CFE.getAtomID(SegName, ResNum, AtomName);
1045  if (AtomID < 0) { ProblemParsing("Invalid AtomID", ResRange); }
1046  RetVal = CFE.requestAtom(AtomID);
1047  if (RetVal < 0) { ProblemParsing("Unable to requestAtom", ResRange); }
1048  Group.Add(AtomID);
1049  }
1050 }
int getAtomID(const char *segid, int resid, const char *aname)
int AtomID
Definition: NamdTypes.h:29
void ProblemParsing(const char *Message, const char *Str, Bool_t Terminate)
void Add(int AnInt)
int GetSegName(char *Str, char *SegName)
void GetResRange(char *ResRange, int &ResNum1, int &ResNum2)
int AddAtoms ( AGroup Group,
char *  Str,
GlobalMasterFreeEnergy CFE 
)

Definition at line 875 of file FreeEnergyParse.C.

References AddAtom(), AddAtomsInResidues(), AddResidues(), kAtom, kAtomName, kAtomNameList, kEndGroup, kFalse, kResidue, kResidueRange, kStartGroup, kTrue, ProblemParsing(), ReadNextItem(), and ReadWhite().

Referenced by GetRestraint().

875  {
876 //----------------------------------------------------------------------------
877 // Str contains specifications for which atoms to add to Group.
878 // The atoms may be:
879 // a) a single atom, b) all atoms of a residue, c) a list of atoms
880 // d) all atoms in a list of residues, e) all atoms in a range of residues,
881 // e) one or more atomnames in a list of residues, or
882 // f) one or more atomnames in a range of residues
883 // Add the AtomID's for these specified atoms to Group.
884 // return the number of characters in Str that were read.
885 //----------------------------------------------------------------------------
886  int NumChars;
887  int RetNumChars = 0;
888  Bool_t GroupMode = kFalse;
889  Bool_t AtomList = kFalse;
890  Bool_t Finished = kFalse;
891  char* SavePtr = 0;
892 
893  while (!Finished) {
894  switch(ReadNextItem(Str, NumChars)) {
895  case kStartGroup:
896  GroupMode = kTrue;
897  break;
898  case kEndGroup:
899  Finished = kTrue;
900  break;
901  case kAtom:
902  AddAtom(Group, Str, CFE);
903  if (!GroupMode) {
904  Finished = kTrue;
905  }
906  break;
907  case kAtomName:
908  case kAtomNameList:
909  AtomList = kTrue;
910  SavePtr = Str;
911  break;
912  case kResidue:
913  case kResidueRange:
914  if (AtomList) {
915  AddAtomsInResidues(Group, SavePtr, Str, CFE);
916  }
917  else {
918  AddResidues(Group, Str, CFE);
919  }
920  if (!GroupMode) {
921  Finished = kTrue;
922  }
923  break;
924  default:
925  Finished = kTrue;
926  ProblemParsing("Can't Read Atoms", Str);
927  break;
928  }
929  Str += NumChars;
930  RetNumChars += NumChars;
931  }
932  RetNumChars += ReadWhite(Str);
933  return(RetNumChars);
934 }
int ReadWhite(const char *Str)
void AddResidues(AGroup &Group, char *ResRange, GlobalMasterFreeEnergy &CFE)
void ProblemParsing(const char *Message, const char *Str, Bool_t Terminate)
Bool_t
void AddAtom(AGroup &Group, char *Atom, GlobalMasterFreeEnergy &CFE)
item_t ReadNextItem(char *Str, int &NumChars)
void AddAtomsInResidues(AGroup &Group, char *AtomNames, char *ResRange, GlobalMasterFreeEnergy &CFE)
void AddAtomsInResidues ( AGroup Group,
char *  AtomNames,
char *  ResRange,
GlobalMasterFreeEnergy CFE 
)

Definition at line 937 of file FreeEnergyParse.C.

References AddAtom(), AddResidues(), ReadAlphaNum(), and ReadWhite().

Referenced by AddAtoms().

938  {
939 //-------------------------------------------------------------------
940 // Group contains a list of int's representing AtomID's.
941 // ResRange should be "(segname, resnum) to (segname, resnum)"
942 // or "(segname, resnum)"
943 // AtomNames should be "(atomname, atomname, ...):" or "atomname:"
944 // get the atomID's for each atomname in ResRange, add them to Group.
945 //-------------------------------------------------------------------
946  int Count, ArrayIndex, i;
947  char AtomNamesArray[21][30];
948 
949  // skip to start of first atomname
950  if (AtomNames[0] == '(') {
951  AtomNames++;
952  Count = ReadWhite(AtomNames);
953  AtomNames += Count;
954  }
955  // put each atomname into the array, finish when ':' or ')' is found
956  ArrayIndex = 0;
957  while ( (AtomNames[0]!=':') && (AtomNames[0]!=')') ) {
958  Count = ReadAlphaNum(AtomNames);
959  strncpy(AtomNamesArray[ArrayIndex], AtomNames, Count);
960  AtomNamesArray[ArrayIndex][Count] = '\0';
961  AtomNames += Count;
962  Count = ReadWhite(AtomNames);
963  AtomNames += Count;
964  ArrayIndex++;
965  }
966  // now add each atomname of Res to Group.
967  // if "all" is specified, add all atoms of Res to Group.
968  for (i=0; i<ArrayIndex; i++) {
969  if (strcmp(AtomNamesArray[i], "all") == 0) {
970  AddResidues(Group, ResRange, CFE);
971  }
972  else {
973  AddAtom(Group, ResRange, AtomNamesArray[i], CFE);
974  }
975  }
976 }
int ReadAlphaNum(const char *Str)
int ReadWhite(const char *Str)
void AddResidues(AGroup &Group, char *ResRange, GlobalMasterFreeEnergy &CFE)
void AddAtom(AGroup &Group, char *Atom, GlobalMasterFreeEnergy &CFE)
void AddResidues ( AGroup Group,
char *  ResRange,
GlobalMasterFreeEnergy CFE 
)

Definition at line 979 of file FreeEnergyParse.C.

References AGroup::Add(), GlobalMasterFreeEnergy::getAtomID(), GlobalMasterFreeEnergy::getNumAtoms(), GetResRange(), GetSegName(), ProblemParsing(), and GlobalMasterFreeEnergy::requestAtom().

Referenced by AddAtoms(), and AddAtomsInResidues().

979  {
980 //-------------------------------------------------------------------
981 // Group contains a list of int's representing AtomID's.
982 // ResRange should be "(segname, resnum) to (segname, resnum)"
983 // or "(segname, resnum)"
984 // get the atomID's for each atom of ResRange, and add them to Group.
985 //-------------------------------------------------------------------
986  char SegName[21];
987  int ResNum1, ResNum2, ResNum;
988  int i, NumAtoms, AtomID, RetVal;
989 
990  // get start and stop residue numbers
991  GetSegName(ResRange, SegName);
992  GetResRange(ResRange, ResNum1, ResNum2);
993 
994  // for each residue of residue range
995  for (ResNum=ResNum1; ResNum<=ResNum2; ResNum++) {
996  // for each atom of residue
997  NumAtoms = CFE.getNumAtoms(SegName, ResNum);
998  if (NumAtoms < 1) { ProblemParsing("No Atoms in Residue", ResRange); }
999  for (i=0; i<NumAtoms; i++) {
1000  // get atomID, register it, add it to Group
1001  AtomID = CFE.getAtomID(SegName, ResNum, i);
1002  if (AtomID < 0) { ProblemParsing("Invalid AtomID", ResRange); }
1003  RetVal = CFE.requestAtom(AtomID);
1004  if (RetVal < 0) { ProblemParsing("Unable to requestAtom", ResRange); }
1005  Group.Add(AtomID);
1006  }
1007  }
1008 }
int getAtomID(const char *segid, int resid, const char *aname)
int AtomID
Definition: NamdTypes.h:29
void ProblemParsing(const char *Message, const char *Str, Bool_t Terminate)
void Add(int AnInt)
int GetSegName(char *Str, char *SegName)
void GetResRange(char *ResRange, int &ResNum1, int &ResNum2)
int getNumAtoms(const char *segid, int resid)
void CheckParentheses ( const char *  Str)

Definition at line 54 of file FreeEnergyParse.C.

References ProblemParsing().

Referenced by ReadInput().

54  {
55 //----------------------------------------------------------------------------
56 // check for balanced '(' ')' and '{' '}'
57 //----------------------------------------------------------------------------
58  int ParenthesesCount = 0;
59  int CurlyBracketCount = 0;
60 
61  for (unsigned int i=0; i<strlen(Str); i++) {
62  if (Str[i] == '(') {ParenthesesCount++;}
63  if (Str[i] == ')') {ParenthesesCount--;}
64  if (Str[i] == '{') {CurlyBracketCount++;}
65  if (Str[i] == '}') {CurlyBracketCount--;}
66  if ((ParenthesesCount<0) || (CurlyBracketCount<0)) {
67  ProblemParsing("Mismatched Parentheses", Str+i);
68  }
69  }
70 }
void ProblemParsing(const char *Message, const char *Str, Bool_t Terminate)
int GetAtomName ( char *  Str,
char *  AtomName 
)

Definition at line 1134 of file FreeEnergyParse.C.

References GetResNum(), ProblemParsing(), ReadAlphaNum(), and ReadWhite().

Referenced by AddAtom().

1134  {
1135 //-------------------------------------------------------------------
1136 // Str should be (segname, resnum, atomname)
1137 // put atomname into AtomName
1138 // return the number of characters from start-of-Str thru ')'
1139 //-------------------------------------------------------------------
1140  int Count, ResNum;
1141  char* FullString=Str;
1142 
1143  Str += GetResNum(Str, ResNum);
1144  Str += ReadWhite(Str);
1145  Count = ReadAlphaNum(Str);
1146  if (Count == 0) {ProblemParsing("Missing Atom Name", Str);}
1147  strncpy(AtomName, Str, Count);
1148  AtomName[Count] = '\0';
1149  Str += Count;
1150  Str += ReadWhite(Str);
1151  if (Str[0] != ')') {ProblemParsing("Missing )", Str);}
1152  Str += 1;
1153  return(Str-FullString);
1154 }
int ReadAlphaNum(const char *Str)
int ReadWhite(const char *Str)
void ProblemParsing(const char *Message, const char *Str, Bool_t Terminate)
int GetResNum(char *Str, int &ResNum)
int GetResNum ( char *  Str,
int &  ResNum 
)

Definition at line 1114 of file FreeEnergyParse.C.

References GetSegName(), ProblemParsing(), ReadDigits(), and ReadWhite().

Referenced by GetAtomName(), and GetResRange().

1114  {
1115 //-------------------------------------------------------------------
1116 // Str should be (segname, resnum) or (segname, resnum, atomname)
1117 // convert resnum to an int and return it
1118 // return the number of characters from start-of-Str thru resnum
1119 //-------------------------------------------------------------------
1120  int Count;
1121  char SegName[21];
1122  char* FullString=Str;
1123 
1124  Str += GetSegName(Str, SegName);
1125  Str += ReadWhite(Str);
1126  ResNum = (int) strtol(Str, NULL, 10);
1127  Count = ReadDigits(Str);
1128  if (Count == 0) {ProblemParsing("Missing Residue Number", Str);}
1129  Str += Count;
1130  return(Str-FullString);
1131 }
int ReadWhite(const char *Str)
void ProblemParsing(const char *Message, const char *Str, Bool_t Terminate)
int ReadDigits(const char *Str)
int GetSegName(char *Str, char *SegName)
void GetResRange ( char *  ResRange,
int &  ResNum1,
int &  ResNum2 
)

Definition at line 1053 of file FreeEnergyParse.C.

References GetResNum(), GetSegName(), ProblemParsing(), ReadAlphaNum(), ReadParentheses(), and ReadWhite().

Referenced by AddAtom(), and AddResidues().

1053  {
1054 //-------------------------------------------------------------------
1055 // ResRange should be "(segname, resnum1) to (segname, resnum2)"
1056 // return ResNum1 & ResNum2
1057 // if "to" is missing, return resnum1 in both ResNum1 & ResNum2
1058 //-------------------------------------------------------------------
1059  char SegName1[21], SegName2[21];
1060 
1061  // get start residue number
1062  GetSegName(ResRange, SegName1);
1063  GetResNum(ResRange, ResNum1);
1064 
1065  // skip to where "to" should appear
1066  ResRange += ReadParentheses(ResRange);
1067  ResRange += ReadWhite(ResRange);
1068 
1069  // if "to" is found
1070  if (strncmp(ResRange, "to", 2) == 0) {
1071  //skip to next residue
1072  ResRange += ReadAlphaNum(ResRange);
1073  ResRange += ReadWhite(ResRange);
1074  // get final residue number
1075  GetSegName(ResRange, SegName2);
1076  GetResNum(ResRange, ResNum2);
1077  // do some checks
1078  if (strcmp(SegName1, SegName2)!=0) {
1079  ProblemParsing("SegNames Differ", ResRange);
1080  }
1081  if (ResNum2 < ResNum1) {
1082  ProblemParsing("Decreasing Residues", ResRange);
1083  }
1084  }
1085 
1086  // otherwise, ResNum2 = ResNum1
1087  else {
1088  ResNum2 = ResNum1;
1089  }
1090 }
int ReadAlphaNum(const char *Str)
int ReadWhite(const char *Str)
int ReadParentheses(const char *Str)
void ProblemParsing(const char *Message, const char *Str, Bool_t Terminate)
int GetResNum(char *Str, int &ResNum)
int GetSegName(char *Str, char *SegName)
ARestraint* GetRestraint ( char *  Str,
int &  NumChars,
GlobalMasterFreeEnergy CFE 
)

Definition at line 410 of file FreeEnergyParse.C.

References A, AddAtoms(), ASSERT, kAngle, kAngleBound, kAnglePMF, kDihe, kDiheBound, kDihePMF, kDist, kDistBound, kDistPMF, kPi, kPosi, kPosiBound, kPosiPMF, kTrue, kUnknownRestr, ProblemParsing(), ReadAValue(), ReadBound(), ReadChar(), ReadNextRestraintType(), ReadWord(), ARestraint::SetBound(), ARestraint::SetGroups(), ARestraint::SetIntervalAngle(), ARestraint::SetKf(), ARestraint::SetLowerAngle(), ARestraint::SetRefAngle(), ARestraint::SetRefDist(), ARestraint::SetRefPos(), ARestraint::SetStartAngle(), ARestraint::SetStartDist(), ARestraint::SetStartPos(), ARestraint::SetStopAngle(), ARestraint::SetStopDist(), ARestraint::SetStopPos(), and ARestraint::SetUpperAngle().

Referenced by ReadRestraints().

410  {
411 //----------------------------------------------------------------------------
412 // read spec's for a restraint, from the input string.
413 // allocate space for and initialize a restraint object with these specs.
414 // note: memory is allocated here, and free'd elsewhere.
415 //
416 // return a pointer to this object.
417 // return the number of characters to read past these specs.
418 // return NumChars=0 for illegal restraint specs.
419 //----------------------------------------------------------------------------
420  AGroup Group1, Group2, Group3, Group4;
421  ARestraint* pRestraint = NULL;
422  restr_t Restraint;
423  Bound_t Bound;
424  int Count;
425  double Kf;
426  double D, D0, D1;
427  double A=0, A0=0, A1=0, A2=0;
428  AVector Pos, Pos0, Pos1;
429  char* FullStr;
430  char* TempStr;
431 
432  const Bool_t kPrintErrMsg=kTrue; // kNoErrMsg=kFalse;
433 
434  // save pointer to full string
435  FullStr = Str;
436  NumChars = 0;
437 
438  // get restraint type
439  Restraint = ReadNextRestraintType(Str, Count);
440  if (Count == 0) {
441  ProblemParsing("Can't Read Restraint Type", Str);
442  return(pRestraint);
443  }
444 
445  // skip past restraint type
446  ASSERT(Restraint != kUnknownRestr);
447  Str += Count;
448 
449  // read in appropriate number of atoms or groups-of-atoms for
450  // this restraint type, put the atoms in Group1 thru Group4
451  switch (Restraint) {
452  case kDihe: case kDiheBound: case kDihePMF:
453  Str += AddAtoms(Group4, Str, CFE);
454  case kAngle: case kAngleBound: case kAnglePMF:
455  Str += AddAtoms(Group3, Str, CFE);
456  case kDist: case kDistBound: case kDistPMF:
457  Str += AddAtoms(Group2, Str, CFE);
458  case kPosi: case kPosiBound: case kPosiPMF:
459  Str += AddAtoms(Group1, Str, CFE);
460  default: ;
461  }
462 
463  // for dihedrals, allow keywords of "barr=", "gap=", OR "kf="
464  // for other restraints, just allow "kf="
465  TempStr = Str;
466  switch(Restraint) {
467  case kDihe:
468  case kDiheBound:
469  case kDihePMF:
470  Str += ReadWord(Str, "barr");
471  Str += ReadWord(Str, "gap");
472  default:
473  Str += ReadWord(Str, "kf");
474  // make sure the word "barr", "gap", or "kf" was read
475  if (Str==TempStr) {
476  ProblemParsing("Word Missing: barr, gap, or kf", Str);
477  }
478  Str += ReadChar(Str, '=');
479  }
480  // get the Kf value
481  Str += ReadAValue(Str, Kf, kPrintErrMsg);
482 
483  // read the reference positions, distances or angles
484  switch (Restraint) {
485  case kPosi:
486  Str += ReadWord(Str, "ref", kPrintErrMsg);
487  Str += ReadChar(Str, '=');
488  Str += ReadChar(Str, '(');
489  Str += ReadAValue(Str, Pos[0], kPrintErrMsg);
490  Str += ReadAValue(Str, Pos[1], kPrintErrMsg);
491  Str += ReadAValue(Str, Pos[2], kPrintErrMsg);
492  Str += ReadChar(Str, ')');
493  break;
494  case kDist:
495  Str += ReadWord(Str, "ref", kPrintErrMsg);
496  Str += ReadChar(Str, '=');
497  Str += ReadAValue(Str, D, kPrintErrMsg);
498  break;
499  case kAngle:
500  Str += ReadWord(Str, "ref", kPrintErrMsg);
501  Str += ReadChar(Str, '=');
502  Str += ReadAValue(Str, A, kPrintErrMsg);
503  break;
504  case kDihe:
505  Str += ReadWord(Str, "ref", kPrintErrMsg);
506  Str += ReadChar(Str, '=');
507  Str += ReadAValue(Str, A, kPrintErrMsg);
508  break;
509  case kPosiBound:
510  if (ReadBound(Str, Bound) == 0) {ProblemParsing("Missing Bound", Str);}
511  Str += ReadWord(Str, "low");
512  Str += ReadWord(Str, "hi");
513  Str += ReadChar(Str, '=');
514  Str += ReadChar(Str, '(');
515  Str += ReadAValue(Str, Pos[0], kPrintErrMsg);
516  Str += ReadAValue(Str, Pos[1], kPrintErrMsg);
517  Str += ReadAValue(Str, Pos[2], kPrintErrMsg);
518  Str += ReadAValue(Str, D, kPrintErrMsg);
519  Str += ReadChar(Str, ')');
520  break;
521  case kDistBound:
522  if (ReadBound(Str, Bound) == 0) {ProblemParsing("Missing Bound", Str);}
523  Str += ReadWord(Str, "low");
524  Str += ReadWord(Str, "hi");
525  Str += ReadChar(Str, '=');
526  Str += ReadAValue(Str, D, kPrintErrMsg);
527  break;
528  case kAngleBound:
529  if (ReadBound(Str, Bound) == 0) {ProblemParsing("Missing Bound", Str);}
530  Str += ReadWord(Str, "low");
531  Str += ReadWord(Str, "hi");
532  Str += ReadChar(Str, '=');
533  Str += ReadAValue(Str, A, kPrintErrMsg);
534  break;
535  case kDiheBound:
536  Str += ReadWord(Str, "low", kPrintErrMsg);
537  Str += ReadChar(Str, '=');
538  Str += ReadAValue(Str, A0, kPrintErrMsg);
539  Str += ReadWord(Str, "hi", kPrintErrMsg);
540  Str += ReadChar(Str, '=');
541  Str += ReadAValue(Str, A1, kPrintErrMsg);
542  Str += ReadWord(Str, "delta", kPrintErrMsg);
543  Str += ReadChar(Str, '=');
544  Str += ReadAValue(Str, A2, kPrintErrMsg);
545  break;
546  case kPosiPMF:
547  Str += ReadWord(Str, "low", kPrintErrMsg);
548  Str += ReadChar(Str, '=');
549  Str += ReadChar(Str, '(');
550  Str += ReadAValue(Str, Pos0[0], kPrintErrMsg);
551  Str += ReadAValue(Str, Pos0[1], kPrintErrMsg);
552  Str += ReadAValue(Str, Pos0[2], kPrintErrMsg);
553  Str += ReadChar(Str, ')');
554  Str += ReadWord(Str, "hi", kPrintErrMsg);
555  Str += ReadChar(Str, '=');
556  Str += ReadChar(Str, '(');
557  Str += ReadAValue(Str, Pos1[0], kPrintErrMsg);
558  Str += ReadAValue(Str, Pos1[1], kPrintErrMsg);
559  Str += ReadAValue(Str, Pos1[2], kPrintErrMsg);
560  Str += ReadChar(Str, ')');
561  break;
562  case kDistPMF:
563  Str += ReadWord(Str, "low", kPrintErrMsg);
564  Str += ReadChar(Str, '=');
565  Str += ReadAValue(Str, D0, kPrintErrMsg);
566  Str += ReadWord(Str, "hi", kPrintErrMsg);
567  Str += ReadChar(Str, '=');
568  Str += ReadAValue(Str, D1, kPrintErrMsg);
569  break;
570  case kAnglePMF:
571  Str += ReadWord(Str, "low", kPrintErrMsg);
572  Str += ReadChar(Str, '=');
573  Str += ReadAValue(Str, A0, kPrintErrMsg);
574  Str += ReadWord(Str, "hi", kPrintErrMsg);
575  Str += ReadChar(Str, '=');
576  Str += ReadAValue(Str, A1, kPrintErrMsg);
577  break;
578  case kDihePMF:
579  Str += ReadWord(Str, "low", kPrintErrMsg);
580  Str += ReadChar(Str, '=');
581  Str += ReadAValue(Str, A0, kPrintErrMsg);
582  Str += ReadWord(Str, "hi", kPrintErrMsg);
583  Str += ReadChar(Str, '=');
584  Str += ReadAValue(Str, A1, kPrintErrMsg);
585  break;
586  default: ;
587  }
588 
589  // convert degrees to radians
590  A *= (kPi/180);
591  A0 *= (kPi/180);
592  A1 *= (kPi/180);
593  A2 *= (kPi/180);
594 
595  // initialize the restraint
596  switch (Restraint) {
597  case kPosi:
598  pRestraint = new AFixedPosRestraint;
599  pRestraint->SetKf(Kf);
600  pRestraint->SetGroups(Group1);
601  pRestraint->SetRefPos(Pos);
602  break;
603  case kDist:
604  pRestraint = new AFixedDistRestraint;
605  pRestraint->SetKf(Kf);
606  pRestraint->SetGroups(Group2, Group1);
607  pRestraint->SetRefDist(D);
608  break;
609  case kAngle:
610  pRestraint = new AFixedAngleRestraint;
611  pRestraint->SetKf(Kf);
612  pRestraint->SetGroups(Group3, Group2, Group1);
613  pRestraint->SetRefAngle(A);
614  break;
615  case kDihe:
616  pRestraint = new AFixedDiheRestraint;
617  pRestraint->SetKf(Kf);
618  pRestraint->SetGroups(Group4, Group3, Group2, Group1);
619  pRestraint->SetRefAngle(A);
620  break;
621  case kPosiBound:
622  pRestraint = new ABoundPosRestraint;
623  pRestraint->SetKf(Kf);
624  pRestraint->SetGroups(Group1);
625  pRestraint->SetRefPos(Pos);
626  pRestraint->SetRefDist(D);
627  pRestraint->SetBound(Bound);
628  break;
629  case kDistBound:
630  pRestraint = new ABoundDistRestraint;
631  pRestraint->SetKf(Kf);
632  pRestraint->SetGroups(Group2, Group1);
633  pRestraint->SetRefDist(D);
634  pRestraint->SetBound(Bound);
635  break;
636  case kAngleBound:
637  pRestraint = new ABoundAngleRestraint;
638  pRestraint->SetKf(Kf);
639  pRestraint->SetGroups(Group3, Group2, Group1);
640  pRestraint->SetRefAngle(A);
641  pRestraint->SetBound(Bound);
642  break;
643  case kDiheBound:
644  pRestraint = new ABoundDiheRestraint;
645  pRestraint->SetKf(Kf);
646  pRestraint->SetGroups(Group4, Group3, Group2, Group1);
647  pRestraint->SetLowerAngle(A0);
648  pRestraint->SetUpperAngle(A1);
649  pRestraint->SetIntervalAngle(A2);
650  break;
651  case kPosiPMF:
652  pRestraint = new AForcingPosRestraint;
653  pRestraint->SetKf(Kf);
654  pRestraint->SetGroups(Group1);
655  pRestraint->SetStartPos(Pos0);
656  pRestraint->SetStopPos(Pos1);
657  break;
658  case kDistPMF:
659  pRestraint = new AForcingDistRestraint;
660  pRestraint->SetKf(Kf);
661  pRestraint->SetGroups(Group2, Group1);
662  pRestraint->SetStartDist(D0);
663  pRestraint->SetStopDist(D1);
664  break;
665  case kAnglePMF:
666  pRestraint = new AForcingAngleRestraint;
667  pRestraint->SetKf(Kf);
668  pRestraint->SetGroups(Group3, Group2, Group1);
669  pRestraint->SetStartAngle(A0);
670  pRestraint->SetStopAngle(A1);
671  break;
672  case kDihePMF:
673  pRestraint = new AForcingDiheRestraint;
674  pRestraint->SetKf(Kf);
675  pRestraint->SetGroups(Group4, Group3, Group2, Group1);
676  pRestraint->SetStartAngle(A0);
677  pRestraint->SetStopAngle(A1);
678  break;
679  default: ;
680  }
681  // calc number of chars to read restraint specs
682  NumChars = Str-FullStr;
683  return(pRestraint);
684 }
restr_t ReadNextRestraintType(char *Str, int &NumChars)
virtual void SetRefPos(AVector)
const BigReal A
virtual void SetStopAngle(double)
virtual void SetBound(Bound_t)
int ReadAValue(char *Str, double &Value, Bool_t ErrMsg)
virtual void SetIntervalAngle(double)
int AddAtoms(AGroup &Group, char *Str, GlobalMasterFreeEnergy &CFE)
virtual void SetStopPos(AVector)
virtual void SetRefAngle(double)
virtual void SetStartDist(double)
void ProblemParsing(const char *Message, const char *Str, Bool_t Terminate)
Bool_t
#define ASSERT(E)
Bound_t
restr_t
int ReadChar(char *Str, char Char, Bool_t ErrMsg)
virtual void SetRefDist(double)
virtual void SetStopDist(double)
const double kPi
virtual void SetStartPos(AVector)
void SetGroups(AGroup &Group1)
virtual void SetStartAngle(double)
int ReadWord(const char *Str, const char *Word, Bool_t ErrMsg)
virtual void SetLowerAngle(double)
virtual void SetUpperAngle(double)
void SetKf(double Kf)
int ReadBound(char *Str, Bound_t &Bound)
int GetSegName ( char *  Str,
char *  SegName 
)

Definition at line 1093 of file FreeEnergyParse.C.

References ProblemParsing(), ReadAlphaNum(), and ReadWhite().

Referenced by AddAtom(), AddResidues(), GetResNum(), and GetResRange().

1093  {
1094 //-------------------------------------------------------------------
1095 // Str should be (segname, resnum) or (segname, resnum, atomname)
1096 // put segname into SegName
1097 // return the number of characters from start-of-Str thru segname
1098 //-------------------------------------------------------------------
1099  int Count;
1100  char* FullString=Str;
1101 
1102  if (Str[0] != '(') {ProblemParsing("Missing (", Str);}
1103  Str += 1;
1104  Str += ReadWhite(Str);
1105  Count = ReadAlphaNum(Str);
1106  if (Count == 0) {ProblemParsing("Missing Segment Name", Str);}
1107  strncpy(SegName, Str, Count);
1108  SegName[Count] = '\0';
1109  Str += Count;
1110  return(Str-FullString);
1111 }
int ReadAlphaNum(const char *Str)
int ReadWhite(const char *Str)
void ProblemParsing(const char *Message, const char *Str, Bool_t Terminate)
double GetTime ( double  Val,
TimeUnits_t  Units 
)

Definition at line 261 of file FreeEnergyParse.C.

References ASSERT, k_fs, k_ns, k_ps, and kFalse.

Referenced by ReadPmfBlock().

261  {
262 //----------------------------------------------------------------------------
263 // convert (Val Units) to fs, where Units is either fs, ps, or ns
264 //----------------------------------------------------------------------------
265  switch (Units) {
266  case k_fs: return(Val);
267  case k_ps: return(Val*1000);
268  case k_ns: return(Val*1000000);
269  default:
270  ASSERT(kFalse);
271  return(Val);
272  }
273 }
Units
Definition: ParseOptions.h:28
#define ASSERT(E)
int IsAResidue ( char *  Str)

Definition at line 1366 of file FreeEnergyParse.C.

References IsAtomNameList(), ReadAlphaNum(), ReadDigits(), and ReadWhite().

Referenced by IsResidue(), and IsResidueRange().

1366  {
1367 //------------------------------------------------------------------------
1368 // see if Str starts with "(segname, resnum)"
1369 // return: the number of characters, including white space.
1370 // 0, if Str does not start with "(segname, resnum)"
1371 //------------------------------------------------------------------------
1372  int Count;
1373  char* FullString=Str;
1374 
1375  // if char following the parentheses is ':', this isn't a residue
1376  if (IsAtomNameList(Str)) {
1377  return(0);
1378  }
1379  // Str must contain the following in sequence to be a legit residue
1380  // <ws> = optional white-space
1381  // '(', <ws>, alphanumeric, <ws>, numeric, <ws>, ')'
1382  if (Str[0] == '(') {
1383  Str += 1;
1384  Str += ReadWhite(Str);
1385  Count = ReadAlphaNum(Str);
1386  if (Count) {
1387  Str += Count;
1388  Str += ReadWhite(Str);
1389  Count = ReadDigits(Str);
1390  if (Count) {
1391  Str += Count;
1392  Str += ReadWhite(Str);
1393  if (Str[0] == ')') {
1394  Str += 1;
1395  return(Str-FullString);
1396  }
1397  }
1398  }
1399  }
1400  return(0);
1401 }
int IsAtomNameList(char *Str)
int ReadAlphaNum(const char *Str)
int ReadWhite(const char *Str)
int ReadDigits(const char *Str)
int IsAtom ( char *  Str)

Definition at line 1273 of file FreeEnergyParse.C.

References IsAtomNameList(), ReadAlphaNum(), ReadDigits(), and ReadWhite().

Referenced by ReadNextItem().

1273  {
1274 //------------------------------------------------------------------------
1275 // see if Str starts with "(segname, resnum, atomname)"
1276 // return: the number of characters, including white space.
1277 // 0, if Str does not start with "(segname, resnum, atomname)"
1278 //------------------------------------------------------------------------
1279  int Count;
1280  char* FullString=Str;
1281 
1282  // if char following the parentheses is ':', this isn't an atom
1283  if (IsAtomNameList(Str)) {
1284  return(0);
1285  }
1286  // Str must contain the following in sequence to be a legit atom
1287  // <ws> = optional white-space
1288  // '(', <ws>, alphanumeric, <ws>, numeric, <ws>, alphanumeric, <ws>, ')'
1289  if (Str[0] == '(') {
1290  Str += 1;
1291  Str += ReadWhite(Str);
1292  Count = ReadAlphaNum(Str);
1293  if (Count) {
1294  Str += Count;
1295  Str += ReadWhite(Str);
1296  Count = ReadDigits(Str);
1297  if (Count) {
1298  Str += Count;
1299  Str += ReadWhite(Str);
1300  Count = ReadAlphaNum(Str);
1301  if (Count) {
1302  Str += Count;
1303  Str += ReadWhite(Str);
1304  if (Str[0] == ')') {
1305  Str += 1;
1306  return(Str-FullString);
1307  }
1308  }
1309  }
1310  }
1311  }
1312  return(0);
1313 }
int IsAtomNameList(char *Str)
int ReadAlphaNum(const char *Str)
int ReadWhite(const char *Str)
int ReadDigits(const char *Str)
int IsAtomName ( char *  Str)

Definition at line 1227 of file FreeEnergyParse.C.

References ReadAlphaNum(), and ReadWhite().

Referenced by ReadNextItem().

1227  {
1228 //-------------------------------------------------------------------
1229 // see if Str starts with "atomname:"
1230 // return: the number of characters, including white space.
1231 // 0, if Str does not start with "atomname:"
1232 //-------------------------------------------------------------------
1233  int Count;
1234  char* FullString=Str;
1235 
1236  Count = ReadAlphaNum(Str);
1237  if (Count) {
1238  Str += Count;
1239  Str += ReadWhite(Str);
1240  if (Str[0] == ':') {
1241  Str += 1;
1242  return(Str-FullString);
1243  }
1244  }
1245  return(0);
1246 }
int ReadAlphaNum(const char *Str)
int ReadWhite(const char *Str)
int IsAtomNameList ( char *  Str)

Definition at line 1249 of file FreeEnergyParse.C.

References ReadParentheses(), and ReadWhite().

Referenced by IsAResidue(), IsAtom(), and ReadNextItem().

1249  {
1250 //------------------------------------------------------------------------
1251 // see if Str starts with "(atomname, atomname, ...):"
1252 // return: the number of characters, including white space.
1253 // 0, if Str does not start with "(atomname, atomname, ...):"
1254 //------------------------------------------------------------------------
1255  int Count;
1256  char* FullString=Str;
1257 
1258  // Str will be considered an atom-name-list if it contains the following:
1259  // '(', anything, ')', ':'
1260  Count = ReadParentheses(Str);
1261  if (Count > 0) {
1262  Str += Count;
1263  Str += ReadWhite(Str);
1264  if (Str[0] == ':') {
1265  Str += 1;
1266  return(Str-FullString);
1267  }
1268  }
1269  return(0);
1270 }
int ReadWhite(const char *Str)
int ReadParentheses(const char *Str)
int IsEndGroup ( char *  Str)

Definition at line 1214 of file FreeEnergyParse.C.

Referenced by ReadNextItem().

1214  {
1215 //-------------------------------------------------------------------
1216 // see if Str starts with "}"
1217 // return: the number of characters, including white space.
1218 // 0, if Str does not start with "}"
1219 //-------------------------------------------------------------------
1220  if (Str[0] == '}') {
1221  return(1);
1222  }
1223  return(0);
1224 }
int IsResidue ( char *  Str)

Definition at line 1346 of file FreeEnergyParse.C.

References IsAResidue(), and IsResidueRange().

Referenced by ReadNextItem().

1346  {
1347 //------------------------------------------------------------------------
1348 // see if Str starts with "(segname, resnum)"
1349 // but not "(segname, resnum) to (segname, resnum)"
1350 //------------------------------------------------------------------------
1351  int Count;
1352 
1353  Count = IsAResidue(Str);
1354  if (Count) {
1355  if (IsResidueRange(Str)) {
1356  return(0);
1357  }
1358  else {
1359  return(Count);
1360  }
1361  }
1362  return(0);
1363 }
int IsAResidue(char *Str)
int IsResidueRange(char *Str)
int IsResidueRange ( char *  Str)

Definition at line 1316 of file FreeEnergyParse.C.

References IsAResidue(), and ReadWhite().

Referenced by IsResidue(), and ReadNextItem().

1316  {
1317 //------------------------------------------------------------------------
1318 // see if Str starts with "(segname, resnum) to (segname, resnum)"
1319 // return: the number of characters, including white space.
1320 // 0, if Str does not start with "(sn, rn) to (sn, rn)"
1321 //------------------------------------------------------------------------
1322  int Count;
1323  char* FullString=Str;
1324 
1325  // Str must contain the following in sequence to be a legit res range
1326  // <ws> = optional white-space
1327  // residue, <ws>, "to", <ws>, residue
1328  Count = IsAResidue(Str);
1329  if (Count) {
1330  Str += Count;
1331  Str += ReadWhite(Str);
1332  if (strncmp(Str, "to", 2) == 0) {
1333  Str += 2;
1334  Str += ReadWhite(Str);
1335  Count = IsAResidue(Str);
1336  if (Count) {
1337  Str += Count;
1338  return(Str-FullString);
1339  }
1340  }
1341  }
1342  return(0);
1343 }
int IsAResidue(char *Str)
int ReadWhite(const char *Str)
int IsStartGroup ( char *  Str)

Definition at line 1194 of file FreeEnergyParse.C.

References ReadWhite().

Referenced by ReadNextItem().

1194  {
1195 //-------------------------------------------------------------------
1196 // see if Str starts with "group {"
1197 // return: the number of characters, including white space.
1198 // 0, if Str does not start with "group {"
1199 //-------------------------------------------------------------------
1200  char* FullString=Str;
1201 
1202  if (strncmp(Str, "group", 5) == 0) {
1203  Str += 5;
1204  Str += ReadWhite(Str);
1205  if (Str[0] == '{') {
1206  Str += 1;
1207  return(Str-FullString);
1208  }
1209  }
1210  return(0);
1211 }
int ReadWhite(const char *Str)
void ProblemParsing ( const char *  Message,
const char *  Str,
Bool_t  Terminate 
)

Copyright (c) 1995, 1996, 1997, 1998, 1999, 2000 by The Board of Trustees of the University of Illinois. All rights reserved.

Definition at line 31 of file FreeEnergyParse.C.

References endi(), iout, and NAMD_die().

Referenced by AddAtom(), AddAtoms(), AddResidues(), CheckParentheses(), GetAtomName(), GetResNum(), GetResRange(), GetRestraint(), GetSegName(), ReadAValue(), ReadChar(), ReadInput(), ReadPmfBlock(), and ReadWord().

31  {
32 //----------------------------------------------------------------------------
33 // print this message if there's a problem parsing
34 //----------------------------------------------------------------------------
35  iout << "FreeEnergy: " << std::endl << endi;
36  iout << "FreeEnergy: ";
37  iout << "Problem parsing input parameters" << std::endl << endi;
38  iout << "FreeEnergy: ";
39  if (Terminate) {
40  iout << " Error: " << Message << std::endl << endi;
41  }
42  else {
43  iout << " Warning: " << Message << std::endl << endi;
44  }
45  iout << "FreeEnergy: ";
46  iout << " Read Until: " << Str << std::endl << endi;
47  iout << "FreeEnergy: " << std::endl << endi;
48  if (Terminate) {
49  NAMD_die("FreeEnergy: Fatal Parsing Error");
50  }
51 }
std::ostream & endi(std::ostream &s)
Definition: InfoStream.C:54
#define iout
Definition: InfoStream.h:51
void NAMD_die(const char *err_msg)
Definition: common.C:85
int ReadAlpha ( const char *  Str)

Definition at line 1424 of file FreeEnergyParse.C.

Referenced by ReadNextPmfSpec(), ReadTaskType(), ReadTimeUnits(), and ReadWord().

1424  {
1425 //-------------------------------------------------------------------
1426 // determine the leading number of alphabetic characters in Str.
1427 //-------------------------------------------------------------------
1428  int i=0;
1429 
1430  while (1) {
1431  if (isalpha(Str[i]) || Str[i]=='\'' || Str[i]=='\"' || Str[i] == '*') {
1432  i++;
1433  }
1434  else {
1435  break;
1436  }
1437  }
1438  return(i);
1439 }
int ReadAlphaNum ( const char *  Str)

Definition at line 1442 of file FreeEnergyParse.C.

Referenced by AddAtomsInResidues(), GetAtomName(), GetResRange(), GetSegName(), IsAResidue(), IsAtom(), IsAtomName(), and ReadNextRestraintType().

1442  {
1443 //-------------------------------------------------------------------
1444 // determine the leading number of alphanumeric characters in Str.
1445 //-------------------------------------------------------------------
1446  int i=0;
1447 
1448  while (1) {
1449  if (isalnum(Str[i]) || Str[i]=='\'' || Str[i]=='\"' || Str[i] == '*') {
1450  i++;
1451  }
1452  else {
1453  break;
1454  }
1455  }
1456  return(i);
1457 }
int ReadAValue ( char *  Str,
double &  Value,
Bool_t  ErrMsg = kFalse 
)

Definition at line 712 of file FreeEnergyParse.C.

References ProblemParsing(), and ReadWhite().

Referenced by GetRestraint(), and ReadPmfBlock().

712  {
713 //----------------------------------------------------------------------------
714 // Str should start with a floating point number. convert it to a double.
715 // also, return the number of chars to read past the value + white-space
716 // return NumChars = 0 if Str does not start with a valid fp number.
717 // Print an error message if ErrMsg is kTrue, and no value is read.
718 //----------------------------------------------------------------------------
719  int NumChars;
720  char* NewStr;
721 
722  // read f.p. number and trailing white-space
723  Value = strtod(Str, &NewStr);
724  if (NewStr != Str) {
725  NewStr += ReadWhite(NewStr);
726  }
727  NumChars = NewStr - Str;
728 
729  // if no number was read, and ErrMsg is kTrue, print a message
730  if ((NumChars==0) && (ErrMsg)) {
731  ProblemParsing("Floating Point Number Expected", Str);
732  }
733 
734  return(NumChars);
735 }
int ReadWhite(const char *Str)
void ProblemParsing(const char *Message, const char *Str, Bool_t Terminate)
int ReadBound ( char *  Str,
Bound_t Bound 
)

Definition at line 687 of file FreeEnergyParse.C.

References kLower, kUnknownBound, kUpper, and ReadWord().

Referenced by GetRestraint().

687  {
688 //----------------------------------------------------------------------------
689 // Str should start with "low" or "hi". determine which it is and
690 // count the number of characters to read past this word + white-space.
691 // return NumChars=0 if Str does not start with "low" or "hi"
692 //----------------------------------------------------------------------------
693  int Count;
694 
695  Bound = kUnknownBound;
696  Count = ReadWord(Str, "low");
697  if (Count) {
698  Bound=kLower;
699  return(Count);
700  }
701 
702  Count = ReadWord(Str, "hi");
703  if (Count) {
704  Bound=kUpper;
705  return(Count);
706  }
707 
708  return(Count); // Count will be 0 if "low" or "hi" wasn't found
709 }
int ReadWord(const char *Str, const char *Word, Bool_t ErrMsg)
int ReadChar ( char *  Str,
char  Char,
Bool_t  ErrMsg = kFalse 
)

Definition at line 738 of file FreeEnergyParse.C.

References ProblemParsing(), and ReadWhite().

Referenced by GetRestraint(), ReadPmfBlock(), and ReadRestraints().

738  {
739 //----------------------------------------------------------------------------
740 // Str should start with Char plus trailing white space.
741 // return the number of chars, including the white space, to read past Char
742 // return 0 if Str does not start with Char.
743 // Print an error message if ErrMsg is kTrue, and Char is not read.
744 //----------------------------------------------------------------------------
745  int NumChars;
746  char* FullString=Str;
747  char Message[64];
748 
749  // initial part of Message
750  strcpy(Message, "Character Missing: ");
751 
752  // read char and trailing white-space
753  if (Str[0] == Char) {
754  Str += 1;
755  Str += ReadWhite(Str);
756  }
757  NumChars = Str - FullString;
758 
759  // if Char was not read, and ErrMsg is kTrue, print a message
760  if ((NumChars==0) && (ErrMsg)) {
761  // add the character that's missing to Message
762  Message[strlen(Message)-1] = Char;
763  ProblemParsing(Message, Str);
764  }
765 
766  return(NumChars);
767 }
int ReadWhite(const char *Str)
void ProblemParsing(const char *Message, const char *Str, Bool_t Terminate)
int ReadDigits ( const char *  Str)

Definition at line 1460 of file FreeEnergyParse.C.

Referenced by GetResNum(), IsAResidue(), and IsAtom().

1460  {
1461 //-------------------------------------------------------------------
1462 // determine the leading number of numeric characters in Str.
1463 //-------------------------------------------------------------------
1464  int i=0;
1465 
1466  while (1) {
1467  if (isdigit(Str[i])) {
1468  i++;
1469  }
1470  else {
1471  break;
1472  }
1473  }
1474  return(i);
1475 }
void ReadInput ( char *  Str,
ARestraintManager RMgr,
ALambdaManager LMgr,
GlobalMasterFreeEnergy CFE,
double  dT 
)

Definition at line 73 of file FreeEnergyParse.C.

References ALambdaManager::Add(), CheckParentheses(), ALambdaControl::Init(), kFalse, ProblemParsing(), ReadPmfBlock(), ReadRestraints(), ReadWhite(), and ToLower().

76  {
77 //----------------------------------------------------------------------------
78 // parse the input string. Add restraints to RMgr. Add PmfBlocks to LMgr.
79 //----------------------------------------------------------------------------
80  int Count;
81  char* OldStr=NULL; //make sure it's not equal Str to start
82  ALambdaControl PmfBlock, OldPmfBlock;
83  // Bool_t Terminate;
84 
85  // read from Str until can't read anymore
86  ToLower(Str);
87  CheckParentheses(Str);
88  Str += ReadWhite(Str);
89  while (OldStr != Str) {
90  OldStr = Str;
91  // add restraints to restraint manager
92  Str += ReadRestraints(Str, RMgr, CFE);
93  // read a single PmfBlock
94  Count = ReadPmfBlock(Str, PmfBlock, dT);
95  if (Count) {
96  Str += Count;
97  // add it to the Lambda manger
98  LMgr.Add(PmfBlock);
99  // initialize the default parameters of the next PmfBlock
100  OldPmfBlock = PmfBlock;
101  PmfBlock.Init(OldPmfBlock);
102  }
103  }
104  Str += ReadWhite(Str);
105  if (strlen(Str) > 0) {
106  ProblemParsing("Unable to Read Entire Input File", Str, /* Terminate= */ kFalse);
107  }
108 }
int Add(ALambdaControl &PmfBlock)
int ReadWhite(const char *Str)
void ProblemParsing(const char *Message, const char *Str, Bool_t Terminate)
void ToLower(char *Str)
void CheckParentheses(const char *Str)
int ReadPmfBlock(char *Str, ALambdaControl &PmfBlock, double dT)
void Init(ALambdaControl &PriorBlock)
int ReadRestraints(char *Str, ARestraintManager &AllRestraints, GlobalMasterFreeEnergy &CFE)
item_t ReadNextItem ( char *  Str,
int &  NumChars 
)

Definition at line 1157 of file FreeEnergyParse.C.

References IsAtom(), IsAtomName(), IsAtomNameList(), IsEndGroup(), IsResidue(), IsResidueRange(), IsStartGroup(), kAtom, kAtomName, kAtomNameList, kEndGroup, kResidue, kResidueRange, kStartGroup, kUnknownItem, and ReadWhite().

Referenced by AddAtoms().

1157  {
1158 //-------------------------------------------------------------------
1159 // Figure out what the next item in Str is, and how many characters
1160 // long it is. The next item should be one of the following:
1161 // 1. kStartGroup: Group {
1162 // 2. kEndGroup: }
1163 // 3. kAtomName: atomname:
1164 // 4. kAtomNameList: (atomname, atomname, ... ):
1165 // 5. kAtom: (segname, resno, atomname)
1166 // 6. kResidue: (segname, resno)
1167 // 7. kResidueRange: (segname, resno) to (segname, resno)
1168 // The following assumptions may be made:
1169 // 1. Str is all lowercase
1170 // 2. There are NO leading white-char's
1171 // Return:
1172 // The length of the next item, plus the white space that follows.
1173 //-------------------------------------------------------------------
1174  int Num;
1175  item_t RetVal=kUnknownItem;
1176 
1177  Num=IsStartGroup(Str); if (Num) {RetVal=kStartGroup; goto Found;}
1178  Num=IsEndGroup(Str); if (Num) {RetVal=kEndGroup; goto Found;}
1179  Num=IsAtomName(Str); if (Num) {RetVal=kAtomName; goto Found;}
1180  Num=IsAtomNameList(Str); if (Num) {RetVal=kAtomNameList; goto Found;}
1181  Num=IsAtom(Str); if (Num) {RetVal=kAtom; goto Found;}
1182  Num=IsResidue(Str); if (Num) {RetVal=kResidue; goto Found;}
1183  Num=IsResidueRange(Str); if (Num) {RetVal=kResidueRange; goto Found;}
1184 
1185  // add the white-space after the item to the length of the item.
1186 Found:
1187  NumChars = Num;
1188  Str += NumChars;
1189  NumChars += ReadWhite(Str);
1190  return(RetVal);
1191 }
int IsAtomNameList(char *Str)
int ReadWhite(const char *Str)
int IsResidueRange(char *Str)
int IsAtomName(char *Str)
int IsAtom(char *Str)
int IsStartGroup(char *Str)
item_t
int IsEndGroup(char *Str)
int IsResidue(char *Str)
int ReadNextPmfSpec ( char *  Str,
pmf_t PmfSpec 
)

Definition at line 337 of file FreeEnergyParse.C.

References kAccumTime, kEquilTime, kLambda, kLambdaT, kNoPrint, kNumRepeats, kPrint, kTask, kTime, kUnknownPmf, ReadAlpha(), and ReadWhite().

Referenced by ReadPmfBlock().

337  {
338 //----------------------------------------------------------------------------
339 // Str should start with the next spec for a pmf or mcti block, one of:
340 // "task", "time", "lambda", "lambdaT", "print",
341 // "equiltime", "accumtime", "numsteps"
342 //
343 // Return an identifier of the above.
344 // Return number of characters, including trailing white space to read past
345 // this word. Return NumChars=0 if Str does not begin with one of the above.
346 //----------------------------------------------------------------------------
347  char* FullString=Str;
348 
349  PmfSpec = kUnknownPmf;
350  if (strncmp(Str,"task",4)==0) {PmfSpec=kTask; goto GotIt;}
351  if (strncmp(Str,"time",4)==0) {PmfSpec=kTime; goto GotIt;}
352  // check for lambdat first, else PmfSpec will be kLambda for "lambdat"
353  if (strncmp(Str,"lambdat",7)==0) {PmfSpec=kLambdaT; goto GotIt;}
354  if (strncmp(Str,"lambda",6)==0) {PmfSpec=kLambda; goto GotIt;}
355  if (strncmp(Str,"print",5)==0) {PmfSpec=kPrint; goto GotIt;}
356  if (strncmp(Str,"nopr",4)==0) {PmfSpec=kNoPrint; goto GotIt;}
357  if (strncmp(Str,"equil",5)==0) {PmfSpec=kEquilTime; goto GotIt;}
358  if (strncmp(Str,"accum",5)==0) {PmfSpec=kAccumTime; goto GotIt;}
359  if (strncmp(Str,"numstep",7)==0) {PmfSpec=kNumRepeats; goto GotIt;}
360  return(0);
361 
362 GotIt:
363  Str += ReadAlpha(Str);
364  Str += ReadWhite(Str);
365  return(Str-FullString);
366 }
int ReadAlpha(const char *Str)
int ReadWhite(const char *Str)
restr_t ReadNextRestraintType ( char *  Str,
int &  NumChars 
)

Definition at line 809 of file FreeEnergyParse.C.

References kAngle, kAngleBound, kAnglePMF, kDihe, kDiheBound, kDihePMF, kDist, kDistBound, kDistPMF, kPosi, kPosiBound, kPosiPMF, kUnknownRestr, ReadAlphaNum(), and ReadWhite().

Referenced by GetRestraint().

809  {
810 //----------------------------------------------------------------------------
811 // Str should start with the next restraint type (no leading white space),
812 // namely one of:
813 //
814 // "posi", "dist", "angle", "dihe"
815 // "posi bound", "dist bound", "angle bound", "dihe bound"
816 // "posi pmf", "dist pmf", "angle pmf", "dihe pmf"
817 //
818 // figure out which it is.
819 // also, return the number of characters, including trailing white space.
820 // return NumChars=0 for an illegal restraint-type
821 //
822 // the words "pos*", "dist*", "angle*", "dihe*", "bound*", and "pmf*"
823 // are all recognized.
824 //----------------------------------------------------------------------------
825  restr_t RestraintType=kUnknownRestr;
826  char* FullString=Str;
827 
828  // check if Str starts with "pos", "dist", "angl", or "dihe"
829  if (strncmp(Str,"pos", 3)==0) {RestraintType=kPosi; goto GotIt;}
830  if (strncmp(Str,"dist",4)==0) {RestraintType=kDist; goto GotIt;}
831  if (strncmp(Str,"angl",4)==0) {RestraintType=kAngle; goto GotIt;}
832  if (strncmp(Str,"dihe",4)==0) {RestraintType=kDihe; goto GotIt;}
833  NumChars = 0;
834  return(RestraintType);
835 
836  // skip to the end of the white space following this word
837 GotIt:
838  Str += 3;
839  Str += ReadAlphaNum(Str);
840  Str += ReadWhite(Str);
841 
842  // check if the next word is "bound", skip to the end of this word
843  if (strncmp(Str,"bound",5)==0) {
844  switch (RestraintType) {
845  case kPosi: RestraintType=kPosiBound; break;
846  case kDist: RestraintType=kDistBound; break;
847  case kAngle: RestraintType=kAngleBound; break;
848  case kDihe: RestraintType=kDiheBound; break;
849  default: break;
850  }
851  Str += 5;
852  Str += ReadAlphaNum(Str);
853  }
854 
855  // check if the next word is "pmf", skip to the end of this word
856  if (strncmp(Str,"pmf",3)==0) {
857  switch (RestraintType) {
858  case kPosi: RestraintType=kPosiPMF; break;
859  case kDist: RestraintType=kDistPMF; break;
860  case kAngle: RestraintType=kAnglePMF; break;
861  case kDihe: RestraintType=kDihePMF; break;
862  default: break;
863  }
864  Str += 3;
865  Str += ReadAlphaNum(Str);
866  }
867 
868  // skip past trailing white space, calcuate num chars string has been advanced
869  Str += ReadWhite(Str);
870  NumChars = Str-FullString;
871  return(RestraintType);
872 }
int ReadAlphaNum(const char *Str)
int ReadWhite(const char *Str)
restr_t
int ReadParentheses ( const char *  Str)

Definition at line 1404 of file FreeEnergyParse.C.

Referenced by GetResRange(), and IsAtomNameList().

1404  {
1405 //-------------------------------------------------------------------
1406 // count the number of characters from the leading '('
1407 // to the first ')' of Str (inclusive).
1408 // no leading '(' => return 0
1409 // no closing ')' => return -1
1410 //-------------------------------------------------------------------
1411  const char* Str2;
1412 
1413  if (Str[0] != '(') {
1414  return(0);
1415  }
1416  Str2 = strchr(Str, ')');
1417  if (Str2 == NULL) {
1418  return(-1);
1419  }
1420  return((Str2-Str)+1);
1421 }
int ReadPmfBlock ( char *  Str,
ALambdaControl PmfBlock,
double  dT 
)

Definition at line 111 of file FreeEnergyParse.C.

References ASSERT, ALambdaControl::GetTask(), GetTime(), k_ps, kAccumTime, kALittle, kDown, kEquilTime, kFade, kFalse, kGrow, kLambda, kLambdaT, kNoGrow, kNoPrint, kNumRepeats, kPrint, kStepDown, kStepFade, kStepGrow, kStepUp, kStop, kTask, kTime, kTrue, kUnknownTask, kUp, ProblemParsing(), ReadAValue(), ReadChar(), ReadNextPmfSpec(), ReadTaskType(), ReadTimeUnits(), ReadWord(), ALambdaControl::SetLambdaKf(), ALambdaControl::SetLambdaRef(), ALambdaControl::SetNumAccumSteps(), ALambdaControl::SetNumEquilSteps(), ALambdaControl::SetNumPrintSteps(), ALambdaControl::SetNumRepeats(), ALambdaControl::SetNumSteps(), and ALambdaControl::SetTask().

Referenced by ReadInput().

111  {
112 //----------------------------------------------------------------------------
113 // if str starts with "pmf" or "mcti", read all the specs for this block
114 // and initialize PmfBlock.
115 //
116 // PmfBlock will already have default values for all parameters.
117 // The parameters that are read will be used to override the defaults.
118 // LambdaKf and LambdaRef are initialized after all parameters have been
119 // read, because the meaning of these parameters depends upon the task.
120 //
121 // If time-units (fs, ps, ns) are not specified, use ps
122 //
123 // return the number of chars to read past this block.
124 // return 0 if Str does not start with "pmf" or "mcti"
125 //----------------------------------------------------------------------------
126  int Count, Count1, Count2;
127  Bool_t Finished=kFalse;
128  char* FullString=Str;
129  char* TempStr;
130  pmf_t PmfSpec;
131  // if time-units are not specified, then they're in ps.
132  TimeUnits_t TimeUnits;
133  TimeUnits_t DefaultTimeUnits = k_ps;
134  // illegal default value. user will have to specify this.
135  feptask_t Task=kUnknownTask;
136  double Lambda=-1, LambdaT=-1, Time;
137  double Dummy;
138  int NumRepeats=-1;
139 
140  const Bool_t kPrintErrMsg=kTrue; // kNoErrMsg=kFalse;
141 
142  // if Str does not begin with "pmf" or "mcti" return 0
143  Count1 = ReadWord(Str, "pmf");
144  Count2 = ReadWord(Str, "mcti");
145  Count = Count1 + Count2;
146  if (Count==0) {
147  return(0);
148  }
149 
150  // skip past "pmf" or "mcti"
151  Str += Count;
152  // skip past "{"
153  Str += ReadChar(Str, '{');
154  // read spec's until "}" is found or can't read a spec
155  do {
156  Count = ReadNextPmfSpec(Str, PmfSpec);
157  Str += Count;
158  if (Count==0) {
159  ProblemParsing("Unable to Read PMF Specification", Str);
160  }
161  // skip past "="
162  Str += ReadChar(Str, '=');
163  switch (PmfSpec) {
164  case kTask:
165  TempStr = Str;
166  Str += ReadTaskType(Str, Task);
167  if (Str == TempStr) {
168  ProblemParsing("Can't Read Task", Str);
169  }
170  PmfBlock.SetTask(Task);
171  break;
172  case kTime:
173  Str += ReadAValue(Str, Time, kPrintErrMsg);
174  Str += ReadTimeUnits(Str, TimeUnits, DefaultTimeUnits);
175  Time = GetTime(Time, TimeUnits);
176  PmfBlock.SetNumSteps((int)(Time/dT));
177  break;
178  case kLambda:
179  Str += ReadAValue(Str, Lambda, kPrintErrMsg);
180  break;
181  case kLambdaT:
182  Str += ReadAValue(Str, LambdaT, kPrintErrMsg);
183  break;
184  case kPrint:
185  Str += ReadAValue(Str, Time, kPrintErrMsg);
186  Str += ReadTimeUnits(Str, TimeUnits, DefaultTimeUnits);
187  Time = GetTime(Time, TimeUnits);
188  PmfBlock.SetNumPrintSteps((int)(Time/dT));
189  break;
190  case kNoPrint:
191  PmfBlock.SetNumPrintSteps(-1);
192  break;
193  case kEquilTime:
194  Str += ReadAValue(Str, Time, kPrintErrMsg);
195  Str += ReadTimeUnits(Str, TimeUnits, DefaultTimeUnits);
196  Time = GetTime(Time, TimeUnits);
197  PmfBlock.SetNumEquilSteps((int)(Time/dT));
198  break;
199  case kAccumTime:
200  Str += ReadAValue(Str, Time, kPrintErrMsg);
201  Str += ReadTimeUnits(Str, TimeUnits, DefaultTimeUnits);
202  Time = GetTime(Time, TimeUnits);
203  PmfBlock.SetNumAccumSteps((int)(Time/dT));
204  break;
205  case kNumRepeats:
206  Str += ReadAValue(Str, Dummy, kPrintErrMsg);
207  NumRepeats = (int)Dummy;
208  PmfBlock.SetNumRepeats(NumRepeats);
209  break;
210  default:
211  ASSERT(kFalse);
212  }
213  Count = ReadChar(Str, '}');
214  Str += Count;
215  // if "}" was read, then we're finished
216  if (Count!=0) {Finished=kTrue;}
217  }
218  while(!Finished);
219 
220  // if Task was not specified above, then use PmfBlock's default task
221  if (Task==kUnknownTask) {
222  Task = PmfBlock.GetTask();
223  }
224  // if Task wasn't specified earlier, die.
225  if (Task==kUnknownTask) {
226  ProblemParsing("Must Specify Task", FullString);
227  }
228 
229  // set LambdaKf and LambdaRef, using Lambda and LambdaT
230  // (the former is the internal representation, the latter is the user's)
231  // there's no need to set them if they haven't been read in this routine
232  switch(Task) {
233  case kStop:
234  PmfBlock.SetLambdaKf(1.0);
235  if (Lambda >= -kALittle) {
236  PmfBlock.SetLambdaRef(Lambda);
237  }
238  break;
239  case kNoGrow:
240  if (Lambda >= -kALittle) {
241  PmfBlock.SetLambdaKf(Lambda);
242  }
243  case kGrow:
244  case kFade:
245  case kStepGrow:
246  case kStepFade:
247  if (LambdaT >= -kALittle) {
248  PmfBlock.SetLambdaRef(LambdaT);
249  }
250  break;
251  default:
252  ASSERT((Task==kUp)||(Task==kDown)||(Task==kStepUp)||(Task==kStepDown));
253  PmfBlock.SetLambdaKf(1.0);
254  break;
255  }
256 
257  return(Str-FullString);
258 }
void SetNumEquilSteps(int Steps)
TimeUnits_t
const double kALittle
void SetNumSteps(int Steps)
void SetLambdaRef(double LambdaRef)
void SetTask(feptask_t Task)
int ReadAValue(char *Str, double &Value, Bool_t ErrMsg)
void SetLambdaKf(double LambdaKf)
feptask_t GetTask()
void ProblemParsing(const char *Message, const char *Str, Bool_t Terminate)
int ReadTimeUnits(char *Str, TimeUnits_t &Units, TimeUnits_t DefaultUnits)
Bool_t
double GetTime(double Val, TimeUnits_t Units)
#define ASSERT(E)
feptask_t
int ReadChar(char *Str, char Char, Bool_t ErrMsg)
int ReadTaskType(char *Str, feptask_t &Task)
void SetNumPrintSteps(int Steps)
void SetNumRepeats(int Repeats)
void SetNumAccumSteps(int Steps)
int ReadWord(const char *Str, const char *Word, Bool_t ErrMsg)
pmf_t
int ReadNextPmfSpec(char *Str, pmf_t &PmfSpec)
int ReadRestraints ( char *  Str,
ARestraintManager RMgr,
GlobalMasterFreeEnergy CFE 
)

Definition at line 369 of file FreeEnergyParse.C.

References ARestraintManager::Add(), GetRestraint(), kFalse, kTrue, ReadChar(), and ReadWord().

Referenced by ReadInput().

370  {
371 //----------------------------------------------------------------------------
372 // if Str starts with "urestr", read each restraint spec, create
373 // a restraint, and put a pointer to the restraint into AllRestraints
374 //
375 // return the number of chars to read past all restraints
376 // return 0 if Str does not start with "urestr"
377 //----------------------------------------------------------------------------
378  int Count;
379  Bool_t Finished=kFalse;
380  char* FullString=Str;
381  ARestraint* pRestraint;
382 
383  Count = ReadWord(Str, "urest");
384  // when "urestraint" is found
385  if (Count) {
386  // skip past "urest..."
387  Str += Count;
388  // skip past "{"
389  Str += ReadChar(Str, '{');
390  // read restraints until "}" is found or can't read a restraint
391  do {
392  pRestraint = GetRestraint(Str, Count, CFE);
393  Str += Count;
394  // if a restraint could not be read, then we're finished
395  if (Count==0) {Finished=kTrue;}
396  if (!Finished) {
397  AllRestraints.Add(pRestraint);
398  Count = ReadChar(Str, '}');
399  Str += Count;
400  // if "}" was read, then we're finished
401  if (Count!=0) {Finished=kTrue;}
402  }
403  }
404  while(!Finished);
405  }
406  return(Str-FullString);
407 }
Bool_t
int ReadChar(char *Str, char Char, Bool_t ErrMsg)
int ReadWord(const char *Str, const char *Word, Bool_t ErrMsg)
ARestraint * GetRestraint(char *Str, int &NumChars, GlobalMasterFreeEnergy &CFE)
int ReadTaskType ( char *  Str,
feptask_t Task 
)

Definition at line 305 of file FreeEnergyParse.C.

References kDown, kFade, kGrow, kNoGrow, kStepDown, kStepFade, kStepGrow, kStepUp, kStop, kUnknownTask, kUp, ReadAlpha(), and ReadWhite().

Referenced by ReadPmfBlock().

305  {
306 //----------------------------------------------------------------------------
307 // Str should start with a task, one of:
308 // "up", "down", "stop", "grow", "fade", "nogrow",
309 // "stepup", "stepdown", "stepgrow", "stepfade"
310 //
311 // return an identifer for the above.
312 // return the number of chars to read past the task. return 0 if Str does
313 // not start with one of the above.
314 //----------------------------------------------------------------------------
315  char* FullString=Str;
316 
317  Task = kUnknownTask;
318  if (strncmp(Str,"up",2)==0) {Task=kUp; goto GotIt;}
319  if (strncmp(Str,"down",4)==0) {Task=kDown; goto GotIt;}
320  if (strncmp(Str,"stop",4)==0) {Task=kStop; goto GotIt;}
321  if (strncmp(Str,"grow",4)==0) {Task=kGrow; goto GotIt;}
322  if (strncmp(Str,"fade",4)==0) {Task=kFade; goto GotIt;}
323  if (strncmp(Str,"nogrow",6)==0) {Task=kNoGrow; goto GotIt;}
324  if (strncmp(Str,"stepup",6)==0) {Task=kStepUp; goto GotIt;}
325  if (strncmp(Str,"stepdown",8)==0) {Task=kStepDown; goto GotIt;}
326  if (strncmp(Str,"stepgrow",8)==0) {Task=kStepGrow; goto GotIt;}
327  if (strncmp(Str,"stepfade",8)==0) {Task=kStepFade; goto GotIt;}
328  return(0);
329 
330 GotIt:
331  Str += ReadAlpha(Str);
332  Str += ReadWhite(Str);
333  return(Str-FullString);
334 }
int ReadAlpha(const char *Str)
int ReadWhite(const char *Str)
int ReadTimeUnits ( char *  Str,
TimeUnits_t Units,
TimeUnits_t  DefaultUnits 
)

Definition at line 276 of file FreeEnergyParse.C.

References k_fs, k_ns, k_ps, kFalse, kTrue, ReadAlpha(), and ReadWhite().

Referenced by ReadPmfBlock().

276  {
277 //----------------------------------------------------------------------------
278 // Str should start with one of:
279 // "fs", "ps", or "ns"
280 //
281 // If Str starts with one of the above, return an identifier for the above.
282 // if Str does not start with one of the above, set Units to DefaultUnits.
283 //
284 // return the number of chars to read past the time units. return 0 if
285 // Str does not start with one of the above.
286 //----------------------------------------------------------------------------
287  char* FullString=Str;
288  Bool_t FoundIt=kFalse;
289 
290  if (strncmp(Str,"fs",2)==0) {Units=k_fs; FoundIt=kTrue;}
291  if (strncmp(Str,"ps",2)==0) {Units=k_ps; FoundIt=kTrue;}
292  if (strncmp(Str,"ns",2)==0) {Units=k_ns; FoundIt=kTrue;}
293 
294  if (FoundIt) {
295  Str += ReadAlpha(Str);
296  Str += ReadWhite(Str);
297  }
298  else {
299  Units = DefaultUnits;
300  }
301  return(Str-FullString);
302 }
int ReadAlpha(const char *Str)
int ReadWhite(const char *Str)
Units
Definition: ParseOptions.h:28
Bool_t
int ReadWhite ( const char *  Str)

Definition at line 1478 of file FreeEnergyParse.C.

Referenced by AddAtoms(), AddAtomsInResidues(), GetAtomName(), GetResNum(), GetResRange(), GetSegName(), IsAResidue(), IsAtom(), IsAtomName(), IsAtomNameList(), IsResidueRange(), IsStartGroup(), ReadAValue(), ReadChar(), ReadInput(), ReadNextItem(), ReadNextPmfSpec(), ReadNextRestraintType(), ReadTaskType(), ReadTimeUnits(), and ReadWord().

1478  {
1479 //-------------------------------------------------------------------
1480 // determine the leading number of white characters in Str.
1481 // a white char is:
1482 // space, tab, linefeed, carriage-return, formfeed,
1483 // vertical-tab, and newline characters.
1484 // a white char is also (for the sake of this program):
1485 // comma, semi-colon, and period.
1486 //-------------------------------------------------------------------
1487  int i=0;
1488 
1489  // count the number of white-char's. break at first non-white-char.
1490  while (1) {
1491  if (
1492  (Str[i] == 9) || // tab
1493  (Str[i] == 10) || // LF
1494  (Str[i] == 11) || // vertical-tab
1495  (Str[i] == 12) || // form-feed
1496  (Str[i] == 13) || // CR
1497  (Str[i] == 32) || // space
1498  (Str[i] == ',') || // comma
1499  (Str[i] == ';') // semi-colon
1500 // (Str[i] == '.') // period (took this out in case of =.4, eg)
1501  )
1502  {
1503  i++;
1504  }
1505  else {
1506  break;
1507  }
1508  }
1509  return(i);
1510 }
int ReadWord ( const char *  Str,
const char *  Word,
Bool_t  ErrMsg = kFalse 
)

Definition at line 770 of file FreeEnergyParse.C.

References ProblemParsing(), ReadAlpha(), and ReadWhite().

Referenced by GetRestraint(), ReadBound(), ReadPmfBlock(), and ReadRestraints().

770  {
771 //----------------------------------------------------------------------------
772 // Str should start with Word plus, perhaps, some extra alphabetic
773 // characters, plus trailing white space.
774 //
775 // (do NOT read past numeric characters which follow Word, so that
776 // this routine can be used on the following: ReadWord(Str, "="),
777 // where Str is, for example, "=123 ...")
778 //
779 // return the number of chars, including the white space, to read past Word
780 // return 0 if Str does not start with Word.
781 //
782 // Print an error message if ErrMsg is kTrue, and word is not read.
783 //----------------------------------------------------------------------------
784  const char* FullString=Str;
785  int NumChars, StrLen;
786  char Message[64];
787 
788  // initial part of message
789  strcpy(Message, "Word Missing: ");
790 
791  StrLen = strlen(Word);
792  if (strncmp(Str, Word, StrLen) == 0) {
793  Str += StrLen;
794  Str += ReadAlpha(Str);
795  Str += ReadWhite(Str);
796  }
797  NumChars = Str - FullString;
798 
799  // if Word was not read, and ErrMsg is kTrue, print a message
800  if ((NumChars==0) && (ErrMsg)) {
801  strcat(Message, Word);
802  ProblemParsing(Message, Str);
803  }
804 
805  return(NumChars);
806 }
int ReadAlpha(const char *Str)
int ReadWhite(const char *Str)
void ProblemParsing(const char *Message, const char *Str, Bool_t Terminate)
void ToLower ( char *  Str)

Definition at line 1513 of file FreeEnergyParse.C.

Referenced by ReadInput().

1513  {
1514 //-------------------------------------------------------------------
1515 // convert Str to all lower case
1516 //-------------------------------------------------------------------
1517  for (unsigned int i=0; i<strlen(Str); i++) {
1518  Str[i] = (char)tolower(Str[i]);
1519  }
1520 }