本文整理汇总了C++中OBMol::NumResidues方法的典型用法代码示例。如果您正苦于以下问题:C++ OBMol::NumResidues方法的具体用法?C++ OBMol::NumResidues怎么用?C++ OBMol::NumResidues使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OBMol
的用法示例。
在下文中一共展示了OBMol::NumResidues方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CheckValidDipeptide
void CheckValidDipeptide(OBConversion &conv,
const string &test,
unsigned int testCount)
{
OBMol mol;
OBResidue *res;
ostringstream os;
mol.Clear();
conv.ReadString(&mol, test);
chainsparser.PerceiveChains(mol);
if (mol.NumResidues() != 2) {
os << "not ok " << testCount << " # expected 2 residues, but found "
<< mol.NumResidues() << '\n';
os << "# ";
FOR_RESIDUES_OF_MOL(res, mol)
os << res->GetName() << " ";
os << endl;
BOOST_CHECK_MESSAGE( 0, os.str().c_str() );
} else {
res = mol.GetResidue(0);
BOOST_CHECK_MESSAGE( res, "Get first AA from dipeptide" );
res = mol.GetResidue(1);
BOOST_CHECK_MESSAGE( res, "Get second AA from dipeptide" );
}
}
示例2: CheckInvalidResidue
void CheckInvalidResidue(OBConversion &conv,
const string &test,
unsigned int testCount)
{
OBMol mol;
mol.Clear();
conv.ReadString(&mol, test);
chainsparser.PerceiveChains(mol);
if (mol.NumResidues() != 0) {
OBResidue *res = mol.GetResidue(0);
if (res->GetName() == "LIG") { // ligand, not residue
cout << "ok " << testCount << " # found ligand, not residue "
<< test << '\n';
} else {
cout << "not ok " << testCount << " # expected 0 residues, found "
<< mol.NumResidues() << '\n';
cout << "# " << res->GetName() << endl;
}
} else
cout << "ok " << testCount << " # correctly rejected " << test << '\n';
}
示例3: CheckInvalidResidue
void CheckInvalidResidue(OBConversion &conv,
const string &test,
unsigned int testCount)
{
OBMol mol;
ostringstream os;
mol.Clear();
conv.ReadString(&mol, test);
chainsparser.PerceiveChains(mol);
if (mol.NumResidues() != 0) {
OBResidue *res = mol.GetResidue(0);
if (res->GetName() == "LIG") { // ligand, not residue
BOOST_CHECK( 1 );
} else {
os << "not ok " << testCount << " # expected 0 residues, found "
<< mol.NumResidues() << '\n';
os << "# " << res->GetName() << endl;
BOOST_CHECK_MESSAGE( 0, os.str().c_str() );
}
} else
BOOST_CHECK( 1 );
}
示例4: CheckValidDipeptide
void CheckValidDipeptide(OBConversion &conv,
const string &test,
unsigned int testCount)
{
OBMol mol;
mol.Clear();
conv.ReadString(&mol, test);
chainsparser.PerceiveChains(mol);
if (mol.NumResidues() != 2) {
cout << "not ok " << testCount << " # expected 2 residues, but found "
<< mol.NumResidues() << '\n';
cout << "# ";
FOR_RESIDUES_OF_MOL(res, mol)
cout << res->GetName() << " ";
cout << endl;
} else {
OBResidue *res;
res = mol.GetResidue(0);
cout << "ok " << testCount << " # " << res->GetName();
res = mol.GetResidue(1);
cout << " " << res->GetName() << '\n';
}
}
示例5: parseAtomRecord
//.........这里部分代码省略.........
resname == "GPG" || resname == "NAD" || resname == "NAL" ||
resname == "NDP" || resname == "ABA") {
if (type.size() > 1)
type = type.substr(0,1);
//type.erase(1,type.size()-1);
} else // other residues
if (isdigit(type[0])){
type = type.substr(1,1);
}
else
if (type.size() > 1 && isdigit(type[1]))
type = type.substr(0,1);
else
if (type.size() > 1 && isalpha(type[1])) {
if (type[0] == 'O' && type[1] == 'H')
type = type.substr(0,1); // no "Oh" element (e.g. 1MBN)
else if(isupper(type[1])) {
type[1] = tolower(type[1]);
}
}
}
} // HETATM records
} // no element column to use
OBAtom atom;
/* X, Y, Z */
string xstr = sbuf.substr(24,8);
string ystr = sbuf.substr(32,8);
string zstr = sbuf.substr(40,8);
vector3 v(atof(xstr.c_str()),atof(ystr.c_str()),atof(zstr.c_str()));
atom.SetVector(v);
atom.ForceImplH();
// useful for debugging unknown atom types (e.g., PR#1577238)
// cout << mol.NumAtoms() + 1 << " : '" << element << "'" << " " << etab.GetAtomicNum(element.c_str()) << endl;
if (elementFound)
atom.SetAtomicNum(etab.GetAtomicNum(element.c_str()));
else // use our old-style guess from athe atom type
atom.SetAtomicNum(etab.GetAtomicNum(type.c_str()));
if ( (! scharge.empty()) && " " != scharge )
{
if ( isdigit(scharge[0]) && ('+' == scharge[1] || '-' == scharge[1]) )
{
const char reorderCharge[3] = { scharge[1], scharge[0], '\0' };
const int charge = atoi(reorderCharge);
atom.SetFormalCharge(charge);
}
else
{
stringstream errorMsg;
errorMsg << "WARNING: Problems reading a PDB file\n"
<< " Problems reading a HETATM or ATOM record.\n"
<< " According to the PDB specification,\n"
<< " columns 79-80 should contain charge of the atom\n"
<< " but OpenBabel found '" << scharge << "' (atom " << mol.NumAtoms()+1 << ").";
obErrorLog.ThrowError(__FUNCTION__, errorMsg.str(), obWarning);
}
}
else {
atom.SetFormalCharge(0);
}
/* residue sequence number */
string resnum = sbuf.substr(16,4);
OBResidue *res = (mol.NumResidues() > 0) ? mol.GetResidue(mol.NumResidues()-1) : NULL;
if (res == NULL
|| res->GetName() != resname
|| res->GetNumString() != resnum
|| res->GetChain() != chain)
{
vector<OBResidue*>::iterator ri;
for (res = mol.BeginResidue(ri) ; res ; res = mol.NextResidue(ri))
if (res->GetName() == resname
&& res->GetNumString() == resnum
&& static_cast<int>(res->GetChain()) == chain)
break;
if (res == NULL) {
res = mol.NewResidue();
res->SetChain(chain);
res->SetName(resname);
res->SetNum(resnum);
}
}
if (!mol.AddAtom(atom))
return(false);
else {
OBAtom *atom = mol.GetAtom(mol.NumAtoms());
res->AddAtom(atom);
res->SetSerialNum(atom, atoi(serno.c_str()));
res->SetAtomID(atom, sbuf.substr(6,4));
res->SetHetAtom(atom, hetatm);
return(true);
}
} // end reading atom records
示例6: main
//.........这里部分代码省略.........
exit (-1);
}
ifstream ifs;
// Read the file
ifs.open(FileIn);
if (!ifs)
{
cerr << program_name << ": cannot read input file!" << endl;
exit (-1);
}
OBMol mol;
OBFormat *canSMIFormat = conv.FindFormat("can");
OBFormat *inchiFormat = conv.FindFormat("inchi");
////////////////////////////////////////////////////////////////////////////
// List of properties
// Name
// Molecular weight (Standard molar mass given by IUPAC atomic masses)
// Number of rings : the size of the smallest set of smallest rings (SSSR)
//.....ADD YOURS HERE.....
for (c = 1;; ++c)
{
mol.Clear();
conv.Read(&mol, &ifs);
if (mol.Empty())
break;
if (!mol.HasHydrogensAdded())
mol.AddHydrogens();
// Print the properties
if (strlen(mol.GetTitle()) != 0)
cout << "name " << mol.GetTitle() << endl;
else
cout << "name " << FileIn << " " << c << endl;
cout << "formula " << mol.GetFormula() << endl;
cout << "mol_weight " << mol.GetMolWt() << endl;
cout << "exact_mass " << mol.GetExactMass() << endl;
string smilesString = "-";
if (canSMIFormat) {
conv.SetOutFormat(canSMIFormat);
smilesString = conv.WriteString(&mol);
if ( smilesString.length() == 0 )
{
smilesString = "-";
}
}
cout << "canonical_SMILES " << smilesString << endl;
string inchiString = "-";
if (inchiFormat) {
conv.SetOutFormat(inchiFormat);
inchiString = conv.WriteString(&mol);
if ( inchiString.length() == 0 )
{
inchiString = "-";
}
}
cout << "InChI " << inchiString << endl;
cout << "num_atoms " << mol.NumAtoms() << endl;
cout << "num_bonds " << mol.NumBonds() << endl;
cout << "num_residues " << mol.NumResidues() << endl;
cout << "num_rotors " << mol.NumRotors() << endl;
if (mol.NumResidues() > 0)
cout << "sequence " << sequence(mol) << endl;
else
cout << "sequence " << "-" << endl;
cout << "num_rings " << nrings(mol) << endl;
OBDescriptor* pDesc;
pDesc= OBDescriptor::FindType("logP");
if(pDesc)
cout << "logP " << pDesc->Predict(&mol) << endl;
pDesc = OBDescriptor::FindType("TPSA");
if(pDesc)
cout << "PSA " << pDesc->Predict(&mol) << endl;
pDesc = OBDescriptor::FindType("MR");
if(pDesc)
cout << "MR " << pDesc->Predict(&mol) << endl;
cout << "$$$$" << endl; // SDF like end of compound descriptor list
//Other OBDescriptors could be output here, even ones that were rarely
// used. Since these are plugin classes, they may not be loaded, but
// then with code like the above they are just ignored.
} // end for loop
return(0);
}