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
00044
00045
00046
00047
00048 #ifndef __MMDB_Chain__
00049 #define __MMDB_Chain__
00050
00051 #include "mmdb_io_stream.h"
00052 #include "mmdb_utils.h"
00053 #include "mmdb_atom.h"
00054 #include "mmdb_defs.h"
00055
00056 namespace mmdb {
00057
00058
00059
00060
00061
00062
00063
00064 DefineClass(ProModel);
00065 DefineStreamFunctions(ProModel);
00066
00067 DefineClass(Manager);
00068
00069 class ProModel : public UDData {
00070
00071 friend class Chain;
00072
00073 public :
00074
00075 ProModel () : UDData () {}
00076 ProModel ( io::RPStream Object ) : UDData ( Object ) {}
00077 ~ProModel () {}
00078
00079 virtual cpstr GetEntryID () { return ""; }
00080 virtual void SetEntryID ( const IDCode ) {}
00081
00082 virtual int AddChain ( PChain ) { return 0; }
00083
00084
00085 virtual PManager GetCoordHierarchy() { return NULL; }
00086
00087
00088 virtual int GetNumberOfModels() { return 0; }
00089
00090
00091
00092 virtual int GetNumberOfAllAtoms() { return 0; }
00093
00094
00095 virtual PPAtom GetAllAtoms() { return NULL; }
00096
00097 virtual int GetSerNum () { return 0; }
00098
00099 virtual void ExpandAtomArray ( int ) {}
00100 virtual void AddAtomArray ( int ) {}
00101
00102 protected :
00103
00104 virtual int _ExcludeChain ( const ChainID ) { return 0; }
00105
00106 };
00107
00108
00109
00110
00111
00112 DefineClass(ChainContainer);
00113 DefineStreamFunctions(ChainContainer);
00114
00115 class ChainContainer : public ClassContainer {
00116
00117 public :
00118
00119 ChainContainer () : ClassContainer () {}
00120 ChainContainer ( io::RPStream Object )
00121 : ClassContainer ( Object ) {}
00122 ~ChainContainer () {}
00123
00124 PContainerClass MakeContainerClass ( int ClassID );
00125
00126 void SetChain ( PChain Chain_Owner );
00127
00128
00129
00130 cpstr Get1stChainID ();
00131 void MoveByChainID ( const ChainID chainID,
00132 PChainContainer chainContainer );
00133
00134 protected :
00135 PChain chain;
00136
00137 };
00138
00139
00140
00141
00142 DefineClass(ContainerChain);
00143 DefineStreamFunctions(ContainerChain);
00144
00145 class ContainerChain : public ContainerClass {
00146
00147 friend class ChainContainer;
00148
00149 public :
00150
00151 ContainerChain ();
00152 ContainerChain ( PChain Chain_Owner );
00153 ContainerChain ( io::RPStream Object ) : ContainerClass(Object) {}
00154
00155 void SetChain ( PChain Chain_Owner );
00156
00157 protected :
00158 PChain chain;
00159 ChainID chainID;
00160
00161 };
00162
00163
00164
00165
00166 DefineClass(DBReference);
00167 DefineStreamFunctions(DBReference);
00168
00169 class DBReference : public ContainerChain {
00170
00171 public :
00172
00173 int seqBeg;
00174 InsCode insBeg;
00175 int seqEnd;
00176 InsCode insEnd;
00177 DBName database;
00178 DBAcCode dbAccession;
00179 DBIdCode dbIdCode;
00180 int dbseqBeg;
00181 InsCode dbinsBeg;
00182 int dbseqEnd;
00183 InsCode dbinsEnd;
00184
00185 DBReference ();
00186 DBReference ( PChain Chain_Owner );
00187 DBReference ( PChain Chain_Owner, cpstr S );
00188 DBReference ( io::RPStream Object );
00189 ~DBReference();
00190
00191 void PDBASCIIDump ( pstr S, int N );
00192 void MakeCIF ( mmcif::PData CIF, int N );
00193 ERROR_CODE ConvertPDBASCII ( cpstr S );
00194 ERROR_CODE GetCIF ( mmcif::PData CIF, int & n );
00195 CLASS_ID GetClassID () { return ClassID_DBReference; }
00196
00197 void Copy ( PContainerClass DBRef );
00198
00199 void write ( io::RFile f );
00200 void read ( io::RFile f );
00201
00202 protected :
00203
00204 void InitDBReference();
00205
00206 };
00207
00208
00209
00210
00211 DefineClass(SeqAdv);
00212 DefineStreamFunctions(SeqAdv);
00213
00214 class SeqAdv : public ContainerChain {
00215
00216 public :
00217
00218 ResName resName;
00219 int seqNum;
00220 InsCode insCode;
00221 DBName database;
00222 DBAcCode dbAccession;
00223 ResName dbRes;
00224 int dbSeq;
00225 pstr conflict;
00226
00227 SeqAdv ();
00228 SeqAdv ( PChain Chain_Owner );
00229 SeqAdv ( PChain Chain_Owner, cpstr S );
00230 SeqAdv ( io::RPStream Object );
00231 ~SeqAdv();
00232
00233 void PDBASCIIDump ( pstr S, int N );
00234 ERROR_CODE ConvertPDBASCII ( cpstr S );
00235 void MakeCIF ( mmcif::PData CIF, int N );
00236 ERROR_CODE GetCIF ( mmcif::PData CIF, int & n );
00237 CLASS_ID GetClassID () { return ClassID_SeqAdv; }
00238
00239 void Copy ( PContainerClass seqAdv );
00240
00241 void write ( io::RFile f );
00242 void read ( io::RFile f );
00243
00244 protected :
00245
00246 void InitSeqAdv();
00247
00248 };
00249
00250
00251
00252
00253 DefineClass(SeqRes);
00254 DefineStreamFunctions(SeqRes);
00255
00256 class SeqRes : public io::Stream {
00257
00258 friend class Model;
00259 friend class Chain;
00260
00261 public :
00262
00263 int numRes;
00264 PResName resName;
00265
00266 SeqRes ();
00267 SeqRes ( io::RPStream Object );
00268 ~SeqRes();
00269
00270 void SetChain ( PChain Chain_Owner );
00271 void PDBASCIIDump ( io::RFile f );
00272 ERROR_CODE ConvertPDBASCII ( cpstr S );
00273
00274 void MakeCIF ( mmcif::PData CIF );
00275 ERROR_CODE GetCIF ( mmcif::PData CIF );
00276
00277 void Copy ( PSeqRes seqRes );
00278
00279 void write ( io::RFile f );
00280 void read ( io::RFile f );
00281
00282 protected :
00283 PChain chain;
00284 ChainID chainID;
00285 int serNum;
00286
00287 void InitSeqRes();
00288 void FreeMemory();
00289
00290 };
00291
00292
00293
00294
00295 DefineClass(ModRes);
00296 DefineStreamFunctions(ModRes);
00297
00298 class ModRes : public ContainerChain {
00299
00300 public :
00301
00302 ResName resName;
00303 int seqNum;
00304 InsCode insCode;
00305 ResName stdRes;
00306 pstr comment;
00307
00308 ModRes ();
00309 ModRes ( PChain Chain_Owner );
00310 ModRes ( PChain Chain_Owner, cpstr S );
00311 ModRes ( io::RPStream Object );
00312 ~ModRes();
00313
00314 void PDBASCIIDump ( pstr S, int N );
00315 void MakeCIF ( mmcif::PData CIF, int N );
00316 ERROR_CODE ConvertPDBASCII ( cpstr S );
00317 ERROR_CODE GetCIF ( mmcif::PData CIF, int & n );
00318 CLASS_ID GetClassID () { return ClassID_ModRes; }
00319
00320 void Copy ( PContainerClass modRes );
00321
00322 void write ( io::RFile f );
00323 void read ( io::RFile f );
00324
00325 protected :
00326
00327 void InitModRes();
00328
00329 };
00330
00331
00332
00333
00334 DefineClass(HetRec);
00335 DefineStreamFunctions(HetRec);
00336
00337 class HetRec : public ContainerChain {
00338
00339 public :
00340
00341 ResName hetID;
00342 int seqNum;
00343 InsCode insCode;
00344 int numHetAtoms;
00345
00346 pstr comment;
00347
00348 HetRec ();
00349 HetRec ( PChain Chain_Owner );
00350 HetRec ( PChain Chain_Owner, cpstr S );
00351 HetRec ( io::RPStream Object );
00352 ~HetRec();
00353
00354 void PDBASCIIDump ( pstr S, int N );
00355 void MakeCIF ( mmcif::PData CIF, int N );
00356 ERROR_CODE ConvertPDBASCII ( cpstr S );
00357 ERROR_CODE GetCIF ( mmcif::PData CIF, int & n );
00358 CLASS_ID GetClassID () { return ClassID_Het; }
00359
00360 void Copy ( PContainerClass Het );
00361
00362 void write ( io::RFile f );
00363 void read ( io::RFile f );
00364
00365 protected :
00366
00367 void InitHetRec();
00368
00369 };
00370
00371
00372
00373
00374 DefineFactoryFunctions(Chain);
00375
00376 class Chain : public UDData {
00377
00378 friend class DBReference;
00379 friend class SeqAdv;
00380 friend class SeqRes;
00381 friend class ModRes;
00382 friend class HetRec;
00383 friend class Residue;
00384 friend class Atom;
00385 friend class Model;
00386 friend class Root;
00387 friend class SelManager;
00388 friend class BondManager;
00389 friend class CoorManager;
00390 friend class Manager;
00391
00392 public :
00393
00394 ChainContainer DBRef;
00395 ChainContainer seqAdv;
00396 SeqRes seqRes;
00397 ChainContainer modRes;
00398 ChainContainer Het;
00399
00400 Chain ();
00401 Chain ( PProModel model, const ChainID chID );
00402 Chain ( io::RPStream Object );
00403 ~Chain();
00404
00405 void FreeAnnotations();
00406
00407 void SetModel ( PProModel model );
00408 void SetChain ( const ChainID chID );
00409
00410 PManager GetCoordHierarchy();
00411
00412
00413
00414
00415 ERROR_CODE ConvertDBREF ( cpstr PDBString );
00416 ERROR_CODE ConvertSEQADV ( cpstr PDBString );
00417 ERROR_CODE ConvertSEQRES ( cpstr PDBString );
00418 ERROR_CODE ConvertMODRES ( cpstr PDBString );
00419 ERROR_CODE ConvertHET ( cpstr PDBString );
00420
00421
00422
00423
00424 void PDBASCIIDump ( io::RFile f );
00425
00426 void PDBASCIIAtomDump ( io::RFile f );
00427 void MakeAtomCIF ( mmcif::PData CIF );
00428
00429
00430
00431
00432 int GetNumberOfResidues();
00433 PResidue GetResidue ( int resNo );
00434
00435
00436
00437
00438
00439
00440
00441 PResidue GetResidue ( int seqNum, const InsCode insCode );
00442
00443
00444
00445
00446
00447 int GetResidueNo ( int seqNum, const InsCode insCode );
00448
00449 void GetResidueTable ( PPResidue & resTable,
00450 int & NumberOfResidues );
00451
00452
00453
00454
00455
00456
00457
00458
00459
00460
00461
00462 PResidue GetResidueCreate ( const ResName resName, int seqNum,
00463 const InsCode insCode, bool Enforce );
00464
00465
00466
00467
00468 int DeleteResidue ( int resNo );
00469 int DeleteResidue ( int seqNum, const InsCode insCode );
00470 int DeleteAllResidues();
00471 int DeleteSolvent ();
00472 void TrimResidueTable ();
00473
00474
00475
00476
00477
00478
00479
00480
00481
00482
00483
00484
00485
00486
00487
00488
00489
00490 int AddResidue ( PResidue res );
00491 int InsResidue ( PResidue res, int pos );
00492 int InsResidue ( PResidue res, int seqNum, const InsCode insCode );
00493
00494
00495
00496 int GetNumberOfAtoms ( bool countTers );
00497 int GetNumberOfAtoms ( int seqNo, const InsCode insCode );
00498 int GetNumberOfAtoms ( int resNo );
00499
00500 PAtom GetAtom ( int seqNo,
00501 const InsCode insCode,
00502 const AtomName aname,
00503 const Element elmnt,
00504 const AltLoc aloc );
00505 PAtom GetAtom ( int seqNo, const InsCode insCode, int atomNo );
00506 PAtom GetAtom ( int resNo,
00507 const AtomName aname,
00508 const Element elmnt,
00509 const AltLoc aloc );
00510 PAtom GetAtom ( int resNo, int atomNo );
00511
00512 void GetAtomTable ( int seqNo, const InsCode insCode,
00513 PPAtom & atomTable, int & NumberOfAtoms );
00514 void GetAtomTable ( int resNo,
00515 PPAtom & atomTable, int & NumberOfAtoms );
00516
00517
00518
00519
00520
00521
00522
00523
00524
00525
00526
00527
00528 void GetAtomTable1 ( int seqNo, const InsCode insCode,
00529 PPAtom & atomTable, int & NumberOfAtoms );
00530 void GetAtomTable1 ( int resNo,
00531 PPAtom & atomTable, int & NumberOfAtoms );
00532
00533
00534
00535 int DeleteAtom ( int seqNo,
00536 const InsCode insCode,
00537 const AtomName aname,
00538 const Element elmnt,
00539 const AltLoc aloc );
00540 int DeleteAtom ( int seqNo,
00541 const InsCode insCode,
00542 int atomNo );
00543 int DeleteAtom ( int resNo,
00544 const AtomName aname,
00545 const Element elmnt,
00546 const AltLoc aloc );
00547 int DeleteAtom ( int resNo, int atomNo );
00548
00549 int DeleteAllAtoms ( int seqNo, const InsCode insCode );
00550 int DeleteAllAtoms ( int resNo );
00551 int DeleteAllAtoms ();
00552
00553
00554
00555
00556
00557
00558
00559 int DeleteAltLocs();
00560
00561
00562
00563 int AddAtom ( int seqNo, const InsCode insCode, PAtom atom );
00564 int AddAtom ( int resNo, PAtom atom );
00565
00566
00567
00568 void ApplyTransform ( mat44 & TMatrix );
00569
00570
00571
00572 int GetModelNum();
00573 PModel GetModel () { return (PModel)model; }
00574 cpstr GetChainID () { return chainID; }
00575 void SetChainID ( const ChainID chID );
00576 cpstr GetChainID ( pstr ChID );
00577
00578 void GetAtomStatistics ( RAtomStat AS );
00579 void CalAtomStatistics ( RAtomStat AS );
00580
00581 int CheckID ( const ChainID chID );
00582 int CheckIDS ( cpstr CID );
00583
00584 cpstr GetEntryID ();
00585 void SetEntryID ( const IDCode idCode );
00586
00587 int GetNumberOfDBRefs ();
00588 PDBReference GetDBRef ( int dbRefNo );
00589
00590 void MaskAtoms ( PMask Mask );
00591 void MaskResidues ( PMask Mask );
00592 void UnmaskAtoms ( PMask Mask );
00593 void UnmaskResidues ( PMask Mask );
00594
00595 void SortResidues ();
00596
00597 int GetNofModResidues();
00598 PModRes GetModResidue ( int modResNo );
00599
00600 bool isSolventChain ();
00601 bool isInSelection ( int selHnd );
00602 bool isAminoacidChain ();
00603 bool isNucleotideChain();
00604
00605
00606
00607 int PutUDData ( int UDDhandle, int iudd );
00608 int PutUDData ( int UDDhandle, realtype rudd );
00609 int PutUDData ( int UDDhandle, cpstr sudd );
00610
00611 int GetUDData ( int UDDhandle, int & iudd );
00612 int GetUDData ( int UDDhandle, realtype & rudd );
00613 int GetUDData ( int UDDhandle, pstr sudd, int maxLen );
00614 int GetUDData ( int UDDhandle, pstr & sudd );
00615
00616 void Copy ( PChain chain );
00617 void CopyAnnotations ( PChain chain );
00618
00619 void write ( io::RFile f );
00620 void read ( io::RFile f );
00621
00622 protected :
00623
00624 ChainID chainID;
00625 ChainID prevChainID;
00626
00627 PProModel model;
00628
00629 int nWeights;
00630 realtype Weight;
00631
00632 int nResidues;
00633 PPResidue residue;
00634
00635 bool Exclude;
00636
00637 void InitChain ();
00638 void FreeMemory();
00639
00640 void ExpandResidueArray ( int inc );
00641
00642
00643
00644 int _ExcludeResidue ( const ResName resName, int seqNum,
00645 const InsCode insCode );
00646 void _copy ( PChain chain );
00647 void _copy ( PChain chain, PPAtom atom, int & atom_index );
00648 void CheckInAtoms();
00649
00650 private :
00651 int resLen;
00652
00653 };
00654
00655
00656 extern void TestChain();
00657
00658
00659 }
00660
00661 #endif
00662