CHARMMParameters* get_all_atom_CHARMM_parameters() { static IMP::Pointer<CHARMMParameters> ret =new CHARMMParameters(get_data_path("top.lib"), get_data_path("par.lib")); ret->set_log_level(SILENT); return ret; }
IMP::ParticlesTemp add_bonds(IMP::atom::Hierarchy mhd) { IMP::atom::CHARMMParameters *ff = IMP::atom::get_heavy_atom_CHARMM_parameters(); IMP::Pointer<IMP::atom::CHARMMTopology> topology = ff->create_topology(mhd); topology->add_atom_types(mhd); IMP::ParticlesTemp bonds = topology->add_bonds(mhd); return bonds; }
void add_radii(Hierarchy d, const ForceFieldParameters* ffp, FloatKey radius_key) { // Temporary hack to maintain old interface for SAXS const CHARMMParameters *cp = dynamic_cast<const CHARMMParameters *>(ffp); if (cp) { IMP::Pointer<CHARMMTopology> top = cp->create_topology(d); top->apply_default_patches(); top->add_atom_types(d); } ffp->add_radii(d, 1.0, radius_key); }
IMPSPB_BEGIN_NAMESPACE IMP::Pointer<core::MonteCarlo> setup_SPBMonteCarlo(Model *m, core::MonteCarloMovers &mvs, double temp, SPBParameters myparam) { IMP::Pointer<core::MonteCarlo> mc; if (myparam.MC.do_wte) { double w0 = myparam.MC.wte_w0 * temp / myparam.MC.tmin; mc = new spb::MonteCarloWithWte( m, myparam.MC.wte_emin, myparam.MC.wte_emax, myparam.MC.wte_sigma, myparam.MC.wte_gamma, w0); } else { mc = new core::MonteCarlo(m); } mc->set_return_best(false); mc->set_kt(temp); mc->add_mover(new core::SerialMover(get_as<core::MonteCarloMoversTemp>(mvs))); return mc.release(); }
int main(int argc, char *argv[]) { IMP::setup_from_argv(argc, argv, "Test ConsecutivePairContainer."); IMP_NEW(IMP::Model, m, ()); IMP::ParticleIndexes ps; IMP::algebra::BoundingBox3D bb(IMP::algebra::Vector3D(0, 0, 0), IMP::algebra::Vector3D(10, 10, 10)); for (unsigned int i = 0; i < 15; ++i) { ps.push_back(m->add_particle("P")); IMP::core::XYZ::setup_particle(m, ps.back(), IMP::algebra::get_random_vector_in(bb)); } IMP_NEW(IMP::container::ConsecutivePairContainer, cpc, (m, ps)); IMP_NEW(IMP::core::HarmonicDistancePairScore, hdps, (0, 1)); IMP::Pointer<IMP::Restraint> r = IMP::container::create_restraint(hdps.get(), cpc.get()); IMP_USAGE_CHECK(r->evaluate(false) > 0, "zero evaluate"); IMP::Pointer<IMP::Restraint> rd = r->create_decomposition(); IMP::RestraintsTemp rds = IMP::get_restraints(IMP::RestraintsTemp(1, rd)); IMP_USAGE_CHECK(rds.size() == ps.size() - 1, "Bad lengths: " << rds.size() << " vs " << ps.size() - 1); double re = r->evaluate(false); double rde = rd->evaluate(false); IMP_CHECK_VARIABLE(re); IMP_CHECK_VARIABLE(rde); IMP_USAGE_CHECK(std::abs(rde - re) < .1, "Invalid decomposed score: " << re << " vs " << rde); return 0; }
int main(int argc, char *argv[]) { IMP::Strings args = IMP::setup_from_argv(argc, argv, "Score a protein-ligand complex", "file.mol2 file.pdb [libfile]", -1); IMP::set_log_level(IMP::SILENT); std::string mol2name, pdbname; for (size_t i = 0; i < args.size(); ++i) { std::string nm(args[i]); if (nm.rfind(".mol2") == nm.size() - 5) { mol2name = nm; } else if (nm.rfind(".pdb") == nm.size() - 4) { pdbname = nm; } else { break; } } if (mol2name.empty() || pdbname.empty()) { std::cerr << "Usage: " << argv[0] << " file.mol2 file.pdb [libfile]" << std::endl; return EXIT_FAILURE; } IMP::TextInput lib; if (args.size() == 3) { lib = IMP::TextInput(args[2]); } { int lib_requested = 0; if (lib) lib_requested++; if (pose_score) lib_requested++; if (rank_score) lib_requested++; if (lib_requested > 1) { std::cerr << "Can only specify one of --pose, --rank, " << "or a library name" << std::endl; return EXIT_FAILURE; } } IMP_NEW(IMP::Model, m, ()); IMP::atom::Hierarchy p, l; { IMP::SetLogState ss(IMP::SILENT); p = IMP::atom::read_pdb(pdbname, m, new IMP::atom::ATOMPDBSelector()); IMP::atom::add_protein_ligand_score_data(p); l = IMP::atom::read_mol2(mol2name, m); IMP::atom::add_protein_ligand_score_data(l); } IMP::atom::Hierarchies mols = IMP::atom::get_by_type(l, IMP::atom::RESIDUE_TYPE); IMP::Pointer<IMP::atom::ProteinLigandAtomPairScore> ps = get_pair_score(lib); double d = ps->get_maximum_distance(); IMP_NEW(IMP::core::GridClosePairsFinder, gcpf, ()); gcpf->set_distance(d); IMP::ParticlesTemp patoms = IMP::atom::get_leaves(p); IMP::ParticleIndexes ipatoms = IMP::get_indexes(patoms); for (unsigned int i = 0; i < mols.size(); ++i) { // IMP::SetLogState ss(i==0? TERSE: IMP::SILENT); IMP::ParticlesTemp latoms = IMP::atom::get_leaves(mols[i]); IMP::ParticleIndexes ilatoms = IMP::get_indexes(latoms); IMP::ParticleIndexPairs ppt = gcpf->get_close_pairs(m, ipatoms, ilatoms); double score = ps->evaluate_indexes(m, ppt, NULL, 0, ppt.size()); std::cout << "Score for " << mols[i]->get_name() << " is " << score << std::endl; } ps->set_was_used(true); return EXIT_SUCCESS; }
int main(int argc, char **argv) { // output arguments for(int i=0; i<argc; i++) std::cerr << argv[i] << " "; std::cerr << std::endl; int number_of_iterations = 100; int number_of_nodes = 100; int save_configuration_number = 10; int number_of_models_in_pdb = 100; int number_of_active_dofs = 0; float radii_scaling = 0.5; bool reset_angles = false; std::string configuration_file; std::string connect_chains_file; po::options_description desc("Options"); desc.add_options() ("help", "PDB file and Rotatable Angles file") ("version", "Written by Dina Schneidman.") ("number_of_iterations,i", po::value<int>(&number_of_iterations)->default_value(100), "number of iterations (default = 100)") ("number_of_nodes,n", po::value<int>(&number_of_nodes)->default_value(100), "number of nodes (default = 100)") ("number_of_path_configurations_saved,p", po::value<int>(&save_configuration_number)->default_value(10), "if the path between two nodes is feasible, each Nth configuration on the path will be added to the tree (default = 10?)") ("number_of_active_dofs,a", po::value<int>(&number_of_active_dofs)->default_value(0), "for many dofs use this option with 10-50 dofs (default = 0)") ("radii_scaling,s", po::value<float>(&radii_scaling)->default_value(0.5), "radii scaling parameter (0.5 < s < 1.0, default = 0.5)") ("reset_angles", "set initial values in rotatable angles to PI (default = false)") ("connect_chains_file,c", po::value<std::string>(&connect_chains_file), "connect chains into one rigid body by adding bonds between specified atoms") ("number_of_models_in_pdb,m", po::value<int>(&number_of_models_in_pdb)->default_value(100), "number of models in output PDB files (default = 100)") ; po::options_description hidden("Hidden options"); hidden.add_options() ("input-files", po::value< std::vector<std::string> >(), "input PDB and rotatable angles files") ("target_configurations,t", po::value<std::string>(&configuration_file), "target_configurations") ; po::options_description cmdline_options; cmdline_options.add(desc).add(hidden); po::options_description visible("Usage: <pdb_file> <rotatable_angles_file>"); visible.add(desc); po::positional_options_description p; p.add("input-files", -1); po::variables_map vm; po::store(po::command_line_parser(argc, argv).options(cmdline_options).positional(p).run(), vm); po::notify(vm); std::vector<std::string> files; if(vm.count("input-files")) { files = vm["input-files"].as< std::vector<std::string> >(); } if(vm.count("help") || files.size() == 0) { std::cout << visible << "\n"; return 0; } if(radii_scaling < 0.5 || radii_scaling > 1.0) { std::cerr << "radii_scaling parameter outside allowed range" << radii_scaling << std::endl; } if(vm.count("reset_angles")) reset_angles=true; std::string pdb_name = files[0]; std::string angle_file_name; if(files.size() > 1) angle_file_name = files[1]; // read in the input protein IMP::Pointer<IMP::Model> model = new IMP::Model(); std::cerr << "Starting reading pdb file " << pdb_name << std::endl; IMP::atom::Hierarchy mhd = IMP::atom::read_pdb(pdb_name, model, new IMP::atom::NonWaterNonHydrogenPDBSelector(), // don't add radii true, true); IMP::ParticlesTemp atoms = IMP::atom::get_by_type(mhd, IMP::atom::ATOM_TYPE); IMP::ParticlesTemp residues = IMP::atom::get_by_type(mhd, IMP::atom::RESIDUE_TYPE); const std::string topology_file_name = IMP::atom::get_data_path("top_heav.lib"); const std::string parameter_file_name = IMP::atom::get_data_path("par.lib"); std::ifstream test(topology_file_name.c_str()); if(!test) { std::cerr << "Please provide topology file " << topology_file_name << std::endl; exit(1); } std::ifstream test1(parameter_file_name.c_str()); if(!test1) { std::cerr << "Please provide parameter file " << parameter_file_name << std::endl; exit(1); } IMP::atom::CHARMMParameters* ff = new IMP::atom::CHARMMParameters(topology_file_name, parameter_file_name); IMP::Pointer<IMP::atom::CHARMMTopology> topology = ff->create_topology(mhd); // We don't want to add/remove any atoms, so we only add atom types topology->apply_default_patches(); // topology->setup_hierarchy(mhd); //removes atoms topology->add_atom_types(mhd); IMP::ParticlesTemp bonds = topology->add_bonds(mhd); // create phi/psi joints IMP::atom::Residues flexible_residues; std::vector<IMP::atom::Atoms> dihedral_angles; if(angle_file_name.length()>0) { read_angle_file(angle_file_name, residues, atoms, flexible_residues, dihedral_angles); } else { flexible_residues = residues; } std::vector<IMP::atom::Atoms> connect_chains_atoms; if(connect_chains_file.length() > 0) { read_connect_chains_file(connect_chains_file, atoms, connect_chains_atoms); for(unsigned i=0; i<connect_chains_atoms.size(); i++) { IMP::atom::Bond bond = create_bond(connect_chains_atoms[i]); if(bond != IMP::atom::Bond()) bonds.push_back(bond); } } IMP::ParticlesTemp angles = ff->create_angles(bonds); IMP::ParticlesTemp dihedrals = ff->create_dihedrals(bonds); std::cerr << "# atoms " << atoms.size() << " # bonds " << bonds.size() << " # angles " << angles.size() << " # dihedrals " << dihedrals.size() << std::endl; add_missing_bonds(atoms, bonds); std::cerr << "# atoms " << atoms.size() << " # bonds " << bonds.size() << " # angles " << angles.size() << " # dihedrals " << dihedrals.size() << std::endl; // add radius ff->add_radii(mhd, radii_scaling); // prepare exclusions list IMP_NEW(IMP::atom::StereochemistryPairFilter, pair_filter, ()); pair_filter->set_bonds(bonds); pair_filter->set_angles(angles); pair_filter->set_dihedrals(dihedrals); // close pair container IMP_NEW(IMP::container::ListSingletonContainer, lsc, (atoms)); IMP_NEW(IMP::container::ClosePairContainer, cpc, (lsc, 15.0)); cpc->add_pair_filter(pair_filter); IMP_NEW(IMP::core::SoftSpherePairScore, score,(1)); IMP_NEW(IMP::container::PairsRestraint, pr, (score, cpc)); // TODO: check why not working: should be much faster //IMP::Pointer<IMP::Restraint> pr= // IMP::container::create_restraint(score, cpc); ProteinKinematics pk(mhd, flexible_residues, dihedral_angles); std::cerr << "ProteinKinematics done" << std::endl; DihedralAngleRevoluteJoints joints = pk.get_ordered_joints(); IMP_NEW(KinematicForestScoreState, kfss, (pk.get_kinematic_forest(), pk.get_rigid_bodies(), atoms)); model->add_score_state(kfss); // create dofs DOFs dofs; for(unsigned int i=0; i<joints.size(); i++) { std::cerr << "Angle = " << joints[i]->get_angle() << " " << 180 * joints[i]->get_angle()/IMP::algebra::PI << std::endl; if(reset_angles) joints[i]->set_angle(IMP::algebra::PI); IMP_NEW(DOF, dof, (joints[i]->get_angle(), -IMP::algebra::PI, IMP::algebra::PI, IMP::algebra::PI/360)); dofs.push_back(dof); } DOFValues val(dofs); if(reset_angles) { kfss->do_before_evaluate(); for(unsigned int i=0; i<joints.size(); i++) { std::cerr << "Angle = " << joints[i]->get_angle() << " " << 180 * joints[i]->get_angle()/IMP::algebra::PI << std::endl; } } DirectionalDOF dd(dofs); IMP_NEW(UniformBackboneSampler, ub_sampler, (joints, dofs)); IMP_NEW(PathLocalPlanner, planner, (model, ub_sampler, &dd, save_configuration_number)); std::cerr << "Init RRT" << std::endl; IMP_NEW(RRT, rrt, (model, ub_sampler, planner, dofs, number_of_iterations, number_of_nodes, number_of_active_dofs)); rrt->set_scoring_function(pr); std::cerr << "Start RRT run" << std::endl; std::string filename = "node_begin.pdb"; IMP::atom::write_pdb(mhd, filename); rrt->run(); std::cerr << "Done RRT " << rrt->get_DOFValues().size() << std::endl; // output PDBs std::ofstream *out = NULL; int file_counter = 1; int model_counter = 0; std::vector<DOFValues> dof_values = rrt->get_DOFValues(); for(unsigned int i = 0; i<dof_values.size(); i++) { ub_sampler->apply(dof_values[i]); kfss->do_before_evaluate(); // open new file if needed if(model_counter % number_of_models_in_pdb == 0) { // open new file if(out !=NULL) out->close(); std::string file_name = "nodes" + std::string(boost::lexical_cast<std::string>(file_counter)) + ".pdb"; out = new std::ofstream(file_name.c_str()); file_counter++; model_counter=0; } IMP::atom::write_pdb(mhd, *out, model_counter+1); model_counter++; } out->close(); return 0; }