本文整理汇总了C++中Molecule::getComponentState方法的典型用法代码示例。如果您正苦于以下问题:C++ Molecule::getComponentState方法的具体用法?C++ Molecule::getComponentState怎么用?C++ Molecule::getComponentState使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Molecule
的用法示例。
在下文中一共展示了Molecule::getComponentState方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: saveSpecies
bool System::saveSpecies(string filename)
{
bool debugOut = false;
//open the output filestream
ofstream speciesFile;
speciesFile.open(filename.c_str());
if(!speciesFile.is_open()) {
cerr<<"Error in System when calling System::saveSpecies(string)! Cannot open output stream to file "<<filename<<". "<<endl;
cerr<<"quitting."<<endl;
exit(1);
}
cout<<"\n\nsaving list of final molecular species..."<<endl;
// create a couple data structures to store results as we go
list <Molecule *> molecules;
list <Molecule *>::iterator iter;
map <int,bool> reportedMolecules;
map <string,int> reportedSpecies;
// loop over all the types of molecules that exist
for( unsigned int k=0; k<allMoleculeTypes.size(); k++)
{
// retrieve the MoleculeType
MoleculeType *mt = allMoleculeTypes.at(k);
// loop over every individual molecule
for(int j=0; j<mt->getMoleculeCount(); j++)
{
// check if we have looked this molecule before, and skip it if we have
if(reportedMolecules.find(mt->getMolecule(j)->getUniqueID())!=reportedMolecules.end()) {
continue;
}
//otherwise, we have not visited this particular species before, so loop over the molecules
//that make up the species
string speciesString = "";
molecules.clear();
mt->getMolecule(j)->traverseBondedNeighborhood(molecules,ReactionClass::NO_LIMIT);
// key: partnerID1, bsiteID1, partnerID2, bsiteID2
vector <vector <int> * > bondNumberMap;
bool isFirst = true;
for( iter = molecules.begin(); iter != molecules.end(); iter++ )
{
Molecule *m = (*iter);
reportedMolecules.insert(pair <int,bool> (m->getUniqueID(),true));
//Fist, output the molecule name
if(isFirst) { speciesString += m->getMoleculeTypeName()+"("; isFirst=false; }
else { speciesString += "."+m->getMoleculeTypeName()+"("; }
//Go through each component of the molecule
for(int s=0; s<m->getMoleculeType()->getNumOfComponents(); s++)
{
// output the component name
string compName = m->getMoleculeType()->getComponentName(s);
if(m->getMoleculeType()->isEquivalentComponent(s)) {
// symmetric site, so we need to look up its sym name
compName = m->getMoleculeType()->getEquivalenceClassComponentNameFromComponentIndex(s);
}
if(s==0) speciesString += compName;
else speciesString += ","+compName;
//output the state of the component, if it is set
if(m->getComponentState(s)>=0) {
speciesString += "~" + m->getMoleculeType()->getComponentStateName(s,m->getComponentState(s));
}
// check if the component is bound, if so we have to output a bond
// we will label the bond incrementally, but we have to check to make
// sure the bond wasn't declared earlier. that's what the vector of int vectors is for.
if(m->isBindingSiteBonded(s)) {
if(debugOut) cout<<"binding site is bonded"<<endl;
int partnerID = m->getBondedMolecule(s)->getUniqueID();
int partnerSite = m->getBondedMoleculeBindingSiteIndex(s);
int thisBondNumber = -1;
// create the key
vector <int> *key = new vector<int>(4);
if(partnerID<m->getUniqueID()) {
key->at(0) = partnerID; key->at(1) = partnerSite;
key->at(2) = m->getUniqueID(); key->at(3)=s;
} else {
key->at(2) = partnerID; key->at(3) = partnerSite;
key->at(0) = m->getUniqueID(); key->at(1)=s;
}
//search if that key was already inserted
bool foundExistingBond = false;
for(unsigned int bnmIndex =0; bnmIndex < bondNumberMap.size(); bnmIndex++) {
if( key->at(0)==bondNumberMap.at(bnmIndex)->at(0) &&
key->at(1)==bondNumberMap.at(bnmIndex)->at(1) &&
//.........这里部分代码省略.........