Commit 9f81a4ef by maarten

Fix in remark 3 parsing

git-svn-id: svn+ssh://gitlab/srv/svn-repos/pdb-redo/trunk@444 a1961a4f-ab94-4bcc-80e8-33b5a54de466
parent c9f37c74
...@@ -1327,10 +1327,21 @@ bool Remark3Parser::parse(const string& expMethod, PDBRecord* r, cif::Datablock& ...@@ -1327,10 +1327,21 @@ bool Remark3Parser::parse(const string& expMethod, PDBRecord* r, cif::Datablock&
vector<programScore> scores; vector<programScore> scores;
auto tryParser = [&](Remark3Parser* p, bool saveSoftware) auto tryParser = [&](Remark3Parser* p)
{ {
unique_ptr<Remark3Parser> parser(p); unique_ptr<Remark3Parser> parser(p);
float score = parser->parse(); float score;
try
{
score = parser->parse();
}
catch(const std::exception& e)
{
std::cerr << "Error parsing REMARK 3 with " << parser->program() << endl
<< e.what() << '\n';
score = 0;
}
if (VERBOSE >= 2) if (VERBOSE >= 2)
cerr << "Score for " << parser->program() << ": " << score << endl; cerr << "Score for " << parser->program() << ": " << score << endl;
...@@ -1340,17 +1351,6 @@ bool Remark3Parser::parse(const string& expMethod, PDBRecord* r, cif::Datablock& ...@@ -1340,17 +1351,6 @@ bool Remark3Parser::parse(const string& expMethod, PDBRecord* r, cif::Datablock&
string program = parser->program(); string program = parser->program();
string version = parser->version(); string version = parser->version();
if (saveSoftware)
{
auto& software = db["software"];
software.emplace({
{ "name", program },
{ "classification", "refinement" },
{ "version", version },
{ "pdbx_ordinal", software.size() + 1 }
});
}
scores.emplace_back(program, parser.release(), score); scores.emplace_back(program, parser.release(), score);
} }
}; };
...@@ -1361,48 +1361,48 @@ bool Remark3Parser::parse(const string& expMethod, PDBRecord* r, cif::Datablock& ...@@ -1361,48 +1361,48 @@ bool Remark3Parser::parse(const string& expMethod, PDBRecord* r, cif::Datablock&
string program(p->begin(), p->end()); string program(p->begin(), p->end());
if (ba::starts_with(program, "BUSTER")) if (ba::starts_with(program, "BUSTER"))
tryParser(new BUSTER_TNT_Remark3Parser(program, expMethod, r, db), true); tryParser(new BUSTER_TNT_Remark3Parser(program, expMethod, r, db));
else if (ba::starts_with(program, "CNS") or ba::starts_with(program, "CNX")) else if (ba::starts_with(program, "CNS") or ba::starts_with(program, "CNX"))
tryParser(new CNS_Remark3Parser(program, expMethod, r, db), true); tryParser(new CNS_Remark3Parser(program, expMethod, r, db));
else if (ba::starts_with(program, "PHENIX")) else if (ba::starts_with(program, "PHENIX"))
tryParser(new PHENIX_Remark3Parser(program, expMethod, r, db), true); tryParser(new PHENIX_Remark3Parser(program, expMethod, r, db));
else if (ba::starts_with(program, "NUCLSQ")) else if (ba::starts_with(program, "NUCLSQ"))
tryParser(new NUCLSQ_Remark3Parser(program, expMethod, r, db), true); tryParser(new NUCLSQ_Remark3Parser(program, expMethod, r, db));
else if (ba::starts_with(program, "PROLSQ")) else if (ba::starts_with(program, "PROLSQ"))
tryParser(new PROLSQ_Remark3Parser(program, expMethod, r, db), true); tryParser(new PROLSQ_Remark3Parser(program, expMethod, r, db));
else if (ba::starts_with(program, "REFMAC")) else if (ba::starts_with(program, "REFMAC"))
{ {
// simply try both and take the best // simply try both and take the best
tryParser(new REFMAC_Remark3Parser(program, expMethod, r, db), true); tryParser(new REFMAC_Remark3Parser(program, expMethod, r, db));
tryParser(new REFMAC5_Remark3Parser(program, expMethod, r, db), false); tryParser(new REFMAC5_Remark3Parser(program, expMethod, r, db));
} }
else if (ba::starts_with(program, "SHELXL")) else if (ba::starts_with(program, "SHELXL"))
tryParser(new SHELXL_Remark3Parser(program, expMethod, r, db), true); tryParser(new SHELXL_Remark3Parser(program, expMethod, r, db));
else if (ba::starts_with(program, "TNT")) else if (ba::starts_with(program, "TNT"))
tryParser(new TNT_Remark3Parser(program, expMethod, r, db), true); tryParser(new TNT_Remark3Parser(program, expMethod, r, db));
else if (ba::starts_with(program, "X-PLOR")) else if (ba::starts_with(program, "X-PLOR"))
tryParser(new XPLOR_Remark3Parser(program, expMethod, r, db), true); tryParser(new XPLOR_Remark3Parser(program, expMethod, r, db));
else if (VERBOSE) else if (VERBOSE)
cerr << "Skipping unknown program (" << program << ") in REMARK 3" << endl; cerr << "Skipping unknown program (" << program << ") in REMARK 3" << endl;
} }
bool guessProgram = false; sort(scores.begin(), scores.end());
if (scores.empty())
bool guessProgram = scores.empty() or scores.front().score < 0.9f;;
if (guessProgram)
{ {
guessProgram = true; cerr << "Unknown or untrusted program in REMARK 3, trying all parsers to see if there is a match" << endl;
cerr << "Unknown program in REMARK 3, trying all parsers to see if there is a match" << endl;
tryParser(new BUSTER_TNT_Remark3Parser("BUSTER-TNT", expMethod, r, db), false); tryParser(new BUSTER_TNT_Remark3Parser("BUSTER-TNT", expMethod, r, db));
tryParser(new CNS_Remark3Parser("CNS", expMethod, r, db), false); tryParser(new CNS_Remark3Parser("CNS", expMethod, r, db));
tryParser(new PHENIX_Remark3Parser("PHENIX", expMethod, r, db), false); tryParser(new PHENIX_Remark3Parser("PHENIX", expMethod, r, db));
tryParser(new NUCLSQ_Remark3Parser("NUCLSQ", expMethod, r, db), false); tryParser(new NUCLSQ_Remark3Parser("NUCLSQ", expMethod, r, db));
tryParser(new PROLSQ_Remark3Parser("PROLSQ", expMethod, r, db), false); tryParser(new PROLSQ_Remark3Parser("PROLSQ", expMethod, r, db));
tryParser(new REFMAC_Remark3Parser("REFMAC", expMethod, r, db), false); tryParser(new REFMAC_Remark3Parser("REFMAC", expMethod, r, db));
tryParser(new REFMAC5_Remark3Parser("REFMAC5", expMethod, r, db), false); tryParser(new REFMAC5_Remark3Parser("REFMAC5", expMethod, r, db));
tryParser(new SHELXL_Remark3Parser("SHELXL", expMethod, r, db), false); tryParser(new SHELXL_Remark3Parser("SHELXL", expMethod, r, db));
tryParser(new TNT_Remark3Parser("TNT", expMethod, r, db), false); tryParser(new TNT_Remark3Parser("TNT", expMethod, r, db));
tryParser(new XPLOR_Remark3Parser("X-PLOR", expMethod, r, db), false); tryParser(new XPLOR_Remark3Parser("X-PLOR", expMethod, r, db));
} }
bool result = false; bool result = false;
...@@ -1411,26 +1411,21 @@ bool Remark3Parser::parse(const string& expMethod, PDBRecord* r, cif::Datablock& ...@@ -1411,26 +1411,21 @@ bool Remark3Parser::parse(const string& expMethod, PDBRecord* r, cif::Datablock&
{ {
result = true; result = true;
sort(scores.begin(), scores.end());
auto& best = scores.front(); auto& best = scores.front();
if (guessProgram) if (VERBOSE)
{ cerr << "Choosing " << best.parser->program() << " version '" << best.parser->version() << "' as refinement program. Score = " << best.score << endl;
if (VERBOSE)
cerr << "Choosing " << best.parser->program() << " version '" << best.parser->version() << "' as refinement program. Score = " << best.score << endl; auto& software = db["software"];
string program = best.parser->program();
auto& software = db["software"]; string version = best.parser->version();
string program = best.parser->program();
string version = best.parser->version(); software.emplace({
{ "name", program },
software.emplace({ { "classification", "refinement" },
{ "name", program }, { "version", version },
{ "classification", "refinement" }, { "pdbx_ordinal", software.size() + 1 }
{ "version", version }, });
{ "pdbx_ordinal", software.size() + 1 }
});
}
best.parser->fixup(); best.parser->fixup();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment