mirror of
https://github.com/rdkit/rdkit.git
synced 2026-06-04 21:54:27 +08:00
38 lines
1.0 KiB
C++
38 lines
1.0 KiB
C++
// $Id$
|
|
//
|
|
// Copyright (C) 2005-2008 Greg Landrum and Rational Discovery LLC
|
|
//
|
|
// @@ All Rights Reserved @@
|
|
// This file is part of the RDKit.
|
|
// The contents are covered by the terms of the BSD license
|
|
// which is included in the file license.txt, found at the root
|
|
// of the RDKit source tree.
|
|
//
|
|
#include <RDGeneral/Invariant.h>
|
|
#include <GraphMol/RDKitBase.h>
|
|
#include "MolDescriptors.h"
|
|
|
|
namespace RDKit{
|
|
namespace Descriptors {
|
|
|
|
static std::string _amwVersion="1.0.0";
|
|
double CalcAMW(const ROMol &mol,bool onlyHeavy){
|
|
double res=0.0;
|
|
for(ROMol::ConstAtomIterator atomIt=mol.beginAtoms();
|
|
atomIt != mol.endAtoms();++atomIt){
|
|
int atNum=(*atomIt)->getAtomicNum();
|
|
if(atNum!=1 || !onlyHeavy){
|
|
res += (*atomIt)->getMass();
|
|
}
|
|
|
|
// add our implicit Hs if we need to:
|
|
if(!onlyHeavy){
|
|
const PeriodicTable *table=PeriodicTable::getTable();
|
|
res += (*atomIt)->getTotalNumHs()*table->getAtomicWeight(1);
|
|
}
|
|
}
|
|
return res;
|
|
}
|
|
} // end of namespace Descriptors
|
|
} // end of namespace RDKit
|