Changeset 35b698 for src/builder.cpp
- Timestamp:
- Jun 23, 2010, 3:52:50 PM (15 years ago)
- 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)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/builder.cpp
rdc0d21 r35b698 80 80 #include "Menu/ActionMenuItem.hpp" 81 81 #include "Parser/ChangeTracker.hpp" 82 #include "Parser/FormatParserStorage.hpp" 83 #include "Parser/PcpParser.hpp" 84 #include "Parser/XyzParser.hpp" 82 85 #include "Actions/ActionRegistry.hpp" 83 86 #include "Actions/ActionHistory.hpp" … … 654 657 int Order1; 655 658 clock_t start, end; 659 std::string path; 656 660 657 661 DoLog(0) && (Log() << Verbose(0) << "Fragmenting molecule with current connection matrix ..." << endl); 658 662 DoLog(0) && (Log() << Verbose(0) << "What's the desired bond order: "); 659 663 cin >> Order1; 664 DoLog(0) && (Log() << Verbose(0) << "What's the output path and prefix [e.g. /home/foo/BondFragment]: "); 665 cin >> path; 660 666 if (mol->first->next != mol->last) { // there are bonds 661 667 start = clock(); 662 mol->FragmentMolecule(Order1, configuration);668 mol->FragmentMolecule(Order1, path); 663 669 end = clock(); 664 670 DoLog(0) && (Log() << Verbose(0) << "Clocks for this operation: " << (end-start) << ", time: " << ((double)(end-start)/CLOCKS_PER_SEC) << "s." << endl); … … 1373 1379 mol->SetNameFromFilename(ConfigFileName); 1374 1380 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 1380 1381 // first save as PDB data 1381 1382 if (ConfigFileName != NULL) … … 1477 1478 DoLog(0) && (Log() << Verbose(0) << "failed." << endl); 1478 1479 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 1483 1480 World::getInstance().destroyMolecule(mol); 1484 1481 }; … … 1500 1497 */ 1501 1498 static int ParseCommandLineOptions(int argc, char **argv, MoleculeListClass *&molecules, periodentafel *&periode, 1502 config& configuration, char **ConfigFileName, s et<int> &ArgcList)1499 config& configuration, char **ConfigFileName, std::string &BondGraphFileName, set<int> &ArgcList) 1503 1500 { 1504 1501 Vector x,y,z,n; // coordinates for absolute point in cell volume … … 1513 1510 int argptr; 1514 1511 molecule *mol = NULL; 1515 string BondGraphFileName("\n");1516 1512 1517 1513 if (argc > 1) { // config file specified as option … … 1625 1621 // simply create a new molecule, wherein the config file is loaded and the manipulation takes place 1626 1622 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); 1627 1626 test.open(argv[1], ios::in); 1628 1627 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; 1640 1630 } else { 1631 configPresent = present; 1632 DoLog(1) && (Log() << Verbose(1) << "Specified config file found, parsing ... "); 1633 FormatParserStorage::getInstance().getPcp().load(&test); 1641 1634 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 }1659 1635 } 1660 1636 } else … … 1671 1647 mol = World::getInstance().createMolecule(); 1672 1648 mol->ActiveFlag = true; 1673 if (*ConfigFileName != NULL)1674 mol->SetNameFromFilename(*ConfigFileName);1675 1649 molecules->insert(mol); 1676 1650 } 1651 if (*ConfigFileName != NULL) 1652 mol->SetNameFromFilename(*ConfigFileName); 1677 1653 1678 1654 // 4. parse again through options, now for those depending on elements db and config presence … … 1733 1709 break; 1734 1710 case 'I': 1735 DoLog(1) && (Log() << Verbose(1) << "Dissecting molecular system into a set of disconnected subgraphs ... " << endl);1736 1711 ArgcList.insert(argptr-1); 1737 1712 argptr+=0; … … 1977 1952 case 't': 1978 1953 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])) ) { 1980 1955 ExitFlag = 255; 1981 1956 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); … … 2074 2049 case 'f': 2075 2050 if (ExitFlag == 0) ExitFlag = 1; 2076 if ((argptr+ 1>= argc) || (argv[argptr][0] == '-')) {2051 if ((argptr+4 >= argc) || (argv[argptr][0] == '-')) { 2077 2052 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); 2079 2087 performCriticalExit(); 2080 2088 } else { … … 2088 2096 } 2089 2097 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 } else2102 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;2121 2098 case 'U': 2122 2099 if (ExitFlag == 0) ExitFlag = 1; … … 2164 2141 } else argptr++; 2165 2142 } while (argptr < argc); 2166 if (SaveFlag)2167 configuration.SaveAll(*ConfigFileName, periode, molecules);2168 2143 } else { // no arguments, hence scan the elements db 2169 2144 if (periode->LoadPeriodentafel(configuration.databasepath)) … … 2171 2146 else 2172 2147 DoLog(0) && (Log() << Verbose(0) << "Element list loading failed." << endl); 2173 configuration.RetrieveConfigPathAndName("main_pcp_linux");2174 2148 } 2175 2149 return(ExitFlag); … … 2179 2153 2180 2154 void cleanUp(){ 2155 FormatParserStorage::purgeInstance(); 2181 2156 ChangeTracker::purgeInstance(); 2182 2157 World::purgeInstance(); … … 2207 2182 bool ArgumentsCopied = false; 2208 2183 char *ConfigFileName = new char[MAXSTRINGSIZE]; 2184 std::string BondGraphFileName("\n"); 2185 FormatParserStorage::getInstance().addMpqc(); 2186 FormatParserStorage::getInstance().addPcp(); 2187 FormatParserStorage::getInstance().addXyz(); 2209 2188 2210 2189 // print version check whether arguments are present at all … … 2235 2214 ArgcList.insert(1); // push back config file name 2236 2215 // 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); 2238 2217 World::getInstance().setExitFlag(ExitFlag); 2239 2218 // copy all remaining arguments to a new argv … … 2248 2227 cout << endl; 2249 2228 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 } 2250 2239 // handle remaining arguments by CommandLineParser 2251 2240 MapOfActions::getInstance().AddOptionsToParser(); … … 2269 2258 } 2270 2259 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(); 2273 2264 2274 2265 // free the new argv
Note:
See TracChangeset
for help on using the changeset viewer.