void cESBTL::pdbReadAtom (const std::string& fileIn, cSetPoint3<double>& atomList, const std::string& atomName) { checkExtension(fileIn); ESBTL::PDB_line_selector pdbSelector; std::vector<ESBTL::Default_system> pdbSystems; ESBTL::All_atom_system_builder<ESBTL::Default_system> pdbBuilder(pdbSystems, pdbSelector.max_nb_systems()); require(ESBTL::read_a_pdb_file(fileIn, pdbSelector, pdbBuilder, Occupancy_policy_all()), "cannot read PDB file"); require(!pdbSystems.empty(), "No PDB system"); require( pdbSystems.size() == 1, "More than one PDB system: pdbSystems.size() = " + num2str(pdbSystems.size())); require(!pdbSystems[0].has_no_model(), "No model in 1st PDB system"); require( pdbSystems[0].number_of_models() == 1, "More than one model in PDB system: pdbSystems[0].number_of_models() = " + num2str(pdbSystems[0].number_of_models())); for (ESBTL::Default_system::Models_iterator iterModel = pdbSystems[0].models_begin(); iterModel != pdbSystems[0].models_end(); iterModel++) { const ESBTL::Default_system::Model& model = *iterModel; for (ESBTL::Default_system::Model::Atoms_const_iterator iterAtom = model.atoms_begin(); iterAtom != model.atoms_end(); iterAtom++) { if ((atomName != "" && iterAtom->atom_name() == atomName) || atomName == "") { atomList.push_back(cVector3<double>(iterAtom->x(),iterAtom->y(),iterAtom->z())); } } } }
void cESBTL::pdbTransRotTrans(const std::string& fileIn, const std::string& fileOut, const cVector3<double>& offset1, const cVector3<double>& angle, const cVector3<double>& offset2) { checkExtension(fileIn); checkExtension(fileOut); // input ESBTL::PDB_line_selector pdbSelector; std::vector<ESBTL::Default_system> pdbSystems; ESBTL::All_atom_system_builder<ESBTL::Default_system> pdbBuilder(pdbSystems, pdbSelector.max_nb_systems()); require(ESBTL::read_a_pdb_file(fileIn, pdbSelector, pdbBuilder, Occupancy_policy_all()), "cannot read PDB file"); require(!pdbSystems.empty(), "No PDB system"); require( pdbSystems.size() == 1, "More than one PDB system: pdbSystems.size() = " + num2str(pdbSystems.size())); require(!pdbSystems[0].has_no_model(), "No model in 1st PDB system"); require( pdbSystems[0].number_of_models() == 1, "More than one model in 1st PDB system: pdbSystems[0].number_of_models() = " + num2str(pdbSystems[0].number_of_models())); // output std::ofstream output(fileOut.c_str()); assure(output); // translate - rotate - translate cVector3<double> pointRot; cMatrix33<double> matRot; transform_rotmat(angle[0], angle[1], angle[2], matRot[0][0], matRot[0][1], matRot[0][2], matRot[1][0], matRot[1][1], matRot[1][2], matRot[2][0], matRot[2][1], matRot[2][2], ROT3D_RIGHT_ZYZ); for (ESBTL::Default_system::Models_iterator iterModel = pdbSystems[0].models_begin(); iterModel != pdbSystems[0].models_end(); iterModel++) { const ESBTL::Default_system::Model& model = *iterModel; for (ESBTL::Default_system::Model::Atoms_const_iterator iterAtom = model.atoms_begin(); iterAtom != model.atoms_end(); iterAtom++) { ESBTL::Default_system::Atom atom(*iterAtom); pointRot = matRot * cVector3<double>(atom.x() + offset1[0], atom.y() + offset1[1], atom.z() + offset1[2]); atom.x() = pointRot[0] + offset2[0]; atom.y() = pointRot[1] + offset2[1]; atom.z() = pointRot[2] + offset2[2]; output << ESBTL::PDB::get_atom_pdb_format(atom) << "\n"; } } }
void cESBTL::pdbTranslate(const std::string& fileIn, const std::string& fileOut, const cVector3<double>& offset) { checkExtension(fileIn); checkExtension(fileOut); // input ESBTL::PDB_line_selector pdbSelector; std::vector<ESBTL::Default_system> pdbSystems; ESBTL::All_atom_system_builder<ESBTL::Default_system> pdbBuilder(pdbSystems, pdbSelector.max_nb_systems()); require(ESBTL::read_a_pdb_file(fileIn, pdbSelector, pdbBuilder, Occupancy_policy_all()), "cannot read PDB file"); require(!pdbSystems.empty(), "No PDB system"); require( pdbSystems.size() == 1, "More than one PDB system: pdbSystems.size() = " + num2str(pdbSystems.size())); require(!pdbSystems[0].has_no_model(), "No model in 1st PDB system"); require( pdbSystems[0].number_of_models() == 1, "More than one model in 1st PDB system: pdbSystems[0].number_of_models() = " + num2str(pdbSystems[0].number_of_models())); // output std::ofstream output(fileOut.c_str()); assure(output); // translate for (ESBTL::Default_system::Models_iterator iterModel = pdbSystems[0].models_begin(); iterModel != pdbSystems[0].models_end(); iterModel++) { const ESBTL::Default_system::Model& model = *iterModel; for (ESBTL::Default_system::Model::Atoms_const_iterator iterAtom = model.atoms_begin(); iterAtom != model.atoms_end(); iterAtom++) { ESBTL::Default_system::Atom atom(*iterAtom); atom.x() += offset[0]; atom.y() += offset[1]; atom.z() += offset[2]; output << ESBTL::PDB::get_atom_pdb_format(atom) << "\n"; } } }
void cESBTL::pdbExtractChain(const std::string& fileIn, const std::string& fileOut, const std::string& chainIDs) { checkExtension(fileIn); checkExtension(fileOut); // input ESBTL::PDB_line_selector pdbSelector; std::vector<ESBTL::Default_system> pdbSystems; ESBTL::All_atom_system_builder<ESBTL::Default_system> pdbBuilder(pdbSystems, pdbSelector.max_nb_systems()); require(ESBTL::read_a_pdb_file(fileIn, pdbSelector, pdbBuilder, Occupancy_policy_all()), "cannot read PDB file"); require(!pdbSystems.empty(), "No PDB system"); require( pdbSystems.size() == 1, "More than one PDB system: pdbSystems.size() = " + num2str(pdbSystems.size())); require(!pdbSystems[0].has_no_model(), "No model in 1st PDB system"); require( pdbSystems[0].number_of_models() == 1, "More than one model in 1st PDB system: pdbSystems[0].number_of_models() = " + num2str(pdbSystems[0].number_of_models())); // output std::ofstream output(fileOut.c_str()); assure(output); // selection ESBTL::Select_by_chainids pdbSelectorChainIDs(chainIDs); for (ESBTL::Default_system::Models_iterator iterModel = pdbSystems[0].models_begin(); iterModel != pdbSystems[0].models_end(); iterModel++) { const ESBTL::Default_system::Model& model = *iterModel; for (Restrict_iterator iterAtom = ESBTL::make_selected_atom_iterator(model.atoms_begin(),pdbSelectorChainIDs); iterAtom != ESBTL::make_selected_atom_iterator<ESBTL::Select_by_chainids>(model.atoms_end()); iterAtom++) { output << ESBTL::PDB::get_atom_pdb_format(*iterAtom) << "\n"; } output.close(); } }
bool extract_balls_from_pdb(const char *filename, std::list<Weighted_point> &weighted_points) { typedef ESBTL::CGAL::EPIC_kernel_with_atom ESBTL_K; typedef ESBTL::CGAL::Default_system ESBTL_System; typedef ESBTL::Generic_classifier<ESBTL::Radius_of_atom<double,ESBTL_System::Atom> > T_Atom_classifier; typedef ESBTL::PDB::Line_format<Mandatory_fields_for_skin_surface> Line_format; typedef ESBTL::Accept_none_occupancy_policy< Line_format > Accept_none_occupancy_policy; typedef ESBTL::Weighted_atom_iterator<ESBTL_System::Model, CGAL::Weighted_point<ESBTL_K::Point_3, double>, ESBTL::Weight_of_atoms<T_Atom_classifier> > Weighted_atom_iterator; //Container for molecular system std::vector<ESBTL_System> systems; ESBTL::PDB_line_selector sel; ESBTL::All_atom_system_builder<ESBTL_System> builder(systems,sel.max_nb_systems()); T_Atom_classifier atom_classifier; ESBTL::Line_reader< Line_format, ESBTL::PDB_line_selector, ESBTL::All_atom_system_builder<ESBTL_System> >(sel,builder).read<ESBTL::ASCII>(filename,Accept_none_occupancy_policy(),' '); //ESBTL::read_a_pdb_file(filename,sel,builder,Accept_none_occupancy_policy()); if ( systems.empty() || systems[0].has_no_model() ){ return false; } const ESBTL_System::Model& model= *systems[0].models_begin(); Weighted_atom_iterator atom_begin(model.atoms_begin(),&atom_classifier); Weighted_atom_iterator atom_end(model.atoms_end(),&atom_classifier); for (Weighted_atom_iterator it = atom_begin; it != atom_end; ++it) { weighted_points.push_back(Weighted_point(Bare_point(it->x(), it->y(), it->z()), it->weight())); } return true; }
void cESBTL::pdbPrintAtom(const std::string& fileIn, const std::string& atomName) { checkExtension(fileIn); ESBTL::PDB_line_selector pdbSelector; std::vector<ESBTL::Default_system> pdbSystems; ESBTL::All_atom_system_builder<ESBTL::Default_system> pdbBuilder(pdbSystems, pdbSelector.max_nb_systems()); require(ESBTL::read_a_pdb_file(fileIn, pdbSelector, pdbBuilder, Occupancy_policy_all()), "cannot read PDB file"); require(!pdbSystems.empty(), "No PDB system"); require( pdbSystems.size() == 1, "More than one PDB system: pdbSystems.size() = " + num2str(pdbSystems.size())); require(!pdbSystems[0].has_no_model(), "No model in 1st PDB system"); require( pdbSystems[0].number_of_models() == 1, "More than one model in 1st PDB system: pdbSystems[0].number_of_models() = " + num2str(pdbSystems[0].number_of_models())); // iterate over all models for (ESBTL::Default_system::Models_iterator iterModel = pdbSystems[0].models_begin(); iterModel != pdbSystems[0].models_end(); iterModel++) { const ESBTL::Default_system::Model& model = *iterModel; //std::cout << "Model " << model.model_number() << std::endl; for (ESBTL::Default_system::Model::Chains_const_iterator iterChain = model.chains_begin(); iterChain != model.chains_end(); iterChain++) { const ESBTL::Default_system::Chain& chain = *iterChain; //std::cout << "Model " << model.model_number() // << ", chain " << chain.chain_identifier() << std::endl; for (ESBTL::Default_system::Chain::Residues_const_iterator iterResidue = chain.residues_begin(); iterResidue != chain.residues_end(); iterResidue++) { const ESBTL::Default_system::Residue& residue = *iterResidue; //std::cout << "Model " << model.model_number() // << ", chain " << chain.chain_identifier() // << ", residue " << residue.residue_name() << std::endl; for (ESBTL::Default_system::Residue::Atoms_const_iterator iterAtom = residue.atoms_begin(); iterAtom != residue.atoms_end(); iterAtom++) { if (atomName == "" || iterAtom->atom_name() == atomName) { std::cout << "Model " << model.model_number() << ", chain " << chain.chain_identifier() << ", residue " << residue.residue_name() << ", atom " << iterAtom->atom_name(); std::cout << std::setprecision(4) << std::fixed << std::setw(7) << iterAtom->atom_serial_number() << std::setw(5) << iterAtom->charge() << std::setw(4) << iterAtom->element() << std::setw(11) << iterAtom->x() << std::setw(11) << iterAtom->y() << std::setw(11) << iterAtom->z(); std::cout << std::endl; } } } } } }