summaryrefslogtreecommitdiff
path: root/mmdb2/mmdb_root.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'mmdb2/mmdb_root.cpp')
-rw-r--r--mmdb2/mmdb_root.cpp179
1 files changed, 115 insertions, 64 deletions
diff --git a/mmdb2/mmdb_root.cpp b/mmdb2/mmdb_root.cpp
index 3a98edb..bef2da1 100644
--- a/mmdb2/mmdb_root.cpp
+++ b/mmdb2/mmdb_root.cpp
@@ -22,7 +22,7 @@
//
// =================================================================
//
-// 14.09.13 <-- Date of Last Modification.
+// 10.05.15 <-- Date of Last Modification.
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// -----------------------------------------------------------------
//
@@ -33,7 +33,7 @@
// **** Classes : mmdb::Root
// ~~~~~~~~~
//
-// (C) E. Krissinel 2000-2013
+// (C) E. Krissinel 2000-2015
//
// =================================================================
//
@@ -986,20 +986,21 @@ namespace mmdb {
crModel0->nChains = k;
}
}
- if (CleanKey & PDBCLEAN_CHAIN_ORDER)
+ if (CleanKey & PDBCLEAN_CHAIN_ORDER) {
for (i=0;i<nAtoms;i++)
if (atom[i]) {
crChain0 = atom[i]->GetChain();
crChain0->nWeights++;
crChain0->Weight += atom[i]->serNum;
}
- else
+ } else {
for (i=0;i<nAtoms;i++)
if (atom[i]) {
crChain0 = atom[i]->GetChain();
crChain0->nWeights++;
crChain0->Weight += atom[i]->GetIndex();
}
+ }
for (i=0;i<nModels;i++) {
crModel0 = model[i];
if (crModel0) {
@@ -1488,7 +1489,12 @@ namespace mmdb {
}
}
+ bool Root::isCompactBinary() {
+ if (Flags & MMDBF_MakeCompactBinary) return true;
+ return false;
+ }
+
int Root::CrystReady() {
// Returns flags:
// CRRDY_Complete if crystallographic information is complete
@@ -1681,15 +1687,15 @@ namespace mmdb {
}
int Root::PutAtom ( int index,
- int serNum,
- const AtomName atomName,
- const ResName resName,
- const ChainID chainID,
- int seqNum,
- const InsCode insCode,
- const AltLoc altLoc,
- const SegID segID,
- const Element element ) {
+ int serNum,
+ const AtomName atomName,
+ const ResName resName,
+ const ChainID chainID,
+ int seqNum,
+ const InsCode insCode,
+ const AltLoc altLoc,
+ const SegID segID,
+ const Element element ) {
// An atom with the specified properties is put into the
// structure. The current model is used; if no model is
@@ -1766,15 +1772,14 @@ namespace mmdb {
}
- int Root::PutAtom ( int index, // same meaning as above
- PAtom A, // pointer to completed atom
- // class
- int serNum // 0 means that the serial
- // number will be set equal
- // to "index". Otherwise,
- // the serial number is set
- // to the specified value
- ) {
+ int Root::PutAtom ( int index, // same meaning as above
+ PAtom A, // pointer to completed atom class
+ int serNum // 0 means that the serial
+ // number will be set equal
+ // to "index". Otherwise,
+ // the serial number is set
+ // to the specified value
+ ) {
int i,kndex,RC,sn;
if (!A) return -1;
@@ -2125,7 +2130,7 @@ namespace mmdb {
int label_seq_id,
int label_entity_id,
const InsCode insCode,
- bool Replace ) {
+ bool Replace ) {
if ((!resName[0]) && (insCode[0]!=char(1)))
return Error_EmptyResidueName;
@@ -2413,6 +2418,7 @@ namespace mmdb {
else return Error_NoLogicalName;
}
+ /*
ERROR_CODE Root::WriteMMDBF ( cpstr MMDBRootName, io::GZ_MODE gzipMode ) {
io::File f;
char Label[100];
@@ -2432,7 +2438,30 @@ namespace mmdb {
return Error_NoError;
}
+*/
+ ERROR_CODE Root::WriteMMDBF ( cpstr MMDBRootName,
+ io::GZ_MODE gzipMode ) {
+ io::File f;
+ f.assign ( MMDBRootName,false,true,gzipMode );
+ if (f.rewrite()) {
+ WriteMMDBF ( f );
+ f.shut();
+ } else
+ return Error_CantOpenFile;
+ return Error_NoError;
+ }
+
+ void Root::WriteMMDBF ( io::RFile f ) {
+ char Label[100];
+ byte Version=Edition;
+ FType = MMDB_FILE_Binary;
+ strcpy ( Label,MMDBFLabel );
+ f.WriteFile ( Label,sizeof(MMDBFLabel) );
+ f.WriteByte ( &Version );
+ write ( f );
+ }
+
pstr Root::GetEntryID() {
return title.idCode;
@@ -2554,8 +2583,8 @@ namespace mmdb {
}
int Root::GetTMatrix ( mat44 & TMatrix, int Nop,
- int cellshift_a, int cellshift_b,
- int cellshift_c ) {
+ int cellshift_a, int cellshift_b,
+ int cellshift_c ) {
// GetTMatrix(..) calculates and returns the coordinate transformation
// matrix, which converts orthogonal coordinates according to
// the symmetry operation number Nop and places them into unit cell
@@ -2572,9 +2601,9 @@ namespace mmdb {
int Root::GetUCTMatrix ( mat44 & TMatrix, int Nop,
- realtype x, realtype y, realtype z,
- int cellshift_a, int cellshift_b,
- int cellshift_c ) {
+ realtype x, realtype y, realtype z,
+ int cellshift_a, int cellshift_b,
+ int cellshift_c ) {
// GetUCTMatrix(..) calculates and returns the coordinate
// transformation matrix, which converts orthogonal coordinates
// according to the symmetry operation number Nop. Translation
@@ -2595,8 +2624,8 @@ namespace mmdb {
int Root::GetFractMatrix ( mat44 & TMatrix, int Nop,
- int cellshift_a, int cellshift_b,
- int cellshift_c ) {
+ int cellshift_a, int cellshift_b,
+ int cellshift_c ) {
// GetFractMatrix(..) calculates and returns the coordinate
// transformation matrix, which converts fractional coordinates
// according to the symmetry operation number Nop and places them
@@ -2811,28 +2840,22 @@ namespace mmdb {
return title.GetStructureTitle ( L );
}
- void Root::SetShortBinary() {
+ void Root::SetCompactBinary() {
// leaves only coordinates in binary files
int i;
+ SetFlag ( MMDBF_MakeCompactBinary );
for (i=0;i<nAtoms;i++)
- if (atom[i]) atom[i]->SetShortBinary();
+ if (atom[i]) atom[i]->SetCompactBinary();
}
void Root::write ( io::RFile f ) {
int i,k;
- byte Version=1;
+ byte Version=2;
f.WriteByte ( &Version );
-
- UDData::write ( f );
-
- title .write ( f );
- cryst .write ( f );
- udRegister.write ( f );
- DefPath .write ( f );
-
- f.WriteWord ( &Flags );
+ f.WriteWord ( &Flags );
+
f.WriteInt ( &nAtoms );
for (i=0;i<nAtoms;i++) {
if (atom[i]) k = 1;
@@ -2848,13 +2871,31 @@ namespace mmdb {
f.WriteInt ( &k );
if (model[i]) model[i]->write ( f );
}
+
+ if (Flags & MMDBF_MakeCompactBinary) {
+
+ f.WriteTerLine ( title.idCode,false );
+ f.WriteReal ( &title.resolution );
+ title.title.write ( f );
+ cryst .write ( f );
+
+ } else {
- SA .write ( f );
- Footnote.write ( f );
- SB .write ( f );
- SC .write ( f );
-
- StreamWrite ( f,CIF );
+ UDData::write ( f );
+
+ title .write ( f );
+ cryst .write ( f );
+ udRegister.write ( f );
+ DefPath .write ( f );
+
+ SA .write ( f );
+ Footnote.write ( f );
+ SB .write ( f );
+ SC .write ( f );
+
+ StreamWrite ( f,CIF );
+
+ }
}
@@ -2866,17 +2907,10 @@ namespace mmdb {
FreeFileMemory();
f.ReadByte ( &Version );
-
- UDData::read ( f );
-
- title .read ( f );
- cryst .read ( f );
- udRegister.read ( f );
- DefPath .read ( f );
-
+ f.ReadWord ( &Flags );
+
// It is important to read atoms before models,
// residues and chains!
- f.ReadWord ( &Flags );
f.ReadInt ( &nAtoms );
atmLen = nAtoms;
if (nAtoms>0) {
@@ -2907,13 +2941,30 @@ namespace mmdb {
model[i] = NULL;
}
}
-
- SA .read ( f );
- Footnote.read ( f );
- SB .read ( f );
- SC .read ( f );
-
- StreamRead ( f,CIF );
+ if (Flags & MMDBF_MakeCompactBinary) {
+
+ f.ReadTerLine ( title.idCode,false );
+ f.ReadReal ( &title.resolution );
+ title.title.read ( f );
+ cryst .read ( f );
+
+ } else {
+
+ UDData::read ( f );
+
+ title .read ( f );
+ cryst .read ( f );
+ udRegister.read ( f );
+ DefPath .read ( f );
+
+ SA .read ( f );
+ Footnote.read ( f );
+ SB .read ( f );
+ SC .read ( f );
+
+ StreamRead ( f,CIF );
+
+ }
}