XEvent Clipboard::checkEvent() { XEvent e; XIfEvent(resourceManager->dpy, &e, &clipboardPredicate, reinterpret_cast<XPointer>(window.get())); DEBUG_CLIP("A selection notify has arrived!"); DEBUG_CLIP("Requester = 0x" << hex << e.xselectionrequest.requestor << dec); DEBUG_CLIP("Target atom = " << getAtomName(resourceManager->dpy, e.xselection.target)); DEBUG_CLIP("Property atom = " << getAtomName(resourceManager->dpy, e.xselection.property)); DEBUG_CLIP("Selection atom = " << getAtomName(resourceManager->dpy, e.xselection.selection)); return e; }
// Print out the details of an atom, taking the form: // Atom Type Atomic Number Atomic Mass(amu) #CGBFS x y z void Logger::print(const Atom& a) const { int q = a.getCharge(); Vector c(3); c = a.getCoords(); outfile << std::fixed << std::setprecision(6); outfile << std::setw(10) << getAtomName(q); outfile << std::setw(10) << q; outfile << std::setw(10) << a.getMass(); outfile << std::setw(10) << a.getNbfs(); outfile << std::setw(4) << "(" << std::setw(8) << c(0); outfile << ", " << std::setw(8) << c(1); outfile << ", " << std::setw(8) << c(2) << ")\n"; }
// Return the atomic number of an atom with text n // the reverse of getAtomName int getAtomCharge(const std::string& n) { // Make it upper case std::string name = n; std::transform(name.begin(), name.end(), name.begin(), ::toupper); int q = 1; bool found = false; while (!found && q < 109 ){ if(getAtomName(q) == name){ found = true; } q++; } return q-1; }
// Print out the basis set specification in the format: // (example is C atom in 3-21G basis set) // BASIS: 6-31G // Total no. of cgbfs: 9 // Total no. of primitives: 9 // =============== // Specification // =============== // Atom Shell #CGBFs #Prims // ...................................... // C s 3 6 // p 6 3 // (if full = true, then continue with this) // =============== // Basis Functions // =============== // Atom Shell BF Coeff Exponent // ................................................. // C s 1 0.0617669 172.2560 // 0.358794 25.91090 // 0.700713 5.533350 // etc... void Logger::print(Basis& b, bool full) const { // Collect the data needed for printing int nbfs = b.getNBFs(); // Store number of cgbfs and prims int nprims = 0; Vector qs = b.getCharges(); // Sort the qs and get rid of duplicates qs.sort(); Vector qtemp(qs.size()); qtemp[0] = qs(0); int k = 1; for (int i = 1; i < qs.size(); i++){ if (qs(i) != qtemp[k-1]){ qtemp[k] = qs(i); k++; } } qs = qtemp; qs.resizeCopy(k); // Now sum over all basis functions to get the number of prims Vector c(3); c[0] = 0.0; c[1] = 0.0; c[2] = 0.0; BF bftemp(c, 0, 0, 0, c, c); for (int i = 0; i < nbfs; i++){ bftemp = b.getBF(i); nprims += bftemp.getNPrims(); } // Start printing title("Basis Set"); outfile << "BASIS: " << b.getName() << "\n"; outfile << "Total no. of cgbfs: " << nbfs << "\n"; outfile << "Total no. of prims: " << nprims << "\n"; title("Specification"); outfile << std::setw(8) << "Atom"; outfile << std::setw(8) << "Shell"; outfile << std::setw(8) << "#CGBFs"; outfile << std::setw(8) << "#Prims\n"; outfile << std::string(35, '.') << "\n"; // loop over the atom types outfile << std::setprecision(2); Vector subshells; Vector sublnums; for (int i = 0; i < k; i++){ int nc = 0; int np = 0; outfile << std::setw(8) << getAtomName(qs(i)); subshells = b.getShells(qs[i]); sublnums = b.getLnums(qs[i]); outfile << std::setw(8) << getShellName(sublnums[0]); outfile << std::setw(8) << subshells[0]; for (int j = 0; j < subshells[0]; j++){ np += b.getBF(qs[i], j).getNPrims(); } nc += subshells[0]; outfile << std::setw(8) << np << "\n"; for (int j = 1; j < subshells.size(); j++){ outfile << std::setw(8) << ""; outfile << std::setw(8) << getShellName(sublnums[j]); outfile << std::setw(8) << subshells[j]; np = 0; for (int l = 0; l < subshells[j]; l++){ np += b.getBF(qs[i], nc + l).getNPrims(); } nc += subshells[j]; outfile << std::setw(8) << np << "\n"; } } outfile << std::setprecision(8); // Now print out basis functions if required if (full) { title("Basis Functions"); outfile << std::setw(8) << "Atom"; outfile << std::setw(8) << "Shell"; outfile << std::setw(5) << "BF"; outfile << std::setw(18) << "Coeff"; outfile << std::setw(18) << "Exponent\n"; outfile << std::string(58, '.') << "\n"; // Loop over all the basis functions Vector subshell; Vector sublnums; Vector coeffs; Vector exps; std::string filler = ""; for (int i = 0; i < k; i++){ subshell = b.getShells(qs(i)); sublnums = b.getLnums(qs(i)); // Loop over shells int sum = 0; for (int r = 0; r < subshell.size(); r++){ // Loop over bfs for (int s = 0; s < subshell[r]; s++){ bftemp = b.getBF(qs(i), s+sum); coeffs = bftemp.getCoeffs(); exps = bftemp.getExps(); // Loop over coeffs/exps for (int t = 0; t < coeffs.size(); t++){ filler = ((r == 0 && s==0 && t==0) ? getAtomName(qs[i]) : ""); outfile << std::setw(8) << filler; filler = ((s == 0 && t == 0) ? getShellName(sublnums[r]) : ""); outfile << std::setw(8) << filler; filler = (t == 0 ? std::to_string(s+1) : ""); outfile << std::setw(5) << filler; outfile << std::setw(18) << std::setprecision(8) << coeffs(t); outfile << std::setw(18) << std::setprecision(8) << exps(t) << "\n"; } } sum += subshell[r]; } } } }
int identifyAtom(char* name, char resname[], int Verbose) { /*dcr041007 allow warning choice*/ int n = -1, emitWarning = 0; switch(name[0]) { case '*': case '\'': case '"': case '`': case '_': case '+': case '-': case ' ': case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': switch(name[1]) { case 'A': switch(name[3]) { case '1': n = atomO; emitWarning = 1; break; case '2': n = atomN; emitWarning = 1; break; } break; case 'B': n = atomB; break; case 'C': n = atomC; break; case 'D': n = atomH; break; case 'F': n = atomF; break; case 'H': switch(name[2]) { case 'E': n = fixAtomName(name,resname,2) ? atomHe : atomH; break; case 'F': n = fixAtomName(name,resname,2) ? atomHf : atomH; break; case 'G': n = fixAtomName(name,resname,2) ? atomHg : atomH; break; case 'O': n = fixAtomName(name,resname,2) ? atomHo : atomH; break; /* case 'S': n = fixAtomName(name,resname,2) ? atomHs : atomH; break; */ default : n = atomH; break; } break; case 'I': n = atomI; break; case 'K': n = atomK; break; case 'N': n = atomN; break; case 'O': n = atomO; break; case 'P': n = atomP; break; /*case 'S': n = atomS; break;*/ case 'S': if(name[0] == ' ' && name[2] == 'E') {/*_SE likely refmac,cns missplaced Selenium atom name dcr041007*/ n = atomSe; emitWarning = 1; break; } else {n = atomS; break;} /*050121 NO warning for other S*/ case 'U': n = atomU; break; case 'V': n = atomV; break; case 'W': n = atomW; break; case 'Y': n = atomY; break; } break; case 'A': switch(name[1]) { case 'C': n = atomC; emitWarning = 1;break;/*nonstd!*/ case 'G': n = atomAg; break; case 'H': n = atomH; emitWarning = 1;break; case 'L': n = atomAl; break; case 'M': n = atomAm; break; case 'N': n = atomN; emitWarning = 1;break; case 'O': n = atomO; emitWarning = 1;break; case 'P': n = atomP; emitWarning = 1;break; case 'R': n = atomAr; break; case 'S': n = atomAs; break; case 'T': n = atomAt; break; case 'U': n = atomAu; break; } break; case 'B': switch(name[1]) { case 'A': n = atomBa; break; case 'E': n = atomBe; break; case 'I': n = atomBi; break; case 'K': n = atomBk; break; case 'R': n = atomBr; break; } break; case 'C': switch(name[1]) { case 'A': n = atomCa; break; case 'C': n = atomC; emitWarning = 1;break; case 'D': n = atomCd; break; case 'E': n = atomCe; break; case 'F': n = atomCf; break; case 'H': n = atomH; emitWarning = 1;break; case 'L': n = atomCl; break; case 'M': n = atomCm; break; case 'N': n = atomN; emitWarning = 1;break; case 'O': n = atomCo; emitWarning = 1;break; case 'P': n = atomP; emitWarning = 1;break; case 'R': n = atomCr; break; case 'S': n = atomCs; break; case 'U': n = atomCu; break; default: n = atomC; emitWarning = 1;break; } break; case 'D': switch(name[1]) { case 'Y': n = atomDy; break; case 'C': n = atomC; emitWarning = 1;break; case 'H': n = atomH; emitWarning = 1;break; case 'N': n = atomN; emitWarning = 1;break; case 'O': n = atomO; emitWarning = 1;break; case 'P': n = atomP; emitWarning = 1;break; default: n = atomH; emitWarning = 1;break; } break; case 'E': switch(name[1]) { case 'R': n = atomEr; break; case 'S': n = atomEs; break; case 'U': n = atomEu; break; case 'C': n = atomC; emitWarning = 1;break; case 'H': n = atomH; emitWarning = 1;break; case 'N': n = atomN; emitWarning = 1;break; case 'O': n = atomO; emitWarning = 1;break; case 'P': n = atomP; emitWarning = 1;break; } break; case 'F': switch(name[1]) { case 'E': n = atomFe; break; case 'M': n = atomFm; break; case 'R': n = atomFr; break; case 'C': n = atomC; emitWarning = 1;break; case 'H': n = atomH; emitWarning = 1;break; case 'N': n = atomN; emitWarning = 1;break; case 'O': n = atomO; emitWarning = 1;break; case 'P': n = atomP; emitWarning = 1;break; } break; case 'G': switch(name[1]) { case 'A': n = atomGa; break; case 'D': n = atomGd; break; case 'E': n = atomGe; break; case 'C': n = atomC; emitWarning = 1;break; case 'H': n = atomH; emitWarning = 1;break; case 'N': n = atomN; emitWarning = 1;break; case 'O': n = atomO; emitWarning = 1;break; case 'P': n = atomP; emitWarning = 1;break; } break; case 'H': switch(name[1]) { case 'E': n = fixAtomName(name,resname,1) ? atomHe : atomH; break; case 'F': n = fixAtomName(name,resname,1) ? atomHf : atomH; break; case 'G': n = fixAtomName(name,resname,1) ? atomHg : atomH; break; case 'O': n = fixAtomName(name,resname,1) ? atomHo : atomH; break; /* case 'S': n = fixAtomName(name,resname,1) ? atomHs : atomH; break; */ default : n = atomH; break; } break; /* case 'E': */ /* if (isdigit(name[2])) { n = atomH; emitWarning = 1;} */ /* Hepsilon?? */ /* else {n = atomHe; emitWarning = 1;} */ /* break; */ /* case 'F': n = atomHf; emitWarning = 1;break; */ /* case 'G': */ /* if (isdigit(name[2])) { n = atomH; emitWarning = 1;} */ /* Hgamma?? */ /* else {n = atomHg; emitWarning = 1;} */ /* break; */ /* case 'O': n = atomHo; emitWarning = 1;break; */ /* default: n = atomH; emitWarning = 1;break; */ /* } break; */ case 'I': switch(name[1]) { case 'N': n = atomIn; break; case 'R': n = atomIr; break; } break; case 'K': if (name[1] == 'R') n = atomKr; break; case 'L': switch(name[1]) { case 'A': n = atomLa; break; case 'I': n = atomLi; break; case 'U': n = atomLu; break; } break; case 'M': switch(name[1]) { case 'D': n = atomMd; break; case 'G': n = atomMg; break; case 'N': n = atomMn; break; case 'O': n = atomMo; break; } break; case 'N': switch(name[1]) { case 'A': n = atomNa; emitWarning = 1;break; case 'B': n = atomNb; emitWarning = 1;break; case 'C': n = atomC; emitWarning = 1;break; case 'D': n = atomNd; emitWarning = 1;break; case 'E': n = atomNe; emitWarning = 1;break; case 'H': n = atomH; emitWarning = 1;break; case 'I': n = atomNi; break; case 'N': n = atomN; emitWarning = 1;break; case 'O': n = atomO; emitWarning = 1;break;/*nonstd!*/ case 'P': n = atomP; emitWarning = 1;break;/*nonstd!*/ case 'S': n = atomS; emitWarning = 1;break; default: n = atomN; emitWarning = 1;break; } break; case 'O': switch(name[1]) { case 'S': n = atomOs; break; default: n = atomO; emitWarning = 1;break; } break; case 'P': switch(name[1]) { case 'A': n = atomPa; emitWarning = 1;break; case 'B': n = atomPb; emitWarning = 1;break; case 'D': n = atomPd; emitWarning = 1;break; case 'M': n = atomPm; break; case 'O': n = atomPo; break; case 'R': n = atomPr; break; case 'T': n = atomPt; break; case 'U': n = atomPu; break; default: n = atomP; emitWarning = 1;break; } break; case 'R': switch(name[1]) { case 'A': n = atomRa; break; case 'B': n = atomRb; break; case 'E': n = atomRe; break; case 'H': n = atomRh; break; case 'N': n = atomRn; break; case 'U': n = atomRu; break; } break; case 'S': switch(name[1]) { case 'B': n = atomSb; emitWarning = 1;break; case 'C': n = atomSc; break; case 'E': n = atomSe; emitWarning = 1;break; case 'I': n = atomSi; break; case 'M': n = atomSm; break; case 'N': n = atomSn; break; case 'R': n = atomSr; break; default: n = atomS; emitWarning = 1;break; } break; case 'T': switch(name[1]) { case 'A': n = atomTa; break; case 'B': n = atomTb; break; case 'C': n = atomTc; break; case 'E': n = atomTe; break; case 'H': n = atomTh; break; case 'I': n = atomTi; break; case 'L': n = atomTl; break; case 'M': n = atomTm; break; } break; case 'X': if (name[1] == 'E') n = atomXe; break; case 'Y': if (name[1] == 'B') n = atomYb; break; case 'Z': switch(name[1]) { case 'N': n = atomZn; break; case 'R': n = atomZr; break; } break; default: break; } if (n < 0) { emitWarning = 1; n = atomC; switch(name[1]) { case 'H': case 'D': n = atomH; break; case 'C': n = atomC; break; case 'N': n = atomN; break; case 'O': n = atomO; break; case 'P': n = atomP; break; case 'S': n = atomS; break; case 'I': n = atomI; break; case 'K': n = atomK; break; case 'V': n = atomV; break; case 'W': n = atomW; break; case 'U': n = atomU; break; case 'A': switch(name[2]) { case 'G': n = atomAg; break; case 'L': n = atomAl; break; case 'S': n = atomAs; break; case 'U': n = atomAu; break; } break; case 'F': if (name[2] == 'E') n = atomFe; break; case 'G': if (name[2] == 'D') n = atomGd; break; case 'L': if (name[2] == 'I') n = atomLi; break; case 'M': switch(name[2]) { case 'G': n = atomMg; break; case 'N': n = atomMn; break; case 'O': n = atomMo; break; } break; case 'Z': if (name[2] == 'N') n = atomZn; break; /* --------- default if we fall through... ---------------------*/ default: n = atomC; break; } } if (emitWarning && Verbose) {/*Verbose controlled dcr041007*/ char warnstr[5]={'_','_','_','_','\0'}; /*dcr041007*/ char warnresn[5]={'_','_','_','_','\0'}; /*rmi070719*/ char* atstr; int j=0; while(name[j]!='\0'&&warnstr[j]!='\0') {/*explicitly show blanks so can understand atom name problem*/ if(name[j]==' ') {warnstr[j]='_';} else {warnstr[j]=name[j];} j++; } j=0; while(resname[j]!='\0'&&warnresn[j]!='\0') {/*explicitly show blanks so can understand residue/atom name problem*/ if(name[j]==' ') {warnresn[j]='_';} else {warnresn[j]=resname[j];} j++; } atstr = getAtomName(n); if(strlen(atstr)==1) {fprintf(stderr,"WARNING: atom %s from resn %s will be treated as %s\n",warnstr,warnresn,atstr);} else {fprintf(stderr,"WARNING: atom %s from resn %s will be treated as %s\n",warnstr,warnresn,atstr);} /*name, getAtomName(n));*/ } return n; }