本文整理汇总了C++中OBAtom::GetY方法的典型用法代码示例。如果您正苦于以下问题:C++ OBAtom::GetY方法的具体用法?C++ OBAtom::GetY怎么用?C++ OBAtom::GetY使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OBAtom
的用法示例。
在下文中一共展示了OBAtom::GetY方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: WriteMolecule
bool JaguarInputFormat::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];
OBAtom *atom;
ofs << mol.GetTitle() << endl << endl;
ofs << "&gen" << endl;
ofs << "&" << endl;
ofs << "&zmat" << endl;
for (i = 1;i <= mol.NumAtoms(); i++)
{
atom = mol.GetAtom(i);
snprintf(buffer, BUFF_SIZE, " %s%d %12.7f %12.7f %12.7f",
etab.GetSymbol(atom->GetAtomicNum()), i,
atom->GetX(),
atom->GetY(),
atom->GetZ());
ofs << buffer << endl;
}
ofs << "&" << endl;
return(true);
}
示例2: WriteXYZ
bool WriteXYZ(ostream &ofs,OBMol &mol)
{
unsigned int i;
char buffer[BUFF_SIZE];
sprintf(buffer,"%d", mol.NumAtoms());
ofs << buffer << endl;
sprintf(buffer,"%s\tEnergy: %15.7f", mol.GetTitle(), mol.GetEnergy());
ofs << buffer << endl;
OBAtom *atom;
string str,str1;
for(i = 1;i <= mol.NumAtoms(); i++)
{
atom = mol.GetAtom(i);
sprintf(buffer,"%3s%15.5f%15.5f%15.5f",
etab.GetSymbol(atom->GetAtomicNum()),
atom->GetX(),
atom->GetY(),
atom->GetZ());
ofs << buffer << endl;
}
return(true);
}
示例3: WriteMolecule
bool PQSFormat::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];
OBAtom *atom;
ofs<<"TEXT="<<mol.GetTitle()<<endl;
ofs<<"GEOM=PQS"<<endl;
for (i=1; i<=mol.NumAtoms(); i++)
{
atom=mol.GetAtom(i);
snprintf(buffer, BUFF_SIZE, "%s %10.6lf %10.6lf %10.6lf",
OBElements::GetSymbol(atom->GetAtomicNum()),
atom->GetX(),
atom->GetY(),
atom->GetZ());
ofs<<buffer<<endl;
}
return(true);
}
示例4: WriteViewMol
bool WriteViewMol(ostream &ofs,OBMol &mol)
{
unsigned int i;
char buffer[BUFF_SIZE];
if (strlen(mol.GetTitle()) > 0)
ofs << "$title" << endl << mol.GetTitle() << endl;
ofs << "$coord 1.0" << endl;
OBAtom *atom;
for(i = 1;i <= mol.NumAtoms(); i++)
{
atom = mol.GetAtom(i);
sprintf(buffer,"%22.14f%22.14f%22.14f %s",
atom->GetX(),
atom->GetY(),
atom->GetZ(),
etab.GetSymbol(atom->GetAtomicNum()));
ofs << buffer << endl;
}
ofs << "$end" << endl;
return(true);
}
示例5: WriteMolecule
bool TurbomoleFormat::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;
double UnitConv=AAU;
if(pConv->IsOption("a"))
UnitConv=1;
ofs << "$coord" <<endl;
char buffer[BUFF_SIZE];
OBAtom *atom;
vector<OBAtom*>::iterator i;
for (atom = mol.BeginAtom(i);atom;atom = mol.NextAtom(i))
{
char symb[8];
strcpy(symb,OBElements::GetSymbol(atom->GetAtomicNum()));
snprintf(buffer, BUFF_SIZE, "%20.14f %20.14f %20.14f %s",
atom->GetX()/UnitConv,
atom->GetY()/UnitConv,
atom->GetZ()/UnitConv,
strlwr(symb) );
ofs << buffer << endl;
}
ofs << "$end" << endl;
return true;
}
示例6: WriteAlchemy
bool WriteAlchemy(ostream &ofs,OBMol &mol)
{
unsigned int i;
char buffer[BUFF_SIZE];
char bond_string[10];
snprintf(buffer, BUFF_SIZE, "%5d ATOMS, %5d BONDS, 0 CHARGES",
mol.NumAtoms(),
mol.NumBonds());
ofs << buffer << endl;
ttab.SetFromType("INT"); ttab.SetToType("ALC");
OBAtom *atom;
string str,str1;
for(i = 1;i <= mol.NumAtoms(); i++)
{
atom = mol.GetAtom(i);
str = atom->GetType();
ttab.Translate(str1,str);
snprintf(buffer, BUFF_SIZE, "%5d %-6s%8.4f %8.4f %8.4f 0.0000",
i,
(char*)str1.c_str(),
atom->GetX(),
atom->GetY(),
atom->GetZ());
ofs << buffer << endl;
}
OBBond *bond;
vector<OBEdgeBase*>::iterator j;
for (bond = mol.BeginBond(j);bond;bond = mol.NextBond(j))
{
switch(bond->GetBO())
{
case 1 : strcpy(bond_string,"SINGLE"); break;
case 2 : strcpy(bond_string,"DOUBLE"); break;
case 3 : strcpy(bond_string,"TRIPLE"); break;
case 5 : strcpy(bond_string,"AROMATIC"); break;
default : strcpy(bond_string,"SINGLE");
}
snprintf(buffer, BUFF_SIZE, "%5d %4d %4d %s",
bond->GetIdx()+1,
bond->GetBeginAtomIdx(),
bond->GetEndAtomIdx(),
bond_string);
ofs << buffer << endl;
}
return(true);
}
示例7: atomPos
BoundingBox
NXOpenGLRenderingEngine::GetBoundingBox(OBMol *const molPtr)
{
BoundingBox bbox;
OBAtomIterator atomIter;
OBAtom *atomPtr = NULL;
for(atomPtr = molPtr->BeginAtom(atomIter);
atomPtr != NULL;
atomPtr = molPtr->NextAtom(atomIter))
{
Vector atomPos(real(atomPtr->GetX()),
real(atomPtr->GetY()),
real(atomPtr->GetZ()));
bbox += atomPos;
}
return bbox;
}
示例8: WriteHIN
bool WriteHIN(ostream &ofs,OBMol &mol)
{
unsigned int i, file_num = 1;
string str,str1;
char buffer[BUFF_SIZE];
OBAtom *atom;
OBBond *bond;
vector<OBEdgeBase*>::iterator j;
char bond_char;
ofs << "mol " << file_num << " " << mol.GetTitle() << endl;;
for(i = 1;i <= mol.NumAtoms(); i++)
{
atom = mol.GetAtom(i);
sprintf(buffer,"atom %d - %-3s ** - %8.5f %8.5f %8.5f %8.5f %d ",
i,
etab.GetSymbol(atom->GetAtomicNum()),
atom->GetPartialCharge(),
atom->GetX(),
atom->GetY(),
atom->GetZ(),
atom->GetValence());
ofs << buffer;
for (bond = atom->BeginBond(j); bond; bond = atom->NextBond(j))
{
switch(bond->GetBO())
{
case 1 : bond_char = 's'; break;
case 2 : bond_char = 'd'; break;
case 3 : bond_char = 't'; break;
case 5 : bond_char = 'a'; break;
default: bond_char = 's'; break;
}
sprintf(buffer,"%d %c ", (bond->GetNbrAtom(atom))->GetIdx(), bond_char);
ofs << buffer;
}
ofs << endl;
}
ofs << "endmol " << file_num << endl;
return(true);
}
示例9: DrawMolecule
bool OBDepict::DrawMolecule(OBMol *mol)
{
if (!d->painter)
return false;
d->mol = mol;
double width=0.0, height=0.0;
OBAtom *atom;
OBBondIterator j;
OBAtomIterator i;
if(mol->NumAtoms()>0) {
// scale bond lengths
double bondLengthSum = 0.0;
for (OBBond *bond = mol->BeginBond(j); bond; bond = mol->NextBond(j))
bondLengthSum += bond->GetLength();
const double averageBondLength = bondLengthSum / mol->NumBonds();
const double f = mol->NumBonds() ? d->bondLength / averageBondLength : 1.0;
for (atom = mol->BeginAtom(i); atom; atom = mol->NextAtom(i))
atom->SetVector(atom->GetX() * f, atom->GetY() * f, 0.0);
// find min/max values
double min_x, max_x;
double min_y, max_y;
atom = mol->BeginAtom(i);
min_x = max_x = atom->GetX();
min_y = max_y = atom->GetY();
for (atom = mol->NextAtom(i); atom; atom = mol->NextAtom(i)) {
min_x = std::min(min_x, atom->GetX());
max_x = std::max(max_x, atom->GetX());
min_y = std::min(min_y, atom->GetY());
max_y = std::max(max_y, atom->GetY());
}
const double margin = 40.0;
// translate all atoms so the bottom-left atom is at margin,margin
for (atom = mol->BeginAtom(i); atom; atom = mol->NextAtom(i))
atom->SetVector(atom->GetX() - min_x + margin, atom->GetY() - min_y + margin, 0.0);
width = max_x - min_x + 2*margin;
height = max_y - min_y + 2*margin;
//d->painter->SetPenWidth(d->penWidth);
//d->painter->SetPenColor(d->pen));
//d->painter->SetFillColor(OBColor("black"));
}
d->painter->NewCanvas(width, height);
// draw bonds
if(d->options & genWedgeHash)
d->SetWedgeAndHash(mol);
for (OBBond *bond = mol->BeginBond(j); bond; bond = mol->NextBond(j)) {
OBAtom *begin = bond->GetBeginAtom();
OBAtom *end = bond->GetEndAtom();
if((d->options & internalColor) && bond->HasData("color"))
d->painter->SetPenColor(OBColor(bond->GetData("color")->GetValue()));
else
d->painter->SetPenColor(d->bondColor);
if (bond->IsWedge()) {
d->DrawWedge(begin, end);
} else if (bond->IsHash()) {
d->DrawHash(begin, end);
} else if (!bond->IsInRing()) {
d->DrawSimpleBond(begin, end, bond->GetBO());
}
}
// draw ring bonds
std::vector<OBRing*> rings(mol->GetSSSR());
OBBitVec drawnBonds;
for (std::vector<OBRing*>::iterator k = rings.begin(); k != rings.end(); ++k) {
OBRing *ring = *k;
std::vector<int> indexes = ring->_path;
vector3 center(VZero);
for (std::vector<int>::iterator l = indexes.begin(); l != indexes.end(); ++l) {
center += mol->GetAtom(*l)->GetVector();
}
center /= indexes.size();
for (unsigned int l = 0; l < indexes.size(); ++l) {
OBAtom *begin = mol->GetAtom(indexes[l]);
OBAtom *end;
if (l+1 < indexes.size())
end = mol->GetAtom(indexes[l+1]);
else
end = mol->GetAtom(indexes[0]);
OBBond *ringBond = mol->GetBond(begin, end);
if (drawnBonds.BitIsSet(ringBond->GetId()))
continue;
if((d->options & internalColor) && ringBond->HasData("color"))
d->painter->SetPenColor(OBColor(ringBond->GetData("color")->GetValue()));
else
d->painter->SetPenColor(d->bondColor);
//.........这里部分代码省略.........
示例10: WriteMolecule
//.........这里部分代码省略.........
break;
}
}
orbitals = valenceE / 2;
if (charged)
{
orbitals = (valenceE / 2) - 1;
valenceE -= 1;
}
ofs << " $TITLEI" << endl;
ofs << endl;
ofs << " " << mol.GetTitle() << endl;
ofs << endl;
ofs << " $END" << endl;
ofs << endl;
ofs << " $CONTRL" << endl;
ofs << endl;
if (charged)
ofs << " SCFTYP ROHF RUNTYP CI ENTTYP COORD" << endl;
else
ofs << " SCFTYP RHF RUNTYP CI ENTTYP COORD" << endl;
ofs << " UNITS ANGS INTTYP 1 IAPX 3" << endl;
if (charged)
{
ofs << endl;
ofs << " NOP = 1 " << endl;
ofs << " NDT = 1 " << endl;
snprintf(buffer, BUFF_SIZE, " FOP(1) =% 4d% 10.6f",
valenceE - 1, 1.0);
ofs << buffer << endl;
}
snprintf(buffer, BUFF_SIZE, " NAT %4d NEL %4d MULT 1",
mol.NumAtoms(),
valenceE);
ofs << buffer << endl;
ofs << " IPRINT -1 ITMAX 100" << endl;
ofs << endl;
ofs << "! ***** BASIS SET AND C. I. SIZE INFORMATION ***** " << endl;
ofs << endl;
snprintf(buffer, BUFF_SIZE, " DYNAL(1) = 0%5d%5d 0 0 1200%5d",
mol.NumAtoms() - mol.NumHvyAtoms(),
mol.NumHvyAtoms(),
orbitals + 25);
ofs << buffer << endl;
ofs << endl;
ofs << " INTFA(1) = 1.000000 1.267000 0.680000 1.000000 1.000000 " << endl;
ofs << endl;
ofs << "! ***** OUTPUT FILE NAME ***** " << endl;
ofs << endl;
ofs << " ONAME = zindo " << endl;
ofs << endl;
ofs << " $END" << endl;
ofs << endl;
ofs << " $DATAIN " << endl;
ofs << endl;
for (atom = mol.BeginAtom(i); atom; atom = mol.NextAtom(i))
{
snprintf(buffer, BUFF_SIZE, "% 10.6f% 10.6f% 10.6f%5d",
atom->GetX(),
atom->GetY(),
atom->GetZ(),
atom->GetAtomicNum());
ofs << buffer << endl;
}
ofs << endl;
ofs << " $END " << endl;
ofs << endl;
ofs << " $CIINPU" << endl;
ofs << endl;
ofs << "! ***** C. I. SPECIFICATION *****" << endl;
ofs << endl;
ofs << " 2 1 25 1 0 0 0 1 10 1 10" << endl;
ofs << " -60000.0 0.0000000" << endl;
ofs << endl;
if (charged)
snprintf(buffer, BUFF_SIZE, "%5d%5d%5d%5d", 1, orbitals, orbitals, orbitals + 1);
else
snprintf(buffer, BUFF_SIZE, "%5d%5d%5d", 1, orbitals, orbitals);
ofs << buffer << endl;
if (charged)
snprintf(buffer, BUFF_SIZE, "%5d%5d%5d%5d%5d",
21, (orbitals - 8), orbitals + 1, orbitals + 1, orbitals + 11);
else
snprintf(buffer, BUFF_SIZE, "%5d%5d%5d%5d%5d",
21, (orbitals - 9), orbitals, orbitals + 1, orbitals + 10);
ofs << buffer << endl;
ofs << endl;
ofs << " $END" << endl;
return(true);
}
示例11: WriteMolecule
bool TinkerFormat::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;
bool mmffTypes = pConv->IsOption("m",OBConversion::OUTOPTIONS) != NULL;
unsigned int i;
char buffer[BUFF_SIZE];
OBBond *bond;
vector<OBBond*>::iterator j;
// Before we try output of MMFF94 atom types, check if it works
OBForceField *ff = OpenBabel::OBForceField::FindForceField("MMFF94");
if (mmffTypes && ff && ff->Setup(mol))
mmffTypes = ff->GetAtomTypes(mol);
else
mmffTypes = false; // either the force field isn't available, or it doesn't work
if (!mmffTypes)
snprintf(buffer, BUFF_SIZE, "%6d %-20s MM2 parameters\n",mol.NumAtoms(),mol.GetTitle());
else
snprintf(buffer, BUFF_SIZE, "%6d %-20s MMFF94 parameters\n",mol.NumAtoms(),mol.GetTitle());
ofs << buffer;
ttab.SetFromType("INT");
OBAtom *atom;
string str,str1;
for(i = 1;i <= mol.NumAtoms(); i++)
{
atom = mol.GetAtom(i);
str = atom->GetType();
ttab.SetToType("MM2");
ttab.Translate(str1,str);
if (mmffTypes) {
// Override the MM2 typing
OBPairData *type = (OpenBabel::OBPairData*)atom->GetData("FFAtomType");
if (type)
str1 = type->GetValue().c_str();
}
snprintf(buffer, BUFF_SIZE, "%6d %2s %12.6f%12.6f%12.6f %5d",
i,
etab.GetSymbol(atom->GetAtomicNum()),
atom->GetX(),
atom->GetY(),
atom->GetZ(),
atoi((char*)str1.c_str()));
ofs << buffer;
for (bond = atom->BeginBond(j); bond; bond = atom->NextBond(j))
{
snprintf(buffer, BUFF_SIZE, "%6d", (bond->GetNbrAtom(atom))->GetIdx());
ofs << buffer;
}
ofs << endl;
}
return(true);
}
示例12: WriteMolecule
bool ChemDrawXMLFormat::WriteMolecule(OBBase* pOb, OBConversion* pConv)
{
static const xmlChar C_MOLECULE[] = "fragment";
static const xmlChar C_CDXML[] = "CDXML";
static const xmlChar C_BONDLENGTH[] = "BondLength";
static const xmlChar C_PAGE[] = "page";
static const xmlChar C_ATOM[] = "n";
static const xmlChar C_BOND[] = "b";
static const xmlChar C_ID[] = "id";
static const xmlChar C_CHARGE[] = "Charge";
static const xmlChar C_COORDS[] = "p";
static const xmlChar C_ELEMENT[] = "Element";
static const xmlChar C_ORDER[] = "Order";
static const xmlChar C_BEGIN[] = "B";
static const xmlChar C_END[] = "E";
static const xmlChar C_DISPLAY[] = "Display";
_pxmlConv = XMLConversion::GetDerived(pConv,false);
if(!_pxmlConv)
return false;
OBMol* pmol = dynamic_cast<OBMol*>(pOb);
if(pmol==NULL)
return false;
OBMol &mol = *pmol;
OBBond *pbond;
vector<OBBond*>::iterator j;
if(_pxmlConv->GetOutputIndex() == 1)
{
xmlTextWriterStartDocument(writer(), NULL, NULL, NULL);
xmlTextWriterWriteDTD(writer(), BAD_CAST "CDXML", NULL, BAD_CAST "http://www.camsoft.com/xml/cdxml.dtd", NULL);
xmlTextWriterStartElement(writer(), C_CDXML);
xmlTextWriterWriteFormatAttribute(writer(), C_BONDLENGTH , "30");
xmlTextWriterStartElement(writer(), C_PAGE); // put everything on one page
// now guess the average bond size for the first molecule and scale to 30.
_scale = 0.;
if (mol.NumBonds())
{
for (pbond = mol.BeginBond(j); pbond; pbond = mol.NextBond(j))
_scale += pbond->GetLength();
_scale /= mol.NumBonds();
}
else
_scale = 1.; // FIXME: what happens if the molecule has no bond?
_scale = 30. / _scale;
_offset = 0;
}
xmlTextWriterStartElement(writer(), C_MOLECULE);
OBAtom *patom;
vector<OBAtom*>::iterator i;
int n;
for (patom = mol.BeginAtom(i); patom; patom = mol.NextAtom(i))
{
xmlTextWriterStartElement(writer(), C_ATOM);
xmlTextWriterWriteFormatAttribute(writer(), C_ID , "%d", patom->GetIdx() + _offset);
xmlTextWriterWriteFormatAttribute(writer(), C_COORDS , "%f %f", patom->GetX() * _scale, patom->GetY() * _scale);
n = patom->GetAtomicNum();
if (n != 6)
{
xmlTextWriterWriteFormatAttribute(writer(), C_ELEMENT , "%d", n);
}
n = patom->GetFormalCharge();
if (n != 0)
{
xmlTextWriterWriteFormatAttribute(writer(), C_CHARGE , "%d", n);
}
xmlTextWriterEndElement(writer());
}
for (pbond = mol.BeginBond(j); pbond; pbond = mol.NextBond(j))
{
xmlTextWriterStartElement(writer(), C_BOND);
patom = pbond->GetBeginAtom();
xmlTextWriterWriteFormatAttribute(writer(), C_BEGIN , "%d", patom->GetIdx() + _offset);
patom = pbond->GetEndAtom();
xmlTextWriterWriteFormatAttribute(writer(), C_END , "%d", patom->GetIdx() + _offset);
n = pbond->GetBO();
if (n != 1)
{
xmlTextWriterWriteFormatAttribute(writer(), C_ORDER , "%d", n);
}
if (pbond->IsHash())
xmlTextWriterWriteFormatAttribute(writer(), C_DISPLAY , "WedgeBegin");
else if (pbond->IsWedge())
xmlTextWriterWriteFormatAttribute(writer(), C_DISPLAY , "WedgedHashEnd");
xmlTextWriterEndElement(writer());
}
_offset += mol.NumAtoms ();
xmlTextWriterEndElement(writer());//molecule
//TODO: Writing property block
if(_pxmlConv->IsLast())
{
//.........这里部分代码省略.........
示例13: WriteMolecule
//.........这里部分代码省略.........
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(),
pUC->GetAlpha(), pUC->GetBeta(), pUC->GetGamma(),
tmpHM.c_str());
}
else
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(),
pUC->GetAlpha(), pUC->GetBeta(), pUC->GetGamma(),
"P1");
ofs << buffer << endl;
}
// before we write any records, we should check to see if any coord < -1000
// which will cause errors in the formatting
double minX, minY, minZ;
minX = minY = minZ = -999.0f;
FOR_ATOMS_OF_MOL(a, mol)
{
if (a->GetX() < minX)
minX = a->GetX();
if (a->GetY() < minY)
minY = a->GetY();
if (a->GetZ() < minZ)
minZ = a->GetZ();
}
vector3 transV = VZero;
if (minX < -999.0)
transV.SetX(-1.0*minX - 900.0);
if (minY < -999.0)
transV.SetY(-1.0*minY - 900.0);
if (minZ < -999.0)
transV.SetZ(-1.0*minZ - 900.0);
// if minX, minY, or minZ was never changed, shift will be 0.0f
// otherwise, move enough so that smallest coord is > -999.0f
mol.Translate(transV);
OBAtom *atom;
OBResidue *res;
for (i = 1; i <= mol.NumAtoms(); i++)
{
atom = mol.GetAtom(i);
strncpy(type_name, etab.GetSymbol(atom->GetAtomicNum()), sizeof(type_name));
type_name[sizeof(type_name) - 1] = '\0';
//two char. elements are on position 13 and 14 one char. start at 14
if (strlen(type_name) > 1)
type_name[1] = toupper(type_name[1]);
else
{
char tmp[10];
strncpy(tmp, type_name, 9); // make sure to null-terminate tmp
snprintf(type_name, sizeof(type_name), " %-3s", tmp);
示例14: WriteMolecule
bool AlchemyFormat::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 bond_string[10];
snprintf(buffer, BUFF_SIZE, "%5d ATOMS, %5d BONDS, 0 CHARGES",
mol.NumAtoms(),
mol.NumBonds());
ofs << buffer << endl;
OBAtom *atom;
string str,str1;
for(i = 1;i <= mol.NumAtoms(); i++)
{
atom = mol.GetAtom(i);
str = atom->GetType();
ttab.SetFromType("INT");
ttab.SetToType("ALC");
ttab.Translate(str1,str);
snprintf(buffer, BUFF_SIZE, "%5d %-6s%8.4f %8.4f %8.4f 0.0000",
i,
(char*)str1.c_str(),
atom->GetX(),
atom->GetY(),
atom->GetZ());
ofs << buffer << endl;
}
OBBond *bond;
vector<OBBond*>::iterator j;
for (bond = mol.BeginBond(j);bond;bond = mol.NextBond(j))
{
switch(bond->GetBO())
{
case 1 :
strcpy(bond_string,"SINGLE");
break;
case 2 :
strcpy(bond_string,"DOUBLE");
break;
case 3 :
strcpy(bond_string,"TRIPLE");
break;
case 5 :
strcpy(bond_string,"AROMATIC");
break;
default :
strcpy(bond_string,"SINGLE");
}
snprintf(buffer, BUFF_SIZE, "%5d %4d %4d %s",
bond->GetIdx()+1,
bond->GetBeginAtomIdx(),
bond->GetEndAtomIdx(),
bond_string);
ofs << buffer << endl;
}
return(true);
}
示例15: 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;
}
if (strlen(mol.GetTitle()) > 0)
snprintf(buffer, BUFF_SIZE, "COMPND %s ",mol.GetTitle());
else
snprintf(buffer, BUFF_SIZE, "COMPND UNNAMED");
ofs << buffer << endl;
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);
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(),
pUC->GetAlpha(), pUC->GetBeta(), pUC->GetGamma(),
pUC->GetSpaceGroup() ?
pUC->GetSpaceGroup()->GetHMName().c_str() : "P1");
ofs << buffer << endl;
}
// before we write any records, we should check to see if any coord < -1000
// which will cause errors in the formatting
double minX, minY, minZ;
minX = minY = minZ = -999.0f;
FOR_ATOMS_OF_MOL(a, mol)
{
if (a->GetX() < minX)
minX = a->GetX();
if (a->GetY() < minY)
minY = a->GetY();
if (a->GetZ() < minZ)
minZ = a->GetZ();
}
vector3 transV = VZero;
if (minX < -999.0)
transV.SetX(-1.0*minX - 900.0);
if (minY < -999.0)
transV.SetY(-1.0*minY - 900.0);
if (minZ < -999.0)
transV.SetZ(-1.0*minZ - 900.0);
// if minX, minY, or minZ was never changed, shift will be 0.0f
// otherwise, move enough so that smallest coord is > -999.0f
mol.Translate(transV);
OBAtom *atom;
OBResidue *res;
for (i = 1; i <= mol.NumAtoms(); i++)
{
atom = mol.GetAtom(i);
strncpy(type_name, etab.GetSymbol(atom->GetAtomicNum()), sizeof(type_name));
type_name[sizeof(type_name) - 1] = '\0';
//two char. elements are on position 13 and 14 one char. start at 14
if (strlen(type_name) > 1)
type_name[1] = toupper(type_name[1]);
else
{
char tmp[10];
strncpy(tmp, type_name, 10);
snprintf(type_name, sizeof(type_name), " %-3s", tmp);
}
if ( (res = atom->GetResidue()) != 0 )
{
het = res->IsHetAtom(atom);
snprintf(the_res,4,"%s",(char*)res->GetName().c_str());
snprintf(type_name,5,"%s",(char*)res->GetAtomID(atom).c_str());
the_chain = res->GetChain();
//.........这里部分代码省略.........