/*************************************************************************** molecules_mod.cpp - description ------------------- begin : Sat Mar 22 01:02:37 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 #include #include #include #include #include #include #include #include #include #include #include using namespace Almost; void auto_connect(Molecules & mol){ //Find d(i,j)> Putative bond "< sequ = segment.sequence(); for(int i=0;i> Putative bond "<> Unable to add bond ....\n"; } } } } return p; } template<> inline string to_string(const Almost::DCDTrj & ){ return ""; } template<> inline string to_string(const Almost::Atom & ){ return ""; } template<> inline string to_string(const Kernel::Molecule & ){ return ">"; } template<> inline string to_string(const Kernel::Molecule & ){ return ">"; } template<> inline string to_string(const Protein & protein){ return ""; } template<> inline string to_string(const NucleicAcid & nucleicacid){ return ""; } template<> inline string to_string(const Lipid & lipid){ return ""; } template<> inline string to_string(const Solvent & solvent){ return ""; } template<> inline string to_string(const Molecules & molecules){ return ""; } template<> inline string to_string(const XMolecules & molecules){ return ""; } template<> inline string to_string(const PDBSegment & pdb){ return ""; } template<> inline string to_string(const MDB & mdb){ return ""; } template<> inline string to_string(const DSSPSecStruct & ){ return ""; } template<> inline string to_string(const AlmSecStruct & ){ return ""; } template<> inline string to_string(const MakeBetaPair & ){ return ""; } #define ALMTOSTRING(s) \ template<> \ inline string to_string(const s & ){ \ return "<" #s ">"; \ } ALMTOSTRING(Almost::BondRotation); ALMTOSTRING(Almost::NameSelection); template<> inline string to_string( const Coor3D & coor){ string str; str = "[ "; for(int i=0;i<3;i++){ str += to_string(coor[i]); if(i!=2) str +=", "; } str += " ]"; return str; } void prot2alm(const Protein & prot, string ofile){ ofstream file; file.open(ofile.c_str()); FormOStream fout(file); fout< mols_coor(const Molecules & molecules){ Coor coor; coor.resize(molecules.atom_size()); for(int i=0; i::DIM*i; coor.coor[pos] = molecules[i][0]; coor.coor[pos+1] = molecules[i][1]; coor.coor[pos+2] = molecules[i][2]; } return coor; } template inline string to_string(const Coor & ){ return ""; } ostream & operator<<(ostream & out,const Coor & ){ out<<""; return out; } template<> inline string to_string(const Coor & ){ return ""; } Coor mol_coor(const Molecules & m){ return Coor(m); } void check_bonds(const Molecules & molecules, const MDB & mdb){ vector bond_first_; vector bond_second_; vector b0__; for(int i=0;i bonds = molecules.bonds(i); string name1 = molecules[i].type_name(); for(int j=0;j2*b0__[i]){ cout<<"\t>> Bond "< inline string to_string(const MaxSub & ){ return ""; } namespace Almost { void maxsub(const Molecules & m1, const Molecules & m2, double d, double & rmsd, int & size){ MaxSub ms(m1,m2,d); rmsd = ms.rmsd(); size = ms.size(); } MaxSub maxsub_const(const Molecules & m1, double d){ return MaxSub(m1,d); } } Protein mutate(Protein & p,int aa, string f,MDB & mdb,string fp, string lp){ return p.mutate(aa,f,mdb,fp,lp); } void mol2psf(const Molecules & mol, MDB & mdb, string out_file){ ofstream out; out.open(out_file.c_str()); if(!out){ throw (">> Unable to open file: "+out_file).c_str(); } char buff[1024]; int nrem = 3; sprintf(buff,"PSF\n\n%8d !NTITLE\n",nrem); out< bonds; for(int i=0;i & b = mol.bonds(i); for(int j=0;j::iterator iter = bonds.begin(),end = bonds.end(); while(iter!=end){ if(count==4){ out<<"\n";count = 0;} sprintf(buff," %7d %7d",iter->first+1,iter->second+1); out< > angles; for(int i=0;i > aa = mol.protein(i).angles(); for(int a = 0; a > aa = mol.nucleicacid(i).angles(); for(int a = 0; a > aa = mol.lipid(i).angles(); for(int a = 0; a > aa = mol.solvent(i).angles(); for(int a = 0; a > dihedrals; for(int i=0;i > aa = mol.protein(i).dihedrals(); for(int a = 0; a > aa = mol.nucleicacid(i).dihedrals(); for(int a = 0; a > aa = mol.lipid(i).dihedrals(); for(int a = 0; a > aa = mol.solvent(i).dihedrals(); for(int a = 0; a > impropers; for(int i=0;i > aa = mol.protein(i).impropers(); for(int a = 0; a > aa = mol.nucleicacid(i).impropers(); for(int a = 0; a > aa = mol.lipid(i).impropers(); for(int a = 0; a > aa = mol.solvent(i).impropers(); for(int a = 0; a // string (Derived::*to_derived(string (Base::*f)() const))() const{ // return f; // } void init_molecules_types(ZModule & module){ init_atom_class(module); init_coor3d_class(module); init_protein_class(module); init_nucleicacid_class(module); init_lipid_class(module); typedef void (Coor::*p_copy)(const Coor &); Class >(module,"coor") .def_method("size",&Coor::size) .def_method("resize",&Coor::resize) .def_method("clear",&Coor::clear) .def_method("X",&Coor::X_coor) .def_method("Y",&Coor::Y_coor) .def_method("Z",&Coor::Z_coor) .def_method("copy",&Coor::copy); Class >(module,"maxsub") .def_method("rmsd",&MaxSub::rmsd) .def_method("size",&MaxSub::size) .def_method("alignment",&MaxSub::alignment) .def_method("score",&MaxSub::score) .def_method("apply_dcd",&MaxSub::apply_dcd) ; Class >(module,"solvent") // .def_method("name",&Solvent::name) // .def_method("set_name",&Solvent::set_name) .def_method("chainID",&Solvent::chainID) .def_method("set_chainID",&Solvent::set_chainID) .def_method("find_atom",&Solvent::find_atom) .def_method("build",&Solvent::build) .def_method("build_sequ",&Solvent::build_sequ) .def_method("translate",&Solvent::translate) .def_method("rotate",&Solvent::rotate) .def_method("cog",&Solvent::cog) .def_method("com",&Solvent::com) .def_method("name",&Solvent::name) .def_method("atom_size",&Solvent::atom_size) .def_doc("atom_size","Returns the number of atoms in the solvent.") ; Class(module,"molecules") .def_method("add_solvent",&Molecules::add_solvent) .def_doc("add_solvent","Adds the solvent to the molecules collection.") .def_method("add_lipid",&Molecules::add_lipid) .def_doc("add_lipid","Adds the lipids to the molecules collection.") .def_method("add_protein",&Molecules::add_protein) .def_doc("add_protein","Adds the protein to the molecules collection.") .def_method("add_nucleicacid",&Molecules::add_nucleicacid) .def_doc("add_nucleicacid","Adds the nucleicacid to the molecules collection.") .def_method("atom_size",&Molecules::atom_size) .def_doc("atom_size","Returns the number of atoms in the molecules collection.") .def_method("atom_name",&Molecules::atom_name) .def_doc("atom_name","Return the name of the atom with atom descriptor specified by the first parameter. The second sets the mode.") .def_method("fragment_size",&Molecules::fragment_size) .def_doc("fragment_size","Returns the number of fragments in the molecules collection.") .def_method("protein_size",&Molecules::protein_size) .def_doc("protein_size","Returns the number of proteins in the molecules collection.") .def_method("nucleicacid_size",&Molecules::nucleicacid_size) .def_doc("nucleicacid_size","Returns the number of nucleicacids in the molecules collection.") .def_method("lipid_size",&Molecules::lipid_size) .def_doc("lipid_size","Returns the number of lipids in the molecules collection.") .def_method("solvent_size",&Molecules::solvent_size) .def_doc("solvent_size","Returns the number of solvents in the molecules collection.") .def_method("protein",&Molecules::protein) .def_doc("protein","Returns a reference to the i-th protein.") .def_method("nucleicacid",&Molecules::nucleicacid) .def_doc("nucleicacid","Returns a reference to the i-th nucleicacid.") .def_method("lipid",&Molecules::lipid) .def_doc("lipid","Returns a reference to the i-th lipid.") .def_method("solvent",&Molecules::solvent) .def_doc("solvent","Returns a reference to the i-th solvent.") .def_method("charge",&Molecules::charge) .def_doc("charge","Returns the charge of the i-th atom.") .def_method("cog",&Molecules::cog) .def_method("com",&Molecules::com) .def_method("translate",&Molecules::translate) .def_method("sequence",&Molecules::sequence) .def_method("find_atom",&Molecules::find_atom) .def_method("find_fragment",&Molecules::find_fragment) .def_method("distance",&Molecules::distance) // .def_method("distanceP2",&Molecules::distanceP2) ; Class >(module,"xmolecules") .def_method("set",&XMolecules::set) .def_method("clear",&XMolecules::clear) .def_method("size",&XMolecules::size); ZObj::BinaryOperator::add_ifndef (index_operator); Class >(module,"dssp") .def_method("secstruct",&DSSPSecStruct::secstruc_hbonds) ; Class >(module,"almsecstruct") .def_method("secstruct",&AlmSecStruct::secstruct) .def_method("secstructf",&AlmSecStruct::secstructf) ; Class(module,"makebeta_pair") .def_method("apply",&MakeBetaPair::apply) .def_method("parallel",&MakeBetaPair::parallel) .def_method("up",&MakeBetaPair::up) .def_method("betabb",&MakeBetaPair::betabb) .def_method("offset",&MakeBetaPair::offset) .def_method("set_parallel",&MakeBetaPair::set_parallel) .def_method("set_up",&MakeBetaPair::set_up) .def_method("set_betabb",&MakeBetaPair::set_betabb) .def_method("set_offset",&MakeBetaPair::set_offset) ; } int f____(){ return ZType::type_id_+ZType::type_id_;} extern "C" { void init_molecules(){ typedef double (*d_fun_)(const Molecules & mols, const NameSelection & s); Module module("molecules","Build and modify molecules"); module.def_function("mols_coor","Return a Coor structure with the coordinates of the molecule.",mols_coor); init_molecules_types(module.self()); module.def_function("protein2alm","Prints the protein to the file specified in almost format.",prot2alm) .def_function("protein2pdb","Prints the protein to the file specified in PDB format.",prot2pdb) .def_function("solvent2alm","Prints the solvent to the file specified in almost format.",solv2alm) .def_function("solvent2pdb","Prints the solvent to the file specified in PDB format.",solv2pdb) .def_function("lipid2alm","Prints the lipid to the file specified in almost format.",lipid2alm) .def_function("lipid2pdb","Prints the lipid to the file specified in PDB format.",lipid2pdb) .def_function("nucleicacid2alm","Prints the na to the file specified in almost format.",na2alm) .def_function("nucleicacid2pdb","Prints the na to the file specified in PDB format.",na2pdb) .def_function("molecules2pdb","Prints the molecules to the file specified in PDB format.",mol2pdb) .def_function("boxsolvate","Creates a water box around a protein.",boxsolvate) .def_function("spheresolvate","Creates a water sphere around a protein.",spheresolvate) .def_function("molspheresolvate","Creates a water sphere around molecules.",molspheresolvate) .def_function("shellsolvate","Creates a water shell around a protein.",shellsolvate) .def_function("molshellsolvate","Creates a water shell around molecules.",molshellsolvate) .def_function("fit","Fits second molecules to first using selected atoms.",fit) .def_function("subfit","Fits second molecules to the first one using selection 1 and returns the rmsd computed on the atoms of selection 2.",subfit) .def_function("fit2","Fits second molecules to first using the two sets of selected atoms.",fit2) .def_function("mfit","Fits second molecules to fitrs using selected atoms and weighting each contribution with the atom mass.",mfit) .def_function("set_torsion","Sets torsion between desired atom to the specified value.",set_torsion) .def_function("set_torsion2","Sets torsion between desired atom to the specified value.",set_torsion2) .def_function("randomize_backbone","Randomizes backbone torsion angles.",randomize_backbone) .def_function("coordinate","Returns coordinates of the molecules",mol_coor) .def_function("ca_secstruct","Computes secondary structure using CA-atoms",secstruc_ca) .def_function("dssp_secstruct","Computes secondary structure using CA-atoms",secstruc_hbonds) .def_function("check_bonds","Checks bond lengths",check_bonds) .def_function("rmsd_prof","Compute amino-acid rmsd profile",rmsd_prof) .def_function("mutate","Wrapper",mutate) .def_function("ramarmsd","Computes mean distance on Ramachandram plot",ramarmsd) .def_function("rgyr","Computes radious of gyration of the selected atoms.",Almost::rgyr) .def_function("dot","Computed dot product",coor3D_scal) .def_function("auto_connect","Find bonded structire of molecules",auto_connect) .def_function("auto_connect_pdb","Find bonded structire of molecules",auto_connect_pdb) .def_function("maxsub_const","",Almost::maxsub_const) .def_function("render_tachyon","",Almost::render_tachyon) .def_function("find_clashes","",Almost::find_clashes) .def_function("psf","Writes charmm PSF (protein structure file).",mol2psf) .def_function("find_disu","Cpmputes the number of disulfide bonds with ditstance lower than the cutoff",Almost::find_disu) ; module .def_const("LONG",(int)Molecules::LONG) .def_const("SHORT",(int)Molecules::SHORT) .def_const("BASE",(int)Molecules::BASE) ; } }