23 #include <basic/Tracer.hh>
25 #include <utility/file/file_sys_util.hh>
27 #include <basic/options/option.hh>
29 #include <basic/options/keys/in.OptionKeys.gen.hh>
35 #include <utility/vector1.hh>
37 #include <boost/lexical_cast.hpp>
42 namespace constraints {
45 using namespace chemical;
46 using namespace conformation;
47 using namespace basic::options;
48 using namespace scoring;
49 using namespace constraints;
50 using namespace sequence;
52 using basic::t_warning;
56 static basic::Tracer
TR(
"core.scoring.constraints.SequenceProfileConstraint");
61 sequence_profile_(NULL),
74 sequence_profile_( profile ),
86 sequence_profile_( sequence_profile ),
110 if( version == -1 ) {
112 std::getline( is, tmp );
113 std::stringstream tmpss(tmp);
114 Size residue_index, aa_count;
115 tmpss >> residue_index >> aa_count;
117 TR(t_debug) <<
"Loading seqprof constraint for resi " << residue_index <<
" with aa_count " << aa_count << std::endl;
118 for(
Size i = 1; i <= aa_count; i++ ) {
121 aa_scores.push_back( tmp );
131 Size residue_index(boost::lexical_cast<Size>(version));
134 is >> profile_filename;
136 TR(t_debug) <<
"reading: " << residue_index <<
" " << profile_filename << std::endl;
137 if ( residue_index < 1 || residue_index > pose.
total_residue() ) {
138 std::cerr <<
"no such residue index " << residue_index <<
" in pose!)" << std::endl;
145 using namespace utility::file;
147 if ( profile_filename !=
"none" ) {
149 utility_exit_with_message(
"no such file " + profile_filename );
152 }
else if ( !
sequence_profile_ && option[ OptionKeys::in::file::pssm ].user() ) {
153 profile_filename = option[ OptionKeys::in::file::pssm ]().front();
155 if ( profile_filename ==
"none" ) {
156 utility_exit_with_message(
"\"none\" is not a valid value for -pssm in this context!");
161 if ( profile_filename !=
"none" ) {
163 newseqprof->read_from_checkpoint(
FileName(profile_filename) );
184 profile_pos = (*mapping_)[
seqpos_];
185 if( profile_pos == 0 )
return;
191 if( profile_pos <= sequence_profile_->
size() ) {
193 os <<
"SequenceProfile -1 " << profile_pos <<
" " << aa_scores.size() <<
" ";
194 for (
Size aa(1); aa <= aa_scores.size(); ++aa ) {
195 os << aa_scores[aa] <<
" ";
227 if ( newseqpos == 0 ) {
return NULL; }
229 TR(t_debug) <<
"Remapping resid " << seqpos_ <<
" to " << newseqpos << std::endl;
234 new_map->downstream_combine( *
mapping_ );
253 if ( newseqpos == 0 ) {
return NULL; }
255 TR(t_debug) <<
"Remapping resid " << seqpos_ <<
" to " << newseqpos << std::endl;
260 new_map->downstream_combine( *
mapping_ );
277 if ( weights[ this->
score_type() ] == 0 )
return;
282 profile_pos = (*mapping_)[
seqpos_];
283 if( profile_pos == 0 )
return;
287 if ( profile_pos > profile.size() )
return;
289 if (
size_t(aa) > position_profile.size() )
return;
290 Real const score( position_profile[aa] );
291 TR(t_trace) <<
"seqpos " <<
seqpos_ <<
" aa " << aa <<
" " <<
weight() * score << std::endl;
325 return "SequenceProfile";