23 #include <basic/Tracer.hh>
24 #include <basic/options/option.hh>
25 #include <basic/options/keys/cm.OptionKeys.gen.hh>
26 #include <basic/options/keys/in.OptionKeys.gen.hh>
27 #include <basic/options/keys/nonlocal.OptionKeys.gen.hh>
28 #include <utility/vector1.hh>
29 #include <utility/file/FileName.hh>
30 #include <utility/io/izstream.hh>
49 namespace comparative_modeling {
51 static basic::Tracer
tr(
"protocols.comparative_modeling.ThreadingJobInputter");
56 std::map< std::string, utility::vector1< core::Size > > extra_residues;
58 for (
Size ii = 1; ii <= fns.size(); ++ii ) {
59 utility::io::izstream input( fns[ii] );
60 if ( !input.good() ) {
62 utility_exit_with_message(msg);
65 while( getline(input,line) ) {
66 if ( line.substr(0,1) ==
"#" )
continue;
67 std::istringstream ss(line);
70 aln_id = ObjexxFCL::uppercased(aln_id);
76 extra_residues[aln_id].push_back(res);
81 extra_residues[aln_id].push_back(res);
89 return extra_residues;
93 input_source_( protocols::jd2::JobInputterInputSource::
NONE )
96 using namespace core::pose;
97 using namespace basic::options;
98 using namespace basic::options::OptionKeys;
100 tr.Debug <<
"Instantiate ThreadingJobInputter" << std::endl;
104 for (
Size ii = 1; ii <= aln_fns.size(); ++ii ) {
108 for (
Size jj = 1; jj <= alns.size(); ++jj ) {
114 if ( option[ in::file::template_pdb ].user() ) {
115 FileList template_pdb_filenames = option[ in::file::template_pdb ]();
120 for ( PoseOPvec::const_iterator it = poses.begin(); it != poses.end(); ++it ) {
122 std::string const base_fn( static_cast< std::string > (fn.base()) );
124 tr.Trace <<
"add template " << match << std::endl;
128 }
else if ( option[ in::file::template_silent ].user() ) {
130 sfd.
read_file( option[ in::file::template_silent ]() );
133 it->fill_pose( *pose );
134 std::string const match( ObjexxFCL::uppercased( it->decoy_tag().substr(2,5) ) );
135 tr.Trace <<
"add template " << match << std::endl;
141 utility_exit_with_message(
"ThreadingJobInputter needs parent-pdbs either as in:file:template_pdb or as in:file:template_silent");
145 if ( option[ cm::steal_extra_residues ].user() ) {
159 tr.Debug <<
"ThreadingJobInputter::pose_from_job" << std::endl;
161 using namespace basic::options;
162 using namespace basic::options::OptionKeys;
163 using namespace core::chemical;
169 job->inner_job().get()
174 if ( option[ in::file::fasta ].user() ) {
177 if ( input_fasta.size() == 0 ) {
178 utility_exit_with_message(
179 "ERROR: Fasta file specified by -in::file::fasta contains no valid sequence"
183 if ( input_fasta.size() > 1 ) {
184 utility_exit_with_message(
185 "ERROR: Fasta file specified by -in::file::fasta should contain a single sequence"
189 sequence = input_fasta[1]->sequence();
191 sequence = tjob->alignment().sequence(1)->ungapped_sequence();
200 Real const alignment_coverage( tjob->alignment().length() - tjob->alignment().gapped_positions() );
205 job->add_string_real_pair(
"aln_len", alignment_coverage );
206 job->add_string_real_pair(
"aln_perc", alignment_perc );
207 job->add_string_real_pair(
"aln_ident", alignment_identities );
224 if ( extra_res.size() > 0 ) {
226 tjob->alignment(), *tjob->get_pose(), extra_res);
233 tr.Debug <<
"ThreadingJobInputter::fill_jobs" << std::endl;
234 using namespace basic::options;
235 using namespace basic::options::OptionKeys;
243 Real filter_threshold = -1;
245 if ( option[ cm::aln_length_filter_quantile ].user() ) {
246 Real quantile = option[ cm::aln_length_filter_quantile ]();
250 std::vector < int > length_list;
251 for ( Alignments::const_iterator align_it =
alignments_.begin(); align_it !=
alignments_.end(); ++align_it ) {
252 length_list.push_back( align_it->length() - align_it->gapped_positions() );
253 tr <<
"Len " << align_it->length() - align_it->gapped_positions() << std::endl;
256 std::vector< int >::iterator i = length_list.begin();
257 std::vector< int >::size_type m = (size_t)( length_list.size() * quantile );
259 std::nth_element(i, i + m, length_list.end());
261 filter_threshold = length_list.at(m);
263 tr <<
"Quantile filter threshold = " << filter_threshold << std::endl;
267 for ( Alignments::const_iterator align_it =
alignments_.begin(); align_it !=
alignments_.end(); ++align_it ) {
269 std::string const alignment_id( align_it->alignment_id() );
270 std::string const template_id( alignment_id.substr(0,5));
271 tr.Debug <<
"creating job for alignment " << alignment_id <<
" on template " << template_id << std::endl;
273 Real const alignment_coverage( align_it->length() - align_it->gapped_positions() );
275 if ( option[ cm::aln_length_filter ].user() ) {
276 filter_threshold = option[ cm::aln_length_filter ]();
279 if ( ( filter_threshold > 0 ) && ( alignment_coverage < filter_threshold ) ) {
280 tr <<
"Skipping alignment " << alignment_id <<
": length = "
281 <<
int( alignment_coverage )
282 <<
" threshold = " <<
int( filter_threshold ) << std::endl;
291 PoseOPs template_poses( iter->second );
292 for ( PoseOPs::const_iterator it = template_poses.begin(); it != template_poses.end(); ++it ) {
295 *it, align_it->clone(),
"S_" + alignment_id, nstruct
298 ExtraResidues::const_iterator extra_res(
extra_residues_.find(alignment_id));
300 ijob->extra_residues_to_steal( extra_res->second );
304 for (
Size index = 1; index <= nstruct; ++index) {
306 jobs.back()->add_string_string_pair(
"aln_id", alignment_id );
311 tr.Error <<
"Warning: no template pdb provided for alignment " << alignment_id << std::endl;
335 return "ThreadingJobInputter";