Skip to content
Snippets Groups Projects
Commit 3e1dc6d2 authored by Bienchen's avatar Bienchen
Browse files

First changes in MMCifParser

parent aac17c6c
Branches
Tags
No related merge requests found
//------------------------------------------------------------------------------
// This file is part of the OpenStructure project <www.openstructure.org>
//
// Copyright (C) 2008-2011 by the OpenStructure authors
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License as published by the Free
// Software Foundation; either version 3.0 of the License, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
// FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
// details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with this library; if not, write to the Free Software Foundation, Inc.,
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
//------------------------------------------------------------------------------
#include <boost/python.hpp>
using namespace boost::python;
#include <ost/io/mol/io_profile.hh>
#include <ost/io/mol/mmcif_reader.hh>
using namespace ost;
using namespace ost::io;
using namespace ost::mol;
void export_mmcif_io()
{
class_<MMCifParser, boost::noncopyable>("MMCifParser", init<const String&, EntityHandle&, const IOProfile&>())
.def("Parse", &MMCifParser::Parse)
.def("SetRestrictChains", &MMCifParser::SetRestrictChains)
.add_property("restrict_chains",
make_function(&MMCifParser::GetRestrictChains,
return_value_policy<copy_const_reference>()),
&MMCifParser::SetRestrictChains)
;
}
......@@ -53,7 +53,6 @@ void MMCifParser::Init()
warned_name_mismatch_ = false;
category_ = DONT_KNOW;
chain_count_ = 0;
record_type_ = "";
atom_count_ = 0;
residue_count_ = 0;
auth_chain_id_ = false;
......@@ -72,7 +71,6 @@ void MMCifParser::ClearState()
residue_count_ = 0;
atom_count_ = 0;
category_ = DONT_KNOW;
record_type_ = "";
warned_name_mismatch_ = false;
}
......@@ -170,11 +168,6 @@ bool MMCifParser::ParseAtomIdent(const std::vector<StringRef>& columns,
StringRef& atom_name,
char& alt_loc)
{
// is checking really neccessary? just by using OnBeginData, enough columns
// should be available!
if (!this->EnsureEnoughColumns(columns, 12)) {
return false;
}
// ATOM name
atom_name = columns[indices_[LABEL_ATOM_ID]];
if (profile_.calpha_only) { // unit test profile
......@@ -187,12 +180,12 @@ bool MMCifParser::ParseAtomIdent(const std::vector<StringRef>& columns,
chain_name = columns[indices_[AUTH_ASYM_ID]].str();
} else {
chain_name = columns[indices_[LABEL_ASYM_ID]].str();
if (restrict_chains_.size() > 0 && // unit test
restrict_chains_.find(chain_name) == String::npos) { // unit test
return false;
}
}
if (restrict_chains_.size() > 0 && // unit test
restrict_chains_.find(chain_name) == String::npos) { // unit test
return false;
}
std::pair<bool, int> a_num = this->TryGetInt(columns[indices_[ID]],
"_atom_site.id",
profile_.fault_tolerant); // unit test
......@@ -236,7 +229,7 @@ void MMCifParser::ParseAndAddAtom(const std::vector<StringRef>& columns)
alt_loc)) {
return;
}
Real occ, temp;
Real occ = 1.00f, temp = 0;
geom::Vec3 apos;
for (int i = CARTN_X; i <= CARTN_Z; ++i) {
......@@ -253,14 +246,10 @@ void MMCifParser::ParseAndAddAtom(const std::vector<StringRef>& columns)
if (indices_[OCCUPANCY] != -1) { // unit test
occ = this->TryGetReal(columns[indices_[OCCUPANCY]], "atom_site.occupancy");
} else {
occ = 1.00f;
}
if (indices_[B_ISO_OR_EQUIV] != -1) { // unit test
temp = this->TryGetReal(columns[indices_[B_ISO_OR_EQUIV]],
"atom_site.B_iso_or_equiv");
} else {
temp = 0;
}
// determine element
......@@ -370,20 +359,14 @@ void MMCifParser::ParseAndAddAtom(const std::vector<StringRef>& columns)
ah = editor.InsertAtom(curr_residue_, aname, apos, s_ele);
++atom_count_;
}
if (indices_[B_ISO_OR_EQUIV] != -1) {// unit test
ah.SetBFactor(temp);
}
if (indices_[OCCUPANCY] != -1) {// unit test
ah.SetOccupancy(occ);
}
ah.SetBFactor(temp);
ah.SetOccupancy(occ);
// record type
if (indices_[GROUP_PDB] != -1) {
record_type_ = columns[indices_[GROUP_PDB]].str();
} else {
record_type_ = "ATOM";
}
ah.SetHetAtom(record_type_[0]=='H');
ah.SetHetAtom(indices_[GROUP_PDB] == -1 ? false :
columns[indices_[GROUP_PDB]][0]=='H');
}
void MMCifParser::OnDataRow(const StarLoopDesc& header,
......
......@@ -29,13 +29,6 @@
namespace ost { namespace io {
/// \enum categories of the mmcif format
typedef enum {
ATOM_SITE,
DONT_KNOW
} MMCifCategory;
/// \brief reader for the mmcif file format
///
/// \section mmcif_format mmcif format description/ coverage
......@@ -183,6 +176,12 @@ private:
GROUP_PDB ///< record name
} AtomSiteItems;
/// \enum categories of the mmcif format
typedef enum {
ATOM_SITE,
DONT_KNOW
} MMCifCategory;
// members
MMCifCategory category_;
int indices_[MAX_ITEMS_IN_ROW]; ///< map items to values in loops
......@@ -196,7 +195,6 @@ private:
int residue_count_;
int atom_count_;
bool warned_name_mismatch_;
String record_type_;
bool go_on_; ///< flow control within the parser hooks
//from pdbdreader
//entity als member, fill in ondatarow
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment