Skip to content
Snippets Groups Projects
Commit 68318cee authored by Tobias Schmidt's avatar Tobias Schmidt
Browse files

Modified CHARMM crd format reader and writer:

  - fixed continuous residue numbering (BZDNG-286)
  - fixed bug with empty lines
  - fixed bug with reading residue name in std format
  - write b_factor in EXT format
  - segment name is now cname instead of 'MOL'
  - fixed alignment of residue name in std format
  - add documentation
  - add unit tests
  - possibility to request EXT format
parent c61030b1
No related branches found
No related tags found
No related merge requests found
...@@ -22,6 +22,7 @@ pov_*test.pov ...@@ -22,6 +22,7 @@ pov_*test.pov
pov_*test.inc pov_*test.inc
*-out.pdb *-out.pdb
*-out.sdf *-out.sdf
*-out.crd
CMakeLists.txt.user CMakeLists.txt.user
OpenStructure.cbp OpenStructure.cbp
DartConfiguration.tcl DartConfiguration.tcl
...@@ -51,4 +52,4 @@ Debug ...@@ -51,4 +52,4 @@ Debug
/deployment/win/create_archive.bat /deployment/win/create_archive.bat
/install_manifest.txt /install_manifest.txt
*_out.csv *_out.csv
/modules/io/tests/temp_img.tmp /modules/io/tests/temp_img.tmp
\ No newline at end of file
...@@ -44,17 +44,17 @@ bool compare_files(const String& test, const String& gold_standard) ...@@ -44,17 +44,17 @@ bool compare_files(const String& test, const String& gold_standard)
} }
if (!test_end) { if (!test_end) {
std::cerr << gold_standard << " contains additional line(s):" std::cerr << gold_standard << " contains additional line(s):"
<< std::endl << gold_line; << std::endl << gold_line << std::endl;
return false; return false;
} }
if (!gold_end) { if (!gold_end) {
std::cerr << test << " contains additional line(s):" std::cerr << test << " contains additional line(s):"
<< std::endl << test_line; << std::endl << test_line << std::endl;
return false; return false;
} }
if (gold_line!=test_line) { if (gold_line!=test_line) {
std::cerr << "line mismatch:" << std::endl << "test: " << test_line std::cerr << "line mismatch:" << std::endl << "test: " << test_line
<< std::endl << "gold: " << gold_line; << std::endl << "gold: " << gold_line << std::endl;
return false; return false;
} }
} }
......
...@@ -43,6 +43,11 @@ namespace ost { namespace io { ...@@ -43,6 +43,11 @@ namespace ost { namespace io {
using boost::format; using boost::format;
/// \brief Reader for CHARMM crd file format
///
/// Standard and extended CHARMM format is supported, and file format is
/// automatically detected based on file header or atom number
CRDReader::CRDReader(const boost::filesystem::path& loc): CRDReader::CRDReader(const boost::filesystem::path& loc):
sequential_atom_list_(), sequential_atom_list_(),
curr_chain_(), curr_chain_(),
...@@ -60,11 +65,14 @@ CRDReader::CRDReader(const boost::filesystem::path& loc): ...@@ -60,11 +65,14 @@ CRDReader::CRDReader(const boost::filesystem::path& loc):
if(!infile_) throw IOException("could not open "+loc.string()); if(!infile_) throw IOException("could not open "+loc.string());
} }
/// \brief Returns an vector containing all atom handles as observed in the file
std::vector<mol::AtomHandle> CRDReader::GetSequentialAtoms() const std::vector<mol::AtomHandle> CRDReader::GetSequentialAtoms() const
{ {
return sequential_atom_list_; return sequential_atom_list_;
} }
/// \brief Performes file import
void CRDReader::Import(mol::EntityHandle& ent) void CRDReader::Import(mol::EntityHandle& ent)
{ {
Profile profile_import("CRDReader::Import"); Profile profile_import("CRDReader::Import");
...@@ -79,21 +87,24 @@ void CRDReader::Import(mol::EntityHandle& ent) ...@@ -79,21 +87,24 @@ void CRDReader::Import(mol::EntityHandle& ent)
std::vector<String> line_content; std::vector<String> line_content;
boost::trim(line); boost::trim(line);
boost::split(line_content,line,boost::is_any_of(" ")); boost::split(line_content,line,boost::is_any_of(" "));
// expanded charmm CARD format check // expanded charmm CARD format check
if (line_content.size() > 1 || boost::lexical_cast<int>(line_content[0]) > 99999) if (line_content.size() > 1 || boost::lexical_cast<int>(line_content[0]) > 99999)
while(std::getline(in_,line)) { while(std::getline(in_,line)) {
ParseAndAddAtomExpanded(line,ent); if (!boost::trim_copy(line).empty())
ParseAndAddAtomExpanded(line,ent);
} }
else else
while(std::getline(in_,line)) { while(std::getline(in_,line)) {
ParseAndAddAtom(line,ent); if (!boost::trim_copy(line).empty())
ParseAndAddAtom(line,ent);
} }
LOG_INFO("imported " << chain_count_ << " chains, " << residue_count_ LOG_INFO("imported " << chain_count_ << " chains, " << residue_count_
<< " residues, " << atom_count_ << " atoms"); << " residues, " << atom_count_ << " atoms");
} }
/// \brief Parsing for standard format
void CRDReader::ParseAndAddAtom(const String& line, mol::EntityHandle& ent) void CRDReader::ParseAndAddAtom(const String& line, mol::EntityHandle& ent)
{ {
mol::XCSEditor editor=ent.EditXCS(mol::BUFFERED_EDIT); mol::XCSEditor editor=ent.EditXCS(mol::BUFFERED_EDIT);
...@@ -103,7 +114,7 @@ void CRDReader::ParseAndAddAtom(const String& line, mol::EntityHandle& ent) ...@@ -103,7 +114,7 @@ void CRDReader::ParseAndAddAtom(const String& line, mol::EntityHandle& ent)
//int anum = boost::lexical_cast<int>(boost::trim_copy(line.substr(0,5))); //int anum = boost::lexical_cast<int>(boost::trim_copy(line.substr(0,5)));
String aname = boost::trim_copy(line.substr(16,4)); String aname = boost::trim_copy(line.substr(16,4));
String ele = aname.substr(0,1); String ele = aname.substr(0,1);
String rname = boost::trim_copy(line.substr(11,3)); String rname = boost::trim_copy(line.substr(11,4));
int irnum = boost::lexical_cast<int>(boost::trim_copy(line.substr(55,4))); int irnum = boost::lexical_cast<int>(boost::trim_copy(line.substr(55,4)));
String s_chain = boost::trim_copy(line.substr(51,4)); String s_chain = boost::trim_copy(line.substr(51,4));
geom::Vec3 apos(boost::lexical_cast<Real>(boost::trim_copy(line.substr(21,9))), geom::Vec3 apos(boost::lexical_cast<Real>(boost::trim_copy(line.substr(21,9))),
...@@ -155,7 +166,8 @@ void CRDReader::ParseAndAddAtom(const String& line, mol::EntityHandle& ent) ...@@ -155,7 +166,8 @@ void CRDReader::ParseAndAddAtom(const String& line, mol::EntityHandle& ent)
sequential_atom_list_.push_back(ah); sequential_atom_list_.push_back(ah);
++atom_count_; ++atom_count_;
} }
/// \brief Parsing for extended format
void CRDReader::ParseAndAddAtomExpanded(const String& line, mol::EntityHandle& ent) void CRDReader::ParseAndAddAtomExpanded(const String& line, mol::EntityHandle& ent)
{ {
mol::XCSEditor editor=ent.EditXCS(mol::BUFFERED_EDIT); mol::XCSEditor editor=ent.EditXCS(mol::BUFFERED_EDIT);
...@@ -167,10 +179,11 @@ void CRDReader::ParseAndAddAtomExpanded(const String& line, mol::EntityHandle& e ...@@ -167,10 +179,11 @@ void CRDReader::ParseAndAddAtomExpanded(const String& line, mol::EntityHandle& e
String ele = aname.substr(0,1); String ele = aname.substr(0,1);
String rname = boost::trim_copy(line.substr(22,8)); String rname = boost::trim_copy(line.substr(22,8));
int irnum = boost::lexical_cast<int>(boost::trim_copy(line.substr(112,8))); int irnum = boost::lexical_cast<int>(boost::trim_copy(line.substr(112,8)));
String s_chain = boost::trim_copy(line.substr(102.8,8)); String s_chain = boost::trim_copy(line.substr(102,8));
geom::Vec3 apos(boost::lexical_cast<Real>(boost::trim_copy(line.substr(40,20))), geom::Vec3 apos(boost::lexical_cast<Real>(boost::trim_copy(line.substr(40,20))),
boost::lexical_cast<Real>(boost::trim_copy(line.substr(60,20))), boost::lexical_cast<Real>(boost::trim_copy(line.substr(60,20))),
boost::lexical_cast<Real>(boost::trim_copy(line.substr(80,20)))); boost::lexical_cast<Real>(boost::trim_copy(line.substr(80,20))));
Real b_factor = boost::lexical_cast<Real>(boost::trim_copy(line.substr(128,12)));
mol::ResidueKey rkey(rname); mol::ResidueKey rkey(rname);
...@@ -213,28 +226,38 @@ void CRDReader::ParseAndAddAtomExpanded(const String& line, mol::EntityHandle& e ...@@ -213,28 +226,38 @@ void CRDReader::ParseAndAddAtomExpanded(const String& line, mol::EntityHandle& e
// finally add atom // finally add atom
LOG_DEBUG("adding atom " << aname << " (" << ele << ") @" << apos); LOG_DEBUG("adding atom " << aname << " (" << ele << ") @" << apos);
mol::AtomHandle ah = editor.InsertAtom(curr_residue_, aname, apos, ele); mol::AtomHandle ah = editor.InsertAtom(curr_residue_, aname, apos, ele,
1.0, b_factor);
sequential_atom_list_.push_back(ah); sequential_atom_list_.push_back(ah);
++atom_count_; ++atom_count_;
} }
CRDWriter::CRDWriter(std::ostream& ostream) : /// \brief CHARMM format writer
outfile_(), outstream_(ostream), atom_count_(0) ///
/// The charmm format writer supports both the standard and the extended
/// format. Standard format supports at maximum 99999 atoms. If less atoms than
/// that are present, the default format is standard format, otherwise the
/// extended format is used. Extended format can be requested by setting the
/// parameter ext to true.
CRDWriter::CRDWriter(std::ostream& ostream, bool ext) :
outfile_(), outstream_(ostream), ext_(ext), atom_count_(0), res_count_(0)
{} {}
CRDWriter::CRDWriter(const boost::filesystem::path& filename) : CRDWriter::CRDWriter(const boost::filesystem::path& filename, bool ext) :
#if BOOST_FILESYSTEM_VERSION==3 #if BOOST_FILESYSTEM_VERSION==3
outfile_(filename.string().c_str()), outstream_(outfile_), outfile_(filename.string().c_str()), outstream_(outfile_),
#else #else
outfile_(filename.file_string().c_str()), outstream_(outfile_), outfile_(filename.file_string().c_str()), outstream_(outfile_),
#endif #endif
atom_count_(0) ext_(ext), atom_count_(0), res_count_(0)
{} {}
CRDWriter::CRDWriter(const String& filename) : CRDWriter::CRDWriter(const String& filename, bool ext) :
outfile_(filename.c_str()), outstream_(outfile_), atom_count_(0) outfile_(filename.c_str()), outstream_(outfile_), ext_(ext), atom_count_(0),
res_count_(0)
{} {}
/// \brief Write header containing standard title and atom count/format row
void CRDWriter::WriteHeader(const mol::EntityView& ent) void CRDWriter::WriteHeader(const mol::EntityView& ent)
{ {
outstream_ << "* COOR FILE CREATED BY OPENSTRUCTURE" << std::endl; outstream_ << "* COOR FILE CREATED BY OPENSTRUCTURE" << std::endl;
...@@ -242,7 +265,7 @@ void CRDWriter::WriteHeader(const mol::EntityView& ent) ...@@ -242,7 +265,7 @@ void CRDWriter::WriteHeader(const mol::EntityView& ent)
atom_total_ = ent.GetAtomCount(); atom_total_ = ent.GetAtomCount();
if (atom_total_ > 99999) { if (atom_total_ > 99999 || ext_) {
outstream_ << format("%10i") % ent.GetAtomCount() << " EXT" << std::endl; outstream_ << format("%10i") % ent.GetAtomCount() << " EXT" << std::endl;
} }
else { else {
...@@ -250,6 +273,43 @@ void CRDWriter::WriteHeader(const mol::EntityView& ent) ...@@ -250,6 +273,43 @@ void CRDWriter::WriteHeader(const mol::EntityView& ent)
} }
} }
/// \brief Performs re-initialisation for writer
///
/// Currently, this only sets the residue count to zero
void CRDWriter::Init()
{
res_count_ = 0;
}
void CRDWriter::Write(const mol::EntityView& ent)
{
if (!outstream_) {
throw IOException("Can't write CRD file. Bad output stream");
}
this->Init();
mol::EntityView non_const_view = ent;
this->WriteHeader(non_const_view);
non_const_view.Apply(*this);
}
void CRDWriter::Write(const mol::EntityHandle& ent)
{
if (!outstream_) {
throw IOException("Can't write CRD file. Bad output stream");
}
this->Init();
mol::EntityView non_const_view = ent.CreateFullView();
this->WriteHeader(non_const_view);
non_const_view.Apply(*this);
}
bool CRDWriter::VisitResidue(const mol::ResidueHandle& r)
{
res_count_++;
return true;
}
bool CRDWriter::VisitAtom(const mol::AtomHandle& atom) bool CRDWriter::VisitAtom(const mol::AtomHandle& atom)
{ {
atom_count_++; atom_count_++;
...@@ -260,27 +320,27 @@ bool CRDWriter::VisitAtom(const mol::AtomHandle& atom) ...@@ -260,27 +320,27 @@ bool CRDWriter::VisitAtom(const mol::AtomHandle& atom)
mol::ResidueHandle res=atom.GetResidue(); mol::ResidueHandle res=atom.GetResidue();
if (atom_total_ > 99999) { if (atom_total_ > 99999 || ext_) {
outstream_ << format("%10i") % atom_count_ outstream_ << format("%10i") % atom_count_
<< format("%10i") % res.GetNumber() << " " << format("%10i") % res_count_ << " "
<< format("%-8s") % res.GetKey() << " " << format("%-8s") % res.GetKey() << " "
<< format("%-8s") % atom.GetName() << format("%-8s") % atom.GetName()
<< format("%20.10f") % atom.GetPos().x << format("%20.10f") % atom.GetPos().x
<< format("%20.10f") % atom.GetPos().y << format("%20.10f") % atom.GetPos().y
<< format("%20.10f") % atom.GetPos().z << " " << format("%20.10f") % atom.GetPos().z << " "
<< format("%-8s") % e_name << " " << format("%-8s") % res.GetChain().GetName() << " "
<< format("%-8i") % res.GetNumber() << format("%-8i") % res.GetNumber()
<< format("%20.10f") % atom.GetBFactor() << format("%20.10f") % atom.GetBFactor()
<< std::endl; << std::endl;
} else { } else {
outstream_ << format("%5i") % atom_count_ outstream_ << format("%5i") % atom_count_
<< format("%5i") % res.GetNumber() << " " << format("%5i") % res_count_ << " "
<< format("%4s") % res.GetKey() << " " << format("%-4s") % res.GetKey() << " "
<< format("%-4s") % atom.GetName() << format("%-4s") % atom.GetName()
<< format("%10.5f") % atom.GetPos().x << format("%10.5f") % atom.GetPos().x
<< format("%10.5f") % atom.GetPos().y << format("%10.5f") % atom.GetPos().y
<< format("%10.5f") % atom.GetPos().z << " " << format("%10.5f") % atom.GetPos().z << " "
<< format("%-4s") % e_name << " " << format("%-4s") % res.GetChain().GetName() << " "
<< format("%-5i") % res.GetNumber() << " " << format("%-5i") % res.GetNumber() << " "
<< format("%8.5f") % atom.GetBFactor() << format("%8.5f") % atom.GetBFactor()
<< std::endl; << std::endl;
...@@ -288,6 +348,7 @@ bool CRDWriter::VisitAtom(const mol::AtomHandle& atom) ...@@ -288,6 +348,7 @@ bool CRDWriter::VisitAtom(const mol::AtomHandle& atom)
return true; return true;
} }
/// \brief CHARMM file format requires builder
bool EntityIOCRDHandler::RequiresBuilder() const bool EntityIOCRDHandler::RequiresBuilder() const
{ {
return true; return true;
...@@ -304,18 +365,14 @@ void EntityIOCRDHandler::Export(const mol::EntityView& ent, ...@@ -304,18 +365,14 @@ void EntityIOCRDHandler::Export(const mol::EntityView& ent,
std::ostream& stream) const std::ostream& stream) const
{ {
CRDWriter writer(stream); CRDWriter writer(stream);
writer.WriteHeader(ent); writer.Write(ent);
mol::EntityView non_const_view = ent;
non_const_view.Apply(writer);
} }
void EntityIOCRDHandler::Export(const mol::EntityView& ent, void EntityIOCRDHandler::Export(const mol::EntityView& ent,
const boost::filesystem::path& loc) const const boost::filesystem::path& loc) const
{ {
CRDWriter writer(loc); CRDWriter writer(loc);
writer.WriteHeader(ent); writer.Write(ent);
mol::EntityView non_const_view = ent;
non_const_view.Apply(writer);
} }
namespace { namespace {
......
...@@ -16,14 +16,13 @@ ...@@ -16,14 +16,13 @@
// along with this library; if not, write to the Free Software Foundation, Inc., // along with this library; if not, write to the Free Software Foundation, Inc.,
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
/*
Author: Ansgar Philippsen, Tobias Schmidt
*/
#ifndef OST_IO_ENTITY_IO_PLUGIN_CRD_H #ifndef OST_IO_ENTITY_IO_PLUGIN_CRD_H
#define OST_IO_ENTITY_IO_PLUGIN_CRD_H #define OST_IO_ENTITY_IO_PLUGIN_CRD_H
/*
CHARMM coordinate file import
Author: Ansgar Philippsen
*/
#include <ost/mol/entity_handle.hh> #include <ost/mol/entity_handle.hh>
#include <ost/mol/chain_handle.hh> #include <ost/mol/chain_handle.hh>
#include <ost/mol/residue_handle.hh> #include <ost/mol/residue_handle.hh>
...@@ -35,6 +34,7 @@ ...@@ -35,6 +34,7 @@
namespace ost { namespace io { namespace ost { namespace io {
/// \brief CHARMM coordinate file import
class DLLEXPORT_OST_IO CRDReader { class DLLEXPORT_OST_IO CRDReader {
public: public:
CRDReader(const boost::filesystem::path& loc); CRDReader(const boost::filesystem::path& loc);
...@@ -58,22 +58,30 @@ private: ...@@ -58,22 +58,30 @@ private:
boost::iostreams::filtering_stream<boost::iostreams::input> in_; boost::iostreams::filtering_stream<boost::iostreams::input> in_;
}; };
/// \brief CHARMM coordinate file export
class DLLEXPORT_OST_IO CRDWriter : public mol::EntityVisitor { class DLLEXPORT_OST_IO CRDWriter : public mol::EntityVisitor {
public: public:
CRDWriter(const String& filename); CRDWriter(const String& filename, bool ext=false);
CRDWriter(const boost::filesystem::path& filename); CRDWriter(const boost::filesystem::path& filename, bool ext=false);
CRDWriter(std::ostream& outstream); CRDWriter(std::ostream& outstream, bool ext=false);
void Write(const mol::EntityView& ent);
void Write(const mol::EntityHandle& ent);
virtual bool VisitAtom(const mol::AtomHandle& atom); virtual bool VisitAtom(const mol::AtomHandle& atom);
virtual bool VisitResidue(const mol::ResidueHandle& r);
void WriteHeader(const mol::EntityView& ent); void WriteHeader(const mol::EntityView& ent);
private: private:
void Init();
std::ofstream outfile_; std::ofstream outfile_;
std::ostream& outstream_; std::ostream& outstream_;
bool ext_;
int atom_count_; int atom_count_;
int atom_total_; int atom_total_;
int res_count_;
}; };
class DLLEXPORT_OST_IO EntityIOCRDHandler: public EntityIOHandler { class DLLEXPORT_OST_IO EntityIOCRDHandler: public EntityIOHandler {
......
...@@ -16,8 +16,10 @@ ...@@ -16,8 +16,10 @@
// along with this library; if not, write to the Free Software Foundation, Inc., // along with this library; if not, write to the Free Software Foundation, Inc.,
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
#include <ost/test_utils/compare_files.hh>
#include <ost/mol/mol.hh> #include <ost/mol/mol.hh>
#include <ost/io/mol/entity_io_crd_handler.hh> #include <ost/io/mol/entity_io_crd_handler.hh>
#include <ost/io/save_entity.hh>
#define BOOST_TEST_DYN_LINK #define BOOST_TEST_DYN_LINK
#include <boost/test/unit_test.hpp> #include <boost/test/unit_test.hpp>
...@@ -27,16 +29,129 @@ using namespace ost::io; ...@@ -27,16 +29,129 @@ using namespace ost::io;
BOOST_AUTO_TEST_SUITE( io ) BOOST_AUTO_TEST_SUITE( io )
BOOST_AUTO_TEST_CASE(test_io_crd_import_handler)
{
String fname("testfiles/crd/test_in.crd");
mol::EntityHandle eh=mol::CreateEntity();
EntityIOCRDHandler crdh;
BOOST_CHECK(EntityIOCRDHandler::ProvidesImport("","crd"));
BOOST_CHECK(EntityIOCRDHandler::ProvidesImport(fname));
BOOST_CHECK(EntityIOCRDHandler::ProvidesImport("test_in.CRD"));
BOOST_CHECK(EntityIOCRDHandler::ProvidesExport("","crd"));
BOOST_CHECK(EntityIOCRDHandler::ProvidesExport(fname));
BOOST_CHECK(EntityIOCRDHandler::ProvidesExport("test_in.CRD"));
}
/// check standard format input
BOOST_AUTO_TEST_CASE(test_io_crd) BOOST_AUTO_TEST_CASE(test_io_crd)
{ {
const String fname("testfiles/test_in.crd"); const String fname("testfiles/crd/test_in.crd");
mol::EntityHandle eh=mol::CreateEntity();
CRDReader crdr(fname);
crdr.Import(eh);
std::vector<mol::AtomHandle> alist = crdr.GetSequentialAtoms();
BOOST_CHECK_EQUAL(eh.GetAtomCount(), 9);
BOOST_CHECK_EQUAL(eh.GetResidueCount(), 2);
BOOST_CHECK_EQUAL(eh.GetChainCount(), 2);
BOOST_CHECK_EQUAL(eh.GetResidueList()[0].GetNumber().GetNum(), 3);
BOOST_CHECK_EQUAL(eh.GetResidueList()[1].GetNumber().GetNum(), 4);
BOOST_CHECK_EQUAL(eh.GetResidueList()[0].GetName(), "ALA");
BOOST_CHECK_EQUAL(eh.GetResidueList()[1].GetName(), "P2AC");
BOOST_CHECK_EQUAL(eh.GetAtomList()[0].GetName(), "N");
BOOST_CHECK_EQUAL(eh.GetAtomList()[7].GetName(), "HA51");
BOOST_CHECK_EQUAL(eh.GetChainList()[0].GetName(), "PEPT");
BOOST_CHECK_EQUAL(eh.GetChainList()[1].GetName(), "RNA");
}
/// check extended format input
BOOST_AUTO_TEST_CASE(test_io_crd_ext)
{
const String fname("testfiles/crd/multisegment.crd");
mol::EntityHandle eh=mol::CreateEntity(); mol::EntityHandle eh=mol::CreateEntity();
CRDReader crdr(fname); CRDReader crdr(fname);
crdr.Import(eh); crdr.Import(eh);
std::vector<mol::AtomHandle> alist = crdr.GetSequentialAtoms(); std::vector<mol::AtomHandle> alist = crdr.GetSequentialAtoms();
BOOST_CHECK_EQUAL(eh.GetAtomCount(), 43);
BOOST_CHECK_EQUAL(eh.GetResidueCount(), 6);
BOOST_CHECK_EQUAL(eh.GetChainCount(), 3);
BOOST_CHECK_EQUAL(eh.GetResidueList()[0].GetNumber().GetNum(), 1);
BOOST_CHECK_EQUAL(eh.GetResidueList()[1].GetNumber().GetNum(), 2);
BOOST_CHECK_EQUAL(eh.GetResidueList()[2].GetNumber().GetNum(), 1);
BOOST_CHECK_EQUAL(eh.GetResidueList()[0].GetName(), "GLY");
BOOST_CHECK_EQUAL(eh.GetResidueList()[1].GetName(), "GLU");
BOOST_CHECK_EQUAL(eh.GetResidueList()[2].GetName(), "G3AC");
BOOST_CHECK_EQUAL(eh.GetAtomList()[0].GetName(), "N");
BOOST_CHECK_EQUAL(eh.GetAtomList()[20].GetName(), "OE1");
BOOST_CHECK_EQUAL(eh.GetChainList()[0].GetName(), "PROTEIN");
BOOST_CHECK_EQUAL(eh.GetChainList()[1].GetName(), "RNA");
BOOST_CHECK_EQUAL(eh.GetChainList()[2].GetName(), "SAM");
} }
BOOST_AUTO_TEST_SUITE_END() /// check that empty lines at end of file are ignored
\ No newline at end of file BOOST_AUTO_TEST_CASE(test_io_crd_empty_line)
{
const String fname("testfiles/crd/empty_line_at_end.crd");
mol::EntityHandle eh=mol::CreateEntity();
CRDReader reader(fname);
reader.Import(eh);
}
/// check extended format with multisegment file output
BOOST_AUTO_TEST_CASE(test_io_crd_writer_ext)
{
const String fname("testfiles/crd/multisegment.crd");
{
mol::EntityHandle eh=mol::CreateEntity();
CRDReader reader(fname);
reader.Import(eh);
CRDWriter writer(String("testfiles/crd/multisegment-out.crd"), true);
writer.Write(eh);
}
BOOST_CHECK(compare_files("testfiles/crd/multisegment-out.crd",
"testfiles/crd/multisegment.crd"));
}
/// check standard format output
BOOST_AUTO_TEST_CASE(test_io_crd_writer_std)
{
const String fname("testfiles/crd/test_in.crd");
{
mol::EntityHandle eh=mol::CreateEntity();
CRDReader reader(fname);
reader.Import(eh);
CRDWriter writer(String("testfiles/crd/test-out.crd"));
writer.Write(eh);
}
BOOST_CHECK(compare_files("testfiles/crd/test-out.crd",
"testfiles/crd/test_in.crd"));
}
/// check standard format is written by default
BOOST_AUTO_TEST_CASE(test_io_crd_default_format)
{
const String fname("testfiles/crd/test_in.crd");
{
mol::EntityHandle eh=mol::CreateEntity();
CRDReader reader(fname);
reader.Import(eh);
ost::io::SaveEntity(eh, "testfiles/crd/test-out.crd");
}
BOOST_CHECK(compare_files("testfiles/crd/test-out.crd",
"testfiles/crd/test_in.crd"));
}
BOOST_AUTO_TEST_SUITE_END()
* COOR FILE CREATED BY OPENSTRUCTURE
*
9
1 1 ALA N -2.53857 10.36006 28.21452 PEPT 3 0.00000
2 1 ALA HT1 -2.09853 10.16934 29.15484 PEPT 3 0.00000
3 1 ALA HT2 -3.19965 9.53958 28.27807 PEPT 3 0.00000
4 1 ALA HT3 -3.03496 11.26844 28.29274 PEPT 3 0.00000
5 1 ALA CA -1.58333 10.24913 27.09525 PEPT 3 0.00000
6 1 ALA HA -0.74083 9.67002 27.43410 PEPT 3 0.00000
7 1 ALA CB -2.26337 9.53603 25.91124 PEPT 3 0.00000
8 2 P2AC HA51 -6.76933 80.69502 15.53886 RNA 4 0.00000
9 2 P2AC HA52 -8.23100 81.32728 16.35343 RNA 4 0.00000
* COOR FILE CREATED BY OPENSTRUCTURE
*
43 EXT
1 1 GLY N -2.0000000000 -8.5000000000 -4.0000000000 PROTEIN 1 0.0000916632
2 1 GLY HT1 -16.1250000000 -16.0009765625 -16.1259765625 PROTEIN 1 0.0000787743
3 1 GLY HT2 -24.0502128601 -10.1571445465 -4.7282133102 PROTEIN 1 0.0000787526
4 1 GLY HT3 -25.6165981293 -10.6957426071 -5.4588241577 PROTEIN 1 0.0000786720
5 1 GLY CA -25.3130340576 -11.3211555481 -3.5009372234 PROTEIN 1 0.0000978857
6 1 GLY HA1 -26.2965011597 -11.7470941544 -3.6310827732 PROTEIN 1 0.0000000000
7 1 GLY HA2 -25.4361457825 -10.4118413925 -2.8764421940 PROTEIN 1 0.0000851970
8 1 GLY C -24.4854793549 -12.3229217529 -2.9330530167 PROTEIN 1 0.0000944421
9 1 GLY O -23.7718524933 -13.0324668884 -3.6388895512 PROTEIN 1 0.0000894775
10 2 GLU N -24.5463562012 -12.6111087799 -1.6436747313 PROTEIN 2 0.0000000000
11 2 GLU HN -23.9035968781 -13.3227586746 -1.3749105930 PROTEIN 2 0.0000000000
12 2 GLU CA -25.4813365936 -12.0606479645 -0.6506563425 PROTEIN 2 0.0000000000
13 2 GLU HA -26.1672992706 -11.3891696930 -1.1180906296 PROTEIN 2 0.0000000000
14 2 GLU CB -26.2274837494 -13.2668724060 0.0429458581 PROTEIN 2 0.0000000000
15 2 GLU HB1 -26.7839298248 -12.7876672745 0.9326843023 PROTEIN 2 0.0030197345
16 2 GLU HB2 -25.4761943817 -13.9268684387 0.5624338984 PROTEIN 2 0.0000000000
17 2 GLU CG -27.2343692780 -13.8997907639 -0.9133957624 PROTEIN 2 0.0166021846
18 2 GLU HG1 -27.7255306244 -14.7208814621 -0.4454757869 PROTEIN 2 0.0368194766
19 2 GLU HG2 -26.6897678375 -14.4738664627 -1.8157539368 PROTEIN 2 0.0017852589
20 2 GLU CD -28.2506389618 -13.0106611252 -1.5168483257 PROTEIN 2 0.0774637908
21 2 GLU OE1 -29.3007488251 -12.8661479950 -0.8537709117 PROTEIN 2 0.1687415987
22 2 GLU OE2 -28.2000064850 -12.5138931274 -2.6356098652 PROTEIN 2 0.0706803948
23 2 GLU C -24.6928653717 -11.2268772125 0.3724045455 PROTEIN 2 0.0000000000
24 2 GLU O -25.2389545441 -10.7677593231 1.3376628160 PROTEIN 2 0.0000000000
25 3 G3AC N9 -15.8120441437 6.0608630180 -6.6949663162 RNA 1 0.0000393577
26 3 G3AC C4 -16.9207630157 6.8197221756 -7.0580096245 RNA 1 0.0000500576
27 3 G3AC N2 -20.2281303406 7.6236495972 -6.4126434326 RNA 1 0.0000850955
28 3 G3AC H21 -20.3844623566 6.9206910133 -5.6787233353 RNA 1 0.0000501027
29 3 G3AC H22 -20.8750762939 8.3805465698 -6.5524845123 RNA 1 0.0000851209
30 3 G3AC N3 -18.1747817993 6.6029930115 -6.5917358398 RNA 1 0.0000000000
31 4 GUA P -1.5319050550 5.2959299088 -0.6717305183 RNA 2 0.0000786968
32 4 GUA O1P -0.8520842195 4.0187578201 -0.6064184904 RNA 2 0.0000477555
33 4 GUA O2P -1.8167773485 6.0385017395 0.5593457222 RNA 2 0.0000425713
34 4 GUA O5' -0.7149851322 6.1814560890 -1.7396181822 RNA 2 0.0000425333
35 5 CYT P 2.5655767918 10.5823450089 -2.4465763569 RNA 3 0.0000425641
36 5 CYT O1P 3.6461751461 10.5359878540 -3.4340066910 RNA 3 0.0000000000
37 5 CYT O2P 2.8808369637 11.1873378754 -1.1375198364 RNA 3 0.0000000000
38 5 CYT O5' 1.2869589329 11.2338676453 -3.0263113976 RNA 3 0.0000917684
39 6 SAM N 4.0659961700 1.8457804918 -0.2989104986 SAM 1 0.0001180591
40 6 SAM HT1 4.6446375847 1.0045971870 -0.1713269502 SAM 1 0.0001002858
41 6 SAM HT2 4.0898685455 2.4858167171 0.5328502059 SAM 1 0.0000425641
42 6 SAM HT3 3.1142795086 1.6198593378 -0.4299965501 SAM 1 0.0000978186
43 6 SAM CA 4.8570294380 2.6207458973 -1.2435295582 SAM 1 0.0000851861
* FULL SYSTEM * COOR FILE CREATED BY OPENSTRUCTURE
* AFTER MINIMIZATION AND 5 PSEC DYNAMICS *
* DATE: 4/ 5/ 5 8:46:31 CREATED BY USER: bernechs 9
* 1 1 ALA N -2.53857 10.36006 28.21452 PEPT 3 0.00000
45283 2 1 ALA HT1 -2.09853 10.16934 29.15484 PEPT 3 0.00000
1 1 ALA N -2.53857 10.36006 28.21452 PEPT 3 0.00000 3 1 ALA HT2 -3.19965 9.53958 28.27807 PEPT 3 0.00000
2 1 ALA HT1 -2.09853 10.16934 29.15484 PEPT 3 0.00000 4 1 ALA HT3 -3.03496 11.26844 28.29274 PEPT 3 0.00000
3 1 ALA HT2 -3.19965 9.53958 28.27807 PEPT 3 0.00000 5 1 ALA CA -1.58333 10.24913 27.09525 PEPT 3 0.00000
4 1 ALA HT3 -3.03496 11.26844 28.29274 PEPT 3 0.00000 6 1 ALA HA -0.74083 9.67002 27.43410 PEPT 3 0.00000
5 1 ALA CA -1.58333 10.24913 27.09525 PEPT 3 0.00000 7 1 ALA CB -2.26337 9.53603 25.91124 PEPT 3 0.00000
6 1 ALA HA -0.74083 9.67002 27.43410 PEPT 3 0.00000 8 2 P2AC HA51 -6.76933 80.69502 15.53886 RNA 4 0.00000
7 1 ALA CB -2.26337 9.53603 25.91124 PEPT 3 0.00000 9 2 P2AC HA52 -8.23100 81.32728 16.35343 RNA 4 0.00000
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment