void PDBFileWriter::writeSecstr(qlib::PrintStream &prs) { MolResiduePtr pRes1; int nhx = 1; MolCoordPtr pMol(m_pMol); ResidIterator riter(pMol); //(MolCoordPtr(m_pMol)); // Write HELIX records for (riter.first(); riter.hasMore(); riter.next()) { LString sec; LString pfx; MolResiduePtr pRes = riter.get(); pRes->getPropStr("secondary2", sec); // MB_DPRINTLN("%s%d => %s", pRes->getChainName().c_str(), pRes->getIndex().first, sec.c_str()); if (sec.length()>=2) pfx= sec.substr(1,1); if (!(sec.startsWith("H")||sec.startsWith("G")||sec.startsWith("I"))) continue; if (pfx.equals("s")) pRes1 = pRes; else if (pfx.equals("e")) { LString resn1 = pRes1->getName().substr(0,3); LString chn1 = pRes1->getChainName().substr(0,1); ResidIndex resix1 = pRes1->getIndex(); char ins1 = resix1.second; if (ins1=='\0') ins1 = ' '; LString resn2 = pRes->getName().substr(0,3); LString chn2 = pRes->getChainName().substr(0,1); ResidIndex resix2 = pRes->getIndex(); char ins2 = resix2.second; if (ins2=='\0') ins2 = ' '; prs.print("HELIX "); // helix seqno prs.format(" %3d", nhx); // helix ID prs.format(" %3d", nhx); // start resname prs.format(" %3s", resn1.c_str()); prs.format(" %1s", chn1.c_str()); prs.format(" %4d", resix1.first); prs.format("%c", ins1); // end resname prs.format(" %3s", resn2.c_str()); prs.format(" %1s", chn2.c_str()); prs.format(" %4d", resix2.first); prs.format("%c", ins2); // typeof helix int ntype = 1; if (sec.startsWith("G")) ntype = 5; else if (sec.startsWith("I")) ntype = 3; prs.format("%2d", ntype); prs.println(""); ++nhx; } } // Write SHEET records int nsh = 1; for (riter.first(); riter.hasMore(); riter.next()) { LString sec; LString pfx; MolResiduePtr pRes = riter.get(); pRes->getPropStr("secondary2", sec); // MB_DPRINTLN("%s%d => %s", pRes->getChainName().c_str(), pRes->getIndex().first, sec.c_str()); if (sec.length()>=2) pfx= sec.substr(1,1); if (!(sec.startsWith("E"))) continue; if (pfx.equals("s")) pRes1 = pRes; else if (pfx.equals("e")) { LString resn1 = pRes1->getName().substr(0,3); LString chn1 = pRes1->getChainName().substr(0,1); ResidIndex resix1 = pRes1->getIndex(); char ins1 = resix1.second; if (ins1=='\0') ins1 = ' '; LString resn2 = pRes->getName().substr(0,3); LString chn2 = pRes->getChainName().substr(0,1); ResidIndex resix2 = pRes->getIndex(); char ins2 = resix2.second; if (ins2=='\0') ins2 = ' '; prs.print("SHEET "); // helix seqno prs.format(" %3d", nsh); // helix ID prs.format(" %3d", nsh); // num of strands prs.print(" 1"); // start resname prs.format(" %3s", resn1.c_str()); prs.format(" %1s", chn1.c_str()); prs.format("%4d", resix1.first); prs.format("%c", ins1); // end resname prs.format(" %3s", resn2.c_str()); prs.format(" %1s", chn2.c_str()); prs.format("%4d", resix2.first); prs.format("%c", ins2); // direction prs.print(" 0"); prs.println(""); ++nsh; } } // for }
void SceneXMLReader::procDataSrcLoad(qlib::LDom2InStream &ois, LDom2Node *pNode) { ////////// // Recursively check the data src load requests LDom2Node::NodeList::const_iterator iter = pNode->childBegin(); LDom2Node::NodeList::const_iterator eiter = pNode->childEnd(); for (; iter!=eiter; ++iter) { LDom2Node *pChNode = *iter; if (pChNode!=NULL) procDataSrcLoad(ois, pChNode); } ////////// // Do data source loading LDataSrcContainer *pCnt = pNode->getDataSrcContainer(); if (pCnt==NULL) return; LString src = pNode->getDataSrc(); LString altsrc = pNode->getDataAltSrc(); LString srctype = pNode->getDataSrcType(); if (src.isEmpty()) return; if (srctype.isEmpty()) { // ERROR!! (TO DO: handling) LOG_DPRINTLN("SceneXML> src %s: srctype is not defined. (ignored)", src.c_str()); return; } if (src.startsWith("datachunk:") && src.length()==15) { // Data source is in datachunk // --> Prepare for reading from data chunk of the stream MB_DPRINTLN("Data chunk found %s, %s ", src.c_str(), srctype.c_str()); // addChunkMap(src, pCnt, srctype); ois.addChunkMap(src, pCnt); return; } //robj->readFromPath(src, altsrc, m_pClient); bool bAlt = false; LString basedir = m_pClient->getBasePath(); LString abs_path = pCnt->readFromSrcAltSrc(src, altsrc, basedir, bAlt); // ATTN 14/06/29: // Update src/altsrc properties based on where the data source has been loaded. // (In the qsc file, there are two alternative sources. However, only one src is actually loaded.) // This is required to keep consistency between the "src prop" and "actual data src". if (bAlt) { // loaded from altsrc; altsrc --> src if (!qlib::isAbsolutePath(altsrc)) altsrc = qlib::makeAbsolutePath(altsrc, basedir); pCnt->updateSrcPath(altsrc); } else { // loaded from src; keep src if (!qlib::isAbsolutePath(src)) src = qlib::makeAbsolutePath(src, basedir); pCnt->updateSrcPath(src); } }