本文整理汇总了C++中BaseMolecule::getAtomNumber方法的典型用法代码示例。如果您正苦于以下问题:C++ BaseMolecule::getAtomNumber方法的具体用法?C++ BaseMolecule::getAtomNumber怎么用?C++ BaseMolecule::getAtomNumber使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BaseMolecule
的用法示例。
在下文中一共展示了BaseMolecule::getAtomNumber方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: _prepare_ee
bool ReactionExactMatcher::_prepare_ee (EmbeddingEnumerator &ee,
BaseMolecule &submol, Molecule &supermol, void *context)
{
int i;
ReactionExactMatcher &self = *(ReactionExactMatcher *)context;
for (i = submol.vertexBegin(); i != submol.vertexEnd(); i = submol.vertexNext(i))
{
const Vertex &vertex = submol.getVertex(i);
if (submol.getAtomNumber(i) == ELEM_H && vertex.degree() == 1 &&
submol.getAtomNumber(vertex.neiVertex(vertex.neiBegin())) != ELEM_H)
if (submol.getAtomIsotope(i) == 0 || !(self.flags & MoleculeExactMatcher::CONDITION_ISOTOPE))
ee.ignoreSubgraphVertex(i);
}
for (i = supermol.vertexBegin(); i != supermol.vertexEnd(); i = supermol.vertexNext(i))
{
const Vertex &vertex = supermol.getVertex(i);
if (supermol.getAtomNumber(i) == ELEM_H && vertex.degree() == 1 &&
supermol.getAtomNumber(vertex.neiVertex(vertex.neiBegin())) != ELEM_H)
if (supermol.getAtomIsotope(i) == 0 || !(self.flags & MoleculeExactMatcher::CONDITION_ISOTOPE))
ee.ignoreSupergraphVertex(i);
}
if (ee.countUnmappedSubgraphVertices() != ee.countUnmappedSupergraphVertices())
return false;
if (ee.countUnmappedSubgraphEdges() != ee.countUnmappedSupergraphEdges())
return false;
return true;
}
示例2: markIgnoredHydrogens
void MoleculeSubstructureMatcher::markIgnoredHydrogens (BaseMolecule &mol, int *arr, int value_keep, int value_ignore)
{
int i;
for (i = mol.vertexBegin(); i != mol.vertexEnd(); i = mol.vertexNext(i))
arr[i] = value_keep;
for (i = mol.vertexBegin(); i != mol.vertexEnd(); i = mol.vertexNext(i))
{
if (mol.getAtomNumber(i) != ELEM_H)
continue;
if (!mol.possibleAtomIsotope(i, 0))
continue;
if (mol.isQueryMolecule())
{
// Check if atom has fragment constraint.
// For example [$([#1][N])] should be ignored
if (mol.asQueryMolecule().getAtom(i).hasConstraint(QueryMolecule::ATOM_FRAGMENT))
continue;
}
const Vertex &vertex = mol.getVertex(i);
if (vertex.degree() == 1)
{
int nei_idx = vertex.neiVertex(vertex.neiBegin());
if (mol.getAtomNumber(nei_idx) == ELEM_H && mol.possibleAtomIsotope(nei_idx, 0))
continue; // do not ignore rare H-H fragment
// Check if hydrogen forms a cis-trans bond or stereocenter
int nei_vertex_idx = vertex.neiVertex(vertex.neiBegin());
if (mol.stereocenters.exists(nei_vertex_idx))
continue;
// For example for this query hydrogens should be unfolded: [H]\\C=C/C
const Vertex &nei_vertex = mol.getVertex(nei_vertex_idx);
bool not_ignore = false;
for (int nei = nei_vertex.neiBegin(); nei != nei_vertex.neiEnd(); nei = nei_vertex.neiNext(nei))
{
int edge = nei_vertex.neiEdge(nei);
if (mol.cis_trans.getParity(edge) != 0)
{
not_ignore = true;
break;
}
}
if (not_ignore)
continue;
arr[i] = value_ignore;
}
}
}
示例3: matchAtomsTau
bool TautomerMatcher::matchAtomsTau (BaseMolecule &g1, BaseMolecule &g2, int n1, int n2)
{
if (g1.isPseudoAtom(n1) || g2.isPseudoAtom(n2))
return false;
if (g1.isRSite(n1) || g2.isRSite(n2))
return false;
return g1.getAtomNumber(n1) == g2.getAtomNumber(n2) &&
g1.possibleAtomIsotope(n1, g2.getAtomIsotope(n2));
}
示例4: _atomCode
int MoleculeFingerprintBuilder::_atomCode (BaseMolecule &mol, int vertex_idx)
{
if (mol.isPseudoAtom(vertex_idx))
return CRC32::get(mol.getPseudoAtom(vertex_idx));
return mol.getAtomNumber(vertex_idx);
}
示例5: collect
void GrossFormula::collect (BaseMolecule &mol, Array<int> &gross)
{
int i;
gross.clear_resize(ELEM_MAX);
gross.zerofill();
for (i = mol.vertexBegin(); i < mol.vertexEnd(); i = mol.vertexNext(i))
{
if (mol.isPseudoAtom(i) || mol.isRSite(i))
continue;
int number = mol.getAtomNumber(i);
if (number > 0)
gross[number]++;
if (!mol.isQueryMolecule())
{
int implicit_h = mol.asMolecule().getImplicitH(i);
if (implicit_h >= 0)
gross[ELEM_H] += implicit_h;
}
}
}
示例6: _commonHasLonePair
bool MoleculeCisTrans::_commonHasLonePair (BaseMolecule &mol, int v1, int v2)
{
if (v1 != -1 && v2 != -1)
return false;
const Vertex *v;
if (v1 == -1)
v = &mol.getVertex(v2);
else
v = &mol.getVertex(v1);
int common = v->neiVertex(v->neiBegin());
if (mol.getAtomNumber(common) == ELEM_N && mol.getAtomCharge(common) == 0)
return true;
return false;
}
示例7: _compare_frequency_base
int MoleculeSubstructureMatcher::_compare_frequency_base (BaseMolecule &mol, int i1, int i2)
{
int label1 = mol.getAtomNumber(i1);
int label2 = mol.getAtomNumber(i2);
if (label1 == 0 && label2 != 0)
return 1;
if (label1 != 0 && label2 != 1)
return -1;
int is_hetero1 = (label1 != 0 && label1 != ELEM_C && label1 != ELEM_H);
int is_hetero2 = (label2 != 0 && label2 != ELEM_C && label2 != ELEM_H);
return is_hetero2 - is_hetero1;
}
示例8: _compare_frequency_asc
int MoleculeSubstructureMatcher::_compare_frequency_asc (BaseMolecule &mol, int i1, int i2)
{
static int labels_by_freq[] =
{ELEM_C, ELEM_H, ELEM_O, ELEM_N, ELEM_P, ELEM_F,
ELEM_S, ELEM_Si, ELEM_Cl, ELEM_Br, ELEM_I, ELEM_At};
int label1 = mol.getAtomNumber(i1);
int label2 = mol.getAtomNumber(i2);
int idx1, idx2;
for (idx1 = 0; idx1 < (int)NELEM(labels_by_freq); idx1++)
if (label1 == labels_by_freq[idx1])
break;
for (idx2 = 0; idx2 < (int)NELEM(labels_by_freq); idx2++)
if (label2 == labels_by_freq[idx2])
break;
return idx2 - idx1;
}
示例9: check
bool TautomerRule::check (BaseMolecule &molecule, int first_idx, int last_idx,
char other_arom_first, char other_arom_last) const
{
if (first_idx != -1 && last_idx != -1)
{
int first_atom = molecule.getAtomNumber(first_idx);
int last_atom = molecule.getAtomNumber(last_idx);
if (list1.find(first_atom) >= 0)
{
if (aromaticity1 == -1 ||
(aromaticity1 == 1 && (atomInAromaticRing(molecule, first_idx) || other_arom_first == 1)) ||
(aromaticity1 == 0 && !atomInAromaticRing(molecule, first_idx)))
{
if (list2.find(last_atom) >= 0)
{
if (aromaticity2 == -1 ||
(aromaticity2 == 1 && (atomInAromaticRing(molecule, last_idx) || other_arom_last == 1)) ||
(aromaticity2 == 0 && !atomInAromaticRing(molecule, last_idx)))
{
return true;
}
}
}
}
if (list2.find(first_atom) >= 0)
{
if (aromaticity2 == -1 ||
(aromaticity2 == 1 && (atomInAromaticRing(molecule, first_idx) || other_arom_first == 1)) ||
(aromaticity2 == 0 && !atomInAromaticRing(molecule, first_idx)))
{
if (list1.find(last_atom) >= 0)
{
if (aromaticity1 == -1 ||
(aromaticity1 == 1 && (atomInAromaticRing(molecule, last_idx) || other_arom_last == 1)) ||
(aromaticity1 == 0 && !atomInAromaticRing(molecule, last_idx)))
{
return true;
}
}
}
}
return false;
} else if (first_idx != -1 || last_idx != -1)
{
if (first_idx == -1)
first_idx = last_idx;
int first_atom = molecule.getAtomNumber(first_idx);
if (list1.find(first_atom) >= 0)
if (aromaticity1 == -1 ||
(aromaticity1 == 1 && (atomInAromaticRing(molecule, first_idx) || other_arom_first == 1)) ||
(aromaticity1 == 0 && !atomInAromaticRing(molecule, first_idx)))
return true;
if (list2.find(first_atom) >= 0)
if (aromaticity2 == -1 ||
(aromaticity2 == 1 && (atomInAromaticRing(molecule, first_idx) || other_arom_first == 1)) ||
(aromaticity2 == 0 && !atomInAromaticRing(molecule, first_idx)))
return true;
return false;
}
return true;
}
示例10: _pureH
bool MoleculeCisTrans::_pureH (BaseMolecule &mol, int idx)
{
return mol.getAtomNumber(idx) == ELEM_H && mol.getAtomIsotope(idx) == 0;
}
示例11: matchAtoms
bool MoleculeExactMatcher::matchAtoms (BaseMolecule& query, BaseMolecule& target, int sub_idx, int super_idx, int flags)
{
if (query.isRSite(sub_idx) && target.isRSite(super_idx))
return query.getRSiteBits(sub_idx) == target.getRSiteBits(super_idx);
if (query.isRSite(sub_idx) || target.isRSite(super_idx))
return false;
if (query.isPseudoAtom(sub_idx) && target.isPseudoAtom(super_idx))
{
if (strcmp(query.getPseudoAtom(sub_idx), target.getPseudoAtom(super_idx)) != 0)
return false;
}
else if (query.isTemplateAtom(sub_idx) && target.isTemplateAtom(super_idx))
{
if (strcmp(query.getTemplateAtom(sub_idx), target.getTemplateAtom(super_idx)) != 0)
return false;
}
else if (!query.isPseudoAtom(sub_idx) && !target.isPseudoAtom(super_idx) &&
!query.isTemplateAtom(sub_idx) && !target.isTemplateAtom(super_idx))
{
if (query.getAtomNumber(sub_idx) != target.getAtomNumber(super_idx))
return false;
}
else
return false;
if (flags & CONDITION_ISOTOPE)
if (query.getAtomIsotope(sub_idx) != target.getAtomIsotope(super_idx))
return false;
if (flags & CONDITION_ELECTRONS)
{
int qcharge = query.getAtomCharge(sub_idx);
int tcharge = target.getAtomCharge(super_idx);
if (qcharge == CHARGE_UNKNOWN)
qcharge = 0;
if (tcharge == CHARGE_UNKNOWN)
tcharge = 0;
if (qcharge != tcharge)
return false;
if (!query.isPseudoAtom(sub_idx) && !query.isTemplateAtom(sub_idx))
{
if (!query.isQueryMolecule() && !target.isQueryMolecule())
{
if (query.getAtomValence(sub_idx) != target.getAtomValence(super_idx))
return false;
}
int qrad = query.getAtomRadical(sub_idx);
int trad = target.getAtomRadical(super_idx);
if (qrad == -1)
qrad = 0;
if (trad == -1)
trad = 0;
if (qrad != trad)
return false;
if (query.isQueryMolecule())
{
int qarom = query.getAtomAromaticity(sub_idx);
int tarom = target.getAtomAromaticity(super_idx);
if (qarom != -1 && tarom != -1)
if (qarom != tarom)
return false;
}
}
}
if (flags & CONDITION_STEREO)
{
int qtype = query.stereocenters.getType(sub_idx);
if (qtype != target.stereocenters.getType(super_idx))
return false;
}
return true;
}
示例12: _calcExtraBits
void MoleculeFingerprintBuilder::_calcExtraBits (BaseMolecule &mol, Filter &vfilter)
{
int counters[9] = {0, 0, 0, 0, 0, 0, 0, 0, 0};
int i;
for (i = mol.vertexBegin(); i != mol.vertexEnd(); i = mol.vertexNext(i))
{
if (!vfilter.valid(i))
continue;
int an = mol.getAtomNumber(i);
if (an == ELEM_C)
counters[0]++;
else if (an == ELEM_N)
counters[1]++;
else if (an == ELEM_O)
counters[2]++;
else if (an == ELEM_P)
counters[3]++;
else if (an == ELEM_S)
counters[4]++;
else if (Element::isHalogen(an))
counters[5]++;
else if (an > ELEM_H)
counters[6]++;
if (!skip_ext_charge && mol.getAtomCharge(i) != 0 && mol.getAtomCharge(i) != CHARGE_UNKNOWN)
counters[7]++;
if (mol.getAtomIsotope(i) > 0)
counters[8]++;
}
byte *fp = _total_fingerprint.ptr();
if (counters[0] > 13) // > 13 C
fp[0] |= 1;
if (counters[0] > 16) // > 16 C
fp[0] |= 2;
if (counters[0] > 19) // > 19 C
fp[0] |= 4;
if (counters[1] > 1) // > 1 N
fp[0] |= 8;
if (counters[1] > 2) // > 2 N
fp[0] |= 16;
if (counters[2] > 3) // > 3 O
fp[0] |= 32;
if (counters[2] > 4) // > 4 O
fp[0] |= 64;
if (counters[3] > 0) // have P
fp[0] |= 128;
if (counters[4] > 0) // have S
fp[1] |= 1;
if (counters[4] > 1) // > 1 S
fp[1] |= 2;
if (counters[5] > 1) // > 1 halogen
fp[1] |= 4;
if (counters[5] > 2) // > 2 halogen
fp[1] |= 8;
if (counters[6] > 0) // have rare atoms
fp[1] |= 16;
if (counters[6] > 1) // > 1 rare atom
fp[1] |= 32;
if (counters[7] > 0) // have charged atoms
fp[1] |= 64;
if (counters[8] > 1) // have isotopes
fp[1] |= 128;
}
示例13: Error
bool MoleculeSubstructureMatcher::matchQueryAtom
(QueryMolecule::Atom *query, BaseMolecule &target, int super_idx,
FragmentMatchCache *fmcache, dword flags)
{
int i;
switch (query->type)
{
case QueryMolecule::OP_NONE:
return true;
case QueryMolecule::OP_AND:
for (i = 0; i < query->children.size(); i++)
if (!matchQueryAtom(query->child(i), target, super_idx, fmcache, flags))
return false;
return true;
case QueryMolecule::OP_OR:
for (i = 0; i < query->children.size(); i++)
if (matchQueryAtom(query->child(i), target,
super_idx, fmcache, flags))
return true;
return false;
case QueryMolecule::OP_NOT:
return !matchQueryAtom(query->child(0), target, super_idx, fmcache,
flags ^ MATCH_DISABLED_AS_TRUE);
case QueryMolecule::ATOM_NUMBER:
return query->valueWithinRange(target.getAtomNumber(super_idx));
case QueryMolecule::ATOM_PSEUDO:
return target.isPseudoAtom(super_idx) &&
strcmp(query->alias.ptr(), target.getPseudoAtom(super_idx)) == 0;
case QueryMolecule::ATOM_RSITE:
return true;
case QueryMolecule::ATOM_ISOTOPE:
return query->valueWithinRange(target.getAtomIsotope(super_idx));
case QueryMolecule::ATOM_CHARGE:
{
if (flags & MATCH_ATOM_CHARGE)
return query->valueWithinRange(target.getAtomCharge(super_idx));
return (flags & MATCH_DISABLED_AS_TRUE) != 0;
}
case QueryMolecule::ATOM_RADICAL:
{
if (target.isPseudoAtom(super_idx) || target.isRSite(super_idx))
return false;
return query->valueWithinRange(target.getAtomRadical(super_idx));
}
case QueryMolecule::ATOM_VALENCE:
{
if (flags & MATCH_ATOM_VALENCE)
{
if (target.isPseudoAtom(super_idx) || target.isRSite(super_idx))
return false;
return query->valueWithinRange(target.getAtomValence(super_idx));
}
return (flags & MATCH_DISABLED_AS_TRUE) != 0;
}
case QueryMolecule::ATOM_CONNECTIVITY:
{
int conn = target.getVertex(super_idx).degree();
if (!target.isPseudoAtom(super_idx) && !target.isRSite(super_idx))
conn += target.asMolecule().getImplicitH(super_idx);
return query->valueWithinRange(conn);
}
case QueryMolecule::ATOM_TOTAL_BOND_ORDER:
{
// TODO: target.isPseudoAtom(super_idx) || target.isRSite(super_idx)
return query->valueWithinRange(target.asMolecule().getAtomConnectivity(super_idx));
}
case QueryMolecule::ATOM_TOTAL_H:
{
if (target.isPseudoAtom(super_idx) || target.isRSite(super_idx))
return false;
return query->valueWithinRange(target.getAtomTotalH(super_idx));
}
case QueryMolecule::ATOM_SUBSTITUENTS:
return query->valueWithinRange(target.getAtomSubstCount(super_idx));
case QueryMolecule::ATOM_SSSR_RINGS:
return query->valueWithinRange(target.vertexCountSSSR(super_idx));
case QueryMolecule::ATOM_SMALLEST_RING_SIZE:
return query->valueWithinRange(target.vertexSmallestRingSize(super_idx));
case QueryMolecule::ATOM_RING_BONDS:
case QueryMolecule::ATOM_RING_BONDS_AS_DRAWN:
return query->valueWithinRange(target.getAtomRingBondsCount(super_idx));
case QueryMolecule::ATOM_UNSATURATION:
return !target.isSaturatedAtom(super_idx);
case QueryMolecule::ATOM_FRAGMENT:
{
if (fmcache == 0)
throw Error("unexpected 'fragment' constraint");
QueryMolecule *fragment = query->fragment.get();
const char *smarts = fragment->fragment_smarts.ptr();
if (fragment->vertexCount() == 0)
throw Error("empty fragment");
if (smarts != 0 && strlen(smarts) > 0)
{
fmcache->expand(super_idx + 1);
int *value = fmcache->at(super_idx).at2(smarts);
//.........这里部分代码省略.........