int main(int argc, const char **argv) { seed(); physics::settings_type physics_settings; scene::settings_type scene_settings; Helix::settings_type helix_settings; std::string input_file, output_file; parse_settings::parse(argc, argv, physics_settings, scene_settings, helix_settings, input_file, output_file); if (input_file.empty() || output_file.empty() || argc < 3) { std::cerr << parse_settings::usage(argv[0]) << std::endl; return 0; } scene mesh(scene_settings, helix_settings); physics phys(physics_settings); try { if (!mesh.read(phys, input_file)) { std::cerr << "Failed to read scene \"" << input_file << "\"" << std::endl; return 1; } } catch (const std::runtime_error & e) { std::cerr << "Failed to read scene \"" << input_file << "\": " << e.what() << std::endl; return 1; } physics::real_type initialmin, initialmax, initialaverage, initialtotal, min, max, average, total; mesh.getTotalSeparationMinMaxAverage(initialmin, initialmax, initialaverage, initialtotal); std::cerr << "Running simulation for scene loaded from \"" << input_file << " outputting to " << output_file << "\"." << std::endl << "Initial: min: " << initialmin << ", max: " << initialmax << ", average: " << initialaverage << ", total: " << initialtotal << " nm" << std::endl << "Connect with NVIDIA PhysX Visual Debugger to " << PVD_HOST << ':' << PVD_PORT << " to visualize the progress. " << std::endl << "Press ^C to stop the relaxation...." << std::endl; setinterrupthandler<handle_exit>(); SceneDescription best_scene; Helix helix1 = Helix(helix_settings, phys, 20, physics::transform_type(physics::vec3_type(1,20,1))); Helix helix2 = Helix(helix_settings, phys, 20, physics::transform_type(physics::vec3_type(1, 20, 8))); helix1.attach(phys, helix2, Helix::AttachmentPoint::kBackwardFivePrime, Helix::AttachmentPoint::kBackwardThreePrime); #if 0 best_scene = simulated_rectification(mesh, phys, []() { return running; }); #else #if 0 simulated_annealing(mesh, phys, 100, 0, 7, 1, [&best_scene](scene & mesh, float e) { std::cerr << "Store best energy: " << e << std::endl; best_scene = SceneDescription(mesh); }, []() { return running; }); #else gradient_descent(mesh, phys, 7, [&best_scene, &min, &max, &average, &total](scene & mesh, physics::real_type min_, physics::real_type max_, physics::real_type average_, physics::real_type total_) { min = min_; max = max_; average = average_; total = total_; std::cerr << "State: min: " << min << ", max: " << max << ", average: " << average << " total: " << total << " nm" << std::endl; best_scene = SceneDescription(mesh); }, []() { return running; }); #endif #endif std::cerr << "Result: min: " << min << ", max: " << max << ", average: " << average << ", total: " << total << " nm" << std::endl; { std::ofstream outfile(output_file); outfile << "# Relaxation of original " << input_file << " file. " << mesh.getHelixCount() << " helices." << std::endl << "# Total separation: Initial: min: " << initialmin << ", max: " << initialmax << ", average: " << initialaverage << ", total: " << initialtotal << " nm" << ", final: min: " << min << ", max: " << max << ", average: " << average << ", total: " << total << " nm" << std::endl; if (!best_scene.write(outfile)) std::cerr << "Failed to write resulting mesh to \"" << output_file << "\"" << std::endl; outfile.close(); } sleepms(2000); return 0; }
int main(int argc, char **argv) { CHAIN **Chain; HBOND **HBond; COMMAND *Cmd; int Cn, NChain=0, NHBond=0, ValidChain=0; float **PhiPsiMapHelix, **PhiPsiMapSheet; register int i; /* argc = ccommand(&argv); */ /* For Macintosh only, see readme.mac */ Chain = (CHAIN **)ckalloc(MAX_CHAIN*sizeof(CHAIN *)); HBond = (HBOND **)ckalloc(MAXHYDRBOND*sizeof(HBOND *)); Cmd = (COMMAND *)ckalloc(sizeof(COMMAND)); ProcessStrideOptions(argv,argc,Cmd); if( !ReadPDBFile(Chain,&NChain,Cmd) || !NChain ) die("Error reading PDB file %s\n",Cmd->InputFile); for( Cn=0; Cn<NChain; Cn++ ) ValidChain += CheckChain(Chain[Cn],Cmd); /* if( Cmd->Stringent ) * exit(0); */ if( !ValidChain ) die("No valid chain in %s\n",Chain[0]->File); if( Cmd->BrookhavenAsn ) GetPdbAsn(Chain,NChain); if( Cmd->DsspAsn ) GetDsspAsn(Chain,NChain,Cmd); BackboneAngles(Chain,NChain); if( Cmd->OutSeq ) OutSeq(Chain,NChain,Cmd); if( Cmd->ContactOrder ) ContactOrder(Chain,NChain,Cmd); if( Cmd->ContactMap ) ContactMap(Chain,NChain,Cmd); if( !strlen(Cmd->MapFileHelix) ) PhiPsiMapHelix = DefaultHelixMap(Cmd); else ReadPhiPsiMap(Cmd->MapFileHelix,&PhiPsiMapHelix,Cmd); if( !strlen(Cmd->MapFileSheet) ) PhiPsiMapSheet = DefaultSheetMap(Cmd); else ReadPhiPsiMap(Cmd->MapFileSheet,&PhiPsiMapSheet,Cmd); for( Cn=0; Cn<NChain; Cn++ ) PlaceHydrogens(Chain[Cn]); if( (NHBond = FindHydrogenBonds(Chain,Cn,HBond,Cmd)) == 0 ) die("No hydrogen bonds found in %s\n",Cmd->InputFile); NoDoubleHBond(HBond,NHBond); DiscrPhiPsi(Chain,NChain,Cmd); if(Cmd->ExposedArea) Area(Chain,NChain,Cmd); for( Cn=0; Cn<NChain; Cn++ ) { if( Chain[Cn]->Valid ) { Helix(Chain,Cn,HBond,Cmd,PhiPsiMapHelix); for( i=0; i<NChain; i++ ) if( Chain[i]->Valid ) Sheet(Chain,Cn,i,HBond,Cmd,PhiPsiMapSheet); BetaTurn(Chain,Cn); GammaTurn(Chain,Cn,HBond); } } Report(Chain,NChain,HBond,Cmd); if( Cmd->MolScript ) MolScript(Chain,NChain,Cmd); for( i=0; i<Cn; i++ ) free(Chain[i]); for( i=0; i<NHBond; i++ ) free(HBond[i]); free(Cmd); return(0); }