Implementing a FeaturesReporter involves the following steps:
The FeatureReporter (rosetta/main/source/src/protocols/features/FeaturesReporter.hh) base class interface has the following components, which should be implemented by a new FeaturesReporter:
Required Methods
Optional Methods
As an example consider the PoseCommentsFeatures (rosetta/main/source/protocols/features/PoseCommentsFeatures.hh) feature reporter. Arbitrary textual information may be associated with a pose in the form of (key, val) comments (See rosetta/main/source/src/core/pose/util.hh). The PoseCommentsFeatures FeaturesReporter extracts all defined comments to a table pose_comments using the struct_id and key as the primary key. The struct_id references the the structures table that identifies each of the structures in the database.
In the report_features function, sessionOP is an owning pointer to the database where the features should be written. See the database interface for how to obtain and interact with database sessions.
string
PoseCommentsFeatures::type_name() const { return "PoseCommentsFeatures"; }
string
PoseCommentsFeatures::schema() const {
return
"CREATE TABLE IF NOT EXISTS pose_comments (\n"
" struct_id INTEGER,\n"
" key TEXT,\n"
" value TEXT,\n"
" FOREIGN KEY (struct_id)\n"
" REFERENCES structures (struct_id)\n"
" DEFERRABLE INITIALLY DEFERRED,\n"
" PRIMARY KEY(struct_id, key));";
}
Size
PoseCommentsFeatures::report_features(
Pose const & pose,
Size struct_id,
sessionOP db_session
){
typedef map< string, string >::value_type kv_pair;
foreach(kv_pair const & kv, get_all_comments(pose)){
statement stmt = (*db_session) <<
"INSERT INTO pose_comments VALUES (?,?,?)" <<
struct_id << kv.first << kv.second;
stmt.exec();
}
return 0;
}