Commit d5a71b0b by Maarten L. Hekkelman

Fix verbose checking

faster aniso_row retrieval
report missing header line for pdb
parent d95b7be2
...@@ -101,13 +101,13 @@ class atom ...@@ -101,13 +101,13 @@ class atom
row_handle row_aniso() row_handle row_aniso()
{ {
auto cat = m_db.get("atom_site_anisotrop"); auto cat = m_db.get("atom_site_anisotrop");
return cat ? cat->find1(key("id") == m_id) : row_handle{}; return cat ? cat->operator[]({ {"id", m_id} }) : row_handle{};
} }
const row_handle row_aniso() const const row_handle row_aniso() const
{ {
auto cat = m_db.get("atom_site_anisotrop"); auto cat = m_db.get("atom_site_anisotrop");
return cat ? cat->find1(key("id") == m_id) : row_handle{}; return cat ? cat->operator[]({ {"id", m_id} }) : row_handle{};
} }
const datablock &m_db; const datablock &m_db;
......
...@@ -6211,8 +6211,17 @@ file read(std::istream &is) ...@@ -6211,8 +6211,17 @@ file read(std::istream &is)
if (ch == 'h' or ch == 'H') if (ch == 'h' or ch == 'H')
ReadPDBFile(is, result); ReadPDBFile(is, result);
else else
{
try
{
result.load(is); result.load(is);
} }
catch (const std::exception &ex)
{
std::throw_with_nested(std::runtime_error("Since the file did not start with a valid PDB HEADER line mmCIF was assumed, but that failed."));
}
}
}
// Must be a PDB like file, right? // Must be a PDB like file, right?
if (result.get_validator() == nullptr) if (result.get_validator() == nullptr)
......
...@@ -320,7 +320,7 @@ struct tls_selection_not : public tls_selection ...@@ -320,7 +320,7 @@ struct tls_selection_not : public tls_selection
for (auto &r : residues) for (auto &r : residues)
r.selected = not r.selected; r.selected = not r.selected;
if (cif::VERBOSE) if (cif::VERBOSE > 0)
{ {
std::cout << std::string(indentLevel * 2, ' ') << "NOT" << std::endl; std::cout << std::string(indentLevel * 2, ' ') << "NOT" << std::endl;
dump_selection(residues, indentLevel); dump_selection(residues, indentLevel);
...@@ -339,7 +339,7 @@ struct tls_selection_all : public tls_selection ...@@ -339,7 +339,7 @@ struct tls_selection_all : public tls_selection
for (auto &r : residues) for (auto &r : residues)
r.selected = true; r.selected = true;
if (cif::VERBOSE) if (cif::VERBOSE > 0)
{ {
std::cout << std::string(indentLevel * 2, ' ') << "ALL" << std::endl; std::cout << std::string(indentLevel * 2, ' ') << "ALL" << std::endl;
dump_selection(residues, indentLevel); dump_selection(residues, indentLevel);
...@@ -361,7 +361,7 @@ struct tls_selection_chain : public tls_selection_all ...@@ -361,7 +361,7 @@ struct tls_selection_chain : public tls_selection_all
for (auto &r : residues) for (auto &r : residues)
r.selected = allChains or r.chainID == m_chain; r.selected = allChains or r.chainID == m_chain;
if (cif::VERBOSE) if (cif::VERBOSE > 0)
{ {
std::cout << std::string(indentLevel * 2, ' ') << "CHAIN " << m_chain << std::endl; std::cout << std::string(indentLevel * 2, ' ') << "CHAIN " << m_chain << std::endl;
dump_selection(residues, indentLevel); dump_selection(residues, indentLevel);
...@@ -384,7 +384,7 @@ struct tls_selection_res_id : public tls_selection_all ...@@ -384,7 +384,7 @@ struct tls_selection_res_id : public tls_selection_all
for (auto &r : residues) for (auto &r : residues)
r.selected = r.seqNr == m_seq_nr and r.iCode == m_icode; r.selected = r.seqNr == m_seq_nr and r.iCode == m_icode;
if (cif::VERBOSE) if (cif::VERBOSE > 0)
{ {
std::cout << std::string(indentLevel * 2, ' ') << "ResID " << m_seq_nr << (m_icode ? std::string{ m_icode } : "") << std::endl; std::cout << std::string(indentLevel * 2, ' ') << "ResID " << m_seq_nr << (m_icode ? std::string{ m_icode } : "") << std::endl;
dump_selection(residues, indentLevel); dump_selection(residues, indentLevel);
...@@ -411,7 +411,7 @@ struct tls_selection_range_seq : public tls_selection_all ...@@ -411,7 +411,7 @@ struct tls_selection_range_seq : public tls_selection_all
(r.seqNr <= m_last or m_last == kResidueNrWildcard)); (r.seqNr <= m_last or m_last == kResidueNrWildcard));
} }
if (cif::VERBOSE) if (cif::VERBOSE > 0)
{ {
std::cout << std::string(indentLevel * 2, ' ') << "Range " << m_first << ':' << m_last << std::endl; std::cout << std::string(indentLevel * 2, ' ') << "Range " << m_first << ':' << m_last << std::endl;
dump_selection(residues, indentLevel); dump_selection(residues, indentLevel);
...@@ -461,7 +461,7 @@ struct tls_selection_range_id : public tls_selection_all ...@@ -461,7 +461,7 @@ struct tls_selection_range_id : public tls_selection_all
} }
} }
if (cif::VERBOSE) if (cif::VERBOSE > 0)
{ {
std::cout << std::string(indentLevel * 2, ' ') << "Through " << m_first << ':' << m_last << std::endl; std::cout << std::string(indentLevel * 2, ' ') << "Through " << m_first << ':' << m_last << std::endl;
dump_selection(residues, indentLevel); dump_selection(residues, indentLevel);
...@@ -502,7 +502,7 @@ struct tls_selection_union : public tls_selection ...@@ -502,7 +502,7 @@ struct tls_selection_union : public tls_selection
for (auto ai = a.begin(), bi = b.begin(), ri = residues.begin(); ri != residues.end(); ++ai, ++bi, ++ri) for (auto ai = a.begin(), bi = b.begin(), ri = residues.begin(); ri != residues.end(); ++ai, ++bi, ++ri)
ri->selected = ai->selected or bi->selected; ri->selected = ai->selected or bi->selected;
if (cif::VERBOSE) if (cif::VERBOSE > 0)
{ {
std::cout << std::string(indentLevel * 2, ' ') << "Union" << std::endl; std::cout << std::string(indentLevel * 2, ' ') << "Union" << std::endl;
dump_selection(residues, indentLevel); dump_selection(residues, indentLevel);
...@@ -543,7 +543,7 @@ struct tls_selection_intersection : public tls_selection ...@@ -543,7 +543,7 @@ struct tls_selection_intersection : public tls_selection
for (auto ai = a.begin(), bi = b.begin(), ri = residues.begin(); ri != residues.end(); ++ai, ++bi, ++ri) for (auto ai = a.begin(), bi = b.begin(), ri = residues.begin(); ri != residues.end(); ++ai, ++bi, ++ri)
ri->selected = ai->selected and bi->selected; ri->selected = ai->selected and bi->selected;
if (cif::VERBOSE) if (cif::VERBOSE > 0)
{ {
std::cout << std::string(indentLevel * 2, ' ') << "Intersection" << std::endl; std::cout << std::string(indentLevel * 2, ' ') << "Intersection" << std::endl;
dump_selection(residues, indentLevel); dump_selection(residues, indentLevel);
...@@ -567,7 +567,7 @@ struct tls_selection_by_name : public tls_selection_all ...@@ -567,7 +567,7 @@ struct tls_selection_by_name : public tls_selection_all
for (auto &r : residues) for (auto &r : residues)
r.selected = r.name == m_name; r.selected = r.name == m_name;
if (cif::VERBOSE) if (cif::VERBOSE > 0)
{ {
std::cout << std::string(indentLevel * 2, ' ') << "Name " << m_name << std::endl; std::cout << std::string(indentLevel * 2, ' ') << "Name " << m_name << std::endl;
dump_selection(residues, indentLevel); dump_selection(residues, indentLevel);
...@@ -595,7 +595,7 @@ struct tls_selection_by_element : public tls_selection_all ...@@ -595,7 +595,7 @@ struct tls_selection_by_element : public tls_selection_all
for (auto &r : residues) for (auto &r : residues)
r.selected = iequals(r.name, m_element); r.selected = iequals(r.name, m_element);
if (cif::VERBOSE) if (cif::VERBOSE > 0)
{ {
std::cout << std::string(indentLevel * 2, ' ') << "Element " << m_element << std::endl; std::cout << std::string(indentLevel * 2, ' ') << "Element " << m_element << std::endl;
dump_selection(residues, indentLevel); dump_selection(residues, indentLevel);
...@@ -1404,7 +1404,7 @@ std::tuple<std::string, int> TLSSelectionParserImplBuster::ParseAtom() ...@@ -1404,7 +1404,7 @@ std::tuple<std::string, int> TLSSelectionParserImplBuster::ParseAtom()
match(':'); match(':');
std::string atom = m_value_s; std::string atom = m_value_s;
if (cif::VERBOSE) if (cif::VERBOSE > 0)
std::cerr << "Warning: ignoring atom ID '" << atom << "' in TLS selection" << std::endl; std::cerr << "Warning: ignoring atom ID '" << atom << "' in TLS selection" << std::endl;
match(bt_IDENT); match(bt_IDENT);
...@@ -1958,14 +1958,14 @@ std::unique_ptr<tls_selection> parse_tls_selection_details(const std::string &pr ...@@ -1958,14 +1958,14 @@ std::unique_ptr<tls_selection> parse_tls_selection_details(const std::string &pr
if (not result) if (not result)
{ {
if (cif::VERBOSE) if (cif::VERBOSE > 0)
std::cerr << "Falling back to old BUSTER" << std::endl; std::cerr << "Falling back to old BUSTER" << std::endl;
result = busterOld.Parse(selection); result = busterOld.Parse(selection);
} }
if (not result) if (not result)
{ {
if (cif::VERBOSE) if (cif::VERBOSE > 0)
std::cerr << "Falling back to PHENIX" << std::endl; std::cerr << "Falling back to PHENIX" << std::endl;
result = phenix.Parse(selection); result = phenix.Parse(selection);
} }
...@@ -1976,35 +1976,35 @@ std::unique_ptr<tls_selection> parse_tls_selection_details(const std::string &pr ...@@ -1976,35 +1976,35 @@ std::unique_ptr<tls_selection> parse_tls_selection_details(const std::string &pr
if (not result) if (not result)
{ {
if (cif::VERBOSE) if (cif::VERBOSE > 0)
std::cerr << "Falling back to BUSTER" << std::endl; std::cerr << "Falling back to BUSTER" << std::endl;
result = buster.Parse(selection); result = buster.Parse(selection);
} }
if (not result) if (not result)
{ {
if (cif::VERBOSE) if (cif::VERBOSE > 0)
std::cerr << "Falling back to old BUSTER" << std::endl; std::cerr << "Falling back to old BUSTER" << std::endl;
result = busterOld.Parse(selection); result = busterOld.Parse(selection);
} }
} }
else else
{ {
if (cif::VERBOSE) if (cif::VERBOSE > 0)
std::cerr << "No known program specified, trying PHENIX" << std::endl; std::cerr << "No known program specified, trying PHENIX" << std::endl;
result = phenix.Parse(selection); result = phenix.Parse(selection);
if (not result) if (not result)
{ {
if (cif::VERBOSE) if (cif::VERBOSE > 0)
std::cerr << "Falling back to BUSTER" << std::endl; std::cerr << "Falling back to BUSTER" << std::endl;
result = buster.Parse(selection); result = buster.Parse(selection);
} }
if (not result) if (not result)
{ {
if (cif::VERBOSE) if (cif::VERBOSE > 0)
std::cerr << "Falling back to old BUSTER" << std::endl; std::cerr << "Falling back to old BUSTER" << std::endl;
result = busterOld.Parse(selection); result = busterOld.Parse(selection);
} }
......
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