From 5c031c576a0f1e2846817df25a8fba391e9f9599 Mon Sep 17 00:00:00 2001 From: Tobias Schmidt <tobias.schmidt@unibas.ch> Date: Mon, 10 Jan 2011 16:54:45 +0100 Subject: [PATCH] fix chainname bug in SDF writer --- modules/io/src/mol/sdf_writer.cc | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/modules/io/src/mol/sdf_writer.cc b/modules/io/src/mol/sdf_writer.cc index b6243b4a6..23f5d3ed4 100644 --- a/modules/io/src/mol/sdf_writer.cc +++ b/modules/io/src/mol/sdf_writer.cc @@ -21,6 +21,7 @@ */ #include "sdf_writer.hh" +#include <boost/regex.hpp> namespace ost { namespace io { @@ -116,11 +117,19 @@ bool SDFWriter::VisitChain(const mol::ChainHandle& chain) { atom_indices_.clear(); } + // remove chain number if added when reading from sdf file + String cname = chain.GetName(); + if (cname.length()>6) { + boost::regex pattern = boost::regex("^[0-9]{5}_"); + if (boost::regex_search(cname, pattern)) { + cname = cname.substr(6); + } + } + // print header lines - ostr_ << chain.GetName().substr(6) << std::endl; + ostr_ << cname << std::endl; ostr_ << std::endl; ostr_ << std::endl; - // print counts line ostr_ << format("%3d") % chain.GetAtomCount() << format("%3d") % chain.GetBondCount() -- GitLab