Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add debug printing for inline residue selector parsing logic. #181

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions source/src/core/select/residue_selector/AndResidueSelector.cc
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,18 @@ std::string AndResidueSelector::class_name() {
return "And";
}

std::string
AndResidueSelector::debug_string() const {
std::string retval = "<" + get_name() + " >\n";
for ( auto const & selector: selectors_ ) {
for ( auto const & substring: utility::split_by_newlines( selector->debug_string() ) ) {
retval += "\t" + substring + "\n";
}
}
retval += "</" + get_name() + " >\n";
return retval;
}

void
AndResidueSelector::provide_xml_schema( utility::tag::XMLSchemaDefinition & xsd ) {
utility::tag::AttributeList attributes;
Expand Down
3 changes: 3 additions & 0 deletions source/src/core/select/residue_selector/AndResidueSelector.hh
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@ public: //Functions needed for the citation manager
/// @brief Provide the citation.
void provide_citation_info(basic::citation_manager::CitationCollectionList & ) const override;

std::string
debug_string() const override;

private: // data members

std::list< ResidueSelectorCOP > selectors_;
Expand Down
11 changes: 11 additions & 0 deletions source/src/core/select/residue_selector/NotResidueSelector.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

// Utility Headers
#include <utility/tag/Tag.hh>
#include <utility/string_util.hh>
#include <utility/tag/XMLSchemaGeneration.hh>

// C++ headers
Expand Down Expand Up @@ -170,6 +171,16 @@ NotResidueSelectorCreator::provide_xml_schema( utility::tag::XMLSchemaDefinition
NotResidueSelector::provide_xml_schema( xsd );
}

std::string
NotResidueSelector::debug_string() const {
std::string retval = "<" + get_name() + " >\n";
for ( auto const & substring: utility::split_by_newlines( selector_->debug_string() ) ) {
retval += "\t" + substring + "\n";
}
retval += "</" + get_name() + " >\n";
return retval;
}


} //namespace residue_selector
} //namespace select
Expand Down
3 changes: 3 additions & 0 deletions source/src/core/select/residue_selector/NotResidueSelector.hh
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ public:
*/
void set_residue_selector(ResidueSelectorCOP selector);

std::string
debug_string() const override;

public: //Functions needed for the citation manager

/// @brief Provide the citation.
Expand Down
12 changes: 12 additions & 0 deletions source/src/core/select/residue_selector/OrResidueSelector.cc
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,18 @@ std::string OrResidueSelector::class_name() {
return "Or";
}

std::string
OrResidueSelector::debug_string() const {
std::string retval = "<" + get_name() + " >\n";
for ( auto const & selector: selectors_ ) {
for ( auto const & substring: utility::split_by_newlines( selector->debug_string() ) ) {
retval += "\t" + substring + "\n";
}
}
retval += "</" + get_name() + " >\n";
return retval;
}

void
OrResidueSelector::provide_xml_schema( utility::tag::XMLSchemaDefinition & xsd ) {
utility::tag::AttributeList attributes;
Expand Down
3 changes: 3 additions & 0 deletions source/src/core/select/residue_selector/OrResidueSelector.hh
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ public:
*/
void apply_or_to_subset(ResidueSubset const & newSubset, ResidueSubset & existingSubset) const;

std::string
debug_string() const override;

public: //Functions needed for the citation manager

/// @brief Provide the citation.
Expand Down
5 changes: 5 additions & 0 deletions source/src/core/select/residue_selector/ResidueSelector.cc
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ ResidueSelector::selection_positions( core::pose::Pose const & pose ) const {
return residue_selector::selection_positions( apply( pose ) );
}

std::string
ResidueSelector::debug_string() const {
return "<" + get_name() + " />\n";
}

} //namespace residue_selector
} //namespace select
} //namespace core
Expand Down
6 changes: 6 additions & 0 deletions source/src/core/select/residue_selector/ResidueSelector.hh
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,12 @@ public:
utility::vector1< core::Size >
selection_positions( core::pose::Pose const & pose ) const;

/// @brief Provide a string representation of the ResidueSelector
/// This is intended mainly for debugging, and may not contain all the information about the selector
virtual
std::string
debug_string() const;

public: //Functions needed for the citation manager

/// @brief Provide citations to the passed CitationCollectionList
Expand Down
3 changes: 3 additions & 0 deletions source/src/core/select/residue_selector/util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,9 @@ get_residue_selector( std::string const & selector_name, basic::datacache::DataM
TR << "Attempting to parse selector logic" << std::endl;
SelectorLogicParser parser;
selector = parser.parse_string_to_residue_selector( data, selector_name );
if ( TR.Debug.visible() ) {
TR.Debug << "Parsed inline selector logic as:\n" << selector->debug_string() << std::endl;
}
}
} catch ( utility::excn::Exception & e ) {
std::stringstream error_msg;
Expand Down