/*************************************************************************** select_mod.cpp - description ------------------- begin : Thu Jul 3 21:52:59 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 using namespace Almost; template<> inline string to_string(const NameSelection & ns){ return to_string(ns.size()); } template<> inline string to_string(const Molecules & molecules){ return ""; } template<> inline string to_string(const ContactGroup &gr){ char buff[256]; sprintf(buff," %i",gr.size()); return gr.name()+buff; } NameSelection sele_fragment(const Molecules & molecules, int i){ int fd = i-1; if(i<1) throw "invalid framget index"; if(i>molecules.fragment_size()) throw "invalid framget index"; vector sequ = molecules.sequence(Molecules::BASE); NameSelection sele = NameSelection(molecules,sequ[fd]+"/*"); return sele; } NameSelection sele_type(const Molecules & molecules, string type_pattern){ //%T means type return NameSelection(molecules,"%T"+type_pattern); } //utilities ContactGroup ca_native(const Molecules & molecules, const NameSelection & sele, double nd, int excl){ ContactGroup g("ca_native"); vector CA; for(int i=0;i CA; for(int i=0;i=nd){ g.add(molecules, molecules.atom_name(CA[i],Molecules::BASE), molecules.atom_name(CA[j],Molecules::BASE), nd); } } } return g; } NameSelection range(const Molecules & mols, int from, int to){ return NameSelection(mols,from,to); } extern "C" { void init_select(){ Module module = Module("select","Atom Selection Tools"); Class >(module.self(),"name") .def_method("size",&NameSelection::size) .def_method("show",&NameSelection::show); module.def_function("range", "Returns selection of atoms from fragment beg to fragment end", range); module.def_function("remove_atoms","Removes atoms in selection.", Almost::remove_atoms); module.def_function("ca_native","Returns CA-native contact group", ca_native); module.def_function("ca_non_native","Returns CA-non-native contact group", ca_non_native); module.def_function("fragment","Returns selection for atoms in fragment i", sele_fragment); module.def_function("type","Returns selection for atoms of type given by the type pattern", sele_type); ZObj::BinaryOperator:: add(or_op_operator); ZObj::BinaryOperator:: add(and_op_operator); ZObj::UnaryOperator:: add(not_op_operator); } }