/** * \file interface_rtc.cpp \brief A program for computing NMR residue * type content of a single interface. * * Copyright 2007-2013 IMP Inventors. All rights reserved. * */ #include "helpers.h" #include "CrossLink.h" #include #include #include #include #include #include #include #include #include #include namespace po = boost::program_options; #include #include namespace { void select_cross_links(const std::vector& cross_links, std::vector& selected_cross_links) { // init random number generator typedef boost::mt19937 base_generator_type; base_generator_type rng; boost::uniform_real<> uni_dist(0,1); boost::variate_generator > uni(rng, uni_dist); for(unsigned int i=0; i "); desc.add_options() ("help", "returns lys-lys cross links for the two molecules.") ("input-files", po::value< std::vector >(), "input PDBs") ("n-ter,n", "use n-termini for cross linking (default = true)") ("output_file,o", po::value(&out_file_name)->default_value("cross_links.dat"), "output file name, default name cross_links.dat") ; po::positional_options_description p; p.add("input-files", -1); po::variables_map vm; po::store( po::command_line_parser(argc,argv).options(desc).positional(p).run(), vm); po::notify(vm); // parse filenames std::string receptor_pdb, ligand_pdb; std::vector files; if(vm.count("input-files")) { files = vm["input-files"].as< std::vector >(); } if(vm.count("help") || files.size() != 3) { std::cout << desc << "\n"; return 0; } if(vm.count("n-ter")) use_nter = false; receptor_pdb = files[0]; ligand_pdb = files[1]; float distance_threshold = atof(files[2].c_str()); // read pdb files, prepare particles IMP::Model *model = new IMP::Model(); IMP::atom::Hierarchy mhd = IMP::atom::read_pdb(receptor_pdb, model, new IMP::atom::NonWaterNonHydrogenPDBSelector(), true, true); IMP::Particles residue_particles1 = get_by_type(mhd, IMP::atom::RESIDUE_TYPE); mhd = IMP::atom::read_pdb(ligand_pdb, model, new IMP::atom::NonWaterNonHydrogenPDBSelector(), true, true); IMP::Particles residue_particles2 = get_by_type(mhd, IMP::atom::RESIDUE_TYPE); // get CA atoms for residues IMP::Particles ca_atoms1, ca_atoms2; for(unsigned int i=0; i cross_links, selected_cross_links; bool chain_id1_set = false; char curr_chain1 = '-'; int link_counter = 0; // compute distance for all accessible LYS calpha atoms + N-ter calpha for(unsigned int i=0; i 0 && (rt1 == IMP::atom::LYS || // LYS residue (use_nter && (!chain_id1_set || // first residue // first residue in new chain (chain_id1_set && curr_chain1 != chain_id1))))) { IMP::algebra::Vector3D v1 =IMP::core::XYZ(ca_atoms1[i]).get_coordinates(); //get cb IMP::algebra::Vector3D v1cb(0.0,0.0,0.0); bool cb1 = false; IMP::atom::Atom at = IMP::atom::get_atom(r1, IMP::atom::AT_CB); if(at) { v1cb = IMP::core::XYZ(at.get_particle()).get_coordinates(); cb1 = true; } bool chain_id2_set = false; char curr_chain2 = '-'; // iterate second mol for(unsigned int j=0; j 0 && (rt2 == IMP::atom::LYS || (use_nter && (!chain_id2_set || (chain_id2_set && curr_chain2 != chain_id2))))) { IMP::algebra::Vector3D v2 = IMP::core::XYZ(ca_atoms2[j]).get_coordinates(); //get cb IMP::algebra::Vector3D v2cb(0.0,0.0,0.0); bool cb2 = false; IMP::atom::Atom at = IMP::atom::get_atom(r2, IMP::atom::AT_CB); if(at) { v2cb = IMP::core::XYZ(at.get_particle()).get_coordinates(); cb2 = true; } // compute distance float dist = IMP::algebra::get_distance(v1,v2); if(dist < distance_threshold) { if(cb1 && cb2) { // check cb distance float dist_cb = IMP::algebra::get_distance(v1cb,v2cb); if(dist_cb < distance_threshold) { link_counter++; std::cout << res_index1 << ' ' << chain_id1 << ' ' << res_index2 << ' ' << chain_id2 << ' ' << dist << std::endl; CrossLink cl(res_index1, chain_id1, res_index2, chain_id2, 3.0, 27.0, dist, dist_cb); cross_links.push_back(cl); } } } } // set chain id2 if(!chain_id2_set) chain_id2_set = true; curr_chain2 = chain_id2; } } // set chain id if(!chain_id1_set) chain_id1_set = true; curr_chain1 = chain_id1; } select_cross_links(cross_links, selected_cross_links); std::random_shuffle(selected_cross_links.begin(), selected_cross_links.end()); if(selected_cross_links.size() > 0) { write_cross_link_file(out_file_name, selected_cross_links); write_cross_link_file("cxms2.dat", selected_cross_links, true); } write_cross_link_file("cxms_all.dat", cross_links, true); std::cerr << link_counter << " links were generated, selected: " << selected_cross_links.size () << std::endl; return 0; }