20 #include <basic/options/option.hh>
21 #include <basic/options/keys/match.OptionKeys.gen.hh>
27 #include <basic/Tracer.hh>
30 #include <utility/io/izstream.hh>
31 #include <utility/pointer/ReferenceCount.hh>
32 #include <utility/string_util.hh>
33 #include <utility/vector1.fwd.hh>
40 namespace match_enzdes_util {
42 static basic::Tracer
TR(
"protocols.toolbox.match_enzdes_util.AllowedSeqposForGeomCst" );
46 : seqpos_for_geomcst_( seqpos_for_geomcst )
67 else if( geomcst >
seqpos_for_geomcst_.size() ) utility_exit_with_message(
"Asking for seqpos list of geomcst "+utility::to_string( geomcst )+
", but lists only exist for "+utility::to_string(
seqpos_for_geomcst_.size() )+
" geomcst.");
118 using namespace basic::options;
121 if ( option[ scaffold_active_site_residues ].user() && option[ scaffold_active_site_residues_for_geomcsts ].user() ) {
122 utility_exit_with_message(
"Conflicting scaffold build point defintion: both "
123 "the -match::scaffold_active_site_residues <filename> flag\n"
124 "and the -match::scaffold_active_site_residues_for_geomcsts <filename> flag were found on the command line" );
129 if ( option[ scaffold_active_site_residues ].user() ) {
134 utility::io::izstream istr( filename.c_str() );
135 std::list< Size > upstream_build_resids;
136 TR <<
"Reading match::scaffold_active_stie_residues " << filename <<
":";
140 if ( ! istr.bad() && resid != 0 ) {
142 upstream_build_resids.push_back( resid );
146 if ( upstream_build_resids.empty() ) {
147 utility_exit_with_message(
"Failed to read any scaffold active site residues from file " + filename +
" specified by the flag match::scaffold_active_stie_residues" );
153 std::copy( upstream_build_resids.begin(), upstream_build_resids.end(),
seqpos_for_geomcst_[1].begin() );
155 else if (option[ scaffold_active_site_residues_for_geomcsts ].user() ) {
159 utility::io::izstream istr( filename.c_str() );
160 std::list< Size > upstream_build_resids;
161 TR <<
"Reading match::scaffold_active_site_residues_for_geomcsts " << filename << std::endl;
163 if ( ! istr.good() ) {
164 utility_exit_with_message(
"Could not read first line from match::scaffold_active_site_residues_for_geomcsts " + filename );
166 istr >> ncsts_string;
168 utility_exit_with_message(
"Failed to read N_CST field in first line from match::scaffold_active_site_residues_for_geomcsts " + filename );
170 if ( ! istr.good() ) {
171 utility_exit_with_message(
"Unexpected end of file after reading N_CST field in first line from match::scaffold_active_site_residues_for_geomcsts " + filename );
173 if ( ncsts_string !=
"N_CST" ) {
174 utility_exit_with_message(
"Failed to read N_CST field in first line from match::scaffold_active_site_residues_for_geomcsts " + filename );
178 utility_exit_with_message(
"Failed to read the number of geometric constraints in first line from match::scaffold_active_site_residues_for_geomcsts " + filename );
190 istr.getline( finish_the_line );
194 Size geomcst_id( 0 );
196 if ( istr.eof() && geomcst_id == 0 )
break;
199 utility_exit_with_message(
"Reading line " + utility::to_string( linenum ) +
" of " + filename +
". Failed to read the geometric constraint id at the beginning of the line." );
201 if ( geomcst_id > ncsts ) {
202 utility_exit_with_message(
"Reading line " + utility::to_string( linenum ) +
" of " + filename +
". Geometric constraint id at the beginning of the line is out of range: "
203 + utility::to_string( geomcst_id ) +
" > " + utility::to_string( ncsts ) );
205 if ( data_read_for_cst[ geomcst_id ] != 0 ) {
206 utility_exit_with_message(
"Reading line " + utility::to_string( linenum ) +
" of " + filename +
". Residue list for geometric constraint #"
207 + utility::to_string( geomcst_id ) +
" appeared already on line " + utility::to_string( data_read_for_cst[ geomcst_id ] ) );
209 data_read_for_cst[ geomcst_id ] = linenum;
212 if ( colon !=
":" ) {
213 utility_exit_with_message(
"Reading line " + utility::to_string( linenum ) +
" of " + filename +
". Failed to read the colon (:) separating the geometric constraint id from the rest of the resids." );
215 TR << std::endl << geomcst_id <<
" :";
218 if( istr.bad() ) utility_exit_with_message(
"Apparently there are no residues listed for geom cst " + utility::to_string( geomcst_id ) +
" in file " + filename +
".");
219 if( ( first_token ==
"ALL" ) || (first_token ==
"all" ) ){
220 if( !pose ) utility_exit_with_message(
"AllowedSeqposForGeomCst requested to use all build pos for a certain constraint, but no pose passed into function, can't generate list.");
221 TR <<
"All pose positions requested, using ";
222 for(
core::Size seqpos = 1; seqpos <= pose->total_residue(); ++seqpos ){
223 if( pose->residue(seqpos).is_protein() ){
228 istr.getline( finish_the_line );
231 std::istringstream firststr( first_token );
232 firststr >> first_resid;
233 if( first_resid != 0) {
235 TR <<
" " << first_resid;
237 utility_exit_with_message(
"Bad first residue listed for geomcst " + utility::to_string( geomcst_id ) +
" in file " + filename +
": " + first_token);
239 istr.getline( finish_the_line );
240 if( finish_the_line !=
""){
241 std::istringstream isstr( finish_the_line );
242 while ( isstr.good() ) {
245 if ( isstr.eof() && resid == 0 )
break;
246 if ( ! isstr.bad() ) {
259 std::cerr << std::endl <<
"ERROR parsing line fragment: " << finish_the_line << std::endl;
260 utility_exit_with_message(
"Reading line " + utility::to_string( linenum ) +
" of " + filename +
". Only integers may be included." );
268 bool any_absent(
false );
269 for (
Size ii = 1; ii <= ncsts; ++ii ) {
270 if ( data_read_for_cst[ ii ] == 0 ) {
271 std::cerr <<
"ERROR reading " << filename <<
": did not find residue list for constraint # " << ii << std::endl;
276 utility_exit_with_message(
"Failed to read a residue list for one or more constraints" );