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_Root__
00042 #define __MMDB_Root__
00043
00044 #include "mmdb_io_file.h"
00045 #include "mmdb_uddata.h"
00046 #include "mmdb_title.h"
00047 #include "mmdb_cryst.h"
00048 #include "mmdb_chain.h"
00049 #include "mmdb_model.h"
00050 #include "mmdb_defs.h"
00051
00052 namespace mmdb {
00053
00054
00055
00056
00057 enum MMDB_READ_FLAG {
00058 MMDBF_AutoSerials = 0x00000001,
00059 MMDBF_NoCoordRead = 0x00000002,
00060 MMDBF_SimRWBROOK = 0x00000004,
00061 MMDBF_PrintCIFWarnings = 0x00000008,
00062 MMDBF_EnforceSpaces = 0x00000010,
00063 MMDBF_IgnoreDuplSeqNum = 0x00000020,
00064 MMDBF_IgnoreSegID = 0x00000040,
00065 MMDBF_IgnoreElement = 0x00000080,
00066 MMDBF_IgnoreCharge = 0x00000100,
00067 MMDBF_IgnoreNonCoorPDBErrors = 0x00000200,
00068 MMDBF_IgnoreUnmatch = 0x00000400,
00069 MMDBF_IgnoreBlankLines = 0x00000800,
00070 MMDBF_IgnoreHash = 0x00001000,
00071 MMDBF_IgnoreRemarks = 0x00002000,
00072 MMDBF_AllowDuplChainID = 0x00004000,
00073 MMDBF_FixSpaceGroup = 0x00008000,
00074 MMDBF_EnforceAtomNames = 0x00010000,
00075 MMDBF_EnforceUniqueChainID = 0x00020000,
00076 MMDBF_DoNotProcessSpaceGroup = 0x00040000
00077 };
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094 enum MMDB_FILE_TYPE {
00095 MMDB_FILE_Undefined = -1,
00096 MMDB_FILE_PDB = 0,
00097 MMDB_FILE_CIF = 1,
00098 MMDB_FILE_Binary = 2
00099 };
00100
00101
00102 enum PDB_CLEAN_FLAG {
00103 PDBCLEAN_ATNAME = 0x00000001,
00104 PDBCLEAN_TER = 0x00000002,
00105 PDBCLEAN_CHAIN = 0x00000004,
00106 PDBCLEAN_CHAIN_STRONG = 0x00000008,
00107 PDBCLEAN_ALTCODE = 0x00000010,
00108 PDBCLEAN_ALTCODE_STRONG = 0x00000020,
00109 PDBCLEAN_SERIAL = 0x00000040,
00110 PDBCLEAN_SEQNUM = 0x00000080,
00111 PDBCLEAN_CHAIN_ORDER = 0x00000100,
00112 PDBCLEAN_CHAIN_ORDER_IX = 0x00000200,
00113 PDBCLEAN_SOLVENT = 0x00000400,
00114 PDBCLEAN_INDEX = 0x00000800,
00115 PDBCLEAN_ELEMENT = 0x00001000,
00116 PDBCLEAN_ELEMENT_STRONG = 0x00002000
00117 };
00118
00119
00120 enum MMDB_CRYST_FLAG {
00121 CRRDY_NotPrecise = 0x00000001,
00122 CRRDY_isTranslation = 0x00000002,
00123 CRRDY_NoOrthCode = 0x00000004,
00124 CRRDY_Complete = 0,
00125 CRRDY_NoTransfMatrices = -1,
00126 CRRDY_Unchecked = -2,
00127 CRRDY_Ambiguous = -3,
00128 CRRDY_NoCell = -4,
00129 CRRDY_NoSpaceGroup = -5
00130 };
00131
00132 DefineClass(Root);
00133 DefineStreamFunctions(Root);
00134
00135 class Root : public UDData {
00136
00137 friend class Model;
00138 friend class Chain;
00139 friend class Residue;
00140 friend class Atom;
00141
00142 public :
00143
00144 Root ();
00145 Root ( io::RPStream Object );
00146 ~Root();
00147
00148 void FreeFileMemory();
00149
00150
00151
00152
00153 void SetFlag ( word Flag );
00154 void RemoveFlag ( word Flag );
00155
00156 ERROR_CODE ReadPDBASCII ( cpstr PDBFileName,
00157 io::GZ_MODE gzipMode=io::GZM_CHECK );
00158 ERROR_CODE ReadPDBASCII1 ( cpstr PDBLFName,
00159 io::GZ_MODE gzipMode=io::GZM_CHECK );
00160 ERROR_CODE ReadPDBASCII ( io::RFile f );
00161
00162 ERROR_CODE ReadCIFASCII ( cpstr CIFFileName,
00163 io::GZ_MODE gzipMode=io::GZM_CHECK );
00164 ERROR_CODE ReadCIFASCII1 ( cpstr CIFLFName,
00165 io::GZ_MODE gzipMode=io::GZM_CHECK );
00166 ERROR_CODE ReadCIFASCII ( io::RFile f );
00167 ERROR_CODE ReadFromCIF ( mmcif::PData CIFD );
00168
00169
00170 ERROR_CODE AddPDBASCII1 ( cpstr PDBLFName,
00171 io::GZ_MODE gzipMode=io::GZM_CHECK );
00172 ERROR_CODE AddPDBASCII ( cpstr PDBFileName,
00173 io::GZ_MODE gzipMode=io::GZM_CHECK );
00174
00175
00176 ERROR_CODE ReadCoorFile ( cpstr LFName,
00177 io::GZ_MODE gzipMode=io::GZM_CHECK );
00178 ERROR_CODE ReadCoorFile1 ( cpstr CFName,
00179 io::GZ_MODE gzipMode=io::GZM_CHECK );
00180 ERROR_CODE ReadCoorFile ( io::RFile f );
00181
00182 ERROR_CODE WritePDBASCII ( cpstr PDBFileName,
00183 io::GZ_MODE gzipMode=io::GZM_CHECK );
00184 ERROR_CODE WritePDBASCII1 ( cpstr PDBLFName,
00185 io::GZ_MODE gzipMode=io::GZM_CHECK );
00186 void WritePDBASCII ( io::RFile f );
00187
00188 ERROR_CODE WriteCIFASCII ( cpstr CIFFileName,
00189 io::GZ_MODE gzipMode=io::GZM_CHECK );
00190 ERROR_CODE WriteCIFASCII1 ( cpstr CIFLFName,
00191 io::GZ_MODE gzipMode=io::GZM_CHECK );
00192
00193 ERROR_CODE ReadMMDBF ( cpstr MMDBRootName,
00194 io::GZ_MODE gzipMode=io::GZM_CHECK );
00195 ERROR_CODE ReadMMDBF1 ( cpstr MMDBLFName,
00196 io::GZ_MODE gzipMode=io::GZM_CHECK );
00197 ERROR_CODE ReadMMDBF ( io::RFile f );
00198 ERROR_CODE WriteMMDBF ( cpstr MMDBRootName,
00199 io::GZ_MODE gzipMode=io::GZM_CHECK );
00200 ERROR_CODE WriteMMDBF1 ( cpstr MMDBLFName,
00201 io::GZ_MODE gzipMode=io::GZM_CHECK );
00202
00203 void GetInputBuffer ( pstr Line, int & count );
00204
00205
00206
00207
00208
00209
00210 ERROR_CODE PutPDBString ( cpstr PDBString );
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222
00223
00224
00225
00226
00227
00228
00229
00230
00231
00232
00233
00234
00235
00236
00237
00238
00239
00240
00241
00242
00243
00244
00245 word PDBCleanup ( word CleanKey );
00246
00247
00248
00249
00250
00251
00252
00253
00254 void MakeHetAtoms ( cpstr chainID, bool Make );
00255
00256
00257
00258 inline PPAtom GetAtomArray () { return atom; }
00259 inline int GetAtomArrayLength() { return atmLen; }
00260
00261 PAtom GetAtomI ( int index );
00262
00263
00264
00265
00266
00267
00268
00269
00270
00271
00272
00273
00274
00275
00276
00277
00278
00279
00280
00281
00282
00283
00284
00285
00286
00287
00288
00289
00290
00291
00292
00293 int PutAtom ( int index,
00294 int serNum,
00295 const AtomName atomName,
00296 const ResName resName,
00297 const ChainID chainID,
00298 int seqNum,
00299 const InsCode insCode,
00300 const AltLoc altLoc,
00301 const SegID segID,
00302 const Element element );
00303
00304 int PutAtom (
00305 int index,
00306 PAtom A,
00307 int serNum=0
00308
00309
00310
00311
00312 );
00313
00314
00315
00316
00317
00318
00319
00320
00321 void RemoveAtom ( int index );
00322
00323 int FinishStructEdit();
00324
00325 void TrimModelTable();
00326
00327
00328
00329 int DeleteAllModels ();
00330 bool GetNewChainID ( int modelNo, ChainID chID, int length=1 );
00331
00332
00333
00334 int CrystReady();
00335
00336
00337
00338
00339
00340
00341
00342
00343
00344
00345
00346
00347
00348
00349 bool isCrystInfo ();
00350 bool isCellInfo ();
00351 bool isSpaceGroup ();
00352 bool isTransfMatrix();
00353
00354 bool isScaleMatrix ();
00355 bool isNCSMatrix ();
00356 int GetNumberOfNCSMatrices();
00357 int GetNumberOfNCSMates ();
00358
00359
00360 bool GetNCSMatrix ( int NCSMatrixNo,
00361 mat44 & ncs_m, int & iGiven );
00362
00363 int GetNumberOfSymOps ();
00364 pstr GetSymOp ( int Nop );
00365
00366
00367
00368
00369 int RegisterUDInteger ( UDR_TYPE udr_type, cpstr UDDataID );
00370 int RegisterUDReal ( UDR_TYPE udr_type, cpstr UDDataID );
00371 int RegisterUDString ( UDR_TYPE udr_type, cpstr UDDataID );
00372 int GetUDDHandle ( UDR_TYPE udr_type, cpstr UDDataID );
00373
00374
00375
00376 void SetSyminfoLib ( cpstr syminfo_lib );
00377 pstr GetSyminfoLib ();
00378 int SetSpaceGroup ( cpstr spGroup );
00379 pstr GetSpaceGroup ();
00380 pstr GetSpaceGroupFix();
00381
00382 void GetAtomStatistics ( RAtomStat AS );
00383
00384 void SetIgnoreSCALEi ( bool ignoreScalei );
00385
00386
00387 void SetCell ( realtype cell_a,
00388 realtype cell_b,
00389 realtype cell_c,
00390 realtype cell_alpha,
00391 realtype cell_beta,
00392 realtype cell_gamma,
00393 int OrthCode=0 );
00394
00395
00396 void PutCell ( realtype cell_a,
00397 realtype cell_b,
00398 realtype cell_c,
00399 realtype cell_alpha,
00400 realtype cell_beta,
00401 realtype cell_gamma,
00402 int OrthCode=0 );
00403
00404 int GetCell ( realtype & cell_a,
00405 realtype & cell_b,
00406 realtype & cell_c,
00407 realtype & cell_alpha,
00408 realtype & cell_beta,
00409 realtype & cell_gamma,
00410 realtype & vol,
00411 int & OrthCode );
00412
00413 int GetRCell ( realtype & cell_as,
00414 realtype & cell_bs,
00415 realtype & cell_cs,
00416 realtype & cell_alphas,
00417 realtype & cell_betas,
00418 realtype & cell_gammas,
00419 realtype & vols,
00420 int & OrthCode );
00421
00422 void GetROMatrix ( mat44 & RO );
00423
00424
00425
00426
00427
00428
00429
00430
00431
00432
00433
00434
00435 int GetTMatrix ( mat44 & TMatrix, int Nop,
00436 int cellshift_a, int cellshift_b,
00437 int cellshift_c );
00438
00439
00440
00441
00442
00443
00444
00445
00446
00447
00448
00449
00450
00451
00452 int GetUCTMatrix ( mat44 & TMatrix, int Nop,
00453 realtype x, realtype y, realtype z,
00454 int cellshift_a, int cellshift_b,
00455 int cellshift_c );
00456
00457
00458
00459
00460
00461
00462
00463
00464
00465
00466
00467
00468 int GetFractMatrix ( mat44 & TMatrix, int Nop,
00469 int cellshift_a, int cellshift_b,
00470 int cellshift_c );
00471
00472
00473
00474
00475
00476
00477
00478
00479
00480
00481
00482 int GetSymOpMatrix ( mat44 & TMatrix, int Nop );
00483
00484
00485 int AddNCSMatrix ( mat33 & ncs_m, vect3 & ncs_v, int iGiven );
00486 int GenerateNCSMates();
00487
00488 pstr GetEntryID ();
00489 void SetEntryID ( const IDCode idCode );
00490
00491 int GetNofExpDataRecs();
00492 pstr GetExpDataRec ( int recNo );
00493
00494 int GetNofMdlTypeRecs();
00495 pstr GetMdlTypeRec ( int recNo );
00496
00497 int GetFileType() { return FType; }
00498
00499 void Copy ( PRoot MMDBRoot );
00500
00501 void SetShortBinary();
00502
00503
00504 int PutUDData ( int UDDhandle, int iudd );
00505 int PutUDData ( int UDDhandle, realtype rudd );
00506 int PutUDData ( int UDDhandle, cpstr sudd );
00507
00508 int GetUDData ( int UDDhandle, int & iudd );
00509 int GetUDData ( int UDDhandle, realtype & rudd );
00510 int GetUDData ( int UDDhandle, pstr sudd, int maxLen );
00511 int GetUDData ( int UDDhandle, pstr & sudd );
00512
00513
00514
00515
00516
00517
00518 pstr GetStructureTitle ( pstr & L );
00519
00520 PCryst GetCrystData() { return &cryst; }
00521
00522 PClassContainer GetUnparsedA() { return &SA; }
00523 PClassContainer GetUnparsedB() { return &SB; }
00524 PClassContainer GetUnparsedC() { return ≻ }
00525
00526 protected :
00527
00528 word Flags;
00529 int FType;
00530
00531
00532
00533
00534
00535
00536 Title title;
00537 Cryst cryst;
00538 UDRegister udRegister;
00539
00540 int nModels;
00541 PPModel model;
00542
00543 int nAtoms;
00544 int atmLen;
00545 PPAtom atom;
00546
00547 AtomPath DefPath;
00548
00549 ClassContainer SA;
00550
00551
00552 ClassContainer Footnote;
00553 ClassContainer SB;
00554
00555
00556 ClassContainer SC;
00557
00558
00559
00560 int lcount;
00561 char S[500];
00562 mmcif::PData CIF;
00563
00564 PModel crModel;
00565 PChain crChain;
00566 PResidue crRes;
00567
00568 bool Exclude;
00569 bool ignoreRemarks;
00570 bool allowDuplChID;
00571 bool enforceUniqueChID;
00572
00573 void InitMMDBRoot ();
00574 void FreeCoordMemory ();
00575 void ReadPDBLine ( io::RFile f, pstr L, int maxlen );
00576 ERROR_CODE ReadPDBAtom ( cpstr L );
00577 ERROR_CODE ReadCIFAtom ( mmcif::PData CIFD );
00578 ERROR_CODE CheckAtomPlace ( int index, cpstr L );
00579 ERROR_CODE CheckAtomPlace ( int index, mmcif::PLoop Loop );
00580 ERROR_CODE SwitchModel ( cpstr L );
00581 ERROR_CODE SwitchModel ( int nM );
00582 ERROR_CODE AllocateAtom ( int index,
00583 const ChainID chainID,
00584 const ChainID label_asym_id,
00585 const ResName resName,
00586 const ResName label_comp_id,
00587 int seqNum,
00588 int label_seq_id,
00589 int label_entity_id,
00590 const InsCode insCode,
00591 bool Replace );
00592 void ExpandAtomArray ( int inc );
00593 void AddAtomArray ( int inc );
00594
00595 void ApplyNCSTransform ( int NCSMatrixNo );
00596
00597 virtual void ResetManager();
00598
00599
00600 void write ( io::RFile f );
00601 void read ( io::RFile f );
00602
00603
00604 int _ExcludeModel ( int serNum );
00605
00606 int CheckInAtom ( int index, PAtom A );
00607 int CheckInAtoms ( int index, PPAtom A, int natms );
00608
00609 virtual PMask GetSelMask ( int selHnd );
00610
00611 private :
00612 int modelCnt;
00613
00614 };
00615
00616
00617
00618
00619
00620
00621
00622
00623
00624
00625 extern int isMMDBBIN ( cpstr FName, io::GZ_MODE gzipMode=io::GZM_CHECK );
00626 extern int isMMDBBIN ( io::RFile f );
00627
00628
00629
00630
00631
00632 extern int isPDB ( cpstr FName, io::GZ_MODE gzipMode=io::GZM_CHECK,
00633 bool IgnoreBlankLines=false );
00634 extern int isPDB ( io::RFile f, bool IgnoreBlankLines=false );
00635
00636 }
00637
00638 #endif
00639