minimol.h

Go to the documentation of this file.
00001 
00004 //C Copyright (C) 2000-2006 Kevin Cowtan and University of York
00005 //L
00006 //L  This library is free software and is distributed under the terms
00007 //L  and conditions of version 2.1 of the GNU Lesser General Public
00008 //L  Licence (LGPL) with the following additional clause:
00009 //L
00010 //L     `You may also combine or link a "work that uses the Library" to
00011 //L     produce a work containing portions of the Library, and distribute
00012 //L     that work under terms of your choice, provided that you give
00013 //L     prominent notice with each copy of the work that the specified
00014 //L     version of the Library is used in it, and that you include or
00015 //L     provide public access to the complete corresponding
00016 //L     machine-readable source code for the Library including whatever
00017 //L     changes were used in the work. (i.e. If you make changes to the
00018 //L     Library you must distribute those, but you do not need to
00019 //L     distribute source or object code to those portions of the work
00020 //L     not covered by this licence.)'
00021 //L
00022 //L  Note that this clause grants an additional right and does not impose
00023 //L  any additional restriction, and so does not affect compatibility
00024 //L  with the GNU General Public Licence (GPL). If you wish to negotiate
00025 //L  other terms, please contact the maintainer.
00026 //L
00027 //L  You can redistribute it and/or modify the library under the terms of
00028 //L  the GNU Lesser General Public License as published by the Free Software
00029 //L  Foundation; either version 2.1 of the License, or (at your option) any
00030 //L  later version.
00031 //L
00032 //L  This library is distributed in the hope that it will be useful, but
00033 //L  WITHOUT ANY WARRANTY; without even the implied warranty of
00034 //L  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00035 //L  Lesser General Public License for more details.
00036 //L
00037 //L  You should have received a copy of the CCP4 licence and/or GNU
00038 //L  Lesser General Public License along with this library; if not, write
00039 //L  to the CCP4 Secretary, Daresbury Laboratory, Warrington WA4 4AD, UK.
00040 //L  The GNU Lesser General Public can also be obtained by writing to the
00041 //L  Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
00042 //L  MA 02111-1307 USA
00043 
00044 
00045 #ifndef CLIPPER_MINIMOL
00046 #define CLIPPER_MINIMOL
00047 
00048 
00049 #include "../core/coords.h"
00050 #include "minimol_data.h"
00051 
00052 
00053 namespace clipper {
00054 
00056   namespace MM {
00057     enum MODE { UNIQUE, ANY };
00058     enum COPY { COPY_NONE, COPY_M, COPY_P, COPY_MP, COPY_C, COPY_MC, COPY_PC, COPY_MPC, MEMBERS=COPY_M, PROPERTIES=COPY_P, CHILDREN=COPY_C };
00059   }
00060 
00061 
00063 
00076   class MAtom : public Atom, public PropertyManager
00077   {
00078   public:
00079     MAtom() {}  
00080     MAtom( const clipper::Atom& atom );  
00081 
00083     const String& id() const { return id_; }
00084     void set_id( const String& s );      
00085 
00087     String name() const { return id_.substr(0,4); }
00088     void set_name( const String s, const String altconf="" );  
00089 
00090     //-- const String& element() const;  //!< get element e.g. H, C, Zn2+
00091     //-- const Coord_orth& coord_orth() const;      //!< get orth coordinate
00092     //-- const ftype& occupancy() const;            //!< get occupancy
00093     //-- const ftype& u_iso() const;                //!< get isotropic U
00094     //-- const U_aniso_orth& u_aniso_orth() const;  //!< get anisotropic U
00095     //-- void set_element( const String& s );             //!< set element
00096     //-- void set_coord_orth( const Coord_orth& s );      //!< set coord_orth
00097     //-- void set_occupancy( const ftype& s );            //!< set occupancy
00098     //-- void set_u_iso( const ftype& s );                //!< set u_iso
00099     //-- void set_u_aniso_orth( const U_aniso_orth& s );  //!< set u_aniso
00100     //-- void transform( const RTop_orth rt );  //!< apply transform to object
00101     const Atom& atom() const { return *this; }  
00102     Atom& atom() { return *this; }              
00103 
00105     MAtom& copy( const MAtom& other, const MM::COPY& mode );
00106 
00107     static String id_tidy( const String& id );  
00108     static bool id_match( const String& id1, const String& id2, const MM::MODE& mode );  
00109   private:
00110     String id_;
00111   };
00112 
00114 
00129   class MMonomer : public PropertyManager
00130   {
00131   public:
00132     const String& id() const { return id_; }  
00133     void set_id( const String& s );           
00134 
00135     const String& type() const { return type_; }   
00136     void set_type( const String& s );  
00137 
00138     int seqnum() const { return id_.i(); }  
00139     void set_seqnum( const int s, const String inscode="" ); 
00140 
00141     // the following methods are similar for all levels of the hierarchy
00142     Atom_list atom_list() const;           
00143     void transform( const RTop_orth rt );  
00144 
00145     int size() const { return children.size(); }
00147     const MAtom& operator[] ( const int& i ) const { return children[i]; }
00149     MAtom& operator[] ( const int& i ) { return children[i]; }
00151     const MAtom& find( const String& n, const MM::MODE mode=MM::UNIQUE ) const;
00153     MAtom& find( const String& n, const MM::MODE mode=MM::UNIQUE );
00155     MMonomer select( const String& sel, const MM::MODE mode=MM::UNIQUE ) const;
00157     int lookup( const String& str, const MM::MODE& mode ) const;
00158     void insert( const MAtom& add, int pos=-1 );  
00159 
00161     friend MMonomer operator& ( const MMonomer& m1, const MMonomer& m2 );
00163     friend MMonomer operator| ( const MMonomer& m1, const MMonomer& m2 );
00164 
00166     MMonomer& copy( const MMonomer& other, const MM::COPY& mode );
00167 
00168     static String id_tidy( const String& id );  
00169     static bool id_match( const String& id1, const String& id2, const MM::MODE& mode );  
00170 
00172     enum TYPE { Default, Dunbrack, Richardson };
00174     void protein_mainchain_build_carbonyl_oxygen( const MMonomer& next );
00176     int protein_sidechain_number_of_rotamers( TYPE t = default_type_ ) const;
00177     int protein_sidechain_number_of_rotomers() const { return protein_sidechain_number_of_rotamers(); }
00179     ftype protein_sidechain_build_rotamer( const int& n, TYPE t = default_type_ );
00180     ftype protein_sidechain_build_rotomer( const int& n ) { return protein_sidechain_build_rotamer( n ); }
00182     static bool protein_peptide_bond( const MMonomer& m1, const MMonomer& m2, ftype r = 1.5 );
00184     static double protein_ramachandran_phi( const MMonomer& m1, const MMonomer& m2 );
00186     static double protein_ramachandran_psi( const MMonomer& m1, const MMonomer& m2 );
00187 
00188     static TYPE& default_type() { return default_type_; }
00189   private:
00190     typedef MAtom CHILDTYPE;
00191     std::vector<CHILDTYPE> children;
00192     String id_, type_;
00193     static TYPE default_type_;
00194     static int rotamer_find( String res, int rota, TYPE t );
00195   };
00196 
00198 
00211   class MPolymer : public PropertyManager
00212   {
00213   public:
00214     const String& id() const { return id_; }  
00215     void set_id( const String& s );           
00216 
00217     // the following methods are similar for all levels of the hierarchy
00218     Atom_list atom_list() const;           
00219     void transform( const RTop_orth rt );  
00220 
00221     int size() const { return children.size(); }
00223     const MMonomer& operator[] ( const int& i ) const { return children[i]; }
00225     MMonomer& operator[] ( const int& i ) { return children[i]; }
00227     const MMonomer& find( const String& n, const MM::MODE mode=MM::UNIQUE ) const;
00229     MMonomer& find( const String& n, const MM::MODE mode=MM::UNIQUE );
00231     MPolymer select( const String& sel, const MM::MODE mode=MM::UNIQUE ) const;
00233     int lookup( const String& str, const MM::MODE& mode ) const;
00234     void insert( const MMonomer& add, int pos=-1 );  
00235 
00237     friend MPolymer operator& ( const MPolymer& m1, const MPolymer& m2 );
00239     friend MPolymer operator| ( const MPolymer& m1, const MPolymer& m2 );
00240 
00242     MPolymer& copy( const MPolymer& other, const MM::COPY& mode );
00243 
00244     static String id_tidy( const String& id );  
00245     static bool id_match( const String& id1, const String& id2, const MM::MODE& mode );  
00246   private:
00247     typedef MMonomer CHILDTYPE;
00248     std::vector<CHILDTYPE> children;
00249     String id_;
00250   };
00251 
00253 
00263   class MModel : public PropertyManager
00264   {
00265   public:
00266     // the following methods are similar for all levels of the hierarchy
00267     Atom_list atom_list() const;           
00268     void transform( const RTop_orth rt );  
00269 
00270     int size() const { return children.size(); }
00272     const MPolymer& operator[] ( const int& i ) const { return children[i]; }
00274     MPolymer& operator[] ( const int& i ) { return children[i]; }
00276     const MPolymer& find( const String& n, const MM::MODE mode=MM::UNIQUE ) const;
00278     MPolymer& find( const String& n, const MM::MODE mode=MM::UNIQUE );
00280     MModel select( const String& sel, const MM::MODE mode=MM::UNIQUE ) const;
00282     int lookup( const String& str, const MM::MODE& mode ) const;
00283     void insert( const MPolymer& add, int pos=-1 );  
00284 
00286     friend MModel operator& ( const MModel& m1, const MModel& m2 );
00288     friend MModel operator| ( const MModel& m1, const MModel& m2 );
00289 
00291     MModel& copy( const MModel& other, const MM::COPY& mode );
00292   private:
00293     typedef MPolymer CHILDTYPE;
00294     std::vector<CHILDTYPE> children;
00295   };
00296 
00298 
00304   class MiniMol : public MModel
00305   {
00306   public:
00307     enum MODE { UNIQUE, ANY };  
00308 
00310     MiniMol();
00312     MiniMol( const Spacegroup& spacegroup, const Cell& cell );
00314     void init( const Spacegroup& spacegroup, const Cell& cell );
00316     const Cell& cell() const { return cell_; }
00318     const Spacegroup& spacegroup() const { return spacegroup_; }
00319     const MModel& model() const { return *this; }  
00320     MModel& model() { return *this; }              
00321 
00322     bool is_null() const;  
00323   private:
00324     Spacegroup spacegroup_;
00325     Cell cell_;
00326   };
00327 
00329   typedef MMonomer MResidue;
00330 
00332   typedef MPolymer MChain;
00333 
00334 
00335 } // namespace clipper
00336 
00337 #endif
00338 

Generated on 4 Jan 2010 for Clipper_minimol by  doxygen 1.6.1