00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041 #ifndef __MMDB_CoorMngr__
00042 #define __MMDB_CoorMngr__
00043
00044 #include "mmdb_root.h"
00045
00046 namespace mmdb {
00047
00048
00049
00050
00051 enum BRICK_STATE {
00052 BRICK_ON_1 = 0x00000001,
00053 BRICK_ON_2 = 0x00000002,
00054 BRICK_READY = 0x00000004
00055 };
00056
00057 DefineClass(Brick);
00058 typedef PPBrick * PPPBrick;
00059
00060 class Brick {
00061
00062 public :
00063 int nAtoms;
00064 PPAtom atom;
00065 ivector id;
00066
00067
00068 Brick ();
00069 ~Brick();
00070
00071 void Clear ();
00072 void AddAtom ( PAtom A, int atomid );
00073
00074 protected :
00075 int nAllocAtoms;
00076 void InitBrick();
00077
00078 };
00079
00080
00081
00082
00083
00084
00085 DefineClass(MBrick);
00086 typedef PPMBrick * PPPMBrick;
00087
00088 class MBrick {
00089
00090 public :
00091 ivector nAtoms;
00092 PPAtom *atom;
00093 imatrix id;
00094
00095
00096 MBrick ( int nStructures );
00097 ~MBrick();
00098
00099 void Clear ();
00100 void AddAtom ( PAtom A, int structNo, int atomid );
00101
00102 protected :
00103 ivector nAlloAtoms;
00104 int nStruct;
00105 void InitMBrick ( int nStructures );
00106
00107 };
00108
00109
00110
00111
00112
00113 DefineClass(GenSym);
00114 DefineStreamFunctions(GenSym);
00115
00116 class GenSym : public SymOps {
00117
00118 friend class CoorManager;
00119
00120 public :
00121
00122 GenSym ();
00123 GenSym ( io::RPStream Object );
00124 ~GenSym();
00125
00126 void FreeMemory();
00127
00128 int AddSymOp ( cpstr XYZOperation );
00129
00130
00131
00132 int AddRenChain ( int Nop, const ChainID ch1, const ChainID ch2 );
00133
00134 void Copy ( PSymOps genSym );
00135
00136 void write ( io::RFile f );
00137 void read ( io::RFile f );
00138
00139 protected :
00140
00141 PChainID * chID1;
00142 PChainID * chID2;
00143 ivector nChains;
00144
00145 void InitGenSym();
00146
00147 private :
00148 int nOpAlloc;
00149
00150 };
00151
00152
00153
00154
00155 DefineStructure(Contact);
00156
00157 struct Contact {
00158 int id1,id2;
00159 long group;
00160 realtype dist;
00161 void Copy ( RContact c );
00162 void Swap ( RContact c );
00163 };
00164
00165
00166
00167
00168 DefineClass(MContact);
00169
00170 class MContact : public io::Stream {
00171
00172 public :
00173 int nStruct,contactID;
00174 ivector nAtoms;
00175 PPAtom * atom;
00176 imatrix id;
00177
00178 MContact ( int nStructures );
00179 ~MContact();
00180
00181 void AddContact ( PAtom A, int structNo, int atomid );
00182
00183 protected:
00184 ivector nAlloc;
00185
00186 };
00187
00188 extern void DeleteMContacts ( PPMContact & mcontact, int nContacts );
00189
00190
00191
00192
00193 DefineClass(CoorManager);
00194 DefineStreamFunctions(CoorManager);
00195
00196
00197 enum CID_RC {
00198 CID_Ok = 0,
00199 CID_NoModel = 1,
00200 CID_NoChain = 2,
00201 CID_NoResidue = 3,
00202 CID_NoAtom = 4,
00203 CID_WrongPath = 5
00204 };
00205
00206
00207 enum GSM_RC {
00208 GSM_Ok = 0,
00209 GSM_NoSymOps = 1,
00210 GSM_NoTransfMatrices = 2,
00211 GSM_NoCell = 3
00212 };
00213
00214 class CoorManager : public Root {
00215
00216 public :
00217
00218 int CoorIDCode;
00219
00220 CoorManager ();
00221 CoorManager ( io::RPStream Object );
00222 ~CoorManager();
00223
00224
00225
00226
00227 int SetDefaultCoorID ( cpstr CID );
00228
00229
00230
00231
00232 void RemoveBricks ();
00233 bool areBricks () { return (brick!=NULL); }
00234 void MakeBricks ( PPAtom atmvec, int avlen,
00235 realtype Margin, realtype BrickSize=6.0 );
00236 void GetBrickDimension (
00237 int & nxmax, int & nymax, int & nzmax );
00238 void GetBrickCoor ( PAtom A, int & nx, int & ny, int & nz );
00239 void GetBrickCoor ( realtype x, realtype y, realtype z,
00240 int & nx, int & ny, int & nz );
00241 PBrick GetBrick ( int nx, int ny, int nz );
00242
00243 void RemoveMBricks ();
00244 bool areMBricks () { return (mbrick!=NULL); }
00245 void MakeMBricks ( PPAtom * atmvec, ivector avlen,
00246 int nStructures, realtype Margin,
00247 realtype BrickSize=6.0 );
00248 void GetMBrickDimension (
00249 int & nxmax, int & nymax, int & nzmax );
00250 void GetMBrickCoor ( PAtom A, int & nx, int & ny, int & nz );
00251 void GetMBrickCoor ( realtype x, realtype y, realtype z,
00252 int & nx, int & ny, int & nz );
00253 PMBrick GetMBrick ( int nx, int ny, int nz );
00254
00255
00256
00257 int GetNumberOfModels () { return nModels; }
00258 int GetFirstModelNum ();
00259 PModel GetFirstDefinedModel();
00260 PModel GetModel ( int modelNo );
00261 PModel GetModel ( cpstr CID );
00262 void GetModelTable ( PPModel & modTable,
00263 int & NumberOfModels );
00264
00265
00266
00267 int DeleteModel ( cpstr CID );
00268 int DeleteModel ( int modelNo );
00269
00270
00271
00272 int AddModel ( PModel mdl );
00273 int InsModel ( PModel mdl, int modelNo );
00274 void RotateModels ( int modelNo1, int modelNo2, int rotdir );
00275 void SwapModels ( int modelNo1, int modelNo2 );
00276
00277
00278
00279 int GetNumberOfChains ( int modelNo );
00280 int GetNumberOfChains ( cpstr CID );
00281 PChain GetChain ( int modelNo, const ChainID chainID );
00282 PChain GetChain ( int modelNo, int chainNo );
00283 PChain GetChain ( cpstr CID );
00284 void GetChainTable ( int modelNo, PPChain & chainTable,
00285 int & NumberOfChains );
00286 void GetChainTable ( cpstr CID, PPChain & chainTable,
00287 int & NumberOfChains );
00288
00289
00290
00291 int DeleteChain ( int modelNo, const ChainID chID );
00292 int DeleteChain ( int modelNo, int chainNo );
00293 int DeleteAllChains ( int modelNo );
00294 int DeleteAllChains ();
00295
00296
00297
00298 int AddChain ( int modelNo, PChain chain );
00299
00300
00301
00302 int GetNumberOfResidues ( int modelNo, const ChainID chainID );
00303 int GetNumberOfResidues ( int modelNo, int chainNo );
00304 int GetNumberOfResidues ( cpstr CID );
00305 PResidue GetResidue ( int modelNo, const ChainID chainID,
00306 int seqNo, const InsCode insCode );
00307 PResidue GetResidue ( int modelNo, int chainNo,
00308 int seqNo, const InsCode insCode );
00309 PResidue GetResidue ( int modelNo, const ChainID chainID,
00310 int resNo );
00311 PResidue GetResidue ( int modelNo, int chainNo, int resNo );
00312 PResidue GetResidue ( cpstr CID );
00313 int GetResidueNo ( int modelNo, const ChainID chainID,
00314 int seqNo, const InsCode insCode );
00315 int GetResidueNo ( int modelNo, int chainNo,
00316 int seqNo, const InsCode insCode );
00317 void GetResidueTable ( PPResidue & resTable,
00318 int & NumberOfResidues );
00319 void GetResidueTable ( int modelNo, const ChainID chainID,
00320 PPResidue & resTable,
00321 int & NumberOfResidues );
00322 void GetResidueTable ( int modelNo, int chainNo,
00323 PPResidue & resTable,
00324 int & NumberOfResidues );
00325 void GetResidueTable ( cpstr CID, PPResidue & resTable,
00326 int & NumberOfResidues );
00327
00328
00329
00330
00331 int DeleteResidue ( int modelNo, const ChainID chainID,
00332 int seqNo, const InsCode insCode );
00333 int DeleteResidue ( int modelNo, const ChainID chainID,
00334 int resNo );
00335 int DeleteResidue ( int modelNo, int chainNo,
00336 int seqNo, const InsCode insCode );
00337 int DeleteResidue ( int modelNo, int chainNo, int resNo );
00338 int DeleteAllResidues ( int modelNo, const ChainID chainID );
00339 int DeleteAllResidues ( int modelNo, int chainNo );
00340 int DeleteAllResidues ( int modelNo );
00341 int DeleteAllResidues ();
00342 int DeleteSolvent ();
00343
00344
00345
00346 int AddResidue ( int modelNo, const ChainID chainID,
00347 PResidue res );
00348 int AddResidue ( int modelNo, int chainNo, PResidue res );
00349
00350
00351
00352 int GetNumberOfAtoms () { return nAtoms; }
00353 int GetNumberOfAtoms ( int modelNo, const ChainID chainID,
00354 int seqNo, const InsCode insCode );
00355 int GetNumberOfAtoms ( int modelNo, int chainNo,
00356 int seqNo, const InsCode insCode );
00357 int GetNumberOfAtoms ( int modelNo, const ChainID chainID,
00358 int resNo );
00359 int GetNumberOfAtoms ( int modelNo, int chainNo, int resNo );
00360 int GetNumberOfAtoms ( cpstr CID );
00361
00362 PAtom GetAtom (
00363 int modelNo,
00364 const ChainID chID,
00365 int seqNo,
00366 const InsCode insCode,
00367 const AtomName aname,
00368 const Element elmnt,
00369 const AltLoc aloc
00370 );
00371
00372 PAtom GetAtom (
00373 int modelNo,
00374 const ChainID chID,
00375 int seqNo,
00376 const InsCode insCode,
00377 int atomNo
00378 );
00379
00380 PAtom GetAtom (
00381 int modelNo,
00382 const ChainID chID,
00383 int resNo,
00384 const AtomName aname,
00385 const Element elmnt,
00386 const AltLoc aloc
00387 );
00388
00389 PAtom GetAtom (
00390 int modelNo,
00391 const ChainID chID,
00392 int resNo,
00393 int atomNo
00394 );
00395
00396 PAtom GetAtom (
00397 int modelNo,
00398 int chNo,
00399 int seqNo,
00400 const InsCode insCode,
00401 const AtomName aname,
00402 const Element elmnt,
00403 const AltLoc aloc
00404 );
00405
00406 PAtom GetAtom (
00407 int modelNo,
00408 int chNo,
00409 int seqNo,
00410 const InsCode insCode,
00411 int atomNo
00412 );
00413
00414 PAtom GetAtom (
00415 int modelNo,
00416 int chNo,
00417 int resNo,
00418 const AtomName aname,
00419 const Element elmnt,
00420 const AltLoc aloc
00421 );
00422
00423 PAtom GetAtom (
00424 int modelNo,
00425 int chNo,
00426 int resNo,
00427 int atomNo
00428 );
00429
00430
00431
00432
00433
00434
00435
00436
00437
00438
00439
00440
00441
00442
00443
00444
00445
00446
00447
00448
00449
00450
00451
00452 PAtom GetAtom ( cpstr CID );
00453
00454
00455 void GetAtomTable ( PPAtom & atomTable, int & NumberOfAtoms );
00456 void GetAtomTable ( int modelNo, const ChainID chainID,
00457 int seqNo, const InsCode insCode,
00458 PPAtom & atomTable, int & NumberOfAtoms );
00459 void GetAtomTable ( int modelNo, int chainNo,
00460 int seqNo, const InsCode insCode,
00461 PPAtom & atomTable, int & NumberOfAtoms );
00462 void GetAtomTable ( int modelNo, const ChainID chainID, int resNo,
00463 PPAtom & atomTable, int & NumberOfAtoms );
00464 void GetAtomTable ( int modelNo, int chainNo, int resNo,
00465 PPAtom & atomTable, int & NumberOfAtoms );
00466 void GetAtomTable ( cpstr CID, PPAtom & atomTable,
00467 int & NumberOfAtoms );
00468
00469
00470
00471
00472
00473
00474
00475
00476
00477
00478
00479
00480 void GetAtomTable1 ( PPAtom & atomTable, int & NumberOfAtoms );
00481 void GetAtomTable1 ( int modelNo, const ChainID chainID,
00482 int seqNo, const InsCode insCode,
00483 PPAtom & atomTable, int & NumberOfAtoms );
00484 void GetAtomTable1 ( int modelNo, int chainNo,
00485 int seqNo, const InsCode insCode,
00486 PPAtom & atomTable, int & NumberOfAtoms );
00487 void GetAtomTable1 ( int modelNo, const ChainID chainID, int resNo,
00488 PPAtom & atomTable, int & NumberOfAtoms );
00489 void GetAtomTable1 ( int modelNo, int chainNo, int resNo,
00490 PPAtom & atomTable, int & NumberOfAtoms );
00491 void GetAtomTable1 ( cpstr CID, PPAtom & atomTable,
00492 int & NumberOfAtoms );
00493
00494
00495
00496
00497 int DeleteAtom ( int modelNo,
00498 const ChainID chID,
00499 int seqNo,
00500 const InsCode insCode,
00501 const AtomName aname,
00502 const Element elmnt,
00503 const AltLoc aloc );
00504 int DeleteAtom ( int modelNo,
00505 const ChainID chID,
00506 int seqNo,
00507 const InsCode insCode,
00508 int atomNo );
00509 int DeleteAtom ( int modelNo,
00510 const ChainID chID,
00511 int resNo,
00512 const AtomName aname,
00513 const Element elmnt,
00514 const AltLoc aloc );
00515 int DeleteAtom ( int modelNo, const ChainID chID,
00516 int resNo, int atomNo );
00517 int DeleteAtom ( int modelNo, int chNo, int seqNo,
00518 const InsCode insCode,
00519 const AtomName aname,
00520 const Element elmnt,
00521 const AltLoc aloc );
00522 int DeleteAtom ( int modelNo, int chNo, int seqNo,
00523 const InsCode insCode, int atomNo );
00524 int DeleteAtom ( int modelNo, int chNo, int resNo,
00525 const AtomName aname,
00526 const Element elmnt,
00527 const AltLoc aloc );
00528 int DeleteAtom ( int modelNo, int chNo, int resNo, int atomNo );
00529
00530 int DeleteAllAtoms ( int modelNo, const ChainID chID,
00531 int seqNo, const InsCode insCode );
00532 int DeleteAllAtoms ( int modelNo, const ChainID chID, int resNo );
00533 int DeleteAllAtoms ( int modelNo, const ChainID chID );
00534 int DeleteAllAtoms ( int modelNo, int chNo, int seqNo,
00535 const InsCode insCode );
00536 int DeleteAllAtoms ( int modelNo, int chNo, int resNo );
00537 int DeleteAllAtoms ( int modelNo, int chNo );
00538 int DeleteAllAtoms ( int modelNo );
00539 int DeleteAllAtoms ();
00540
00541
00542
00543
00544
00545
00546 int DeleteAltLocs ();
00547
00548
00549
00550
00551 int AddAtom ( int modelNo, const ChainID chID,
00552 int seqNo, const InsCode insCode, PAtom atom );
00553 int AddAtom ( int modelNo, const ChainID chID, int resNo,
00554 PAtom atom );
00555 int AddAtom ( int modelNo, int chNo, int seqNo,
00556 const InsCode insCode, PAtom atom );
00557 int AddAtom ( int modelNo, int chNo, int resNo, PAtom atom );
00558
00559
00560
00561
00562 int GenerateSymMates ( PGenSym genSym=NULL );
00563
00564
00565
00566
00567
00568 void ApplyTransform ( mat44 & TMatrix );
00569
00570
00571
00572 int BringToUnitCell();
00573
00574
00575
00576
00577
00578
00579
00580 bool Frac2Orth (
00581 realtype xfrac, realtype yfrac, realtype zfrac,
00582 realtype & xorth, realtype & yorth, realtype & zorth );
00583 bool Orth2Frac (
00584 realtype xorth, realtype yorth, realtype zorth,
00585 realtype & xfrac, realtype & yfrac, realtype & zfrac );
00586
00587
00588
00589
00590 bool Frac2Orth ( mat44 & F, mat44 & T );
00591 bool Orth2Frac ( mat44 & T, mat44 & F );
00592
00593
00594
00595 void SeekContacts (
00596 PPAtom AIndex,
00597 int ilen,
00598 int atomNum,
00599
00600
00601
00602 realtype dist1,
00603 realtype dist2,
00604 int seqDist,
00605
00606
00607
00608
00609
00610
00611
00612
00613
00614
00615
00616
00617
00618
00619 RPContact contact,
00620
00621
00622
00623
00624
00625 int & ncontacts,
00626
00627
00628
00629
00630
00631 int maxlen=0,
00632
00633
00634
00635
00636
00637
00638
00639
00640
00641
00642
00643 long group=0
00644
00645
00646
00647
00648 );
00649
00650 void SeekContacts (
00651 PAtom A,
00652 PPAtom AIndex,
00653
00654 int ilen,
00655 realtype dist1,
00656 realtype dist2,
00657 int seqDist,
00658
00659
00660
00661
00662
00663
00664
00665
00666
00667
00668
00669
00670
00671 RPContact contact,
00672
00673
00674
00675
00676 int & ncontacts,
00677
00678
00679
00680
00681 int maxlen=0,
00682
00683
00684
00685
00686
00687
00688
00689
00690
00691
00692
00693 long group=0
00694
00695
00696
00697
00698 );
00699
00700 void SeekContacts (
00701 PPAtom AIndex1,
00702 int ilen1,
00703 PPAtom AIndex2,
00704
00705 int ilen2,
00706 realtype dist1,
00707 realtype dist2,
00708 int seqDist,
00709
00710
00711
00712
00713
00714
00715
00716
00717
00718
00719
00720
00721
00722
00723 RPContact contact,
00724
00725
00726
00727
00728
00729
00730 int & ncontacts,
00731
00732
00733
00734
00735 int maxlen=0,
00736
00737
00738
00739
00740
00741
00742
00743
00744
00745
00746
00747 mat44 * TMatrix=NULL,
00748
00749 long group=0,
00750
00751
00752
00753
00754 int bricking=0,
00755
00756
00757 bool doSqrt=true
00758
00759 );
00760
00761
00762
00763
00764
00765
00766
00767
00768 void SeekContacts (
00769 PPAtom AIndex1,
00770 int ilen1,
00771 PPAtom AIndex2,
00772
00773 int ilen2,
00774 realtype contDist,
00775 PContact contact,
00776
00777
00778
00779
00780
00781
00782 int & ncontacts,
00783 int bricking=0
00784
00785
00786 );
00787
00788 void SeekContacts (
00789 PPAtom AIndex1,
00790 int ilen1,
00791 PPAtom * AIndex2,
00792
00793
00794
00795 ivector ilen2,
00796 int nStructures,
00797 realtype dist1,
00798 realtype dist2,
00799 PPMContact & contact,
00800
00801
00802
00803
00804
00805 int bricking=0
00806
00807
00808 );
00809
00810 protected :
00811
00812
00813 realtype brick_size, xbrick_0,ybrick_0,zbrick_0;
00814 int nbrick_x,nbrick_y,nbrick_z;
00815 PPPBrick * brick;
00816
00817 realtype mbrick_size, xmbrick_0,ymbrick_0,zmbrick_0;
00818 int nmbrick_x,nmbrick_y,nmbrick_z;
00819 PPPMBrick * mbrick;
00820
00821
00822 void write ( io::RFile f );
00823 void read ( io::RFile f );
00824
00825 void InitMMDBCoorManager();
00826
00827 void ApplySymTransform ( int SymMatrixNo, PGenSym genSym=NULL );
00828
00829 void ResetManager ();
00830
00831 void FindSeqSection ( PAtom atom, int seqDist,
00832 int & seq1, int & seq2 );
00833 bool iContact ( PAtom a1, PAtom a2,
00834 int seq1, int seq2,
00835 realtype dd, realtype d12,
00836 realtype d22, realtype & d2 );
00837 bool iContact ( realtype x, realtype y,
00838 realtype z, PAtom a2,
00839 realtype dd, realtype d12,
00840 realtype d22, realtype & d2 );
00841
00842 };
00843
00844
00845
00846
00847
00848
00849
00850
00851
00852
00853
00854
00855 extern void GetEulerRotMatrix ( mat33 & erm, realtype alpha,
00856 realtype beta, realtype gamma );
00857
00858
00859
00860
00861
00862
00863
00864 extern void GetEulerTMatrix ( mat44 & erm, realtype alpha,
00865 realtype beta, realtype gamma,
00866 realtype x0, realtype y0, realtype z0 );
00867
00868
00869
00870
00871
00872 extern void EulerRotation ( PPAtom A, int nA,
00873 realtype alpha, realtype beta, realtype gamma,
00874 realtype x0, realtype y0, realtype z0 );
00875
00876
00877
00878
00879 extern void GetVecRotMatrix ( mat33 & vrm, realtype alpha,
00880 realtype vx, realtype vy, realtype vz );
00881
00882
00883
00884
00885
00886
00887
00888
00889
00890
00891
00892 extern void GetRotParameters ( mat33 & vrm, realtype & alpha,
00893 realtype & vx, realtype & vy, realtype & vz );
00894
00895
00896
00897
00898
00899
00900
00901 extern void GetVecTMatrix ( mat44 & vrm, realtype alpha,
00902 realtype vx, realtype vy, realtype vz,
00903 realtype x0, realtype y0, realtype z0 );
00904
00905
00906
00907
00908
00909 extern void VectorRotation ( PPAtom A, int nA, realtype alpha,
00910 realtype vx, realtype vy, realtype vz,
00911 realtype x0, realtype y0, realtype z0 );
00912
00913 extern void GetMassCenter ( PPAtom A, int nA,
00914 realtype & xmc, realtype & ymc, realtype & zmc );
00915
00916
00917 enum SPOSEAT_RC {
00918 SPOSEAT_Ok = 0,
00919 SPOSEAT_NoAtoms = 1,
00920 SPOSEAT_SVD_Fail = 2
00921 };
00922
00923
00924
00925
00926
00927
00928
00929
00930
00931
00932
00933
00934 extern int SuperposeAtoms ( mat44 & T, PPAtom A1, int nA, PPAtom A2,
00935 ivector C=NULL );
00936
00937 enum CNSORT_DIR {
00938 CNSORT_OFF = 0,
00939 CNSORT_1INC = 1,
00940 CNSORT_1DEC = 2,
00941 CNSORT_2INC = 3,
00942 CNSORT_2DEC = 4,
00943 CNSORT_DINC = 5,
00944 CNSORT_DDEC = 6
00945 };
00946
00947 extern void SortContacts ( PContact contact, int ncontacts,
00948 CNSORT_DIR sortmode );
00949
00950
00951 extern const realtype NO_TORSION;
00952
00953 extern realtype getPhi ( PPAtom A );
00954 extern realtype getPsi ( PPAtom A );
00955
00956 }
00957
00958 #endif
00959