00001
00008 #if !defined(HAMOLSET_H)
00009 #define HAMOLSET_H
00010
00011 #include "hastl.h"
00012 #include "command.h"
00013 #include "haatgroup.h"
00014 #include "object3d.h"
00015
00016
00018 enum AtomParams {
00019 BACKBONE_CHRG = 0x0001,
00020 PROT_CHARGED_GROUPS_CHRG = 0x0002,
00021 ZERO_CHRG = 0x00010,
00022 AMBER_ALL_ATOM_CHRGS = 0x00020,
00023 AMBER_ALL_ATOM_FF_SYMBOLS = 0x0100,
00024 AMBER_ALL_ATOM_MASSES = 0x0200,
00025 ATOM_MASSES_ELEMENT = 0x400,
00026 ATOM_HBOND_DA_STATUS = 0x800
00027 };
00028
00029
00030 class HaMolecule;
00031 class HaAtom;
00032 class HaBond;
00033 class HaMat_double;
00034 class HaMolView;
00035 class HaQCMod;
00036 class ChemGroup;
00037 class HaCompMod;
00038 class ETCoupl;
00039 class HaDalton;
00040 class HaGaussian;
00041 class ElectrostMod;
00042 class HaInterMolMod;
00043 class HaMolMechMod;
00044 class HaScatterMod;
00045 class Object3D;
00046 class HaDisplayedSurface;
00047 class HaMolSetDoc;
00048 class StmMod;
00049 class NuclAcidMod;
00050
00051 class AtomIteratorMolSet;
00052 class AtomIteratorMolSet_const;
00053 class BondIteratorMolSet;
00054 class ResidueIteratorMolSet;
00055
00056
00059 class HaMolSet
00060 {
00061 friend class MolSetParDlg;
00062 public:
00064
00065 HaMolSet();
00066 HaMolSet(const HaString& new_name);
00067
00068 virtual ~HaMolSet();
00070
00071
00072 enum DEBUG_FLAG_PARAMS { file_reading_debug = 0x0001 };
00073 int debug_flag;
00075 bool Print_info(ostream &sout, const int level);
00076
00077
00079
00080
00081
00082 typedef BondIteratorMolSet BondIterator;
00083 typedef ResidueIteratorMolSet ResidueIterator;
00085
00086
00087 int ExecuteCommand(CmdParser& cmd_pr);
00088 int ExecuteShowCommand(CmdParser& cmd_pr);
00090
00091
00092 double OverlapMol(AtomList& fmolatset, AtomList& smolatset);
00093 double AlignOverlapMol(AtomList& fmolatset, HaMolecule* pMol2,
00094 PtrPtrMap* fit=NULL, HaVec_double* p_trans=NULL, HaMat_double* p_rot=NULL);
00095
00096
00097
00098 static int m_calc_bonds_flag;
00099 int m_unique_atom_names_flag;
00100
00101 int m_save_connect;
00102 int m_save_transform;
00103 int m_save_selected;
00104 HaString m_save_mol_name;
00105
00106 int FetchFile(int format, const char* file_name );
00107 bool LoadHarlemFile (const char* fname);
00108 int LoadAmberPrepFile(const char* fname);
00109 int LoadRWFMolecule (const char* fname);
00110 int LoadPDBFile(const char* fname, int flag=0);
00111 int LoadMol2File(const char* fname);
00112 int LoadMDLFile(const char* fname);
00113 int LoadXYZFile(const char* fname);
00114
00115 protected:
00116 void ProcessPDBAtom(int heta, IntPtrMap& id_at_map, HaMolecule* pMol);
00117
00118 public:
00119 enum MOL_SAVE_FLAG { SAVE_SELECTED = 0x0001, SAVE_AS_ONE_MOL = 0x0002,
00120 SAVE_TRANSFORMED = 0x0004 } save_flags;
00121
00122 int SavePDBFile(const char* filename );
00123 int SaveHarlemFile(const char* filename );
00124 int SaveXYZFile(const char* filename );
00125 int SaveXYZRadFile(const char* filename );
00126
00127
00129
00130 vector<HaMolecule*> HostMolecules;
00131
00132 HaMolecule* CreateMolecule();
00133 HaMolecule* GetFirstMolecule();
00134 HaMolecule* GetMoleculeNum(int imol);
00135
00136 void DeleteAll();
00137 bool DeleteMol(HaMolecule* pMol);
00138 bool DeleteAtomWithRef(const char* atref);
00139 bool DeleteAtom(HaAtom* aptr);
00140 bool DeleteAtoms(AtomCollection& atset);
00141
00142 int MergeMolecules(HaMolecule* pMol1, HaMolecule* pMol2);
00143
00144 int add_molset_copies(int nx, int ny, int nz);
00145
00146 int solvate();
00147 HaString solv_name;
00148 int solv_buffer_dist;
00149
00150 int place_to_orig();
00151
00152 HaMolecule* CreateTransAlk(const int nunit, const HaString name="ALK");
00153 HaMolecule* CreateSurf(const int num_layers, const HaString name="GOLD");
00154 bool Create2DMolArray(HaMolecule* pMol_ref,
00155 const double deltx, const double delty, const int nx, const int ny,
00156 const double alpha, const double tilt);
00157
00158
00159 void DeleteExtraAtoms();
00160 void AddMissingAtoms();
00161 void AddHydrogens();
00162 void AddPolarHydrogens();
00163
00164 void AddHydrogensHybrid();
00165
00166 bool AddElectrSurf(int add_surf_below_flag, int add_surf_top_flag, int add_atom_top_flag,
00167 int add_atom_below_flag);
00168
00169
00170 int SetBondDist(HaAtom* aptr1, HaAtom* aptr2, double new_dist);
00171 int SetAngle(HaAtom* aptr1, HaAtom* aptr2, HaAtom* aptr3, double ang_new);
00172 int SetTorsion(HaAtom* aptr1, HaAtom* aptr2, HaAtom* aptr3, HaAtom* aptr4, double tors_new);
00173
00175
00176
00177 int GetNMol() const;
00178 int GetNRes() const;
00179 int GetNChains() const;
00180 int GetNAtoms() const;
00181 int GetNBonds() const;
00182 int GetSeqNumOfAtom(const HaAtom* aptr) const;
00183
00184 double FindClosestContact(HaAtom* atc1,HaAtom* atc2);
00185
00186 HaResidue* GetResByRef(const char* res_ref);
00187 HaAtom* GetAtomByRef(const char* at_ref);
00188 bool GetAtomsByRef(const char* at_ref, AtomList& at_set);
00189 HaMolecule* GetMolByName(const char* mol_name);
00190
00191 bool GetMinMaxCrd(double& MinX_v, double& MinY_v, double& MinZ_v,
00192 double& MaxX_v, double& MaxY_v, double& MaxZ_v);
00193
00194 bool GetMinMaxCrdSelected(double& MinX_v, double& MinY_v, double& MinZ_v,
00195 double& MaxX_v, double& MaxY_v, double& MaxZ_v);
00196
00197 bool set_min_max;
00198
00200
00201
00202 void SelectAllAtoms();
00203 void UnSelectAllAtoms();
00204 void ReverseAtomSelection();
00205 void SelectOnly(AtomCollection* atom_coll);
00206 void SelectZone( int mask );
00207 void SelectZoneExpr( Expr* expr );
00208 void DisplaySelectCount();
00209
00210
00211
00212 int AreHBonded(HaAtom* src, HaAtom* dst) const;
00213 bool CalcHBonds(bool recalc=false);
00214 static int m_calc_s_hbonds_flag;
00215
00216
00218
00219 HaString spacegroup;
00220 double pbox_x, pbox_y, pbox_z;
00221 double pbox_alpha, pbox_beta, pbox_gamma;
00222
00223
00224
00225 void SetName(const char* new_name);
00226 const char* GetName();
00227 HaString GetUniqueMolName(const HaString suggest_name);
00228
00229 HaString name;
00230
00231
00232
00233 int GetNChemGroups() const;
00234 ChemGroup* AddBlankChemGroup(const HaString& gid = "" );
00235 bool DeleteChemGroup(const HaString& gid );
00236 bool DeleteChemGroupPtr( ChemGroup* grp_ptr );
00237 bool SetChemGrpSelected(const HaString& gid);
00238 ChemGroup& GetChemGroupByIdx(int index) ;
00239 ChemGroup* GetChemGroupByID(const HaString & gid);
00240
00241 ChemGroup* GetChemGroupByAtom(const HaAtom* aptr);
00242
00243 bool SetStdChemGroups();
00244 void RenumberGrp();
00245
00246 bool CheckUniqChemGrpID(const HaString& gid);
00247 HaString GetUniqChemGrpID(int buf_reg_flag);
00248
00249 list<ChemGroup> ChemGroups;
00250 VecPtr chemg_idx;
00251 typedef list<ChemGroup> ChemGroupsType;
00252
00254
00255
00256 AtomList* AddAtomList( const char* id = "");
00257 AtomList* GetAtomListByID( const char* id);
00258
00259 AtomList* SetAtomListFromSelection( const HaString& id);
00260
00261 list<AtomList> NamedAtomLists;
00262 typedef list<AtomList> NamedAtomListsType;
00263
00264 bool DeleteAtomList(const HaString& gid );
00265 bool DeleteAtomListPtr( AtomList* alist_ptr );
00266
00267
00269
00270 HaDisplayedSurface* CalcMolSurface();
00271 HaDisplayedSurface* CalcMolSurfDens();
00272
00273
00274
00275 void SetStdResPK();
00276 void SetStdResPK_G1();
00277 void CalcPKsForSelection();
00278 int CalcSCFPK(VecPtr& act_chem_st, HaMat_double& inter_mat);
00279 void SetAltStatesActive(int set_flag);
00280
00281 bool SetChargesForPH( double pH_val);
00282 bool SetChargesForCurrentPH();
00283 void SetPH(double new_ph);
00284 double GetPH() const;
00285
00286 double ph;
00287
00288
00289 public:
00291
00292 bool SetStdAtomicParams(const int at_params_type);
00293
00294 double CalculatePotential( double x, double y, double z );
00295
00296 bool CalcDipole();
00297 bool SetVdwRadii();
00298 bool SetParseRadii();
00299
00300 vector<MatPoint_double_map> ChargeMaps;
00301
00302 MatPoint_double_map* GetChargeMapByName(const char* map_name);
00303 MatPoint_double_map* CreateChargeMap(const char* map_name);
00304 int SetChargeMapByCurrentCharges(const char* map_name);
00305 int SetChargesFromChargeMap(MatPoint_double_map* charge_map);
00306
00307
00308
00309 HaMolSet* GetLastFragment();
00310 HaMolSet* set_fragment_selected(const char* frag_name);
00311 list<HaMolSet*> Fragments;
00313
00314
00315 HaQCMod* GetQCMod( const bool create_module = false);
00316 ETCoupl* GetETCouplMod( const bool create_module = false);
00317 HaGaussian* GetGaussMod( const bool create_module = false);
00318 HaDalton* GetDaltonMod( const bool create_module = false);
00319 ElectrostMod* GetElectrostMod( const bool create_module = false);
00320 HaInterMolMod* GetInterMolMod( const bool create_module = false);
00321 HaMolMechMod* GetMolMechMod( const bool create_module = false);
00322 HaScatterMod* GetScatterMod( const bool create_module = false);
00323 StmMod* GetSTMMod( const bool create_module = false);
00324 NuclAcidMod* GetNuclAcidMod( const bool create_module = false);
00325 HaCompMod* GetCompModule( const int mtype, const bool create_module = false);
00326
00327 void ResetETModule();
00328 list<HaCompMod*> CompModules;
00329
00330 public:
00332
00333 virtual int AnnounceGeomChange();
00334 void RefreshAllViews(long lHint = 0L);
00335 HaMolView* GetActiveMolView();
00336
00337 HaMolView* mset_pview;
00338 HaMolSetDoc* pmsetdoc;
00339
00340 bool AddObject3D(Object3D* new_view_object);
00341 bool DeleteObject3D(Object3D* pobj);
00342 bool DeleteObject3D(const HaString obj_name);
00343
00344 list<Object3D*> ViewObjects;
00345
00346 void ClearPickedAtoms();
00347 AtomList picked_atoms;
00348
00349 StrVec info_str;
00350
00351 };
00352
00353
00354
00355 typedef vector<HaMolecule*> MoleculesType;
00356
00357 class AtomIteratorMolSet
00359 {
00360 public:
00361 AtomIteratorMolSet(HaMolSet* new_pmset);
00362 virtual ~AtomIteratorMolSet();
00363
00364 HaAtom* GetFirstAtom();
00365 HaAtom* GetNextAtom();
00366
00367 protected:
00368 list<HaAtom>::iterator aitrm;
00369 MoleculesType::iterator mol_itr;
00370
00371 HaMolSet* pmset;
00372 };
00373
00374 class ResidueIteratorMolSet
00376 {
00377 public:
00378 ResidueIteratorMolSet(HaMolSet* new_pmset);
00379 virtual ~ResidueIteratorMolSet();
00380
00381 HaResidue* GetFirstRes();
00382 HaResidue* GetNextRes();
00383
00384 protected:
00385 Residues_type::iterator res_itr;
00386 list<HaChain>::iterator ch_itr;
00387 MoleculesType::iterator mol_itr;
00388
00389 HaMolSet* pmset;
00390 };
00391
00392 class ChemGroupIterator
00394 {
00395 public:
00396 ChemGroupIterator(HaMolSet* new_pmset);
00397 virtual ~ChemGroupIterator();
00398
00399 ChemGroup* GetFirst();
00400 ChemGroup* GetNext();
00401
00402 protected:
00403 list<ChemGroup>::iterator CurGroupItr;
00404 HaMolSet* pmset;
00405 };
00406
00407 class AtomListIteratorMolSet
00409 {
00410 public:
00411 AtomListIteratorMolSet(HaMolSet* new_pmset);
00412 virtual ~AtomListIteratorMolSet();
00413
00414 AtomList* GetFirst();
00415 AtomList* GetNext();
00416
00417 protected:
00418 list<AtomList>::iterator CurListItr;
00419 HaMolSet* pmset;
00420 };
00421
00422 class BondIteratorMolSet
00424 {
00425 public:
00426 BondIteratorMolSet(HaMolSet* new_pmset);
00427 virtual ~BondIteratorMolSet();
00428
00429 HaBond* GetFirstBond();
00430 HaBond* GetNextBond();
00431
00432 protected:
00433 set< HaBond,less<HaBond> >::iterator bitrm;
00434 MoleculesType::iterator mol_itr;
00435
00436 HaMolSet* pmset;
00437 };
00438
00439 class HBondIteratorMolSet
00441 {
00442 public:
00443 HBondIteratorMolSet(HaMolSet* new_pmset,int new_ssbond_flag = 0);
00444 virtual ~HBondIteratorMolSet();
00445
00446 HaHBond* GetFirstBond();
00447 HaHBond* GetNextBond();
00448
00449 int ssbond_flag;
00450 protected:
00451 set< HaHBond,less<HaHBond> >::iterator bitrm;
00452 MoleculesType::iterator mol_itr;
00453
00454
00455 HaMolSet* pmset;
00456 };
00457
00458
00459
00460 class AtomIteratorMolSet_const
00462 {
00463 public:
00464 AtomIteratorMolSet_const(const HaMolSet* new_pmset);
00465 virtual ~AtomIteratorMolSet_const();
00466
00467 const HaAtom* GetFirstAtom();
00468 const HaAtom* GetNextAtom();
00469
00470 protected:
00471 list<HaAtom>::const_iterator aitrm;
00472 MoleculesType::const_iterator mol_itr;
00473
00474 const HaMolSet* pmset;
00475 };
00476
00477
00478
00479 extern "C" {
00480 #if defined(HAMOLSET_CPP)
00481 HaMolSet* CurMolSet;
00482 HaMolSet* GetCurMolSet() { return CurMolSet; }
00483 #else
00484 extern HaMolSet* CurMolSet;
00485 extern HaMolSet* GetCurMolSet();
00486 #endif
00487 }
00488
00489 #define ForEachMolInSet for( mol_itr=HostMolecules.begin(); mol_itr != HostMolecules.end(); mol_itr++)
00490
00491 #define ForEachResidueInSet for( mol_itr=HostMolecules.begin(); mol_itr != HostMolecules.end(); mol_itr++) \
00492 for( chain= (*mol_itr)->GetFirstChain();chain; chain= (*mol_itr)->GetNextChain()) \
00493 for( group=chain->GetFirstRes(); group; group=chain->GetNextRes() )
00494
00495 #define ForEachChainInSet for( mol_itr=HostMolecules.begin(); mol_itr != HostMolecules.end(); mol_itr++) \
00496 for( chain= (*mol_itr)->GetFirstChain();chain; chain= (*mol_itr)->GetNextChain())
00497
00498 #define ForEachChainInMolInSet for( chain= (*mol_itr)->GetFirstChain();chain; chain= (*mol_itr)->GetNextChain())
00499
00500
00501 #endif // end !defined(HARLEM_MFC_DOC_H)