Ignore:
Timestamp:
Aug 14, 2014, 2:49:51 PM (10 years ago)
Author:
Frederik Heber <heber@…>
Branches:
Action_Thermostats, Add_AtomRandomPerturbation, Add_FitFragmentPartialChargesAction, Add_RotateAroundBondAction, Add_SelectAtomByNameAction, Added_ParseSaveFragmentResults, AddingActions_SaveParseParticleParameters, Adding_Graph_to_ChangeBondActions, Adding_MD_integration_tests, Adding_ParticleName_to_Atom, Adding_StructOpt_integration_tests, AtomFragments, Automaking_mpqc_open, AutomationFragmentation_failures, Candidate_v1.5.4, Candidate_v1.6.0, Candidate_v1.6.1, ChangeBugEmailaddress, ChangingTestPorts, ChemicalSpaceEvaluator, CombiningParticlePotentialParsing, Combining_Subpackages, Debian_Package_split, Debian_package_split_molecuildergui_only, Disabling_MemDebug, Docu_Python_wait, EmpiricalPotential_contain_HomologyGraph, EmpiricalPotential_contain_HomologyGraph_documentation, Enable_parallel_make_install, Enhance_userguide, Enhanced_StructuralOptimization, Enhanced_StructuralOptimization_continued, Example_ManyWaysToTranslateAtom, Exclude_Hydrogens_annealWithBondGraph, FitPartialCharges_GlobalError, Fix_BoundInBox_CenterInBox_MoleculeActions, Fix_ChargeSampling_PBC, Fix_ChronosMutex, Fix_FitPartialCharges, Fix_FitPotential_needs_atomicnumbers, Fix_ForceAnnealing, Fix_IndependentFragmentGrids, Fix_ParseParticles, Fix_ParseParticles_split_forward_backward_Actions, Fix_PopActions, Fix_QtFragmentList_sorted_selection, Fix_Restrictedkeyset_FragmentMolecule, Fix_StatusMsg, Fix_StepWorldTime_single_argument, Fix_Verbose_Codepatterns, Fix_fitting_potentials, Fixes, ForceAnnealing_goodresults, ForceAnnealing_oldresults, ForceAnnealing_tocheck, ForceAnnealing_with_BondGraph, ForceAnnealing_with_BondGraph_continued, ForceAnnealing_with_BondGraph_continued_betteresults, ForceAnnealing_with_BondGraph_contraction-expansion, FragmentAction_writes_AtomFragments, FragmentMolecule_checks_bonddegrees, GeometryObjects, Gui_Fixes, Gui_displays_atomic_force_velocity, ImplicitCharges, IndependentFragmentGrids, IndependentFragmentGrids_IndividualZeroInstances, IndependentFragmentGrids_IntegrationTest, IndependentFragmentGrids_Sole_NN_Calculation, JobMarket_RobustOnKillsSegFaults, JobMarket_StableWorkerPool, JobMarket_unresolvable_hostname_fix, MoreRobust_FragmentAutomation, ODR_violation_mpqc_open, PartialCharges_OrthogonalSummation, PdbParser_setsAtomName, PythonUI_with_named_parameters, QtGui_reactivate_TimeChanged_changes, Recreated_GuiChecks, Rewrite_FitPartialCharges, RotateToPrincipalAxisSystem_UndoRedo, SaturateAtoms_findBestMatching, SaturateAtoms_singleDegree, StoppableMakroAction, Subpackage_CodePatterns, Subpackage_JobMarket, Subpackage_LinearAlgebra, Subpackage_levmar, Subpackage_mpqc_open, Subpackage_vmg, Switchable_LogView, ThirdParty_MPQC_rebuilt_buildsystem, TrajectoryDependenant_MaxOrder, TremoloParser_IncreasedPrecision, TremoloParser_MultipleTimesteps, TremoloParser_setsAtomName, Ubuntu_1604_changes, stable
Children:
3fbdca
Parents:
9fd44f
git-author:
Frederik Heber <heber@…> (08/26/13 19:49:32)
git-committer:
Frederik Heber <heber@…> (08/14/14 14:49:51)
Message:

