Skip to content
Snippets Groups Projects
Commit fb1e41fb authored by Ansgar Philippsen's avatar Ansgar Philippsen
Browse files

fixed slow MAE import; debug output cleanup

parent c110b907
Branches
Tags
No related merge requests found
...@@ -119,8 +119,8 @@ HeuristicBuilder::HeuristicBuilder(): ...@@ -119,8 +119,8 @@ HeuristicBuilder::HeuristicBuilder():
heuristic_connect::CONN_DEF_ENTRY& def_entry = heuristic_connect::def_entry_table[ec]; heuristic_connect::CONN_DEF_ENTRY& def_entry = heuristic_connect::def_entry_table[ec];
detail::ConnResEntry entry(def_entry.abbrev, def_entry.single, detail::ConnResEntry entry(def_entry.abbrev, def_entry.single,
def_entry.chem_class); def_entry.chem_class);
LOG_DEBUG("creating table entry for " << def_entry.abbrev); LOG_TRACE("creating table entry for " << def_entry.abbrev);
LOG_DEBUG("working on bond entries"); LOG_TRACE("working on bond entries");
for (int xx=0;xx<def_entry.name_count;++xx) { for (int xx=0;xx<def_entry.name_count;++xx) {
String name=def_entry.name_list[xx]; String name=def_entry.name_list[xx];
if (name!="OXT") if (name!="OXT")
...@@ -152,9 +152,9 @@ HeuristicBuilder::HeuristicBuilder(): ...@@ -152,9 +152,9 @@ HeuristicBuilder::HeuristicBuilder():
else if(conn_nam[1]==String("-")) { entry.SetPrev(conn_nam[0]);} else if(conn_nam[1]==String("-")) { entry.SetPrev(conn_nam[0]);}
else if(conn_nam[0]==String("+")) { entry.SetNext(conn_nam[1]);} else if(conn_nam[0]==String("+")) { entry.SetNext(conn_nam[1]);}
else if(conn_nam[1]==String("+")) { entry.SetNext(conn_nam[0]);} else if(conn_nam[1]==String("+")) { entry.SetNext(conn_nam[0]);}
LOG_DEBUG(" " << conn_nam[0] << " " << conn_nam[1]); LOG_TRACE(" " << conn_nam[0] << " " << conn_nam[1]);
} else { } else {
LOG_DEBUG(" " << conn_nam[0] << " " << conn_nam[1]); LOG_TRACE(" " << conn_nam[0] << " " << conn_nam[1]);
entry.AddConn(conn_nam[0],conn_nam[1]); entry.AddConn(conn_nam[0],conn_nam[1]);
} }
} }
...@@ -205,18 +205,18 @@ void HeuristicBuilder::ConnectivityFromAtomNames(const mol::ResidueHandle& res, ...@@ -205,18 +205,18 @@ void HeuristicBuilder::ConnectivityFromAtomNames(const mol::ResidueHandle& res,
mol::AtomHandleList::iterator it2=it1; mol::AtomHandleList::iterator it2=it1;
++it2; ++it2;
for (;it2!=atomlist.end();++it2) { for (;it2!=atomlist.end();++it2) {
LOG_DEBUG("checking for atom pair (" << it1->GetName() << "," LOG_TRACE("checking for atom pair (" << it1->GetName() << ","
<< it2->GetName() << ") in connectivity table of " << it2->GetName() << ") in connectivity table of "
<< res.GetKey() << "... "); << res.GetKey() << "... ");
int conn=centry.Check(it1->GetName(),it2->GetName()); int conn=centry.Check(it1->GetName(),it2->GetName());
if (conn==1 && this->IsBondFeasible(*it1, *it2)) { if (conn==1 && this->IsBondFeasible(*it1, *it2)) {
LOG_DEBUG( "found"); LOG_TRACE( "found");
editor.Connect(*it1,*it2); editor.Connect(*it1,*it2);
} else if(conn==2 && this->IsBondFeasible(*it2, *it1)) { } else if(conn==2 && this->IsBondFeasible(*it2, *it1)) {
LOG_DEBUG( "found (reversed)"); LOG_TRACE( "found (reversed)");
editor.Connect(*it2,*it1); editor.Connect(*it2,*it1);
} else { } else {
LOG_DEBUG( "not found"); LOG_TRACE( "not found");
} }
} }
} else { } else {
...@@ -227,7 +227,7 @@ void HeuristicBuilder::ConnectivityFromAtomNames(const mol::ResidueHandle& res, ...@@ -227,7 +227,7 @@ void HeuristicBuilder::ConnectivityFromAtomNames(const mol::ResidueHandle& res,
void HeuristicBuilder::ConnectAtomsOfResidue(mol::ResidueHandle res) void HeuristicBuilder::ConnectAtomsOfResidue(mol::ResidueHandle res)
{ {
LOG_DEBUG("HeuristicBuilder: ConnectAtomsOfResidue on " << res.GetKey() << " " << res.GetNumber()); LOG_TRACE("HeuristicBuilder: ConnectAtomsOfResidue on " << res.GetKey() << " " << res.GetNumber());
mol::AtomHandleList atomlist = res.GetAtomList(); mol::AtomHandleList atomlist = res.GetAtomList();
mol::AtomHandleList unk_atomlist; mol::AtomHandleList unk_atomlist;
...@@ -237,7 +237,7 @@ void HeuristicBuilder::ConnectAtomsOfResidue(mol::ResidueHandle res) ...@@ -237,7 +237,7 @@ void HeuristicBuilder::ConnectAtomsOfResidue(mol::ResidueHandle res)
for(mol::AtomHandleList::iterator it=atomlist.begin();it!=atomlist.end();++it) { for(mol::AtomHandleList::iterator it=atomlist.begin();it!=atomlist.end();++it) {
ss << " " << it->GetName() << " @" << it->GetPos(); ss << " " << it->GetName() << " @" << it->GetPos();
} }
LOG_DEBUG(ss.str()); LOG_TRACE(ss.str());
#endif #endif
std::pair<detail::ConnResEntry,bool> ret = LookupResEntry(res.GetKey()); std::pair<detail::ConnResEntry,bool> ret = LookupResEntry(res.GetKey());
...@@ -248,11 +248,11 @@ void HeuristicBuilder::ConnectAtomsOfResidue(mol::ResidueHandle res) ...@@ -248,11 +248,11 @@ void HeuristicBuilder::ConnectAtomsOfResidue(mol::ResidueHandle res)
for(mol::AtomHandleList::iterator it1=unk_atomlist.begin(); for(mol::AtomHandleList::iterator it1=unk_atomlist.begin();
it1!=unk_atomlist.end(); it1!=unk_atomlist.end();
++it1) { ++it1) {
LOG_DEBUG( "atom " << it1->GetName() << " not found, using distance based connect"); LOG_TRACE( "atom " << it1->GetName() << " not found, using distance based connect");
Builder::DistanceBasedConnect(*it1); Builder::DistanceBasedConnect(*it1);
} }
} else { } else {
LOG_DEBUG("no residue entry found, using distance based connect"); LOG_TRACE("no residue entry found, using distance based connect");
for(mol::AtomHandleList::iterator it1=atomlist.begin(); for(mol::AtomHandleList::iterator it1=atomlist.begin();
it1!=atomlist.end(); it1!=atomlist.end();
++it1) { ++it1) {
...@@ -270,16 +270,16 @@ void ConnectPrevNext(HeuristicBuilder* builder,mol::ResidueHandle res0, ...@@ -270,16 +270,16 @@ void ConnectPrevNext(HeuristicBuilder* builder,mol::ResidueHandle res0,
static String fname=flag ? "HeuristicBuilder: ConnectNextXCS" : "HeuristicBuilder: ConnectPrevXCS"; static String fname=flag ? "HeuristicBuilder: ConnectNextXCS" : "HeuristicBuilder: ConnectPrevXCS";
if(!res0) return; // return if invalid if(!res0) return; // return if invalid
mol::XCSEditor editor=res0.GetEntity().EditXCS(mol::BUFFERED_EDIT); mol::XCSEditor editor=res0.GetEntity().EditXCS(mol::BUFFERED_EDIT);
LOG_DEBUG(fname << " on " << res0.GetKey() << " " << res0.GetNumber()); LOG_TRACE(fname << " on " << res0.GetKey() << " " << res0.GetNumber());
if(!res1) { if(!res1) {
// auto-detect prev or next residue in chain // auto-detect prev or next residue in chain
// and perform sequence check // and perform sequence check
if(flag) { if(flag) {
LOG_DEBUG(fname << " autodecting next residue"); LOG_TRACE(fname << " autodecting next residue");
res1 = res0.GetChain().GetNext(res0); res1 = res0.GetChain().GetNext(res0);
} else { } else {
LOG_DEBUG(fname << " autodecting next residue"); LOG_TRACE(fname << " autodecting next residue");
res1 = res0.GetChain().GetPrev(res0); res1 = res0.GetChain().GetPrev(res0);
} }
} else { } else {
...@@ -292,7 +292,7 @@ void ConnectPrevNext(HeuristicBuilder* builder,mol::ResidueHandle res0, ...@@ -292,7 +292,7 @@ void ConnectPrevNext(HeuristicBuilder* builder,mol::ResidueHandle res0,
} }
if(!res1) return; // ignore if prev/next residue is invalid if(!res1) return; // ignore if prev/next residue is invalid
LOG_DEBUG(fname << " found second residue " << res1.GetKey() LOG_TRACE(fname << " found second residue " << res1.GetKey()
<< " " << res1.GetNumber()); << " " << res1.GetNumber());
std::pair<detail::ConnResEntry,bool> res0_ret = builder->LookupResEntry(res0.GetKey()); std::pair<detail::ConnResEntry,bool> res0_ret = builder->LookupResEntry(res0.GetKey());
...@@ -300,7 +300,7 @@ void ConnectPrevNext(HeuristicBuilder* builder,mol::ResidueHandle res0, ...@@ -300,7 +300,7 @@ void ConnectPrevNext(HeuristicBuilder* builder,mol::ResidueHandle res0,
if(!res0_ret.second) { if(!res0_ret.second) {
if(res0.FindAtom("N") && res0.FindAtom("CA") && res0.FindAtom("C")) { if(res0.FindAtom("N") && res0.FindAtom("CA") && res0.FindAtom("C")) {
LOG_DEBUG("using default peptide for " << res0.GetKey()); LOG_TRACE("using default peptide for " << res0.GetKey());
res0_ret.first=builder->DefaultPeptide(); res0_ret.first=builder->DefaultPeptide();
res0_ret.second=true; res0_ret.second=true;
} }
...@@ -308,7 +308,7 @@ void ConnectPrevNext(HeuristicBuilder* builder,mol::ResidueHandle res0, ...@@ -308,7 +308,7 @@ void ConnectPrevNext(HeuristicBuilder* builder,mol::ResidueHandle res0,
if(!res1_ret.second) { if(!res1_ret.second) {
if(res1.FindAtom("N") && res1.FindAtom("CA") && res1.FindAtom("C")) { if(res1.FindAtom("N") && res1.FindAtom("CA") && res1.FindAtom("C")) {
LOG_DEBUG("using default peptide for " << res1.GetKey()); LOG_TRACE("using default peptide for " << res1.GetKey());
res1_ret.first=builder->DefaultPeptide(); res1_ret.first=builder->DefaultPeptide();
res1_ret.second=true; res1_ret.second=true;
} }
...@@ -321,13 +321,13 @@ void ConnectPrevNext(HeuristicBuilder* builder,mol::ResidueHandle res0, ...@@ -321,13 +321,13 @@ void ConnectPrevNext(HeuristicBuilder* builder,mol::ResidueHandle res0,
String res1_atom_name = res1_centry.GetNext(); String res1_atom_name = res1_centry.GetNext();
if(res0_atom_name.empty() || res1_atom_name.empty()) return; if(res0_atom_name.empty() || res1_atom_name.empty()) return;
LOG_DEBUG(fname << ": looking up atom names " << res0_atom_name << " " << res1_atom_name); LOG_TRACE(fname << ": looking up atom names " << res0_atom_name << " " << res1_atom_name);
// lookup both atoms in their respective residues // lookup both atoms in their respective residues
mol::AtomHandle res0_atom = res0.FindAtom(res0_atom_name); mol::AtomHandle res0_atom = res0.FindAtom(res0_atom_name);
mol::AtomHandle res1_atom = res1.FindAtom(res1_atom_name); mol::AtomHandle res1_atom = res1.FindAtom(res1_atom_name);
if(res0_atom && res1_atom) { if(res0_atom && res1_atom) {
LOG_DEBUG(fname << ": found atoms, connecting"); LOG_TRACE(fname << ": found atoms, connecting");
if(flag) { if(flag) {
if (builder->DoesPeptideBondExist(res0_atom, res1_atom)) { if (builder->DoesPeptideBondExist(res0_atom, res1_atom)) {
editor.Connect(res0_atom,res1_atom); editor.Connect(res0_atom,res1_atom);
...@@ -405,11 +405,11 @@ void HeuristicBuilder::AssignTorsionsToResidue(mol::ResidueHandle res) ...@@ -405,11 +405,11 @@ void HeuristicBuilder::AssignTorsionsToResidue(mol::ResidueHandle res)
mol::TorsionHandle th = editor.AddTorsion(tel[ti].name, ah[0], ah[1], mol::TorsionHandle th = editor.AddTorsion(tel[ti].name, ah[0], ah[1],
ah[2], ah[3]); ah[2], ah[3]);
if(th) { if(th) {
LOG_DEBUG("added torsion entry for " << tel[ti].a[0] << " " LOG_TRACE("added torsion entry for " << tel[ti].a[0] << " "
<< tel[ti].a[1] << " " << tel[ti].a[2] << " " << tel[ti].a[1] << " " << tel[ti].a[2] << " "
<< tel[ti].a[3]); << tel[ti].a[3]);
} else { } else {
LOG_DEBUG("no torsion entry for " << tel[ti].a[0] << " " LOG_TRACE("no torsion entry for " << tel[ti].a[0] << " "
<< tel[ti].a[1] << " " << tel[ti].a[2] << tel[ti].a[1] << " " << tel[ti].a[2]
<< " " << tel[ti].a[3]); << " " << tel[ti].a[3]);
} }
...@@ -469,10 +469,10 @@ std::pair<detail::ConnResEntry,bool> HeuristicBuilder::LookupResEntry(const mol: ...@@ -469,10 +469,10 @@ std::pair<detail::ConnResEntry,bool> HeuristicBuilder::LookupResEntry(const mol:
detail::ConnResEntryMap::iterator pos = emap_.find(key); detail::ConnResEntryMap::iterator pos = emap_.find(key);
if(pos!=emap_.end()) { if(pos!=emap_.end()) {
LOG_DEBUG("reskey '" << key << "' found in connectivity map"); LOG_TRACE("reskey '" << key << "' found in connectivity map");
return std::make_pair(pos->second,true); return std::make_pair(pos->second,true);
} }
LOG_DEBUG("reskey '" << key << "' not found connectivity map"); LOG_TRACE("reskey '" << key << "' not found connectivity map");
return std::make_pair(dummy,false); return std::make_pair(dummy,false);
} }
......
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
#include <boost/algorithm/string.hpp> #include <boost/algorithm/string.hpp>
#include <boost/format.hpp> #include <boost/format.hpp>
#include <boost/regex.hpp> #include <boost/regex.hpp>
#include <boost/shared_array.hpp>
#include <ost/log.hh> #include <ost/log.hh>
#include <ost/conop/conop.hh> #include <ost/conop/conop.hh>
...@@ -48,41 +49,6 @@ namespace ost { namespace io { ...@@ -48,41 +49,6 @@ namespace ost { namespace io {
using boost::format; using boost::format;
namespace {
std::vector<std::string> tokenize(const std::string& line)
{
std::vector<std::string> nrvo;
bool in_string=false;
int p0=0;
for(size_t p1=1;p1<line.size();++p1) {
if(in_string) {
if(line[p1]=='"') {
in_string=false;
nrvo.push_back(std::string(line.substr(p0,p1-p0)));
++p1;
p0=p1;
while(isspace(line[p1]) && p1<line.size()) {++p0;++p1;}
--p0; --p1;
}
} else {
if(isspace(line[p1])) {
nrvo.push_back(std::string(line.substr(p0+1,p1-p0-1)));
++p1;
p0=p1;
while(isspace(line[p1]) && p1<line.size()) {++p0;++p1;}
--p0; --p1;
} else if(line[p1]=='"') {
in_string=true;
p0=p1+1;
}
}
}
return nrvo;
}
}
MAEReader::MAEReader(const boost::filesystem::path& loc): MAEReader::MAEReader(const boost::filesystem::path& loc):
curr_chain_(), curr_chain_(),
curr_residue_(), curr_residue_(),
...@@ -106,6 +72,7 @@ void MAEReader::Import(mol::EntityHandle& ent) ...@@ -106,6 +72,7 @@ void MAEReader::Import(mol::EntityHandle& ent)
static const boost::regex r_ct_block("f_m_ct +\\{"); static const boost::regex r_ct_block("f_m_ct +\\{");
static const boost::regex r_atom_block("m_atom\\[.*\\] +\\{"); static const boost::regex r_atom_block("m_atom\\[.*\\] +\\{");
static const boost::regex r_delim(":::"); static const boost::regex r_delim(":::");
static const boost::regex r_end(" *\\} *");
String line; String line;
bool in_ct_block=false; bool in_ct_block=false;
...@@ -121,13 +88,15 @@ void MAEReader::Import(mol::EntityHandle& ent) ...@@ -121,13 +88,15 @@ void MAEReader::Import(mol::EntityHandle& ent)
int i_chain_name=-1; int i_chain_name=-1;
mol::XCSEditor editor=ent.EditXCS(mol::BUFFERED_EDIT); mol::XCSEditor editor=ent.EditXCS(mol::BUFFERED_EDIT);
boost::shared_array<char> xline(new char[512]);
while(std::getline(in_,line)) { while(std::getline(in_,line)) {
line = boost::trim_copy(line); //line = boost::trim_copy(line);
if(in_ct_block) { if(in_ct_block) {
if(in_atom_block) { if(in_atom_block) {
if(parsing_atoms) { if(parsing_atoms) {
if(boost::regex_match(line,r_delim)) { if(boost::regex_search(line,r_delim)) {
LOG_TRACE( "stopping atom parsing" ); LOG_TRACE( "stopping atom parsing" );
parsing_atoms=false; parsing_atoms=false;
prop_list.clear(); prop_list.clear();
...@@ -140,23 +109,14 @@ void MAEReader::Import(mol::EntityHandle& ent) ...@@ -140,23 +109,14 @@ void MAEReader::Import(mol::EntityHandle& ent)
i_chain_name=-1; i_chain_name=-1;
} else { } else {
// parsing atom line // parsing atom line
std::vector<std::string> tokens=tokenize(line); memset(xline.get(),0,512);
for(size_t i=0;i<tokens.size();++i) { strncpy(xline.get(),line.c_str(),511);
LOG_TRACE( "[" << tokens[i] << "] "); parse_and_add_atom(ent,editor,xline.get(),line.size(),
} i_atom_name, i_atom_xpos, i_atom_ypos, i_atom_zpos,
LOG_TRACE(""); i_res_name, i_res_num, i_chain_name);
add_atom(ent,editor,
i_atom_name>=0 && i_atom_name<(int)tokens.size() ? tokens[i_atom_name] : "X",
i_atom_xpos>=0 && i_atom_xpos<(int)tokens.size() ? tokens[i_atom_xpos] : "0",
i_atom_ypos>=0 && i_atom_ypos<(int)tokens.size() ? tokens[i_atom_ypos] : "0",
i_atom_zpos>=0 && i_atom_zpos<(int)tokens.size() ? tokens[i_atom_zpos] : "0",
i_res_name>=0 && i_res_name<(int)tokens.size() ? tokens[i_res_name] : "X",
i_res_num>=0 && i_res_num<(int)tokens.size() ? tokens[i_res_num] : "0",
i_chain_name>=0 && i_chain_name<(int)tokens.size() ? tokens[i_chain_name] : "X");
} }
} else { // not parsing atoms } else { // not parsing atoms
if(boost::regex_match(line,r_delim)) { if(boost::regex_search(line,r_delim)) {
if(i_atom_name==-1 || if(i_atom_name==-1 ||
i_atom_xpos==-1 || i_atom_xpos==-1 ||
i_atom_ypos==-1 || i_atom_ypos==-1 ||
...@@ -167,36 +127,37 @@ void MAEReader::Import(mol::EntityHandle& ent) ...@@ -167,36 +127,37 @@ void MAEReader::Import(mol::EntityHandle& ent)
} }
LOG_TRACE( "starting atom parsing" ); LOG_TRACE( "starting atom parsing" );
parsing_atoms=true; parsing_atoms=true;
} else if(line[0]=='}') { } else if(boost::regex_search(line,r_end)) {
LOG_TRACE( "exiting atom block" ); LOG_TRACE( "exiting atom block" );
in_atom_block=false; in_atom_block=false;
} else { } else {
std::string line2=boost::trim_copy(line);
// parsing property line // parsing property line
if(line[0]!='#') { if(line2[0]!='#') {
int pid=prop_list.size()+1; int pid=prop_list.size()+1;
prop_list.push_back(line); prop_list.push_back(line2);
LOG_TRACE( "found property '" << prop_list.back() << "' id=" << pid ); LOG_TRACE( "found property '" << prop_list.back() << "' id=" << pid );
if(line=="s_m_pdb_atom_name") i_atom_name=pid; if(line2=="s_m_pdb_atom_name") i_atom_name=pid;
else if(line=="r_m_x_coord") i_atom_xpos=pid; else if(line2=="r_m_x_coord") i_atom_xpos=pid;
else if(line=="r_m_y_coord") i_atom_ypos=pid; else if(line2=="r_m_y_coord") i_atom_ypos=pid;
else if(line=="r_m_z_coord") i_atom_zpos=pid; else if(line2=="r_m_z_coord") i_atom_zpos=pid;
else if(line=="s_m_pdb_residue_name") i_res_name=pid; else if(line2=="s_m_pdb_residue_name") i_res_name=pid;
else if(line=="i_m_residue_number") i_res_num=pid; else if(line2=="i_m_residue_number") i_res_num=pid;
else if(line=="s_m_pdb_segment_name") i_chain_name=pid; else if(line2=="s_m_pdb_segment_name") i_chain_name=pid;
} }
} }
} }
} else { // not in atom block } else { // not in atom block
if(boost::regex_match(line,r_atom_block)) { if(boost::regex_search(line,r_atom_block)) {
LOG_TRACE( "entering atom block" ); LOG_TRACE( "entering atom block" );
in_atom_block=true; in_atom_block=true;
} else if(line[0]=='}') { } else if(boost::regex_search(line,r_end)) {
LOG_TRACE( "exiting ct block" ); LOG_TRACE( "exiting ct block" );
in_ct_block=false; in_ct_block=false;
} }
} }
} else { // not in ct block } else { // not in ct block
if(boost::regex_match(line,r_ct_block)) { if(boost::regex_search(line,r_ct_block)) {
LOG_TRACE( "entering ct block" ); LOG_TRACE( "entering ct block" );
in_ct_block=true; in_ct_block=true;
} }
...@@ -208,27 +169,95 @@ void MAEReader::Import(mol::EntityHandle& ent) ...@@ -208,27 +169,95 @@ void MAEReader::Import(mol::EntityHandle& ent)
} }
void MAEReader::add_atom(mol::EntityHandle ent, void MAEReader::parse_and_add_atom(mol::EntityHandle ent,
mol::XCSEditor& editor, mol::XCSEditor& editor,
const std::string& aname2, char* line,
const std::string& s_axpos, size_t line_len,
const std::string& s_aypos, int i_atom_name,
const std::string& s_azpos, int i_atom_xpos,
const std::string& rname2, int i_atom_ypos,
const std::string& s_rnum, int i_atom_zpos,
const std::string& cname2) int i_res_name,
int i_res_num,
int i_chain_name)
{ {
std::string aname=boost::trim_copy(aname2); std::string aname("X");
std::string rname=boost::trim_copy(rname2); std::string rname("UNK");
std::string cname=boost::trim_copy(cname2); std::string cname("X");
geom::Vec3 apos;
int irnum;
LOG_TRACE("[" << std::string(line) << "]");
bool in_string=false;
char* p0=line;
char* p2=line+line_len;
while(isspace(*p0) && p0<=p2) ++p0;
int tcount=0;
for(char* p1=p0+1;p1<p2;++p1) {
if(in_string) {
if((*p1)=='"') {
in_string=false;
char* p3=p1;
(*p3)='\0';
while(isspace(*p0) && p0<=p3) ++p0;
while(isspace(*(p3-1)) && p3>p0) --p3;
(*p3)='\0';
if(tcount==i_atom_name) {
aname=std::string(p0);
} else if(tcount==i_atom_xpos) {
apos[0]=atof(p0);
} else if(tcount==i_atom_ypos) {
apos[1]=atof(p0);
} else if(tcount==i_atom_zpos) {
apos[2]=atof(p0);
} else if(tcount==i_res_name) {
rname=std::string(p0);
} else if(tcount==i_res_num) {
irnum=atoi(p0);
} else if(tcount==i_chain_name) {
cname=std::string(p0);
}
++tcount;
++p1;
p0=p1;
while(isspace((*p1)) && p1<p2) {++p0;++p1;}
--p0; --p1;
}
} else { // not instring
if(isspace((*p1))) {
(*p1)='\0';
++p0;
if(tcount==i_atom_name) {
aname=std::string(p0);
} else if(tcount==i_atom_xpos) {
apos[0]=atof(p0);
} else if(tcount==i_atom_ypos) {
apos[1]=atof(p0);
} else if(tcount==i_atom_zpos) {
apos[2]=atof(p0);
} else if(tcount==i_res_name) {
rname=std::string(p0);
} else if(tcount==i_res_num) {
irnum=atoi(p0);
} else if(tcount==i_chain_name) {
cname=std::string(p0);
}
++tcount;
++p1;
p0=p1;
while(isspace((*p1)) && p1<p2) {++p0;++p1;}
--p0; --p1;
} else if((*p1)=='"') {
in_string=true;
p0=p1+1;
}
}
}
std::string ele=aname.empty() ? "X" : aname.substr(0,1); std::string ele=aname.empty() ? "X" : aname.substr(0,1);
if(isdigit(ele[0])) ele="H"; if(isdigit(ele[0])) ele="H";
int irnum = atoi(s_rnum.c_str());
geom::Vec3 apos(atof(s_axpos.c_str()),
atof(s_aypos.c_str()),
atof(s_azpos.c_str()));
mol::ResidueKey rkey(rname); mol::ResidueKey rkey(rname);
mol::ResNum rnum(irnum); mol::ResNum rnum(irnum);
...@@ -335,14 +364,8 @@ mol::EntityHandle LoadMAE(const String& file_name) ...@@ -335,14 +364,8 @@ mol::EntityHandle LoadMAE(const String& file_name)
MAEReader reader(file_name); MAEReader reader(file_name);
mol::EntityHandle ent=mol::CreateEntity(); mol::EntityHandle ent=mol::CreateEntity();
mol::XCSEditor editor=ent.EditXCS(mol::BUFFERED_EDIT); mol::XCSEditor editor=ent.EditXCS(mol::BUFFERED_EDIT);
{ reader.Import(ent);
Profile profile("import MAE"); conop::Conopology::Instance().ConnectAll(builder,ent);
reader.Import(ent);
}
{
Profile profile("connect all");
conop::Conopology::Instance().ConnectAll(builder,ent);
}
return ent; return ent;
} }
......
...@@ -34,14 +34,17 @@ public: ...@@ -34,14 +34,17 @@ public:
private: private:
void add_atom(mol::EntityHandle ent, void parse_and_add_atom(mol::EntityHandle ent,
mol::XCSEditor& editor,const std::string& s_aname, mol::XCSEditor& editor,
const std::string& s_axpos, char* line,
const std::string& s_aypos, size_t line_len,
const std::string& s_azpos, int i_atom_name,
const std::string& s_rname, int i_atom_xpos,
const std::string& s_rnum, int i_atom_ypos,
const std::string& s_cname); int i_atom_zpos,
int i_res_name,
int i_res_num,
int i_chain_name);
mol::ChainHandle curr_chain_; mol::ChainHandle curr_chain_;
mol::ResidueHandle curr_residue_; mol::ResidueHandle curr_residue_;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment