/*************************************************************************** pdb_mod.cpp - description ------------------- begin : Thu Mar 20 17:53:57 2003 copyright : (C) 2002 by Cavalli Andrea email : cavalli@bioc.unizh.ch **************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ #include #include #include #include #include #include #include #include #include #include #ifdef HAVE_BZLIB_H #include #endif #include #include using namespace Almost; template<> inline string to_string(const PDB & pdb){ return ""; } template<> inline string to_string(const PDBModel & pdbmodel){ return ""; } template<> inline string to_string(const PDBSegment & pdbsegment){ return ""; } template<> inline string to_string(const PDBFragment & pdbfragment){ return ""; } template<> inline string to_string(const PDBAtomLine & pdbatomline){ return ""; } template<> inline string to_string(const FingerPrint & fp){ return fp.comp+" "+fp.category+" "+fp.finger_print; } template<> inline string to_string(const FingerPrintDB & fp){ return ""; } vector aminoacids(){ vector aa; aa.push_back("ALA"); aa.push_back("CYS"); aa.push_back("ASP"); aa.push_back("GLU"); aa.push_back("PHE"); aa.push_back("GLY"); aa.push_back("HIS"); aa.push_back("ILE"); aa.push_back("LYS"); aa.push_back("LEU"); aa.push_back("MET"); aa.push_back("ASN"); aa.push_back("PRO"); aa.push_back("GLN"); aa.push_back("ARG"); aa.push_back("SER"); aa.push_back("THR"); aa.push_back("VAL"); aa.push_back("TRP"); aa.push_back("TYR"); return aa; } void init_pdb_types(ZModule & module){ //class PDB Class >(module,"pdb") .def_method("size",&PDB::size) .def_method("info",&PDB::info) .def_method("header",&PDB::header) .def_method("title",&PDB::title) .def_method("compound",&PDB::compound) .def_method("source",&PDB::source) .def_method("author",&PDB::author) .def_method("journal",&PDB::journal) .def_method("remark",&PDB::remark) .def_method("seqres",&PDB::seqres) .def_method("rename_atom",&PDB::rename_atom) .def_method("rename_frag",&PDB::rename_frag) .def_method("align_seqres",&PDB::align_seqres) .def_method("remarks",&PDB::remarks) ; ZObj::BinaryOperator::BOM()[pair (typeid(ZType), typeid(ZInt))] = index_operator; ZObj::BinaryOperator::BOM()[pair (typeid(ZType), typeid(ZInt))] = index_operator; //class PDBModel Class(module,"model") .def_method("size",&PDBModel::size); ZObj::BinaryOperator::BOM()[pair (typeid(ZType), typeid(ZInt))] = index_operator; ZObj::BinaryOperator::BOM()[pair (typeid(ZType), typeid(ZInt))] = index_operator; //class PDBSegment Class(module,"segment") .def_method("size",&PDBSegment::size) .def_method("name",&PDBSegment::name) .def_method("set_name",&PDBSegment::set_name) .def_method("chainID",&PDBSegment::chainID) .def_method("set_chainID",&PDBSegment::set_chainID) .def_method("sequence",&PDBSegment::sequence) .def_method("sub",&PDBSegment::sub) .def_method("fix_numbering",&PDBSegment::fix_numbering) .def_method("swap_atom",&PDBSegment::swap_atom) ; Class(module,"frgment") .def_method("name",&PDBFragment::name) .def_method("fingerprint",&PDBFragment::fingerprint) .def_method("fingerprint_string",&PDBFragment::fingerprint_string) ; ZObj::BinaryOperator::BOM()[pair (typeid(ZType), typeid(ZInt))] = index_operator; ZObj::BinaryOperator::BOM()[pair (typeid(ZType), typeid(ZInt))] = index_operator; Class(module,"fingerprint") .def_attribute("finger_print",&FingerPrint::finger_print,"Undocumented") .def_attribute("kind",&FingerPrint::kind,"Undocumented") .def_attribute("category",&FingerPrint::category,"Undocumented") .def_attribute("comp",&FingerPrint::comp,"Undocumented") .def_attribute("parent_comp",&FingerPrint::parent_comp,"Undocumented") ; Class >("fingerprintvect") .def_method("push_back",&vector::push_back) .def_method("size",&vector::size) .def_method("clear",&vector::clear) // .def_method("resize",&vector::resize) ; ZObj::BinaryOperator::add_ifndef,int> (index_operator ,int,FingerPrint &>); Class >(module,"fingerprintdb") .def_method("find",&FingerPrintDB::find) .def_method("category",&FingerPrintDB::category) .def_method("kind",&FingerPrintDB::kind) ; } PDB open_ext(string file){ return PDB(file,true);} bool hetero_can_map(string q){ if(q=="MSE") return true; return false; } PDBFragment * hetero_map(const PDBFragment & src){ if(src.name()=="MSE"){ PDBFragment * f = new PDBFragment(src); f->set_name("MET"); for(int i=0;iatom.size();i++){ f->atom[i]->kind = PDBAtomLine::ATOM; if(f->atom[i]->name == "SE") f->atom[i]->name = "SG"; } return f; } return NULL; } PDBSegment heteromap_segment(const PDBSegment & seg){ PDBSegment s; for(int i=0;i > & mat){ // cout<<"DEBUG extract_biomt(istream & in, vector > & mat)"<>tmp; if(i>=4) mat.back().push_back(atof(tmp.c_str())); } } ++linenum; } // cout<<"DEBUG "< > pdb_biomt(string file){ // cout<<"DEBUG pdb_biomt(string file)"< > mat; int comp = 0; int len = file.size()-1; if(file[len]=='z'&&file[len-1]=='g') comp =1; if(file[len]=='2'&&file[len-1]=='z'&&file[len-2]=='b') comp=2; if(comp==0){ ifstream in; in.open(file.c_str()); if(!in){ cout<<"FATAL ERROR: no such file: "<("one2three", "Return three letters code of amino acid", one2three); module.def_function("is_protein", "Return true if segment is protein", is_protein); module.def_function("info","Prints usefull info about proteins", info); module.def_function("open","Extended open",&open_ext); module.def_function("heteromap","Map hetero residues.",&heteromap_segment); module.def_function("pdb_biomt","Extracts bio-molecules transformation from PDB file.",pdb_biomt); module.def_function("aminoacids","Return a vector with three-letter code of standard amino-acids.",aminoacids); module.def_function("read_fasta","Reads fasta file.",read_fasta); module.def_function("fasta2three","Return vector containing sequence in three letter code. If the second argument is true the it will append the srial number to the amino-acid code (example: ALA_1 TRY_2 ...).",fasta2three); module.def_function("is_connected","Checks that the back-bone of a protein is connected",is_connected); module.def_function("split","Splits a segment with chain breaks on continuous sub-segments",split); module .def_const("LONG",(int)PDBSegment::LONG) .def_const("SHORT",(int)PDBSegment::SHORT) .def_const("ICODE",(int)PDBSegment::ICODE) ; } }