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
00042
00043 #ifndef __MMDB_Atom__
00044 #define __MMDB_Atom__
00045
00046 #include "mmdb_io_stream.h"
00047 #include "mmdb_uddata.h"
00048 #include "mmdb_utils.h"
00049 #include "mmdb_defs.h"
00050
00051
00052 namespace mmdb {
00053
00054
00055
00056
00057 enum ASET_FLAG {
00058 ASET_Coordinates = 0x00000001,
00059 ASET_Occupancy = 0x00000002,
00060 ASET_tempFactor = 0x00000004,
00061 ASET_CoordSigma = 0x00000010,
00062 ASET_OccSigma = 0x00000020,
00063 ASET_tFacSigma = 0x00000040,
00064 ASET_Anis_tFac = 0x00000100,
00065 ASET_Anis_tFSigma = 0x00001000,
00066 ASET_Charge = 0x00000080,
00067 ASET_All = 0x000FFFFF
00068 };
00069
00070 const int ATOM_NoSeqNum = MinInt4;
00071
00072 extern bool ignoreSegID;
00073 extern bool ignoreElement;
00074 extern bool ignoreCharge;
00075 extern bool ignoreNonCoorPDBErrors;
00076 extern bool ignoreUnmatch;
00077
00078
00079 DefineStructure(AtomStat);
00080
00081 struct AtomStat {
00082
00083 public :
00084 int nAtoms;
00085
00086 realtype xmin,ymin,zmin;
00087 realtype xmax,ymax,zmax;
00088 realtype xm ,ym ,zm;
00089 realtype xm2 ,ym2 ,zm2;
00090
00091 realtype occ_min,occ_max;
00092 realtype occ_m ,occ_m2;
00093
00094 realtype tFmin,tFmax;
00095 realtype tFm ,tFm2;
00096
00097 realtype u11_min,u11_max;
00098 realtype u22_min,u22_max;
00099 realtype u33_min,u33_max;
00100 realtype u12_min,u12_max;
00101 realtype u13_min,u13_max;
00102 realtype u23_min,u23_max;
00103
00104 realtype u11_m,u11_m2;
00105 realtype u22_m,u22_m2;
00106 realtype u33_m,u33_m2;
00107 realtype u12_m,u12_m2;
00108 realtype u13_m,u13_m2;
00109 realtype u23_m,u23_m2;
00110
00111 word WhatIsSet;
00112
00113 void Init ();
00114 void Finish();
00115
00116 realtype GetMaxSize();
00117
00118 private :
00119 bool finished;
00120
00121 };
00122
00123
00124 DefineStructure(AtomBondI);
00125
00126 struct AtomBondI {
00127 int index;
00128 byte order;
00129 };
00130
00131
00132 DefineStructure(AtomBond);
00133
00134 struct AtomBond {
00135 PAtom atom;
00136 byte order;
00137 };
00138
00139
00140 DefineFactoryFunctions(Atom);
00141
00142 class Atom : public UDData {
00143
00144 friend class Residue;
00145 friend class Model;
00146 friend class Root;
00147 friend class CoorManager;
00148 friend class SelManager;
00149
00150 public :
00151 int serNum;
00152 AtomName name;
00153 AtomName label_atom_id;
00154 AltLoc altLoc;
00155 SegID segID;
00156 Element element;
00157 EnergyType energyType;
00158 PResidue residue;
00159 realtype x,y,z;
00160 realtype occupancy;
00161 realtype tempFactor;
00162 realtype charge;
00163 realtype sigX,sigY,sigZ;
00164 realtype sigOcc;
00165 realtype sigTemp;
00166 realtype u11,u22,u33;
00167 realtype u12,u13,u23;
00168 realtype su11,su22,su33;
00169 realtype su12,su13,su23;
00170 bool Het;
00171 bool Ter;
00172
00173 word WhatIsSet;
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183 Atom ();
00184 Atom ( PResidue res );
00185 Atom ( io::RPStream Object );
00186 ~Atom();
00187
00188 void SetResidue ( PResidue res );
00189 void PDBASCIIDump ( io::RFile f );
00190 void MakeCIF ( mmcif::PData CIF );
00191
00192
00193
00194
00195
00196
00197
00198
00199 int AddBond ( PAtom bond_atom, int bond_order,
00200 int nAdd_bonds=1 );
00201 int GetNBonds();
00202
00203
00204
00205 void GetBonds ( RPAtomBond atomBond, int & nAtomBonds );
00206 void FreeBonds();
00207
00208
00209
00210
00211 void GetBonds ( RPAtomBondI atomBondI, int & nAtomBonds );
00212
00213
00214
00215
00216 void GetBonds ( PAtomBondI atomBondI, int & nAtomBonds,
00217 int maxlength );
00218
00219
00220
00221
00222
00223
00224
00225
00226
00227
00228
00229 ERROR_CODE ConvertPDBATOM ( int ix, cpstr S );
00230 ERROR_CODE ConvertPDBSIGATM ( int ix, cpstr S );
00231 ERROR_CODE ConvertPDBANISOU ( int ix, cpstr S );
00232 ERROR_CODE ConvertPDBSIGUIJ ( int ix, cpstr S );
00233 ERROR_CODE ConvertPDBTER ( int ix, cpstr S );
00234 ERROR_CODE ConvertPDBHETATM ( int ix, cpstr S );
00235
00236 ERROR_CODE GetCIF ( int ix, mmcif::PLoop Loop,
00237 mmcif::PLoop LoopAnis );
00238
00239 bool RestoreElementName();
00240 bool MakePDBAtomName();
00241
00242 void SetAtomName ( int ix,
00243 int sN,
00244 const AtomName aName,
00245 const AltLoc aLoc,
00246 const SegID sID,
00247 const Element eName );
00248
00249
00250 void SetAtomName ( const AtomName atomName );
00251 void SetElementName ( const Element elName );
00252 void SetCharge ( cpstr chrg );
00253 void SetCharge ( realtype chrg );
00254
00255 void SetAtomIndex ( int ix );
00256
00257 void MakeTer();
00258
00259 void SetCoordinates ( realtype xx, realtype yy, realtype zz,
00260 realtype occ, realtype tFac );
00261
00262 int GetModelNum ();
00263 pstr GetChainID ();
00264 pstr GetLabelAsymID ();
00265 pstr GetResName ();
00266 pstr GetLabelCompID ();
00267 int GetAASimilarity ( const ResName resName );
00268 int GetAASimilarity ( PAtom A );
00269 realtype GetAAHydropathy();
00270 realtype GetOccupancy ();
00271 int GetSeqNum ();
00272 int GetLabelSeqID ();
00273 int GetLabelEntityID ();
00274 pstr GetInsCode ();
00275 int GetSSEType ();
00276 pstr GetAtomName () { return name; }
00277 pstr GetElementName () { return element; }
00278 pstr GetAtomCharge ( pstr chrg );
00279
00280
00281
00282
00283
00284
00285
00286
00287
00288
00289
00290
00291
00292
00293
00294
00295 void GetChainCalphas ( PPAtom & Calphas, int & nCalphas,
00296 cpstr altLoc = "" );
00297
00298 bool isTer () { return Ter; }
00299 bool isMetal ();
00300 bool isSolvent ();
00301 bool isInSelection ( int selHnd );
00302 bool isNTerminus ();
00303 bool isCTerminus ();
00304
00305 void CalAtomStatistics ( RAtomStat AS );
00306
00307 realtype GetDist2 ( PAtom a );
00308 realtype GetDist2 ( PAtom a, mat44 & tm );
00309 realtype GetDist2 ( PAtom a, mat33 & r, vect3 & t );
00310 realtype GetDist2 ( realtype ax, realtype ay, realtype az );
00311
00312
00313
00314 realtype GetCosine ( PAtom a1, PAtom a2 );
00315
00316 PResidue GetResidue ();
00317 PChain GetChain ();
00318 PModel GetModel ();
00319 int GetResidueNo();
00320 void * GetCoordHierarchy();
00321
00322
00323
00324
00325
00326
00327
00328
00329
00330
00331
00332
00333
00334
00335
00336
00337 pstr GetAtomID ( pstr AtomID );
00338
00339 pstr GetAtomIDfmt ( pstr AtomID );
00340
00341
00342
00343
00344
00345
00346
00347
00348
00349
00350
00351
00352
00353
00354
00355
00356
00357
00358
00359
00360
00361
00362
00363
00364 int CheckID ( const AtomName aname, const Element elname=NULL,
00365 const AltLoc aloc=pstr("") );
00366
00367
00368
00369
00370
00371
00372
00373
00374
00375
00376
00377
00378
00379
00380
00381
00382
00383
00384
00385
00386
00387
00388
00389
00390
00391 int CheckIDS ( cpstr ID );
00392
00393
00394
00395 void Transform ( mat33 & tm, vect3 & v );
00396 void Transform ( mat44 & tm );
00397 void TransformCopy ( mat44 & tm,
00398 realtype & xx, realtype & yy, realtype & zz );
00399 void TransformSet ( mat44 & tm,
00400 realtype xx, realtype yy, realtype zz );
00401
00402
00403
00404 int PutUDData ( int UDDhandle, int iudd );
00405 int PutUDData ( int UDDhandle, realtype rudd );
00406 int PutUDData ( int UDDhandle, cpstr sudd );
00407
00408 int GetUDData ( int UDDhandle, int & iudd );
00409 int GetUDData ( int UDDhandle, realtype & rudd );
00410 int GetUDData ( int UDDhandle, pstr sudd, int maxLen );
00411 int GetUDData ( int UDDhandle, pstr & sudd );
00412
00413
00414 int GetIndex() { return index; }
00415
00416 virtual void Copy ( PAtom atom );
00417
00418
00419 void SetShortBinary();
00420 void write ( io::RFile f );
00421 void read ( io::RFile f );
00422
00423 protected :
00424 int index;
00425 int nBonds;
00426 PAtomBond Bond;
00427
00428 void InitAtom ();
00429 void FreeMemory ();
00430 void StandardPDBOut ( cpstr Record, pstr S );
00431 void GetData ( cpstr S );
00432 ERROR_CODE CheckData ( cpstr S );
00433 void GetStat ( realtype v,
00434 realtype & v_min, realtype & v_max,
00435 realtype & v_m, realtype & v_m2 );
00436 void _setBonds ( PPAtom A );
00437
00438 };
00439
00440
00441
00442
00443 enum ALTLOC_FLAG {
00444 ALF_NoAltCodes = 0x00000000,
00445 ALF_EmptyAltLoc = 0x00000001,
00446 ALF_NoEmptyAltLoc = 0x00000002,
00447 ALF_Mess = 0x00000004,
00448 ALF_Occupancy = 0x00000008
00449 };
00450
00451 enum SSE_FLAG {
00452 SSE_None = 0,
00453 SSE_Strand = 1,
00454 SSE_Bulge = 2,
00455 SSE_3Turn = 3,
00456 SSE_4Turn = 4,
00457 SSE_5Turn = 5,
00458 SSE_Helix = 6
00459 };
00460
00461 DefineFactoryFunctions(Residue);
00462
00463 class Residue : public UDData {
00464
00465 friend class Atom;
00466 friend class Chain;
00467 friend class Root;
00468
00469 public :
00470
00471 ResName name;
00472 ResName label_comp_id;
00473 ChainID label_asym_id;
00474 InsCode insCode;
00475 PChain chain;
00476 PPAtom atom;
00477 int seqNum;
00478 int label_seq_id;
00479 int label_entity_id;
00480 int index;
00481 int nAtoms;
00482 byte SSE;
00483
00484 Residue ();
00485 Residue ( PChain Chain_Owner );
00486 Residue ( PChain Chain_Owner, const ResName resName,
00487 int sqNum, const InsCode ins );
00488 Residue ( io::RPStream Object );
00489 ~Residue();
00490
00491 void SetChain ( PChain Chain_Owner );
00492 void SetResID ( const ResName resName, int sqNum,
00493 const InsCode ins );
00494 void SetChainID ( const ChainID chID );
00495
00496 void PDBASCIIAtomDump ( io::RFile f );
00497 void MakeAtomCIF ( mmcif::PData CIF );
00498
00499 PChain GetChain();
00500 PModel GetModel();
00501
00502 int GetModelNum ();
00503 pstr GetChainID ();
00504 pstr GetLabelAsymID();
00505 pstr GetResName ();
00506 pstr GetLabelCompID();
00507 int GetAASimilarity ( const ResName resName );
00508 int GetAASimilarity ( PResidue res );
00509 realtype GetAAHydropathy();
00510 void SetResName ( const ResName resName );
00511 int GetSeqNum ();
00512 int GetLabelSeqID ();
00513 int GetLabelEntityID();
00514 pstr GetInsCode ();
00515 int GetResidueNo ();
00516 int GetCenter ( realtype & x, realtype & y, realtype & z );
00517 void * GetCoordHierarchy();
00518
00519 void GetAtomStatistics ( RAtomStat AS );
00520 void CalAtomStatistics ( RAtomStat AS );
00521
00522 pstr GetResidueID ( pstr ResidueID );
00523
00524
00525
00526
00527
00528
00529
00530
00531
00532
00533
00534
00535
00536
00537
00538
00539
00540
00541
00542
00543
00544
00545
00546
00547
00548
00549
00550
00551
00552
00553 void GetAltLocations ( int & nAltLocs, PAltLoc & aLoc,
00554 rvector & occupancy, int & alflag );
00555 int GetNofAltLocations();
00556
00557 bool isAminoacid ();
00558 bool isNucleotide ();
00559 int isDNARNA ();
00560 bool isSugar ();
00561 bool isSolvent ();
00562 bool isModRes ();
00563 bool isInSelection ( int selHnd );
00564 bool isNTerminus ();
00565 bool isCTerminus ();
00566
00567
00568
00569
00570
00571
00572
00573
00574
00575
00576
00577
00578
00579
00580 int CheckID ( int * snum, const InsCode inscode=pstr(""),
00581 const ResName resname=NULL );
00582
00583
00584
00585
00586
00587
00588
00589
00590
00591
00592
00593
00594
00595
00596
00597
00598
00599
00600
00601
00602
00603
00604
00605
00606
00607
00608 int CheckIDS ( cpstr ID );
00609
00610
00611
00612
00613 int GetNumberOfAtoms ();
00614 int GetNumberOfAtoms ( bool countTers );
00615
00616 PAtom GetAtom ( const AtomName aname, const Element elname=NULL,
00617 const AltLoc aloc=cpstr("") );
00618 PAtom GetAtom ( int atomNo );
00619
00620 void GetAtomTable ( PPAtom & atomTable, int & NumberOfAtoms );
00621
00622
00623
00624
00625
00626
00627
00628
00629
00630
00631
00632 void GetAtomTable1 ( PPAtom & atomTable, int & NumberOfAtoms );
00633
00634
00635
00636
00637 int DeleteAtom ( const AtomName aname, const Element elname=NULL,
00638 const AltLoc aloc=cpstr("") );
00639 int DeleteAtom ( int atomNo );
00640 int DeleteAllAtoms();
00641
00642
00643
00644
00645
00646
00647
00648
00649 int DeleteAltLocs ();
00650
00651 void TrimAtomTable ();
00652
00653
00654
00655
00656
00657
00658
00659
00660
00661
00662
00663 int AddAtom ( PAtom atm );
00664
00665
00666
00667
00668
00669
00670
00671
00672
00673
00674 int InsertAtom ( PAtom atm, int position );
00675
00676
00677
00678 int InsertAtom ( PAtom atm, const AtomName aname );
00679
00680
00681
00682 void ApplyTransform ( mat44 & TMatrix );
00683
00684
00685
00686
00687 void MaskAtoms ( PMask Mask );
00688 void UnmaskAtoms ( PMask Mask );
00689
00690
00691
00692 int PutUDData ( int UDDhandle, int iudd );
00693 int PutUDData ( int UDDhandle, realtype rudd );
00694 int PutUDData ( int UDDhandle, cpstr sudd );
00695
00696 int GetUDData ( int UDDhandle, int & iudd );
00697 int GetUDData ( int UDDhandle, realtype & rudd );
00698 int GetUDData ( int UDDhandle, pstr sudd, int maxLen );
00699 int GetUDData ( int UDDhandle, pstr & sudd );
00700
00701
00702 bool isMainchainHBond ( PResidue res );
00703
00704 void Copy ( PResidue res );
00705
00706 void write ( io::RFile f );
00707 void read ( io::RFile f );
00708
00709 protected :
00710
00711 int AtmLen;
00712 bool Exclude;
00713
00714 void InitResidue ();
00715 void FreeMemory ();
00716 int _AddAtom ( PAtom atm );
00717 int _ExcludeAtom ( int kndex );
00718
00719 void _copy ( PResidue res );
00720 void _copy ( PResidue res, PPAtom atm, int & atom_index );
00721 void ExpandAtomArray ( int nAdd );
00722 void CheckInAtoms ();
00723
00724 };
00725
00726
00727 extern realtype BondAngle ( PAtom A, PAtom B, PAtom C );
00728
00729 }
00730
00731 #endif
00732