44 #include <utility/io/izstream.hh>
45 #include <utility/io/ozstream.hh>
46 #include <utility/excn/Exceptions.hh>
48 #include <basic/Tracer.hh>
49 #include <basic/options/option_macros.hh>
50 #include <basic/options/keys/in.OptionKeys.gen.hh>
51 #include <basic/prof.hh>
57 #include <utility/vector1.hh>
59 OPT_2GRP_KEY( File, noesy, in, resonances )
60 OPT_2GRP_KEY( FileVector, noesy, in, peaks )
61 OPT_2GRP_KEY( FileVector, noesy, in, peak_resonance_pairs )
62 OPT_2GRP_KEY( Boolean, noesy, in, use_assignments )
63 OPT_2GRP_KEY( File, noesy, in, decoys )
64 OPT_2GRP_KEY( File, noesy, in, local_dist_table )
66 OPT_2GRP_KEY( File, noesy, out, resonances )
67 OPT_2GRP_KEY( File, noesy, out, peaks )
68 OPT_2GRP_KEY( File, noesy, out, talos )
69 OPT_2GRP_KEY( Boolean, noesy, out, names )
70 OPT_2GRP_KEY( Boolean, noesy, out, separate_peak_files )
71 OPT_2GRP_KEY( Boolean, noesy, out, unambiguous )
72 OPT_2GRP_KEY(
String, noesy, out, format )
73 OPT_2GRP_KEY(
Real, noesy, out, minVC )
74 OPT_2GRP_KEY( Real, noesy, out, padding )
87 bool protocols::noesy_assign::
NoesyModule::cmdline_options_activated() {
88 using namespace basic::options;
89 using namespace OptionKeys;
90 return ( option[ noesy::in::resonances ].user() && option[ noesy::in::peaks ].user() )
91 || option[ noesy::in::peak_resonance_pairs ].user();
95 using namespace basic::options;
96 using namespace OptionKeys;
104 NEW_OPT( noesy::in::resonances,
"file with assigned chemical shifts",
"" );
106 NEW_OPT( noesy::in::peaks,
"file with noesy peaks",
"" );
107 NEW_OPT( noesy::in::peak_resonance_pairs,
"pairs of files that belong together: cc.peaks cc.prot ilv.peaks ilv.prot",
"" );
108 NEW_OPT( noesy::in::use_assignments,
"when reading peaks the already existing assignments are not ignored",
false );
109 NEW_OPT( noesy::in::decoys,
"silent file with decoys used for 3D structural compatibility test",
"" );
110 NEW_OPT( noesy::in::local_dist_table,
"file with distances determined for instances with FragToAtomDist ",
"" );
112 NEW_OPT( noesy::out::resonances,
"the parsed resonances file with translated atom names etc.",
"cs_out.dat" );
113 NEW_OPT( noesy::out::peaks,
"the parsed peaks file with assignments",
"NOE_out.dat" );
114 NEW_OPT( noesy::out::talos,
"write the resonances also as talos file",
"cs_prot.tab" );
115 NEW_OPT( noesy::out::names,
"write atom-names rather then resonance ID for assignments",
true );
116 NEW_OPT( noesy::out::separate_peak_files,
"write peaks to independent files with out::peaks as prefix",
false );
117 NEW_OPT( noesy::out::unambiguous,
"write only the assignment with hightest VC",
false );
118 NEW_OPT( noesy::out::minVC,
"write only assignments that contribute more than X to the peak-volume", 0.0 );
119 NEW_OPT( noesy::out::format,
"write as xeasy or sparky file",
"xeasy" );
120 NEW_OPT( noesy::out::padding,
"add padding of X Angstrom to final constraints", 0.0 );
121 NEW_OPT( noesy::no_decoys,
"check comp. with decoys",
false );
125 static basic::Tracer
tr(
"protocols.noesy_assign.NoesyModule");
128 using namespace core;
129 using namespace basic;
130 using namespace basic::options;
134 namespace protocols {
135 namespace noesy_assign {
138 NoesyModule::~NoesyModule() {}
162 basic::ProfileThis doit( basic::NOESY_ASSIGN_READ_INPUT );
163 using namespace basic::options;
165 if ( option[ OptionKeys::noesy::in::resonances ].user() ) {
166 utility::io::izstream input_file( option[ OptionKeys::noesy::in::resonances ]() );
167 utility::io::ozstream output_file( option[ OptionKeys::noesy::out::resonances ]() );
168 if ( input_file.good() ) {
171 if ( option[ OptionKeys::noesy::out::talos ].user() ) {
172 utility::io::ozstream talos_file( option[ OptionKeys::noesy::out::talos ]() );
176 tr.Error <<
"cannot read " << input_file << std::endl;
177 throw utility::excn::EXCN_FileNotFound( option[ OptionKeys::noesy::in::resonances ]() );
184 Size nfiles( option[ OptionKeys::noesy::in::peaks ]().
size() );
187 for (
core::Size ifile = 1; ifile <= nfiles; ++ifile ) {
188 std::string file( option[ OptionKeys::noesy::in::peaks ]()[ ifile ] );
189 utility::io::izstream input_file( file );
190 if ( input_file.good() ) {
192 throw utility::excn::EXCN_BadInput(
"attempt to read Peak-Files with option -noesy:in:peaks without a global resonance file: -noesy:in:resonances" );
195 format.
set_filename( option[ OptionKeys::noesy::in::peaks ]()[ ifile ].base() );
197 tr.Info <<
"reading " << file <<
"... " << std::endl;
200 tr.Error <<
"cannot read " << file << std::endl;
206 if ( option[ OptionKeys::noesy::in::peak_resonance_pairs ].user() ) {
207 Size n_pair_files( option[ OptionKeys::noesy::in::peak_resonance_pairs ]().
size() );
208 if ( n_pair_files % 2 != 0 ) {
209 throw utility::excn::EXCN_BadInput(
"odd number of entries in option -noesy:in:peak_resonance_pairs, always provide pairs of files <*.peaks> <*.prot>" );
211 for (
core::Size ifile = 1; ifile <= n_pair_files; ifile += 2 ) {
213 utility::io::izstream res_input_file( option[ OptionKeys::noesy::in::peak_resonance_pairs ]()[ ifile+1 ] );
214 if ( res_input_file.good() ) {
215 resonances->read_from_stream( res_input_file );
217 tr.Error <<
"cannot read " << res_input_file << std::endl;
218 throw utility::excn::EXCN_FileNotFound( option[ OptionKeys::noesy::in::resonances ]() );
220 std::string file( option[ OptionKeys::noesy::in::peak_resonance_pairs ]()[ ifile ] );
221 utility::io::izstream input_file( file );
222 if ( input_file.good() ) {
224 format.
set_filename( option[ OptionKeys::noesy::in::peak_resonance_pairs ]()[ ifile ].base() );
226 tr.Info <<
"reading " << file <<
"... " << std::endl;
227 crosspeaks_->read_from_stream( input_file, format, resonances );
229 tr.Error <<
"cannot read " << file << std::endl;
234 if ( option[ OptionKeys::noesy::in::local_dist_table ].user() ) {
240 using namespace core::scoring::constraints;
242 if ( (*it)->eliminated() )
continue;
243 if ( (*it)->min_seq_separation_residue_assignment( 0.1 ) < 1 )
continue;
245 FuncOP func(
new BoundFunc(1.5, (*it)->distance_bound(), 1,
"NOE Peak " ) );
247 (*ait)->set_native_distance_viol( new_cst->score( native_pose ) );
254 using namespace basic::options;
256 ProfileThis doit( NOESY_ASSIGN_WRITE_ASSIGNMENTS );
257 if ( file_name ==
"use_cmd_line" ) {
258 file_name = option[ OptionKeys::noesy::out::peaks ]();
261 std::string const format_str( option[ OptionKeys::noesy::out::format ]() );
262 if ( format_str ==
"xeasy" ) {
264 }
else if ( format_str ==
"sparky" ) {
266 }
else utility_exit_with_message(
"NOE_data output format "+format_str+
" is not known! ");
267 format->set_write_atom_names( option[ OptionKeys::noesy::out::names ]() );
268 format->set_write_only_highest_VC( option[ OptionKeys::noesy::out::unambiguous ]() );
269 format->set_min_VC_to_write( option[ OptionKeys::noesy::out::minVC ]() );
270 if ( option[ OptionKeys::noesy::out::separate_peak_files ]() ) {
271 crosspeaks_->write_peak_files( file_name, *format );
273 utility::io::ozstream output_file( file_name );
274 crosspeaks_->write_to_stream( output_file, *format );
280 using namespace basic::options;
281 using namespace OptionKeys;
285 if ( !option[ noesy::no_decoys ]() ) {
286 if ( option[ noesy::in::decoys ].user() ) {
287 file_name = option[ noesy::in::decoys ]();
288 sfd.read_file( file_name );
290 if ( sfd.size() == 0 && option[ OptionKeys::in::file::silent ].user() ) {
291 file_name = option[ OptionKeys::in::file::silent ]()[ 1 ];
292 sfd.read_file( file_name );
295 if ( sfd.begin() != sfd.end() ) {
297 std::ostringstream
str;
298 str <<
"Sequence of input structures in file " << file_name <<
" does not match the sequence in resonance file and fasta-file\n";
300 str <<
"Ensemble: " << sfd.begin()->sequence().one_letter_sequence();
301 utility_exit_with_message( str.str() );
304 assign( sfd.begin(), sfd.end() );
315 bool ignore_elimination_candidates,
316 bool elimination_candidates
319 PROF_START( NOESY_ASSIGN_GEN_CST );
321 using namespace core::scoring::constraints;
322 using namespace basic::options;
323 using namespace OptionKeys;
330 tr.Info <<
"generate constraints..." << std::endl;
339 option[ noesy::out::padding ](),
340 ignore_elimination_candidates,
341 elimination_candidates
344 PROF_STOP( NOESY_ASSIGN_GEN_CST );
346 tr.Info <<
"write constraints..." << std::endl;
347 PROF_START( NOESY_ASSIGN_WRITE_CST );
352 PROF_STOP( NOESY_ASSIGN_WRITE_CST );