15 #include <core/types.hh>
16 #include <core/chemical/AA.hh>
17 #include <core/conformation/Residue.hh>
18 #include <core/chemical/ChemicalManager.hh>
19 #include <core/io/silent/SilentFileData.hh>
20 #include <core/io/silent/BinarySilentStruct.hh>
21 #include <core/scoring/Energies.hh>
22 #include <core/scoring/ScoreFunction.hh>
23 #include <core/scoring/ScoreFunctionFactory.hh>
24 #include <core/chemical/rna/util.hh>
25 #include <core/scoring/rna/RNA_ScoringInfo.hh>
26 #include <core/scoring/constraints/ConstraintSet.fwd.hh>
29 #include <protocols/viewer/viewers.hh>
30 #include <protocols/stepwise/modeler/util.hh>
31 #include <protocols/stepwise/setup/util.hh>
32 #include <core/pose/Pose.hh>
33 #include <core/pose/util.hh>
34 #include <core/pose/rna/util.hh>
35 #include <core/pose/rna/RNA_BasePairClassifier.hh>
36 #include <core/pose/PDBInfo.hh>
37 #include <core/init/init.hh>
39 #include <core/io/pdb/pose_io.hh>
52 #include <protocols/farna/util.hh>
53 #include <protocols/farna/libraries/BasePairStepLibrary.hh>
64 #include <basic/options/keys/out.OptionKeys.gen.hh>
65 #include <basic/options/keys/in.OptionKeys.gen.hh>
66 #include <basic/options/keys/rna.OptionKeys.gen.hh>
68 #include <core/import_pose/import_pose.hh>
69 #include <core/kinematics/Jump.hh>
74 #include <core/scoring/EnergyGraph.hh>
79 using namespace core::pose::rna;
80 using namespace protocols;
81 using namespace basic::options::OptionKeys;
83 using io::pdb::dump_pdb;
84 using protocols::farna::libraries::MAX_BULGE_LENGTH;
92 OPT_KEY( IntegerVector, exclude_res )
94 OPT_KEY( Boolean, use_lores_base_pair_classification )
101 using namespace basic::options::OptionKeys;
102 using namespace core::chemical;
104 ResidueTypeSetCOP rsd_set;
105 rsd_set = core::chemical::ChemicalManager::get_instance()->residue_type_set( FA_STANDARD );
108 std::string
outfile =
option[ basic::options::OptionKeys::rna::farna::vall_torsions ]();
115 for (
Size n = 1; n <= infiles.size(); n++ ) {
117 core::import_pose::pose_from_pdb( pose, *rsd_set, infiles[n] );
119 protocols::farna::make_phosphate_nomenclature_matches_mini( pose );
122 protocols::farna::create_rna_vall_torsions( pose, torsions_out, exclude_res_list );
124 std::cout <<
"***********************************************************" << std::endl;
125 std::cout <<
"Put torsions from PDB file " << infiles[n] <<
" into " <<
outfile << std::endl;
126 std::cout <<
"***********************************************************" << std::endl;
137 char & edge_i,
char & orientation )
139 static Real const CONTACT_CUTOFF2( 3.0 * 3.0 );
141 scoring::rna::RNA_ScoringInfo & rna_scoring_info( scoring::rna::nonconst_rna_scoring_info_from_pose( pose ) );
142 scoring::rna::RNA_CentroidInfo & rna_centroid_info( rna_scoring_info.rna_centroid_info() );
147 conformation::Residue
const & rsd_i( pose.residue( i ) );
149 bool found_contact(
false );
150 for (
Size ii=rsd_i.first_sidechain_atom()+1 ;
ii<= rsd_i.nheavyatoms(); ++
ii ) {
152 Real const dist2( (rsd_i.xyz(
ii ) - atom_j ).length_squared() ) ;
153 if ( dist2 < CONTACT_CUTOFF2 ) {
155 found_contact =
true;
160 if ( !found_contact )
return false;
162 Vector const & centroid_i( base_centroids[i] );
163 kinematics::Stub
const & stub_i( base_stubs[i] );
164 Matrix const & M_i( stub_i.M );
169 Vector d_ij = atom_j - centroid_i;
176 if (
std::abs(zeta) < 60.0 ) edge_i =
'W';
177 else if ( zeta > +60.0 ) edge_i =
'H';
180 orientation =
dot( dir_vector, z_i ) > 0 ?
'A' :
'P';
190 char edge_i, orientation;
192 conformation::Residue
const & rsd_i( pose.residue( i ) );
193 conformation::Residue
const & rsd_j( pose.residue( j ) );
195 std::string
const atom_name =
" O2'";
196 Vector const atom_vector = rsd_j.xyz( atom_name );
197 Vector const dir_vector = rsd_j.xyz(
" O2'" ) - rsd_j.xyz(
" C2'" );
198 if ( !
check_for_contacts( pose, i, atom_vector, dir_vector, edge_i, orientation) )
return;
200 char const edge_j =
'2';
202 kinematics::Stub
const stub1( rsd_i.xyz( rsd_i.chi_atoms(1)[4] ),
203 rsd_i.xyz( rsd_i.chi_atoms(1)[3] ),
204 rsd_i.xyz( rsd_i.chi_atoms(1)[2] ) );
206 kinematics::Stub
const stub2( rsd_j.xyz( atom_name ),
208 rsd_j.xyz(
" C3'" ) );
210 dataout <<
"PAIR " <<
211 I(5, i) <<
' ' << edge_i <<
' ' <<
212 I(5, j) <<
' ' << edge_j <<
" " <<
213 orientation <<
" " <<
214 pose.residue(i).name1() <<
' ' << pose.residue(j).name1() <<
" " <<
215 rsd_i.atom_name( rsd_i.chi_atoms(1)[4] ) <<
" " <<
217 kinematics::Jump( stub1, stub2) <<
228 char edge_i, orientation;
230 conformation::Residue
const & rsd_i( pose.residue( i ) );
231 conformation::Residue
const & rsd_j( pose.residue( j ) );
232 conformation::Residue
const & prev_rsd( pose.residue( j-1 ) );
235 Vector dir_vector =
cross( rsd_j.xyz(
" OP1" ) - rsd_j.xyz(
" P " ),
236 rsd_j.xyz(
" OP2" ) - rsd_j.xyz(
" P " ) );
238 std::string atom_name =
" OP2";
239 Vector atom_vector = rsd_j.xyz( atom_name );
242 atom_vector = rsd_j.xyz( atom_name );
243 if ( !
check_for_contacts( pose, i, atom_vector, dir_vector, edge_i, orientation) )
return;
247 char const edge_j =
'P';
249 kinematics::Stub
const stub1( rsd_i.xyz( rsd_i.chi_atoms(1)[4] ),
250 rsd_i.xyz( rsd_i.chi_atoms(1)[3] ),
251 rsd_i.xyz( rsd_i.chi_atoms(1)[2] ) );
253 kinematics::Stub
const stub2_fwd( rsd_j.xyz( atom_name ),
255 prev_rsd.xyz(
" O3'" ) );
257 kinematics::Stub
const stub2_back( rsd_j.xyz( atom_name ),
259 rsd_j.xyz(
" O5'" ) );
261 dataout <<
"PAIR " <<
262 I(5, i) <<
' ' << edge_i <<
' ' <<
263 I(5, j) <<
' ' << edge_j <<
" " <<
264 orientation <<
" " <<
265 pose.residue(i).name1() <<
' ' << pose.residue(j).name1() <<
" " <<
266 rsd_i.atom_name( rsd_i.chi_atoms(1)[4] ) <<
" " <<
268 kinematics::Jump( stub1, stub2_fwd ) <<
269 kinematics::Jump( stub1, stub2_back ) <<
279 using namespace chemical;
280 using namespace core::scoring;
281 using namespace core::scoring::rna;
283 using namespace basic::options::OptionKeys;
284 using namespace protocols::farna;
288 ResidueTypeSetCOP rsd_set;
289 rsd_set = core::chemical::ChemicalManager::get_instance()->residue_type_set( FA_STANDARD );
295 core::import_pose::pose_from_pdb(
pose, *rsd_set, infile );
296 make_phosphate_nomenclature_matches_mini(
pose );
302 ScoreFunctionOP lores_scorefxn = ScoreFunctionFactory::create_score_function( RNA_LORES_WTS );
303 (*lores_scorefxn)(
pose );
306 RNA_ScoringInfo
const & rna_scoring_info( rna_scoring_info_from_pose(
pose ) );
307 RNA_FilteredBaseBaseInfo
const & rna_filtered_base_base_info( rna_scoring_info.rna_filtered_base_base_info() );
308 EnergyBasePairList scored_base_pair_list( rna_filtered_base_base_info.scored_base_pair_list() );
313 it != scored_base_pair_list.end(); ++it ) {
315 BasePair
const base_pair = it->second;
317 int const i = base_pair.res1();
318 int const k = base_pair.edge1();
320 int const j = base_pair.res2();
321 int const m = base_pair.edge2();
323 if ( is_num_in_list(i, exclude_res_list) || is_num_in_list(j, exclude_res_list) ) {
327 char const orientation = ( base_pair.orientation() == 1) ?
'A' :
'P';
329 char const edge_i = core::chemical::rna::get_edge_from_num( k );
330 char const edge_j = core::chemical::rna::get_edge_from_num( m );
333 conformation::Residue
const & rsd_i(
pose.residue( i ) );
334 conformation::Residue
const & rsd_j(
pose.residue( j ) );
335 kinematics::Stub
const stub_i( rsd_i.xyz( rsd_i.chi_atoms(1)[4] ),
336 rsd_i.xyz( rsd_i.chi_atoms(1)[3] ),
337 rsd_i.xyz( rsd_i.chi_atoms(1)[2] ) );
338 kinematics::Stub
const stub_j( rsd_j.xyz( rsd_j.chi_atoms(1)[4] ),
339 rsd_j.xyz( rsd_j.chi_atoms(1)[3] ),
340 rsd_j.xyz( rsd_j.chi_atoms(1)[2] ) );
342 dataout <<
"PAIR " <<
343 I(5, i) <<
' ' << edge_i <<
' ' <<
344 I(5, j) <<
' ' << edge_j <<
" " <<
345 orientation <<
" " <<
346 pose.residue(i).name1() <<
' ' <<
pose.residue(j).name1() <<
" " <<
347 rsd_i.atom_name( rsd_i.chi_atoms(1)[4] ) <<
" " <<
348 rsd_j.atom_name( rsd_j.chi_atoms(1)[4] ) <<
" " <<
349 kinematics::Jump( stub_i, stub_j) <<
356 core::scoring::EnergyGraph
const & energy_graph(
pose.energies().energy_graph() );
357 for (
Size i = 1; i <=
pose.total_residue(); i++ ) {
360 for ( graph::Graph::EdgeListConstIter
361 iru = energy_graph.get_node(i)->const_edge_list_begin(),
362 irue = energy_graph.get_node(i)->const_edge_list_end();
363 iru != irue; ++iru ) {
364 EnergyEdge
const * edge( static_cast< EnergyEdge const *> ( *iru ) );
365 Size const j( edge->get_other_ind(i) );
367 if ( is_num_in_list(i, exclude_res_list) || is_num_in_list(j, exclude_res_list) ) {
383 std::cout <<
"***********************************************************" << std::endl;
384 std::cout <<
"Put jumps from PDB file " << infile <<
" into " <<
outfile << std::endl;
385 std::cout <<
"***********************************************************" << std::endl;
395 bps_seq += sequence[ base_pair_res[1]-1 ];
396 bps_seq += sequence[ base_pair_res[2]-1 ];
400 bps_seq += sequence[ base_pair_res[3]-1 ];
401 int seq_sep =
int( base_pair_res[ 4 ] ) -
int( base_pair_res[ 3 ] );
402 if ( seq_sep > 0 && seq_sep <= (MAX_BULGE_LENGTH+1) ) {
403 for (
Size i = base_pair_res[3]+1; i < base_pair_res[4]; i++ ) bps_seq +=
'n';
407 bps_seq += sequence[ base_pair_res[4]-1 ];
418 pose::PDBInfoCOP pdb_info = pose.pdb_info();
420 std::stringstream pdb_tag_stream;
421 pdb_tag_stream << infile;
422 for (
Size n = 1; n <= base_pair_res.size(); n++ ) {
423 pdb_tag_stream <<
"_";
424 pdb_tag_stream << pdb_info->chain( base_pair_res[1] ) << pdb_info->number( base_pair_res[n] );
427 return pdb_tag_stream.str();
435 if ( seq_sep == 1 ) {
437 }
else if ( seq_sep >= 2 && seq_sep <= (MAX_BULGE_LENGTH+1) ) {
440 return "long_distance/";
448 int seq_sep =
int( base_pair_res[ 4 ] ) -
int( base_pair_res[ 3 ] );
456 std::string
const & intag,
457 bool const use_sub_directories =
true )
460 static SilentFileData silent_file_data;
463 core::pose::pdbslice( bps_pose, pose, base_pair_res );
465 std::string bps_seq =
get_bps_seq( base_pair_res, pose.sequence() );
466 std::string bps_tag =
get_bps_tag( base_pair_res, intag, pose );
468 std::cout <<
"Found base pair step! " << bps_seq <<
" " << bps_tag << std::endl;
470 std::string bps_sub_dir;
471 if ( use_sub_directories ) {
475 std::string
const silent_file = bps_sub_dir + bps_seq +
".out";
476 BinarySilentStruct
s( bps_pose, bps_tag );
477 silent_file_data.write_silent_struct( s, silent_file,
false );
483 std::string
const & intag )
493 std::string
const & intag )
495 std::map< Size, Size >
partner;
496 protocols::farna::figure_out_base_pair_partner( pose, partner,
false );
499 it != partner.end(); ++it ) {
501 Size const i = it->first;
502 Size const j = it->second;
504 if ( i < pose.total_residue() &&
505 partner.find( i+1 ) != partner.end() && j > 1 && partner[ i+1 ] == j-1 &&
506 !pose.fold_tree().is_cutpoint(i) && !pose.fold_tree().is_cutpoint(j-1) ) {
519 std::string
const & intag )
524 base_pair_list= protocols::farna::classify_base_pairs_lores( pose );
526 base_pair_list= classify_base_pairs( pose );
529 std::map< std::pair< Size, Size >,
bool > partnered;
530 for (
Size n = 1; n <= base_pair_list.size(); n++ ) {
532 BasePair
const base_pair = base_pair_list[ n ];
534 Size const i = base_pair.res1();
535 Size const j = base_pair.res2();
540 partnered[ std::make_pair( i, j ) ] =
true;
541 partnered[ std::make_pair( j, i ) ] =
true;
544 for (
Size i = 1; i < pose.total_residue(); i++ ) {
545 for (
Size j = 1; j <= pose.total_residue(); j++ ) {
547 if ( partnered[ std::make_pair( i, j ) ] ) {
553 for (
int n = 0; n <= MAX_BULGE_LENGTH; n++ ) {
555 if (
int(j) > (n+1) &&
std::abs(
int(i) -
int(j) ) > (
int(n)+1) &&
556 partnered[ std::make_pair( i+1, j-n-1 ) ] &&
557 !pose.fold_tree().is_cutpoint( i ) ) {
559 bool found_cut(
false );
560 for (
int q = 1; q <= n+1; q++ ) {
561 if ( pose.fold_tree().is_cutpoint( j-q ) ) {
565 if ( found_cut )
continue;
569 outputted_bps[ j-n-1 ] =
true;
576 for (
Size k = 1; k <= pose.total_residue(); k++ ) {
577 if ( outputted_bps[ k ] )
continue;
578 if ( partnered[ std::make_pair( i+1, k ) ] ) {
595 using namespace chemical;
596 using namespace core::scoring;
597 using namespace core::scoring::rna;
599 using namespace basic::options::OptionKeys;
600 using namespace protocols::farna;
601 using namespace protocols::stepwise;
605 ResidueTypeSetCOP rsd_set;
606 rsd_set = core::chemical::ChemicalManager::get_instance()->residue_type_set( FA_STANDARD );
610 for (
Size n = 1; n <= infiles.size(); n++ ) {
611 std::string
const & infile = infiles[ n ];
613 std::string intag = infile;
614 Size pos( intag.find(
".pdb" ) );
615 intag.replace(
pos, 4,
"" );
618 core::import_pose::pose_from_pdb( pose, *rsd_set, std::string(
option[
in::path::pdb ](1) ) + infile );
619 core::pose::rna::figure_out_reasonable_rna_fold_tree( pose );
620 std::string
const sequence = pose.sequence();
622 if (
option[ general_bps ]() ) {
628 std::cout <<
"***********************************************************" << std::endl;
629 std::cout <<
"Put base pair steps from " << infile <<
" into .out files" << std::endl;
630 std::cout <<
"***********************************************************" << std::endl;
643 using namespace basic::options::OptionKeys::rna::farna;
644 using namespace basic::options::OptionKeys::rna::farna::db;
646 if (
option[ jump_database ] ) {
648 }
else if (
option[ vall_torsions ].
user() ) {
650 }
else if (
option[ bps_database ]() ) {
654 std::cout <<
"Please specify: " << std::endl;
655 std::cout <<
" -vall_torsions for generating torsions library " << std::endl;
656 std::cout <<
" -jump_database for generating database of rigid-body orientations " << std::endl;
657 std::cout <<
" -bps_database for generating database of Watson-Crick base pair steps " << std::endl;
667 main(
int argc,
char * argv [] )
674 std::cout << std::endl <<
"Basic usage: " << argv[0] <<
" -s <pdb1> [... <more pdbs>] -vall_torsions [name of output torsions file to create] " << std::endl;
675 std::cout <<
" " << argv[0] <<
" -s <pdb1> [... <more pdbs>] -jump_database [name of rigid-body orientation database to create] " << std::endl;
676 std::cout << std::endl <<
" Type -help for full slate of options." << std::endl << std::endl;
678 NEW_OPT( exclude_res,
"Residues excluded for database creation (works for one file only)", blank_size_vector );
679 NEW_OPT( general_bps,
"For bps_database, output base pair steps involving noncanonicals",
false );
680 NEW_OPT( use_lores_base_pair_classification,
"Use loose base-pair classifier (same as used in FARNA)",
false );
681 option.add_relevant( basic::options::OptionKeys::rna::farna::vall_torsions );
682 option.add_relevant( basic::options::OptionKeys::rna::farna::db::jump_database );
683 option.add_relevant( basic::options::OptionKeys::rna::farna::db::bps_database );
695 protocols::viewer::viewer_main(
my_main );
697 std::cout <<
"caught exception " << e.
msg() << std::endl;
virtual std::string const msg() const
utility::keys::KeyLookup< KeyType >::const_iterator const_iterator
Key collection iterators.
Vector col_y() const
Column y.
bool check_for_contacts(pose::Pose &pose, Size const i, Vector const &atom_j, Vector const dir_vector, char &edge_i, char &orientation)
BooleanOptionKey const user("options:user")
void create_rna_vall_torsions_test()
void check_for_contacts_and_output_jump_phosphate(pose::Pose &pose, Size const i, Size const j, utility::io::ozstream &dataout)
Platform independent operations on files (except I/O)
#define runtime_assert(_Expression)
Assert that the condition holds. Evaluated for both debug and release builds.
Conversions between degrees and radians.
std::string get_bps_tag(utility::vector1< Size > const &base_pair_res, std::string const &infile, pose::Pose const &pose)
common derived classes for thrown exceptions
std::string get_bps_sub_dir(int const seq_sep)
void output_general_base_pair_steps(pose::Pose const &pose, std::string const &intag)
void check_for_contacts_and_output_jump_o2prime(pose::Pose &pose, Size const i, Size const j, utility::io::ozstream &dataout)
Vector col_x() const
Column x.
T abs(T const &x)
std::abs( x ) == | x |
std::vector with 1-based indexing
numeric::xyzMatrix< Real > Matrix
void create_base_pair_step_database_test()
T degrees(T const &radians)
Degrees of radians.
FArray1D< T > cross(FArray1< T > const &a, FArray1< T > const &b)
Cross Product of Two 3-Tuple Vectors.
bool create_directory_recursive(std::string const &dir_path)
Create a directory and its parent directories if they doesn't already exist.
rule< Scanner, options_closure::context_t > options
#define OPT_KEY(type, key)
T dot_product(CArray< T > const &a, CArray< T > const &b)
Dot product.
utility::options::OptionCollection option
OptionCollection global.
Output file stream wrapper for uncompressed and compressed files.
void create_bp_jump_database_test()
#define NEW_OPT(akey, help, adef)
Vector col_z() const
Column z.
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
bool file_exists(std::string const &path)
Does File Exist?
void output_canonical_base_pair_steps(pose::Pose &pose, std::string const &intag)
std::string get_bps_seq(utility::vector1< Size > const &base_pair_res, std::string const &sequence)
ozstream: Output file stream wrapper for uncompressed and compressed files
void write_base_pair_step_to_silent_struct(pose::Pose const &pose, utility::vector1< int > base_pair_res, std::string const &intag, bool const use_sub_directories=true)
xyzVector and xyzMatrix functions
T dot(CArray< T > const &a, CArray< T > const &b)
Dot product.
void init()
set global 'init_was_called' to true
Program options global and initialization function.
int const silent
Named verbosity levels.
rule< Scanner, option_closure::context_t > option