Skip to content

Commit a711cbd

Browse files
drroeDaniel R. Roe
andauthored
Add support for reading/writing Hybrid36 fields from PDB files (Amber-MD#1171)
* Adapt hybrid36 routines from https://raw.githubusercontent.com/cctbx/cctbx_project/master/iotbx/pdb/hybrid_36_c.c * Fix issue comparing int to unsigned * Start adding a hybrid36 mode * Add hybrid36 keyword * Update depends * Ensure error messages from h36 are trapped * Add hybrid36 to SSBOND/CONECT; allow overflow for these instead of reset to match original behavior when wrap is RESET * Add the flush command * Automatically detect and decode hybrid36 fields * Print message if hybrid36 detected on read * Make hybrid36 the default * V7.3.0. Hybrid36 is now the default for large PDBs * Add note about Hybrid36 code origin to README * Add specific author --------- Co-authored-by: Daniel R. Roe <daniel.roe@nih.gov>
1 parent 07e1ce0 commit a711cbd

15 files changed

Lines changed: 588 additions & 23 deletions

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,3 +250,5 @@ External code/libraries bundled with CPPTRAJ
250250
* The code for quaternion RMSD calculation was adapted from code in [qcprot.c](https://theobald.brandeis.edu/qcp/qcprot.c) originally written by Douglas L. Theobald and Pu Lio (Brandeis University).
251251

252252
* The code for reading numpy arrays in `src/libnpy` is from [libnpy](https://github.com/llohse/libnpy) written by Leon Merten Lohse et al. (Universität Göttingen).
253+
254+
* The code for reading/writing atom/residue number fields in large PDB files (in `Hybrid36.cpp`) is adapted from code written by Ralf W. Grosse-Kunstleve in the Computational Crystallography Toolbox, https://doi.org/10.1107/S0021889801017824, https://raw.githubusercontent.com/cctbx/cctbx_project/master/iotbx/pdb/hybrid_36_c.c

src/Command.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
#include "Exec_Random.h"
4242
#include "Exec_CompareClusters.h"
4343
#include "Exec_ParseTiming.h"
44+
#include "Exec_Flush.h"
4445
// ----- SYSTEM ----------------------------------------------------------------
4546
#include "Exec_System.h"
4647
// ----- COORDS ----------------------------------------------------------------
@@ -245,6 +246,7 @@ void Command::Init() {
245246
Command::AddCmd( new Exec_DataSetCmd(), Cmd::EXE, 1, "dataset" );
246247
Command::AddCmd( new Exec_EnsFileExt(), Cmd::EXE, 1, "ensextension" );
247248
Command::AddCmd( new Exec_Flatten(), Cmd::EXE, 1, "flatten" );
249+
Command::AddCmd( new Exec_Flush(), Cmd::EXE, 1, "flush" );
248250
Command::AddCmd( new Exec_GenerateAmberRst(),Cmd::EXE, 1, "rst" );
249251
Command::AddCmd( new Exec_Help(), Cmd::EXE, 1, "help" );
250252
Command::AddCmd( new Exec_ListAll(), Cmd::EXE, 1, "list" );

src/DataFileList.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,17 @@ void DataFileList::List() const {
356356
}
357357
}
358358

359+
/** Call write for all data files. and close out and clear all CpptrajFiles. */
360+
void DataFileList::Flush() {
361+
WriteAllDF();
362+
for (CFarray::iterator it = cfList_.begin(); it != cfList_.end(); ++it) {
363+
(*it)->CloseFile();
364+
delete *it;
365+
}
366+
cfList_.clear();
367+
cfData_.clear();
368+
}
369+
359370
// DataFileList::WriteAllDF()
360371
/** Call write for all DataFiles in list for which writeFile is true. Once
361372
* a file has been written set writeFile to false; it can be reset to

src/DataFileList.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ class DataFileList {
7070
void List() const;
7171
/// Write all DataFiles in list that have not yet been written.
7272
void WriteAllDF();
73+
/// Write all DataFiles and close out all CpptrajFiles
74+
void Flush();
7375
/// \return true if DataFiles have not yet been written.
7476
bool UnwrittenData() const;
7577
/// Reset the write status of all DataFiles so they will be written

src/Exec_Flush.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#include "Exec_Flush.h"
2+
#include "CpptrajStdio.h"
3+
4+
// Exec_Flush::Help()
5+
void Exec_Flush::Help() const
6+
{
7+
mprintf(" Write any pending data files; close all other files.\n");
8+
}
9+
10+
// Exec_Flush::Execute()
11+
Exec::RetType Exec_Flush::Execute(CpptrajState& State, ArgList& argIn)
12+
{
13+
State.DFL().Flush();
14+
return CpptrajState::OK;
15+
}

src/Exec_Flush.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#ifndef INC_EXEC_FLUSH_H
2+
#define INC_EXEC_FLUSH_H
3+
#include "Exec.h"
4+
/// <Enter description of Exec_Flush here>
5+
class Exec_Flush : public Exec {
6+
public:
7+
Exec_Flush() : Exec(GENERAL) {}
8+
void Help() const;
9+
DispatchObject* Alloc() const { return (DispatchObject*)new Exec_Flush(); }
10+
RetType Execute(CpptrajState&, ArgList&);
11+
};
12+
#endif

0 commit comments

Comments
 (0)