28 #include <boost/foreach.hpp>
29 #define foreach BOOST_FOREACH
32 #include <basic/Tracer.hh>
33 #include <utility/string_util.hh>
34 #include <utility/vector1.hh>
35 #include <utility/tag/Tag.hh>
37 #include <utility/vector0.hh>
40 static basic::Tracer
TR(
"core.pose.selection" );
45 using namespace core::scoring;
54 bool const pdb_num_used( tag_ptr->hasOption( prefix +
"pdb_num" ) );
57 TR<<
"Bad tag: "<< *tag_ptr<<std::endl;
58 utility_exit_with_message(
"pdb_num used but no pdb_info found. Use res_num instead" );
66 char const chain( pdbnum[ pdbnum.length() - 1 ] );
67 std::stringstream ss( pdbnum.substr( 0, pdbnum.length() - 1 ) );
70 resnum = pose_map.find( chain, number );
74 resnum = tag_ptr->getOption<
core::Size>( prefix +
"res_num" );
76 runtime_assert( resnum );
93 string::const_iterator input_end = resnum.end();
95 string::const_iterator number_start = resnum.begin();
96 string::const_iterator number_end = resnum.begin();
97 while( number_end != input_end && *number_end >=
'0' && *number_end <=
'9' ) {
101 string::const_iterator chain_start = number_end;
102 string::const_iterator chain_end = number_end;
103 while( chain_end != input_end
104 && ((
'A' <= *chain_end && *chain_end <=
'Z') ||
105 (
'a' <= *chain_end && *chain_end <=
'z') ||
106 '_' == *chain_end ) )
111 string number(number_start,number_end);
112 string chain(chain_start,chain_end);
115 if( chain_end != input_end || chain.size() > 1 || number.size() < 1) {
116 TR.Error <<
"Could not parse '" << resnum <<
"' into a residue number." << std::endl;
121 std::istringstream ss( number );
123 if( chain.size() == 1 ) {
124 TR.Trace <<
"Interpretting " << n << chain <<
" as a pdb number." << std::endl;
126 runtime_assert(info);
127 return info->pdb2pose( chain[0], n );
130 TR.Trace <<
"Interpreting " << n <<
" as a Rosetta residue number." << std::endl;
149 if(sele.size()==9&&sele.substr(0,6)==
"name3="){
150 string name3 = sele.substr(6,3);
173 if( ! tag_ptr->hasOption( tag ) ) {
174 TR<<
"Error: No "<<tag<<
" option was found in tag "<<tag_ptr<<std::endl;
180 resnums.insert( resnums.begin(), resnums_set.begin(), resnums_set.end() );
181 sort( resnums.begin(), resnums.end() );
182 unique( resnums.begin(), resnums.end() );
193 using namespace utility;
198 foreach(
string const res, str_residues ){
199 if( res ==
"" )
continue;
200 if( res.find(
'-') != string::npos) {
203 if ( str_limits.size() == 2) {
206 if ( start && end && start > end ) {
207 utility_exit_with_message(
"Invalid residue range: " + res);
217 runtime_assert( num );
232 using namespace utility;
237 foreach(
string const res, str_residues ){
238 if( res ==
"" )
continue;
239 if( res.find(
'-') != string::npos) {
242 if ( str_limits.size() == 2) {
245 if ( start && end && start > end ) {
246 utility_exit_with_message(
"Invalid residue range: " + res);
249 resid.push_back( i );
256 runtime_assert( num );
257 resid.push_back( num );