173 #include <utility/vector1.hh>
174 #include <utility/io/izstream.hh>
185 static basic::Tracer
tr(
"core.chemical");
200 if( spos < rsd_type.
name().length() )
return rsd_type.
name().substr( spos );
210 std::istringstream l( line );
212 if ( l.fail() )
return "";
226 bool in_selector(
false );
227 for (
uint i=1; i<= lines.size(); ++i ) {
230 if ( tag ==
"BEGIN_SELECTOR" ) {
231 assert( !in_selector );
233 }
else if ( tag ==
"END_SELECTOR" ) {
235 }
else if ( in_selector ) {
236 pcase->selector().add_line( lines[i] );
239 if ( operation ) pcase->add_operation( operation );
254 iter_end=
operations_.end(); iter != iter_end; ++iter ) {
255 bool const fail( (*iter)->apply( *rsd ) );
256 if ( fail )
return 0;
271 tr.Debug <<
"Reading patch file: " << filename << std::endl;
281 utility::io::izstream data( filename.c_str() );
283 utility_exit_with_message(
"Cannot find patch file: "+filename);
286 while ( getline( data,line ) ) {
288 if ( tag.size() && tag[0] !=
'#' ) lines.push_back( line );
293 for (
uint i=1; i<= lines.size(); ++i ) {
294 std::istringstream l(lines[i]);
297 if ( tag ==
"NAME" ) {
299 }
else if ( tag ==
"TYPES" ) {
302 while ( !l.fail() ) {
306 }
else if ( tag ==
"REPLACE_RES_TYPE" ) {
313 bool in_selector(
false );
314 for (
uint i=1; i<= lines.size(); ++i ) {
316 if ( tag ==
"BEGIN_CASE" ) {
318 }
else if ( tag ==
"BEGIN_SELECTOR" ) {
319 assert( !in_selector );
321 }
else if ( tag ==
"END_SELECTOR" ) {
322 assert( in_selector );
324 }
else if ( in_selector ) {
332 bool in_case(
false );
333 while ( !lines.empty() ) {
336 if ( tag ==
"BEGIN_CASE" ) {
337 assert( case_lines.empty() );
340 }
else if ( tag ==
"END_CASE" ) {
342 if ( new_case )
cases_.push_back( new_case );
345 }
else if ( in_case ) case_lines.push_back( lines[1] );
347 lines.erase( lines.begin() );
359 using namespace basic;
360 static basic::Tracer core_chemical(
"core.chemical");
363 iter_end =
cases_.end(); iter != iter_end; ++iter ) {
365 if ( (*iter)->applies_to( rsd_type ) ) {
367 ResidueTypeOP patched_rsd_type( (*iter)->apply( rsd_type ) );
368 if ( patched_rsd_type ) {
373 iter_end =
types_.end(); iter != iter_end; ++iter ) {
374 patched_rsd_type->add_variant_type( *iter );
377 patched_rsd_type->name( name_new );
379 tr.Debug <<
"successfully patched: " << rsd_type.
name() <<
" to: " << patched_rsd_type->name() << std::endl;
380 return patched_rsd_type;