本文整理汇总了C++中OBAtom::IsChiral方法的典型用法代码示例。如果您正苦于以下问题:C++ OBAtom::IsChiral方法的具体用法?C++ OBAtom::IsChiral怎么用?C++ OBAtom::IsChiral使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OBAtom
的用法示例。
在下文中一共展示了OBAtom::IsChiral方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetChirality
// Seems to make a vector chirality become filled with array of +/- 1 for chiral atoms.
void GetChirality(OBMol &mol, std::vector<int> &chirality)
{
chirality.resize(mol.NumAtoms()+1);
fill(chirality.begin(),chirality.end(),0);
OBAtom *atom;
vector<OBAtom*>::iterator i;
for (atom = mol.BeginAtom(i);atom;atom = mol.NextAtom(i))
if (atom->IsChiral())
{
if (!atom->HasChiralVolume())
{
double sv = CalcSignedVolume(mol,atom);
if (sv < 0.0)
{
chirality[atom->GetIdx()-1] = -1;
atom->SetNegativeStereo();
}
else if (sv > 0.0)
{
chirality[atom->GetIdx()-1] = 1;
atom->SetPositiveStereo();
}
}
else // already calculated signed volume (e.g., imported from somewhere)
{
if (atom ->IsPositiveStereo())
chirality[atom->GetIdx()-1] = 1;
else
chirality[atom->GetIdx()-1] = -1;
}
}
}
示例2: WriteChiral
void WriteChiral(ostream &ofs,OBMol &mol)
{
OBAtom *atom;
vector<OBNodeBase*>::iterator i;
char buffer[BUFF_SIZE];
for (atom = mol.BeginAtom(i);atom;atom = mol.NextAtom(i))
{
if (atom->IsChiral())
{
sprintf(buffer,"%4s %5d is chiral: %s",
etab.GetSymbol(atom->GetAtomicNum()),
atom->GetIdx(),
(atom->IsClockwise() ? "clockwise" : "counterclockwise"));
ofs << buffer << endl;
}
}
}
示例3: main
int main(int argc,char **argv)
{
char *program_name= argv[0];
char *FileIn = NULL;
if (argc != 2)
{
cout << "Usage: " << program_name << " <filename>" << endl;
exit(-1);
}
else
{
FileIn = argv[1];
// const char* p = strrchr(FileIn,'.');
}
// Find Input filetype
OBConversion conv;
OBFormat *format = conv.FormatFromExt(FileIn);
if (!format || !conv.SetInAndOutFormats(format, format))
{
cerr << program_name << ": cannot read input format!" << endl;
exit (-1);
}
ifstream ifs;
// Read the file
ifs.open(FileIn);
if (!ifs)
{
cerr << program_name << ": cannot read input file!" << endl;
exit (-1);
}
OBMol mol;
OBAtom *atom;
for (int c=1;;++c) // big for loop (replace with do while?)
{
mol.Clear();
conv.Read(&mol, &ifs);
if (mol.Empty())
break;
cout << "Molecule "<< c << ": " << mol.GetTitle() << endl;
//mol.FindChiralCenters(); // labels all chiral atoms
vector<OBAtom*>::iterator i; // iterate over all atoms
for (atom = mol.BeginAtom(i);atom;atom = mol.NextAtom(i))
{
if(!atom->IsChiral())continue; // aborts if atom isn't chiral
cout << "Atom " << atom->GetIdx() << " Is Chiral ";
cout << atom->GetType()<<endl;
OBChiralData* cd = (OBChiralData*)atom->GetData(OBGenericDataType::ChiralData);
if (cd){
vector<unsigned int> x=cd->GetAtom4Refs(input);
size_t n=0;
cout <<"Atom4refs:";
for (n=0;n<x.size();++n)
cout <<" "<<x[n];
cout <<endl;
}
else{cd=new OBChiralData;atom->SetData(cd);}
vector<unsigned int> _output;
unsigned int n;
for(n=1;n<5;++n) _output.push_back(n);
cd->SetAtom4Refs(_output,output);
/* // MOLV3000 uses 1234 unless an H then 123H
if (atom->GetHvyValence()==3)
{
OBAtom *nbr;
int Hid=1000;// max Atom ID +1 should be used here
vector<unsigned int> nbr_atms;
vector<OBBond*>::iterator i;
for (nbr = atom->BeginNbrAtom(i);nbr;nbr = atom->NextNbrAtom(i))
{
if (nbr->IsHydrogen()){Hid=nbr->GetIdx();continue;}
nbr_atms.push_back(nbr->GetIdx());
}
sort(nbr_atms.begin(),nbr_atms.end());
nbr_atms.push_back(Hid);
OBChiralData* cd=(OBChiralData*)atom->GetData(OBGenericDataType::ChiralData);
cd->SetAtom4Refs(nbr_atms,output);
}
else if (atom->GetHvyValence()==4)
{
OBChiralData* cd=(OBChiralData*)atom->GetData(OBGenericDataType::ChiralData);
vector<unsigned int> nbr_atms;
int n;
for(n=1;n<5;++n)nbr_atms.push_back(n);
cd->SetAtom4Refs(nbr_atms,output);
} */
/* FIXME
if (!mol.HasNonZeroCoords())
{
cout << "Calcing 0D chirality "<< CorrectChirality(mol,atom)<<endl;
}
else {
//.........这里部分代码省略.........