本文整理汇总了C++中OBPairData::GetAttribute方法的典型用法代码示例。如果您正苦于以下问题:C++ OBPairData::GetAttribute方法的具体用法?C++ OBPairData::GetAttribute怎么用?C++ OBPairData::GetAttribute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OBPairData
的用法示例。
在下文中一共展示了OBPairData::GetAttribute方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: WriteMolecule
bool PDBFormat::WriteMolecule(OBBase* pOb, OBConversion* pConv)
{
OBMol* pmol = dynamic_cast<OBMol*>(pOb);
if(pmol==NULL)
return false;
//Define some references so we can use the old parameter names
ostream &ofs = *pConv->GetOutStream();
OBMol &mol = *pmol;
unsigned int i;
char buffer[BUFF_SIZE];
char type_name[10], padded_name[10];
char the_res[10];
char the_chain = ' ';
const char *element_name;
int res_num;
bool het=true;
int model_num = 0;
if (!pConv->IsLast() || pConv->GetOutputIndex() > 1)
{ // More than one molecule record
model_num = pConv->GetOutputIndex(); // MODEL 1-based index
snprintf(buffer, BUFF_SIZE, "MODEL %8d", model_num);
ofs << buffer << endl;
}
// write back all fields (REMARKS, HELIX, SHEET, SITE, ...)
bool compndWritten = false;
bool authorWritten = false;
std::vector<OBGenericData*> pairData = mol.GetAllData(OBGenericDataType::PairData);
for (std::vector<OBGenericData*>::iterator data = pairData.begin(); data != pairData.end(); ++data) {
OBPairData *pd = static_cast<OBPairData*>(*data);
string attr = pd->GetAttribute();
// filter to make sure we are writing pdb fields only
if (attr != "HEADER" && attr != "OBSLTE" && attr != "TITLE" && attr != "SPLIT" &&
attr != "CAVEAT" && attr != "COMPND" && attr != "SOURCE" && attr != "KEYWDS" &&
attr != "EXPDTA" && attr != "NUMMDL" && attr != "MDLTYP" && attr != "AUTHOR" &&
attr != "REVDAT" && attr != "SPRSDE" && attr != "JRNL" && attr != "REMARK" &&
attr != "DBREF" && attr != "DBREF1" && attr != "DBREF2" && attr != "SEQADV" &&
attr != "SEQRES" && attr != "MODRES" && attr != "HET" && attr != "HETNAM" &&
attr != "HETSYN" && attr != "FORMUL" && attr != "HELIX" && attr != "SHEET" &&
attr != "SSBOND" && attr != "LINK" && attr != "CISPEP" && attr != "SITE" &&
attr != "ORIGX1" && attr != "ORIGX2" && attr != "ORIGX3" && attr != "SCALE1" &&
attr != "SCALE2" && attr != "SCALE3" && attr != "MATRIX1" && attr != "MATRIX2" &&
attr != "MATRIX3" && attr != "MODEL")
continue;
if (attr == "COMPND")
compndWritten = true;
if (attr == "AUTHOR")
authorWritten = true;
// compute spacing needed. HELIX, SITE, HET, ... are trimmed when reading
int nSpacing = 6 - attr.size();
for (int i = 0; i < nSpacing; ++i)
attr += " ";
std::string lines = pd->GetValue();
string::size_type last = 0;
string::size_type pos = lines.find('\n');
while (last != string::npos) {
string line = lines.substr(last, pos - last);
if (pos == string::npos)
last = string::npos;
else
last = pos + 1;
pos = lines.find('\n', last);
ofs << attr << line << endl;
}
}
if (!compndWritten) {
if (strlen(mol.GetTitle()) > 0)
snprintf(buffer, BUFF_SIZE, "COMPND %s ",mol.GetTitle());
else
snprintf(buffer, BUFF_SIZE, "COMPND UNNAMED");
ofs << buffer << endl;
}
if (!authorWritten) {
snprintf(buffer, BUFF_SIZE, "AUTHOR GENERATED BY OPEN BABEL %s",BABEL_VERSION);
ofs << buffer << endl;
}
// Write CRYST1 record, containing unit cell parameters, space group
// and Z value (supposed to be 1)
if (pmol->HasData(OBGenericDataType::UnitCell))
{
OBUnitCell *pUC = (OBUnitCell*)pmol->GetData(OBGenericDataType::UnitCell);
if(pUC->GetSpaceGroup()){
string tmpHM=pUC->GetSpaceGroup()->GetHMName();
// Do we have an extended HM symbol, with origin choice as ":1" or ":2" ? If so, remove it.
size_t n=tmpHM.find(":");
if(n!=string::npos) tmpHM=tmpHM.substr(0,n);
snprintf(buffer, BUFF_SIZE,
"CRYST1%9.3f%9.3f%9.3f%7.2f%7.2f%7.2f %-11s 1",
pUC->GetA(), pUC->GetB(), pUC->GetC(),
//.........这里部分代码省略.........