Changeset 35b698 for src/builder.cpp


Ignore:
Timestamp:
Jun 23, 2010, 3:52:50 PM (15 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:
d0fbec
Parents:
dc0d21
git-author:
Frederik Heber <heber@…> (06/23/10 15:20:35)
git-committer:
Frederik Heber <heber@…> (06/23/10 15:52:50)
Message:

BIG CHANGE: config::load and config::save in ParseCommandLineOptions() and main() replaced with FormatParser replacements.

Fragmentation:

  • FIX: MoleculeFillWithMoleculeAction: filler atoms have to be removed before the system can be stored to file.
  • FIX: PcpParser::load() - has to put the molecule also into World's MoleculeListClass (otherwise the name cannot be set right after loading)
  • new Libparser.a
  • all sources from PARSER subdir are compiled into libparser such that only ParserUnitTest is recompiled.

Testfixes:

  • testsuite-fragmentation - changes to due to different -f calling syntax.
  • most of the xyz files had to be replaced due to a single whitespace at the end of each entry: Domain/6, Simple_configuration/2, Simple_configuration/3, Simple_configuration/4, Simple_configuration/5, Simple_configuration/8
  • in many cases were the number orbitals (and thus MaxMinStopStep) wrong: Filling/1, Simple_configuration/4, Simple_configuration/5

Signed-off-by: Frederik Heber <heber@…>

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/builder.cpp

    rdc0d21 r35b698  
    8080#include "Menu/ActionMenuItem.hpp"
    8181#include "Parser/ChangeTracker.hpp"
     82#include "Parser/FormatParserStorage.hpp"
     83#include "Parser/PcpParser.hpp"
     84#include "Parser/XyzParser.hpp"
    8285#include "Actions/ActionRegistry.hpp"
    8386#include "Actions/ActionHistory.hpp"
     
    654657  int Order1;
    655658  clock_t start, end;
     659  std::string path;
    656660
    657661  DoLog(0) && (Log() << Verbose(0) << "Fragmenting molecule with current connection matrix ..." << endl);
    658662  DoLog(0) && (Log() << Verbose(0) << "What's the desired bond order: ");
    659663  cin >> Order1;
     664  DoLog(0) && (Log() << Verbose(0) << "What's the output path and prefix [e.g. /home/foo/BondFragment]: ");
     665  cin >> path;
    660666  if (mol->first->next != mol->last) {  // there are bonds
    661667    start = clock();
    662     mol->FragmentMolecule(Order1, configuration);
     668    mol->FragmentMolecule(Order1, path);
    663669    end = clock();
    664670    DoLog(0) && (Log() << Verbose(0) << "Clocks for this operation: " << (end-start) << ", time: " << ((double)(end-start)/CLOCKS_PER_SEC) << "s." << endl);
     
    13731379  mol->SetNameFromFilename(ConfigFileName);
    13741380
    1375   if (!strcmp(configuration->configpath, configuration->GetDefaultPath())) {
    1376     DoeLog(2) && (eLog()<< Verbose(2) << "config is found under different path then stated in config file::defaultpath!" << endl);
    1377   }
    1378 
    1379 
    13801381  // first save as PDB data
    13811382  if (ConfigFileName != NULL)
     
    14771478    DoLog(0) && (Log() << Verbose(0) << "failed." << endl);
    14781479
    1479   if (!strcmp(configuration->configpath, configuration->GetDefaultPath())) {
    1480     DoeLog(2) && (eLog()<< Verbose(2) << "config is found under different path then stated in config file::defaultpath!" << endl);
    1481   }
    1482 
    14831480  World::getInstance().destroyMolecule(mol);
    14841481};
     
    15001497 */
    15011498static int ParseCommandLineOptions(int argc, char **argv, MoleculeListClass *&molecules, periodentafel *&periode,
    1502                                    config& configuration, char **ConfigFileName, set<int> &ArgcList)
     1499                                   config& configuration, char **ConfigFileName, std::string &BondGraphFileName, set<int> &ArgcList)
    15031500{
    15041501  Vector x,y,z,n;  // coordinates for absolute point in cell volume
     
    15131510  int argptr;
    15141511  molecule *mol = NULL;
    1515   string BondGraphFileName("\n");
    15161512
    15171513  if (argc > 1) { // config file specified as option
     
    16251621      // simply create a new molecule, wherein the config file is loaded and the manipulation takes place
    16261622      DoLog(0) && (Log() << Verbose(0) << "Config file given." << endl);
     1623      std::string filenameprefix(argv[1]);
     1624      strcpy(*ConfigFileName, filenameprefix.substr(0,filenameprefix.find('.')).c_str());
     1625      DoLog(1) && (Log() << Verbose(1) << "Setting config file name prefix to " << *ConfigFileName << "." << endl);
    16271626      test.open(argv[1], ios::in);
    16281627      if (test == NULL) {
    1629         //return (1);
    1630         output.open(argv[1], ios::out);
    1631         if (output == NULL) {
    1632           DoLog(1) && (Log() << Verbose(1) << "Specified config file " << argv[1] << " not found." << endl);
    1633           configPresent = absent;
    1634         } else {
    1635           DoLog(0) && (Log() << Verbose(0) << "Empty configuration file." << endl);
    1636           strcpy(*ConfigFileName, argv[1]);
    1637           configPresent = empty;
    1638           output.close();
    1639         }
     1628        DoLog(1) && (Log() << Verbose(1) << "Specified config file " << argv[1] << " not found." << endl);
     1629        configPresent = empty;
    16401630      } else {
     1631        configPresent = present;
     1632        DoLog(1) && (Log() << Verbose(1) << "Specified config file found, parsing ... ");
     1633        FormatParserStorage::getInstance().getPcp().load(&test);
    16411634        test.close();
    1642         strcpy(*ConfigFileName, argv[1]);
    1643         DoLog(1) && (Log() << Verbose(1) << "Specified config file found, parsing ... ");
    1644         switch (configuration.TestSyntax(*ConfigFileName, periode)) {
    1645           case 1:
    1646             DoLog(0) && (Log() << Verbose(0) << "new syntax." << endl);
    1647             configuration.Load(*ConfigFileName, BondGraphFileName, periode, molecules);
    1648             configPresent = present;
    1649             break;
    1650           case 0:
    1651             DoLog(0) && (Log() << Verbose(0) << "old syntax." << endl);
    1652             configuration.LoadOld(*ConfigFileName, BondGraphFileName, periode, molecules);
    1653             configPresent = present;
    1654             break;
    1655           default:
    1656             DoLog(0) && (Log() << Verbose(0) << "Unknown syntax or empty, yet present file." << endl);
    1657             configPresent = empty;
    1658        }
    16591635      }
    16601636    } else
     
    16711647       mol = World::getInstance().createMolecule();
    16721648       mol->ActiveFlag = true;
    1673        if (*ConfigFileName != NULL)
    1674          mol->SetNameFromFilename(*ConfigFileName);
    16751649       molecules->insert(mol);
    16761650     }
     1651     if (*ConfigFileName != NULL)
     1652       mol->SetNameFromFilename(*ConfigFileName);
    16771653
    16781654    // 4. parse again through options, now for those depending on elements db and config presence
     
    17331709              break;
    17341710            case 'I':
    1735               DoLog(1) && (Log() << Verbose(1) << "Dissecting molecular system into a set of disconnected subgraphs ... " << endl);
    17361711              ArgcList.insert(argptr-1);
    17371712              argptr+=0;
     
    19771952            case 't':
    19781953              if (ExitFlag == 0) ExitFlag = 1;
    1979               if ((argptr+4 >= argc) || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1])) || (!IsValidNumber(argv[argptr+2])) ) {
     1954              if ((argptr+6 >= argc) || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1])) || (!IsValidNumber(argv[argptr+2])) ) {
    19801955                ExitFlag = 255;
    19811956                DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for translation: -t <x> <y> <z> --molecule-by-id <molecule_id> --periodic <0/1>" << endl);
     
    20742049            case 'f':
    20752050              if (ExitFlag == 0) ExitFlag = 1;
    2076               if ((argptr+1 >= argc) || (argv[argptr][0] == '-')) {
     2051              if ((argptr+4 >= argc) || (argv[argptr][0] == '-')) {
    20772052                ExitFlag = 255;
    2078                 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments for fragmentation: -f <max. bond distance> <bond order>" << endl);
     2053                DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments for fragmentation: -f <path/prefix> --molecule-by-id <molecule id> --distance <max_distance> --order <order>" << endl);
     2054                performCriticalExit();
     2055              } else {
     2056                ArgcList.insert(argptr-1);
     2057                ArgcList.insert(argptr);
     2058                ArgcList.insert(argptr+1);
     2059                ArgcList.insert(argptr+2);
     2060                ArgcList.insert(argptr+3);
     2061                ArgcList.insert(argptr+4);
     2062                ArgcList.insert(argptr+5);
     2063                ArgcList.insert(argptr+6);
     2064                argptr+=7;
     2065              }
     2066              break;
     2067            case 'm':
     2068              if (ExitFlag == 0) ExitFlag = 1;
     2069              j = atoi(argv[argptr++]);
     2070              if ((j<0) || (j>1)) {
     2071                DoeLog(1) && (eLog()<< Verbose(1) << "Argument of '-m' should be either 0 for no-rotate or 1 for rotate." << endl);
     2072                j = 0;
     2073              }
     2074              if (j) {
     2075                SaveFlag = true;
     2076                DoLog(0) && (Log() << Verbose(0) << "Converting to prinicipal axis system." << endl);
     2077                mol->PrincipalAxisSystem((bool)j);
     2078              } else
     2079                ArgcList.insert(argptr-1);
     2080                argptr+=0;
     2081              break;
     2082            case 'o':
     2083              if (ExitFlag == 0) ExitFlag = 1;
     2084              if ((argptr+4 >= argc) || (argv[argptr][0] == '-')){
     2085                ExitFlag = 255;
     2086                DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for convex envelope: -o <molecule_id> --output-file <output file> --output-file <binned output file>" << endl);
    20792087                performCriticalExit();
    20802088              } else {
     
    20882096              }
    20892097              break;
    2090             case 'm':
    2091               if (ExitFlag == 0) ExitFlag = 1;
    2092               j = atoi(argv[argptr++]);
    2093               if ((j<0) || (j>1)) {
    2094                 DoeLog(1) && (eLog()<< Verbose(1) << "Argument of '-m' should be either 0 for no-rotate or 1 for rotate." << endl);
    2095                 j = 0;
    2096               }
    2097               if (j) {
    2098                 SaveFlag = true;
    2099                 DoLog(0) && (Log() << Verbose(0) << "Converting to prinicipal axis system." << endl);
    2100                 mol->PrincipalAxisSystem((bool)j);
    2101               } else
    2102                 ArgcList.insert(argptr-1);
    2103                 argptr+=0;
    2104               break;
    2105             case 'o':
    2106               if (ExitFlag == 0) ExitFlag = 1;
    2107               if ((argptr+4 >= argc) || (argv[argptr][0] == '-')){
    2108                 ExitFlag = 255;
    2109                 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for convex envelope: -o <molecule_id> --output-file <output file> --output-file <binned output file>" << endl);
    2110                 performCriticalExit();
    2111               } else {
    2112                 ArgcList.insert(argptr-1);
    2113                 ArgcList.insert(argptr);
    2114                 ArgcList.insert(argptr+1);
    2115                 ArgcList.insert(argptr+2);
    2116                 ArgcList.insert(argptr+3);
    2117                 ArgcList.insert(argptr+4);
    2118                 argptr+=5;
    2119               }
    2120               break;
    21212098            case 'U':
    21222099              if (ExitFlag == 0) ExitFlag = 1;
     
    21642141      } else argptr++;
    21652142    } while (argptr < argc);
    2166     if (SaveFlag)
    2167       configuration.SaveAll(*ConfigFileName, periode, molecules);
    21682143  } else {  // no arguments, hence scan the elements db
    21692144    if (periode->LoadPeriodentafel(configuration.databasepath))
     
    21712146    else
    21722147      DoLog(0) && (Log() << Verbose(0) << "Element list loading failed." << endl);
    2173     configuration.RetrieveConfigPathAndName("main_pcp_linux");
    21742148  }
    21752149  return(ExitFlag);
     
    21792153
    21802154void cleanUp(){
     2155  FormatParserStorage::purgeInstance();
    21812156  ChangeTracker::purgeInstance();
    21822157  World::purgeInstance();
     
    22072182    bool ArgumentsCopied = false;
    22082183    char *ConfigFileName = new char[MAXSTRINGSIZE];
     2184    std::string BondGraphFileName("\n");
     2185    FormatParserStorage::getInstance().addMpqc();
     2186    FormatParserStorage::getInstance().addPcp();
     2187    FormatParserStorage::getInstance().addXyz();
    22092188
    22102189    // print version check whether arguments are present at all
     
    22352214      ArgcList.insert(1); // push back config file name
    22362215      // handle arguments by ParseCommandLineOptions()
    2237       ExitFlag = ParseCommandLineOptions(argc,argv,World::getInstance().getMolecules(),World::getInstance().getPeriode(),*World::getInstance().getConfig(), &ConfigFileName, ArgcList);
     2216      ExitFlag = ParseCommandLineOptions(argc,argv,World::getInstance().getMolecules(),World::getInstance().getPeriode(),*World::getInstance().getConfig(), &ConfigFileName, BondGraphFileName, ArgcList);
    22382217      World::getInstance().setExitFlag(ExitFlag);
    22392218      // copy all remaining arguments to a new argv
     
    22482227      cout << endl;
    22492228      ArgumentsCopied = true;
     2229
     2230      // construct bond graph
     2231      if (World::getInstance().getConfig()->BG == NULL) {
     2232        World::getInstance().getConfig()->BG = new BondGraph(World::getInstance().getConfig()->GetIsAngstroem());
     2233        if (World::getInstance().getConfig()->BG->LoadBondLengthTable(BondGraphFileName)) {
     2234          DoLog(0) && (Log() << Verbose(0) << "Bond length table loaded successfully." << endl);
     2235        } else {
     2236          DoeLog(1) && (eLog()<< Verbose(1) << "Bond length table loading failed." << endl);
     2237        }
     2238      }
    22502239      // handle remaining arguments by CommandLineParser
    22512240      MapOfActions::getInstance().AddOptionsToParser();
     
    22692258    }
    22702259
    2271     Log() << Verbose(0) << "Saving to " << ConfigFileName << "." << endl;
    2272     World::getInstance().getConfig()->SaveAll(ConfigFileName, World::getInstance().getPeriode(), World::getInstance().getMolecules());
     2260    std::string FilenamePrefix(ConfigFileName);
     2261    FormatParserStorage::getInstance().SetOutputPrefixForAll(FilenamePrefix);
     2262    FormatParserStorage::getInstance().SaveAll();
     2263    ChangeTracker::getInstance().saveStatus();
    22732264
    22742265  // free the new argv
Note: See TracChangeset for help on using the changeset viewer.