Removed molecule::AddHydrogenReplacement() and BreadthFirstSearchAdd.

  • this capability has been transfered to SaturatedFragment, and BFSAdd has not been used for a long, long time.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Fragmentation/Exporters/ExportGraph.cpp

    r9fd44f r06804b  
    137137}
    138138
    139 /** Internal helper to create from each keyset a molecule
    140  *
    141  */
    142 void ExportGraph::prepareMolecule()
    143 {
    144   size_t count = 0;
    145   for(Graph::const_iterator runner = TotalGraph.begin(); runner != TotalGraph.end(); runner++) {
    146     KeySet test = (*runner).first;
    147     LOG(2, "DEBUG: Fragment No." << (*runner).second.first << " with TEFactor "
    148         << (*runner).second.second << ".");
    149     BondFragments.insert(StoreFragmentFromKeySet(test, World::getInstance().getConfig()));
    150     ++count;
    151   }
    152   LOG(1, "INFO: " << count << "/" << BondFragments.ListOfMolecules.size()
    153       << " fragments generated from the keysets.");
    154 }
    155 
    156 /** Stores a fragment from \a KeySet into \a molecule.
    157  * First creates the minimal set of atoms from the KeySet, then creates the bond structure from the complete
    158  * molecule and adds missing hydrogen where bonds were cut.
    159  * \param &Leaflet pointer to KeySet structure
    160  * \param IsAngstroem whether we have Ansgtroem or bohrradius
    161  * \return pointer to constructed molecule
    162  */
    163 molecule * ExportGraph::StoreFragmentFromKeySet(KeySet &Leaflet, bool IsAngstroem)
    164 {
    165   Info info(__func__);
    166   ListOfLocalAtoms_t SonList;
    167   molecule *Leaf = World::getInstance().createMolecule();
    168 
    169   StoreFragmentFromKeySet_Init(Leaf, Leaflet, SonList);
    170   // create the bonds between all: Make it an induced subgraph and add hydrogen
    171 //  LOG(2, "Creating bonds from father graph (i.e. induced subgraph creation).");
    172   CreateInducedSubgraphOfFragment(Leaf, SonList, IsAngstroem);
    173 
    174   //Leaflet->Leaf->ScanForPeriodicCorrection(out);
    175   return Leaf;
    176 }
    177 
    178 /** Initializes some value for putting fragment of \a *mol into \a *Leaf.
    179  * \param *Leaf fragment molecule
    180  * \param &Leaflet pointer to KeySet structure
    181  * \param SonList calloc'd list which atom of \a *Leaf is a son of which atom in \a *mol
    182  * \return number of atoms in fragment
    183  */
    184 int ExportGraph::StoreFragmentFromKeySet_Init(molecule *Leaf, KeySet &Leaflet, ListOfLocalAtoms_t &SonList)
    185 {
    186   atom *FatherOfRunner = NULL;
    187 
    188   // first create the minimal set of atoms from the KeySet
    189   World &world = World::getInstance();
    190   int size = 0;
    191   for(KeySet::const_iterator runner = Leaflet.begin(); runner != Leaflet.end(); runner++) {
    192     FatherOfRunner = world.getAtom(AtomById(*runner));  // find the id
    193     SonList.insert( std::make_pair(FatherOfRunner->getNr(), Leaf->AddCopyAtom(FatherOfRunner) ) );
    194     size++;
    195   }
    196   return size;
    197 }
    198 
    199 /** Creates an induced subgraph out of a fragmental key set, adding bonds and hydrogens (if treated specially).
    200  * \param *Leaf fragment molecule
    201  * \param IsAngstroem whether we have Ansgtroem or bohrradius
    202  * \param SonList list which atom of \a *Leaf is another atom's son
    203  */
    204 void ExportGraph::CreateInducedSubgraphOfFragment(molecule *Leaf, ListOfLocalAtoms_t &SonList, bool IsAngstroem)
    205 {
    206   bool LonelyFlag = false;
    207   atom *OtherFather = NULL;
    208   atom *FatherOfRunner = NULL;
    209 
    210   // we increment the iter just before skipping the hydrogen
    211   // as we use AddBond, we cannot have a const_iterator here
    212   for (molecule::iterator iter = Leaf->begin(); iter != Leaf->end();) {
    213     LonelyFlag = true;
    214     FatherOfRunner = (*iter)->father;
    215     ASSERT(FatherOfRunner,"Atom without father found");
    216     if (SonList.find(FatherOfRunner->getNr()) != SonList.end())  {  // check if this, our father, is present in list
    217       // create all bonds
    218       const BondList& ListOfBonds = FatherOfRunner->getListOfBonds();
    219       for (BondList::const_iterator BondRunner = ListOfBonds.begin();
    220           BondRunner != ListOfBonds.end();
    221           ++BondRunner) {
    222         OtherFather = (*BondRunner)->GetOtherAtom(FatherOfRunner);
    223         if (SonList.find(OtherFather->getNr()) != SonList.end()) {
    224 //          LOG(2, "INFO: Father " << *FatherOfRunner << " of son " << *SonList[FatherOfRunner->getNr()]
    225 //              << " is bound to " << *OtherFather << ", whose son is "
    226 //              << *SonList[OtherFather->getNr()] << ".");
    227           if (OtherFather->getNr() > FatherOfRunner->getNr()) { // add bond (Nr check is for adding only one of both variants: ab, ba)
    228             std::stringstream output;
    229 //            output << "ACCEPT: Adding Bond: "
    230             output << Leaf->AddBond((*iter), SonList[OtherFather->getNr()], (*BondRunner)->getDegree());
    231 //            LOG(3, output.str());
    232             //NumBonds[(*iter)->getNr()]++;
    233           } else {
    234 //            LOG(3, "REJECY: Not adding bond, labels in wrong order.");
    235           }
    236           LonelyFlag = false;
    237         } else {
    238 //          LOG(2, "INFO: Father " << *FatherOfRunner << " of son " << *SonList[FatherOfRunner->getNr()]
    239 //              << " is bound to " << *OtherFather << ", who has no son in this fragment molecule.");
    240           if (saturation == DoSaturate) {
    241 //          LOG(3, "ACCEPT: Adding Hydrogen to " << (*iter)->Name << " and a bond in between.");
    242             if (!Leaf->AddHydrogenReplacementAtom((*BondRunner), (*iter), FatherOfRunner, OtherFather, IsAngstroem))
    243               exit(1);
    244           } else if ((treatment == ExcludeHydrogen) && (OtherFather->getElementNo() == (atomicNumber_t)1)) {
    245             // just copy the atom if it's a hydrogen
    246             atom * const OtherWalker = Leaf->AddCopyAtom(OtherFather);
    247             Leaf->AddBond((*iter), OtherWalker, (*BondRunner)->getDegree());
    248           }
    249           //NumBonds[(*iter)->getNr()] += Binder->getDegree();
    250         }
    251       }
    252     } else {
    253       ELOG(1, "Son " << (*iter)->getName() << " has father " << FatherOfRunner->getName() << " but its entry in SonList is " << SonList[FatherOfRunner->getNr()] << "!");
    254     }
    255     if ((LonelyFlag) && (Leaf->getAtomCount() > 1)) {
    256       LOG(0, **iter << "has got bonds only to hydrogens!");
    257     }
    258     ++iter;
    259     if (saturation == DoSaturate) {
    260       while ((iter != Leaf->end()) && ((*iter)->getType()->getAtomicNumber() == 1)){ // skip added hydrogen
    261         iter++;
    262       }
    263     }
    264   }
    265 }
     139///** Internal helper to create from each keyset a molecule
     140// *
     141// */
     142//void ExportGraph::prepareMolecule()
     143//{
     144//  size_t count = 0;
     145//  for(Graph::const_iterator runner = TotalGraph.begin(); runner != TotalGraph.end(); runner++) {
     146//    KeySet test = (*runner).first;
     147//    LOG(2, "DEBUG: Fragment No." << (*runner).second.first << " with TEFactor "
     148//        << (*runner).second.second << ".");
     149//    BondFragments.insert(StoreFragmentFromKeySet(test, World::getInstance().getConfig()));
     150//    ++count;
     151//  }
     152//  LOG(1, "INFO: " << count << "/" << BondFragments.ListOfMolecules.size()
     153//      << " fragments generated from the keysets.");
     154//}
     155//
     156///** Stores a fragment from \a KeySet into \a molecule.
     157// * First creates the minimal set of atoms from the KeySet, then creates the bond structure from the complete
     158// * molecule and adds missing hydrogen where bonds were cut.
     159// * \param &Leaflet pointer to KeySet structure
     160// * \param IsAngstroem whether we have Ansgtroem or bohrradius
     161// * \return pointer to constructed molecule
     162// */
     163//molecule * ExportGraph::StoreFragmentFromKeySet(KeySet &Leaflet, bool IsAngstroem)
     164//{
     165//  Info info(__func__);
     166//  ListOfLocalAtoms_t SonList;
     167//  molecule *Leaf = World::getInstance().createMolecule();
     168//
     169//  StoreFragmentFromKeySet_Init(Leaf, Leaflet, SonList);
     170//  // create the bonds between all: Make it an induced subgraph and add hydrogen
     171////  LOG(2, "Creating bonds from father graph (i.e. induced subgraph creation).");
     172//  CreateInducedSubgraphOfFragment(Leaf, SonList, IsAngstroem);
     173//
     174//  //Leaflet->Leaf->ScanForPeriodicCorrection(out);
     175//  return Leaf;
     176//}
     177//
     178///** Initializes some value for putting fragment of \a *mol into \a *Leaf.
     179// * \param *Leaf fragment molecule
     180// * \param &Leaflet pointer to KeySet structure
     181// * \param SonList calloc'd list which atom of \a *Leaf is a son of which atom in \a *mol
     182// * \return number of atoms in fragment
     183// */
     184//int ExportGraph::StoreFragmentFromKeySet_Init(molecule *Leaf, KeySet &Leaflet, ListOfLocalAtoms_t &SonList)
     185//{
     186//  atom *FatherOfRunner = NULL;
     187//
     188//  // first create the minimal set of atoms from the KeySet
     189//  World &world = World::getInstance();
     190//  int size = 0;
     191//  for(KeySet::const_iterator runner = Leaflet.begin(); runner != Leaflet.end(); runner++) {
     192//    FatherOfRunner = world.getAtom(AtomById(*runner));  // find the id
     193//    SonList.insert( std::make_pair(FatherOfRunner->getNr(), Leaf->AddCopyAtom(FatherOfRunner) ) );
     194//    size++;
     195//  }
     196//  return size;
     197//}
     198//
     199///** Creates an induced subgraph out of a fragmental key set, adding bonds and hydrogens (if treated specially).
     200// * \param *Leaf fragment molecule
     201// * \param IsAngstroem whether we have Ansgtroem or bohrradius
     202// * \param SonList list which atom of \a *Leaf is another atom's son
     203// */
     204//void ExportGraph::CreateInducedSubgraphOfFragment(molecule *Leaf, ListOfLocalAtoms_t &SonList, bool IsAngstroem)
     205//{
     206//  bool LonelyFlag = false;
     207//  atom *OtherFather = NULL;
     208//  atom *FatherOfRunner = NULL;
     209//
     210//  // we increment the iter just before skipping the hydrogen
     211//  // as we use AddBond, we cannot have a const_iterator here
     212//  for (molecule::iterator iter = Leaf->begin(); iter != Leaf->end();) {
     213//    LonelyFlag = true;
     214//    FatherOfRunner = (*iter)->father;
     215//    ASSERT(FatherOfRunner,"Atom without father found");
     216//    if (SonList.find(FatherOfRunner->getNr()) != SonList.end())  {  // check if this, our father, is present in list
     217//      // create all bonds
     218//      const BondList& ListOfBonds = FatherOfRunner->getListOfBonds();
     219//      for (BondList::const_iterator BondRunner = ListOfBonds.begin();
     220//          BondRunner != ListOfBonds.end();
     221//          ++BondRunner) {
     222//        OtherFather = (*BondRunner)->GetOtherAtom(FatherOfRunner);
     223//        if (SonList.find(OtherFather->getNr()) != SonList.end()) {
     224////          LOG(2, "INFO: Father " << *FatherOfRunner << " of son " << *SonList[FatherOfRunner->getNr()]
     225////              << " is bound to " << *OtherFather << ", whose son is "
     226////              << *SonList[OtherFather->getNr()] << ".");
     227//          if (OtherFather->getNr() > FatherOfRunner->getNr()) { // add bond (Nr check is for adding only one of both variants: ab, ba)
     228//            std::stringstream output;
     229////            output << "ACCEPT: Adding Bond: "
     230//            output << Leaf->AddBond((*iter), SonList[OtherFather->getNr()], (*BondRunner)->getDegree());
     231////            LOG(3, output.str());
     232//            //NumBonds[(*iter)->getNr()]++;
     233//          } else {
     234////            LOG(3, "REJECY: Not adding bond, labels in wrong order.");
     235//          }
     236//          LonelyFlag = false;
     237//        } else {
     238////          LOG(2, "INFO: Father " << *FatherOfRunner << " of son " << *SonList[FatherOfRunner->getNr()]
     239////              << " is bound to " << *OtherFather << ", who has no son in this fragment molecule.");
     240//          if (saturation == DoSaturate) {
     241////          LOG(3, "ACCEPT: Adding Hydrogen to " << (*iter)->Name << " and a bond in between.");
     242//            if (!Leaf->AddHydrogenReplacementAtom((*BondRunner), (*iter), FatherOfRunner, OtherFather, IsAngstroem))
     243//              exit(1);
     244//          } else if ((treatment == ExcludeHydrogen) && (OtherFather->getElementNo() == (atomicNumber_t)1)) {
     245//            // just copy the atom if it's a hydrogen
     246//            atom * const OtherWalker = Leaf->AddCopyAtom(OtherFather);
     247//            Leaf->AddBond((*iter), OtherWalker, (*BondRunner)->getDegree());
     248//          }
     249//          //NumBonds[(*iter)->getNr()] += Binder->getDegree();
     250//        }
     251//      }
     252//    } else {
     253//      ELOG(1, "Son " << (*iter)->getName() << " has father " << FatherOfRunner->getName() << " but its entry in SonList is " << SonList[FatherOfRunner->getNr()] << "!");
     254//    }
     255//    if ((LonelyFlag) && (Leaf->getAtomCount() > 1)) {
     256//      LOG(0, **iter << "has got bonds only to hydrogens!");
     257//    }
     258//    ++iter;
     259//    if (saturation == DoSaturate) {
     260//      while ((iter != Leaf->end()) && ((*iter)->getType()->getAtomicNumber() == 1)){ // skip added hydrogen
     261//        iter++;
     262//      }
     263//    }
     264//  }
     265//}
Note: See TracChangeset for help on using the changeset viewer.