BALL  1.4.1
sdGenerator.h
Go to the documentation of this file.
00001 // -*- Mode: C++; tab-width: 2; -*-
00002 // vi: set ts=2:
00003 //
00004 
00005 #ifndef BALL_STRUCTURE_SDGENERATOR_H
00006 #define BALL_STRUCTURE_SDGENERATOR_H
00007 
00008 #ifndef BALL_DATATYPE_OPTIONS_H
00009 # include <BALL/DATATYPE/options.h>
00010 #endif
00011 
00012 #ifndef BALL_STRUCTURE_RINGANALYSER_H
00013 # include <BALL/STRUCTURE/ringAnalyser.h>
00014 #endif
00015 
00016 #ifndef BALL_KERNEL_PDBATOM_H
00017 # include <BALL/KERNEL/PDBAtom.h>
00018 #endif
00019 
00020 #include <vector>
00021 #include <queue>
00022 
00023 namespace BALL
00024 {
00025   class System;
00026   class Atom;
00027 
00033   class BALL_EXPORT SDGenerator
00034   {
00035     public:
00036     
00040       enum Property
00041       {
00042         FIRST_SDGENERATOR_PROPERTY = PDBAtom::NUMBER_OF_PROPERTIES+1,
00043         IN_RING,
00044         CORE_CHAIN,
00045         DEPOSITED,
00046         FXAS,
00047         EQAS,
00048         HEAD,
00049         EDGE,
00050         ASSEMBLED,
00051         ZIG,
00052         ZAG,
00053         INITIALIZED_HEAD_CFS,
00054         LAST_SDGENERATOR_PROPERTY
00055       };
00056 
00060 
00061       struct BALL_EXPORT Option
00062       { 
00065         static const char* SHOW_HYDROGENS;
00066 
00070         static const char* STANDARD_BOND_LENGTH;
00071       };
00072 
00074       struct BALL_EXPORT Default
00075       {
00076         static const bool SHOW_HYDROGENS;
00077 
00078         static const float STANDARD_BOND_LENGTH;
00079       };
00081       
00085 
00089       SDGenerator(bool show_hydrogens = false);
00090 
00094       virtual ~SDGenerator();
00096 
00100 
00101       Options options;
00103 
00109       void setDefaultOptions();
00111 
00116       void generateSD(System& molecule_sys);
00117 
00121       void clear();
00122 
00123     protected:
00124       
00127       class AtomComparator
00128       {
00129         public:
00130           bool operator() (Atom const* first, Atom const* second) const
00131           {
00132             Size first_value  =  first->getProperty("SDGenerator::PRIORITY").getUnsignedInt();
00133             Size second_value = second->getProperty("SDGenerator::PRIORITY").getUnsignedInt();
00134 
00135             return first_value < second_value;
00136           }
00137       };
00138 
00143       void prepare_();
00144 
00149       void constructRingSystem_(Position current_ring_system);
00150 
00151       // Obtain the CFS from the properties of the atom...
00152       Angle getCFS_(Atom const* atom, bool hi);
00153 
00154       // Convert a vector into the corresponding CFS angle
00155       Angle computeCFS_(Vector3 const& input);
00156 
00157       // store the CFS for an atom
00158       void setCFS_(Atom* atom, Angle cfs, bool high);
00159 
00160       // push the CFS before it is overwritten
00161       void pushCFS_(Atom* atom);
00162 
00163       // retrieve backup CVS values
00164       Angle getBackupCFS_(Atom const*, bool hi);
00165 
00166       //  Compute the CFS values for a full regular polygon
00167       void computeCoreCFS_(RingAnalyser::Ring& ring, bool clockwise);
00168 
00169       //
00170       Angle computeAngularSeparation_(Atom* seed);
00171 
00172       //
00173       Angle computeAngularDemand_(Atom* seed);
00174 
00175       //
00176       std::vector<Atom*> sequenceSubstituents_(Atom* seed);
00177 
00180       void computeShelleyPriorities_();
00181 
00184       void buildRegularPolygon_(RingAnalyser::Ring& ring, Position first_anchor_index, bool clockwise);
00185 
00188       void buildOpenPolygon_(RingAnalyser::Ring& ring, Position first_anchor_index, Position second_anchor_index);
00189 
00196       void attachCore_(Position current_ring, std::vector<RingAnalyser::Ring>& current_system, float x_start);
00197 
00203       void attachTemplate_(Position current_ring, std::vector<RingAnalyser::Ring>& current_system);
00204 
00210       void attachFused_(Position current_ring, std::vector<RingAnalyser::Ring>& current_system);
00211 
00217       void attachBridged_(Position current_ring, std::vector<RingAnalyser::Ring>& current_system);
00218 
00224       void attachSpiro_(Position current_ring, std::vector<RingAnalyser::Ring>& current_system);
00225 
00227       void computeAdjacencyMatrix_(std::vector<Atom*>& chain, std::vector<bool>& result);
00228 
00230       static bool compareChains_(const vector<Atom*>& x, const vector<Atom*>& y);
00231 
00235       void treatChains_();
00236 
00237       //
00238       void smoothCFSAngle_(Atom* seed);
00239 
00240       //
00241       void placeSubstituent_(Atom* seed, Atom* head, Atom* next);
00242 
00243       //
00244       void depositPFU_(Atom* seed_atom, Atom* next_neighbour);
00245 
00246       //
00247       void checkOverlap_(Atom* atom);
00248 
00249       //Check whether the ring is clockwise or not
00250       bool ringIsClockwise_(const RingAnalyser::Ring& ring, Index start_index = 0) const;
00251 
00255       void assembleSD_();
00256 
00257       // The backtracking for our Floyd-Warshall implementation
00258       void findFloydWarshallPath_(std::vector<int>& path, std::vector<Index>& next, Size remaining_atoms, Position i, Position j, std::list<Index>& output);
00259 
00261       RingAnalyser ring_analyser_;
00262 
00264       std::list<std::list<Atom*> > chains_;
00265 
00267       std::priority_queue<Atom*, std::vector<Atom*>, AtomComparator> redraw_queue_;
00268 
00270       System* system_;
00271   };
00272 
00273 } // namepspace BALL
00274 
00275 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines