23 #include <core/types.hh>
24 #include <core/chemical/AA.hh>
25 #include <core/chemical/ChemicalManager.hh>
26 #include <core/chemical/VariantType.hh>
27 #include <core/conformation/Residue.hh>
28 #include <core/conformation/ResidueFactory.hh>
29 #include <core/scoring/func/HarmonicFunc.hh>
30 #include <core/chemical/rna/util.hh>
31 #include <core/scoring/ScoreFunction.hh>
32 #include <core/scoring/methods/EnergyMethodOptions.hh>
33 #include <core/scoring/sasa.hh>
34 #include <core/scoring/ScoringManager.hh>
35 #include <core/scoring/rna/RNA_LowResolutionPotential.hh>
36 #include <core/pose/rna/RNA_BaseDoubletClasses.hh>
37 #include <core/scoring/rna/RNA_CentroidInfo.hh>
38 #include <core/scoring/rna/RNA_ScoringInfo.hh>
39 #include <core/scoring/rna/data/RNA_DMS_Potential.hh>
40 #include <core/scoring/rna/data/RNA_DMS_LowResolutionPotential.hh>
41 #include <core/io/rna/RDAT.hh>
42 #include <core/scoring/hbonds/HBondSet.hh>
43 #include <core/scoring/hbonds/HBondOptions.hh>
44 #include <core/scoring/hbonds/hbonds.hh>
46 #include <core/id/AtomID_Map.hh>
47 #include <core/id/AtomID.hh>
48 #include <core/id/NamedAtomID.hh>
49 #include <core/id/DOF_ID.hh>
50 #include <core/init/init.hh>
51 #include <core/io/pdb/pdb_writer.hh>
52 #include <core/kinematics/AtomTree.hh>
53 #include <core/kinematics/FoldTree.hh>
54 #include <core/kinematics/Jump.hh>
55 #include <core/kinematics/Stub.hh>
57 #include <core/pose/Pose.hh>
58 #include <core/pose/PDBInfo.hh>
59 #include <core/pose/PDBInfo.fwd.hh>
60 #include <core/pose/util.hh>
61 #include <core/pose/rna/RNA_BasePairClassifier.hh>
62 #include <core/import_pose/import_pose.hh>
66 #include <protocols/farna/util.hh>
67 #include <protocols/viewer/viewers.hh>
103 #include <core/conformation/Conformation.hh>
104 #include <core/scoring/constraints/Constraint.hh>
111 using namespace core;
112 using namespace core::conformation;
114 using namespace basic::options::OptionKeys;
130 Size & feature_counter,
131 std::string
const & feature_name,
136 if ( feature_counter > feature_names.size() ) feature_names.push_back( feature_name );
139 feature_vals.push_back( feature_val );
146 using namespace core::conformation;
150 using namespace core::kinematics;
151 using namespace core::id;
161 Size res_count( 0 ), num_features( 0 );
162 Size const nres = pose.total_residue();
163 core::pose::PDBInfoCOP pdb_info = pose.pdb_info();
166 AtomID_Map< core::Real > atom_sasa;
169 scoring::calc_per_atom_sasa( pose, atom_sasa, rsd_sasa, probe_radius,
true );
171 RNA_DMS_Potential & rna_dms_potential = ScoringManager::get_instance()->get_RNA_DMS_Potential();
172 pose.update_residue_neighbors();
173 rna_dms_potential.initialize( pose );
175 RNA_DMS_LowResolutionPotential & rna_dms_low_resolution_potential = ScoringManager::get_instance()->get_RNA_DMS_LowResolutionPotential();
177 rna_dms_low_resolution_potential.initialize( pose );
180 Size const num_nt = nt_names.size();
183 for (
Size i = 1; i <=
nres; i++ ) {
185 Residue
const & rsd = pose.residue( i );
186 if ( !rsd.is_RNA() )
continue;
189 seqchars.push_back( rsd.name1() );
190 resnums.push_back( pdb_info->number( i ) );
191 chains.push_back( pdb_info->chain( i ) );
194 Size feature_counter( 0 );
199 for (
Size m = 1; m <= num_nt; m++ ) {
200 is_nt.push_back( rsd.name1() == nt_names[m] );
201 is_nt_tag.push_back(
"is_" + std::string(&nt_names[m],1) );
202 save_feature( feature_names, feature_vals, feature_counter, is_nt_tag[m], is_nt[m] );
207 bool wc_near_o2prime = rna_dms_low_resolution_potential.get_wc_near_o2prime( pose, i );
211 for (
Size m = 1; m <= num_nt; m++ ) {
212 save_feature( feature_names, feature_vals, feature_counter, is_nt_tag[m]+
"_and_wc_edge_paired" ,
213 rna_dms_low_resolution_potential.wc_edge_paired()[i] * is_nt[m] );
214 save_feature( feature_names, feature_vals, feature_counter, is_nt_tag[m]+
"_and_hoog_edge_paired" ,
215 rna_dms_low_resolution_potential.hoog_edge_paired()[i] * is_nt[m]);
216 save_feature( feature_names, feature_vals, feature_counter, is_nt_tag[m]+
"_and_sugar_edge_paired",
217 rna_dms_low_resolution_potential.sugar_edge_paired()[i] * is_nt[m]);
218 save_feature( feature_names, feature_vals, feature_counter, is_nt_tag[m]+
"_and_is_bulged",
219 rna_dms_low_resolution_potential.is_bulged()[i] * is_nt[m] );
220 save_feature( feature_names, feature_vals, feature_counter, is_nt_tag[m]+
"_and_wc_near_o2prime" , wc_near_o2prime * is_nt[m] );
221 save_feature( feature_names, feature_vals, feature_counter, is_nt_tag[m]+
"_and_wc_edge_paired_or_near_o2prime",
222 ( wc_near_o2prime || rna_dms_low_resolution_potential.wc_edge_paired()[i] ) * is_nt[m] );
227 bool ade_n1_hbonded = is_nt[1] && rna_dms_potential.check_hbonded( pose, i,
" N1 ",
true );
229 for (
Size m = 1; m <= num_nt; m++ ) {
233 ResidueTypeSet
const & rsd_set = *rsd.residue_type_set();
234 ResidueType
const & rsd_type = *( rsd_set.get_representative_type_aa( core::chemical::aa_from_oneletter_code( nt_names[m] ) ) );
237 AtomIndices accpt_pos = rsd_type.accpt_pos();
238 for (
Size k = 1; k <= accpt_pos.size(); k++ ) {
239 std::string atom_name = rsd_type.atom_name( accpt_pos[ k ] );
240 bool hbonded = is_nt[m] && rna_dms_potential.check_hbonded( pose, i, atom_name,
true );
242 save_feature( feature_names, feature_vals, feature_counter, is_nt_tag[m]+
"_and_"+atom_name+
"_hbonded", hbonded);
245 if ( m==1 )
save_feature( feature_names, feature_vals, feature_counter, is_nt_tag[m]+
"_and_"+atom_name+
"_hbonded"+
"_and_N1_hbonded", hbonded && ade_n1_hbonded);
249 bool ade_n1_chbonded(
false );
250 if ( is_nt[1] ) ade_n1_chbonded = rna_dms_potential.check_chbonded( pose, i,
" N1 " );
251 save_feature( feature_names, feature_vals, feature_counter, is_nt_tag[m]+
"_and_N1_chbonded", ade_n1_chbonded );
252 save_feature( feature_names, feature_vals, feature_counter, is_nt_tag[m]+
"_and_N1_hbonded_or_chbonded",
253 ade_n1_chbonded || ade_n1_hbonded );
258 AtomIndices Hpos_polar = rsd_type.Hpos_polar();
259 for (
Size k = 1; k <= Hpos_polar.size(); k++ ) {
260 std::string atom_name = rsd_type.atom_name( Hpos_polar[ k ] );
261 bool hbonded = is_nt[m] && rna_dms_potential.check_hbonded( pose, i, atom_name,
false );
263 save_feature( feature_names, feature_vals, feature_counter, is_nt_tag[m]+
"_and_"+atom_name+
"_hbonded", hbonded);
266 if ( m==1 )
save_feature( feature_names, feature_vals, feature_counter, is_nt_tag[m]+
"_and_"+atom_name+
"_hbonded"+
"_and_N1_hbonded", hbonded && ade_n1_hbonded);
272 for (
Size m = 1; m <= num_nt; m++ ) {
276 ResidueTypeSet
const & rsd_set = *rsd.residue_type_set();
277 ResidueType
const & rsd_type = *( rsd_set.get_representative_type_aa( core::chemical::aa_from_oneletter_code( nt_names[m] ) ) );
278 for (
Size k = 1; k <= rsd_type.nheavyatoms(); k++ ) {
279 std::string atom_name = rsd_type.atom_name( k );
281 if ( rsd.type().has( atom_name ) ) {
282 AtomID atom_id = pose::named_atom_id_to_atom_id( NamedAtomID( atom_name, i ), pose );
283 sasa_value = atom_sasa[ atom_id ];
286 save_feature( feature_names, feature_vals, feature_counter, is_nt_tag[m]+
"_and_"+atom_name+
"_SASA", sasa_value);
291 for (
Size m = 1; m <= num_nt; m++ ) {
292 core::Real chi = is_nt[m] ? pose.chi( i ) : 0.0;
293 save_feature( feature_names, feature_vals, feature_counter, is_nt_tag[m]+
"_and_chi", chi);
294 save_feature( feature_names, feature_vals, feature_counter, is_nt_tag[m]+
"_and_is_syn", (chi < 0.0) );
296 for (
Size m = 1; m <= num_nt; m++ ) {
297 core::Real delta = is_nt[m] ? pose.delta( i ) : 0.0;
298 save_feature( feature_names, feature_vals, feature_counter, is_nt_tag[m]+
"_and_delta", delta);
299 save_feature( feature_names, feature_vals, feature_counter, is_nt_tag[m]+
"_and_is_south", ( delta > 120.0) );
306 for (
Size m = 1; m <= probe_dists.size(); m++ ) {
308 core::Real const probe_dist = probe_dists[ m ];
310 core::Vector const probe_xyz = rna_dms_potential.get_probe_xyz( pose.residue( i ), probe_dist );
311 rna_dms_potential.get_occupancy_densities( occupancy_densities, pose, i , probe_xyz, shells );
313 for (
Size k = 1; k <= occupancy_densities.size(); k++ ) {
314 std::string
const tag = is_nt_tag[1]+
"_and_pseudomethyldist"+
F(3,1,probe_dist)+
"_shell_"+
I( 1, shells[k] ) +
"-" +
I( 1, shells[k+1]);
315 save_feature( feature_names, feature_vals, feature_counter, tag, occupancy_densities[k] );
321 rna_dms_potential.get_probe_scorefxn(
true,
false ),
322 rna_dms_potential.get_probe_scorefxn(
true,
true ) );
324 for (
Size k = 1; k <= probe_scorefxns.size(); k++ ) {
325 core::Real pseudo_methyl_plus_oxygen_energy( 0 );
326 for (
Size m = 1; m <= probe_dists.size(); m++ ) {
327 core::Real const probe_dist = probe_dists[ m ];
330 core::Vector const probe_xyz = rna_dms_potential.get_probe_xyz( pose.residue( i ), probe_dist );
331 binding_energy = rna_dms_potential.get_binding_energy( i, probe_xyz, *probe_scorefxns[k] );
333 if ( probe_dist == 3.5 || probe_dist == 5.5 ) pseudo_methyl_plus_oxygen_energy += binding_energy;
334 std::string
const tag = is_nt_tag[1]+
"_and_pseudomethyldist"+
F(3,1,probe_dist)+
"_"+scorefxntags[k]+
"_energy";
335 if ( is_nt[ 1 ] )
std::cout << pose.pdb_info()->number( i ) <<
" " << tag <<
": " << binding_energy << std::endl;
336 save_feature( feature_names, feature_vals, feature_counter, tag, binding_energy );
339 if ( is_nt[ 1 ] )
std::cout << std::endl;
340 std::string
const tag = is_nt_tag[1]+
"_and_pseudomethyl_plus_oxygen_"+scorefxntags[k]+
"_energy";
341 save_feature( feature_names, feature_vals, feature_counter, tag, pseudo_methyl_plus_oxygen_energy );
344 if ( num_features == 0 ) num_features = feature_counter;
347 all_feature_vals.push_back( feature_vals );
352 rdat.fill_data_from_features( seqchars, resnums, feature_names, all_feature_vals );
363 using namespace basic::options::OptionKeys;
365 using namespace core::import_pose;
375 std::cerr <<
"Can't find list file " << pdb_list << std::endl;
381 std::string pdb_file,
line;
382 while (
getline( instream, line ) ) {
383 std::istringstream line_stream( line );
384 line_stream >> pdb_file;
385 pdb_files.push_back( pdb_file );
391 ResidueTypeSetCOP rsd_set = core::chemical::ChemicalManager::get_instance()->residue_type_set(
"fa_standard" );
396 Size total_residues( 0 );
398 for (
Size n = 1; n <= pdb_files.size(); n++ ) {
400 std::string
const pdb_file = pdb_files[n];
402 std::string pdb_file_load = pdb_file;
403 if ( file_path !=
"./" ) pdb_file_load = file_path +
'/' + pdb_file;
404 pose_from_file(
pose, *rsd_set, pdb_file_load , core::import_pose::PDB_file);
407 std::cout <<
"Doing input file " <<
I(4,count) <<
" ==> " << pdb_file << std::endl;
408 std::cout <<
"Read in pose sequence: " <<
pose.annotated_sequence() << std::endl;
409 pose.dump_pdb(
"dump.pdb" );
412 else outfile = pdb_file +
".rdat";
415 rdat.fill_header_information(
pose );
417 rdat.output_rdat_to_file(
outfile );
421 std::cout <<
"FINISHED ==> TOTAL RESIDUES Processed: " << total_residues << std::endl;
431 protocols::viewer::clear_conformation_viewers();
438 main(
int argc,
char * argv [] )
446 protocols::viewer::viewer_main(
my_main );
449 std::cout <<
"caught exception " << e.
msg() << std::endl;
ocstream cerr(std::cerr)
Wrapper around std::cerr.
virtual std::string const msg() const
void exit(std::string const &file, int const line, std::string const &message, int const status)
Exit with file + line + message + optional status.
std::string & strip_whitespace(std::string &s)
Strip Whitespace from a string's Tails.
BooleanOptionKey const scoring
std::istream & getline(std::istream &stream, Fstring &s)
Get Line from Stream.
void save_feature(vector1< std::string > &feature_names, vector1< core::Real > &feature_vals, Size &feature_counter, std::string const &feature_name, core::Real const feature_val)
FileVectorOptionKey const l("in:file:l")
#define runtime_assert(_Expression)
Assert that the condition holds. Evaluated for both debug and release builds.
Conversions between degrees and radians.
BooleanOptionKey const farna
Functions for opening database files.
BooleanOptionKey const rna
macros to define options on a per-application basis at the top of app files (those with main) ...
izstream: Input file stream wrapper for uncompressed and compressed files
Input file stream wrapper for uncompressed and compressed files.
std::vector with 1-based indexing
PathVectorOptionKey const pdb("in:path:pdb")
File name class supporting Windows and UN*X/Linux format names.
basic::options::OptionKeys collection
rule< Scanner, options_closure::context_t > options
Output file stream wrapper for uncompressed and compressed files.
StringOptionKey const pdb_list
numeric::xyzMatrix< core::Real > Matrix
ocstream cout(std::cout)
Wrapper around std::cout.
BooleanOptionKey const exit("options:exit")
vector1: std::vector with 1-based indexing
xyzMatrix: Fast 3x3 xyz matrix template
StringOptionKey const o("out:file:o")
basic::options::OptionKeys collection
Common numeric constants in varying precisions.
xyzVector and xyzMatrix functions
void init()
set global 'init_was_called' to true
Program options global and initialization function.
rule< Scanner, tag_closure::context_t > tag
Size rna_features_from_pose(core::io::rna::RDAT &rdat, pose::Pose &pose)
BooleanOptionKey const chemical
basic::options::OptionKeys collection
Fast (x,y,z)-coordinate numeric vector.
StringOptionKey const user
FileVectorOptionKey const s("in:file:s")
rule< Scanner, option_closure::context_t > option
RealOptionKey const probe_radius