22 #include <basic/options/option.hh>
23 #include <basic/options/keys/templates.OptionKeys.gen.hh>
39 #include <ObjexxFCL/format.hh>
42 #include <utility/vector1.hh>
43 #include <basic/Tracer.hh>
57 static THREAD_LOCAL basic::Tracer
tr(
"protocols.abinitio.Templates" );
59 using namespace basic;
60 using namespace basic::options;
61 using namespace ObjexxFCL::format;
64 using namespace basic::options;
65 using namespace basic::options::OptionKeys;
66 option.add_relevant( templates::min_frag_size );
67 option.add_relevant( templates::max_shrink );
68 option.add_relevant( templates::shrink_step );
69 option.add_relevant( templates::shrink_pos_step );
70 option.add_relevant( templates::min_padding );
71 option.add_relevant( templates::min_align_pos );
72 option.add_relevant( templates::max_align_pos );
79 Template::~Template() {}
82 using namespace fragment;
83 using namespace scoring::constraints;
87 for (
Size i = 1; i<=nres; i++ ) {
88 if ( (i-1)%10 == 0 ) { out << i;
continue; }
90 if ( (i>=10) && (i-2)%10 == 0 ) {
continue; }
91 if ( (i>=100) && (i-3)%10 == 0 ) {
continue; }
92 if ( (i>=1000) && (i-4)%10 == 0 ) {
continue; }
96 for (
Size i = 1; i<=nres; i++ ) {
97 if ( mm.
get_bb( i ) ) out <<
'F';
106 tr.Error <<
"STUB ERROR: Template::Template(pose, mapping) constructure, not really finished yet !!! " << std::endl;
124 using namespace basic::options;
125 using namespace basic::options::OptionKeys;
130 tr.Info <<
"template " << name <<
" read alignment file: " << map_file << std::endl;
138 size_t found = pdb_seq.find(
mapping_.
seq2().substr(0,25) );
139 if ( found!=std::string::npos ) {
143 tr.Error <<
"query sequence could not be found for model " + name << std::endl;
144 tr.Error <<
"pdb_seq: " << pdb_seq << std::endl;
146 std::ofstream out(
"BAD_SEQUENCES", std::ios_base::out | std::ios_base::app );
149 <<
" PDBseq: " << pdb_seq << std::endl;
154 if ( option[ templates::min_align_pos ].user() ) {
155 Size const min_align_pos( option[ templates::min_align_pos ] );
161 if ( option[ templates::max_align_pos ].user() ) {
162 Size const max_align_pos( option[ templates::max_align_pos ] );
181 tr.Info <<
" strand_pairings of " << name <<
" aligned to target \n" << target_strand_pairings << std::endl;
185 Size tpos, pos = 1;
while ( (tpos =
mapping_[ pos++ ])<=0 ) ;
186 tr.Info <<
"template sequence " << seq.substr( tpos-1 ) << std::endl;
188 tr.Info <<
"first 10 aligned residues:" << std::endl;
189 for (
Size i = pos-1; i<= pos + 9; i++ ) {
202 typedef utility::vector1< Size > FragLengthMap;
203 FrameList template_frames;
205 FragLengthMap frag_length( nres, 0);
206 for (
Size pos1 = nres; pos1 >= 2; pos1-- ) {
209 Size cont_length( 0 );
210 for (
Size pos2 = pos1;
215 frag_length[ pos2 ] = cont_length;
219 pos1 = pos1 - cont_length + 1;
223 frag_length[ 1 ] = frag_length[ 2 ] + 1;
225 if (
tr.Trace.visible() ) {
226 tr.Trace <<
"frag_lengths:\n pos length";
227 for (
Size pos = 1; pos <= nres; pos++ ) {
228 tr.Trace <<
"\n" << pos <<
" " << frag_length[ pos ];
230 tr.Trace << std::endl;
234 using namespace basic::options;
235 using namespace basic::options::OptionKeys;
236 Size const min_size( option[ templates::min_frag_size ] );
237 Size const min_padding( option[ templates::min_padding ] );
238 Size const opt_max_shrink( option[ templates::max_shrink ] );
239 Size const shrink_step( option[ templates::shrink_step ]);
240 Size const pos_step( option[ templates::shrink_pos_step ]);
243 for (
Size pos = 1; pos<= nres; pos += std::max( (
int) frag_length[ pos ], 1) ) {
244 Size const max_size( frag_length[ pos ] );
245 if ( max_size < min_size )
continue;
246 Size const max_shrink( std::min( (
int) opt_max_shrink, (
int) max_size - (
int) min_size ) );
248 for (
Size shrink = min_padding; shrink <= max_shrink; shrink+=shrink_step ) {
249 Size const size( max_size - shrink );
255 for (
Size offset = min_padding; offset <= max_size - size; offset+=pos_step ) {
256 FrameOP aFrame(
new Frame( pos + offset, frag_type ) );
257 for (
Size i = 1; i<=ncopies; i++ ) {
258 aFrame->steal( *
pose_ );
261 template_frames.push_back( aFrame );
265 tr.Trace << template_frames << std::endl;
267 frag_set.add( template_frames );
268 return template_frames.size();
275 FrameList template_frames;
278 for ( FrameList::iterator it = template_frames.begin(),
279 eit = template_frames.end(); it!=eit; ++it ) {
280 tr.Trace <<
name() <<
" pick frags at " << (*it)->start() <<
" " << (*it)->end() <<
" " <<
pose_->total_residue() << std::endl;
281 for (
Size ct = 1; ct <= ncopies; ct ++ ) {
282 if ( (*it)->steal( *
pose_ ) ) total++;
288 accumulator.add( template_frames );
298 return !( out.
Pos1() <= 0 || out.
Pos2() <= 0 );
303 for ( core::scoring::dssp::PairingsList::const_iterator it = in.begin(),
304 eit = in.end(); it!=eit; ++it ) {
312 for ( core::scoring::dssp::PairingsList::const_iterator it = in.begin(),
313 eit = in.end(); it!=eit; ++it ) {
316 tr.Trace <<
"template: "<<*it<<
" target: " << pairing;
322 for ( FrameList::const_iterator it=frames.begin(),
323 eit = frames.end(); it!=eit; ++it ) {
324 FrameOP frame = (*it)->clone_with_frags();
326 target_frames.push_back( frame );
333 for ( FrameList::const_iterator it=frames.begin(),
334 eit = frames.end(); it!=eit; ++it ) {
337 tr.Trace <<
start <<
" " << frame->end() << std::endl;
339 std::cerr <<
start <<
" could not align frame " << *frame << std::endl;
340 utility_exit_with_message(
"Could not align frame ");
347 for ( FrameList::const_iterator it=frames.begin(),
348 eit = frames.end(); it!=eit; ++it ) {
350 tr.Error <<
"could not align frame " << **it << std::endl;
351 utility_exit_with_message(
"Could not align frame ");
358 for ( FrameList::const_iterator it=target_frames.begin(),
359 eit = target_frames.end(); it!=eit; ++it ) {
360 FrameOP frame = (*it)->clone();
363 template_frames.push_back( frame );
368 using namespace core::scoring::constraints;
376 typedef utility::vector1< ConstraintCOP > FlatList;
377 FlatList all_cst = cstset->get_all_constraints();
378 for ( FlatList::const_iterator it = all_cst.begin(),
379 eit = all_cst.end(); it!=eit; ++it ) {
386 tr.Warning <<
"WARNING: constraint found that is not AtomPairConstraint... will be ignored by Template" << std::endl;
396 using namespace core::id;
399 for ( NamedAtomPairConstraintList::const_iterator it = template_list.begin(),
400 eit = template_list.end(); it!=eit; ++it ) {
403 target_list.push_back( new_cst );
405 tr.Trace <<
"map2target: could not align constraint " << **it << std::endl;
415 using namespace core::id;
416 template_list.clear();
417 for ( NamedAtomPairConstraintList::const_iterator it = target_list.begin(),
418 eit = target_list.end(); it!=eit; ++it ) {
421 template_list.push_back( new_cst );
423 tr.Trace <<
"map2template: could not align constraint " << **it << std::endl;
433 using namespace core::scoring::constraints;
434 for ( NamedAtomPairConstraintList::const_iterator it = target_list.begin(),
435 eit = target_list.end(); it!=eit; ++it ) {
438 tr.Trace <<
"test: (target)" << cst->atom(1) <<
" " << cst->atom(2) << std::endl;
439 if ( cst->score( *
pose_ ) < 1.0 ) {
440 culled_list.push_back( *it );
442 tr.Trace <<
"cull constraint with score: " << cst->score( *
pose_ ) <<
" "
443 << cst->atom(1) <<
" " << cst->atom(2) << std::endl;
446 culled_list.push_back( *it );
core::scoring::dssp::StrandPairingSetOP strand_pairings_
core::sequence::DerivedSequenceMapping reverse_mapping_
void map2target(core::fragment::FrameList const &template_frames, core::fragment::FrameList &target_frames) const
core::sequence::DerivedSequenceMapping mapping_
void cull_violators(NamedAtomPairConstraintList const &target_list, NamedAtomPairConstraintList &culled_list) const
void map_pairings2target(core::scoring::dssp::PairingList const &in, core::scoring::dssp::PairingList &out) const
Declarations for the MoveMap class.
utility::pointer::shared_ptr< AtomPairConstraint > AtomPairConstraintOP
utility::pointer::shared_ptr< FragData const > FragDataCOP
utility::pointer::shared_ptr< SingleResidueFragData > SingleResidueFragDataOP
core::sequence::DerivedSequenceMapping simple_mapping_from_file(std::string const &filename)
Read in a SequenceMapping from a file. File format is super-simple, it just contains single lines lik...
A class specifying DOFs to be flexible or fixed.
Size const & start_seq2() const
utility::pointer::shared_ptr< Pose const > PoseCOP
utility::pointer::shared_ptr< Constraint const > ConstraintCOP
static THREAD_LOCAL basic::Tracer tr("protocols.abinitio.Templates")
utility::vector1< Pairing > PairingList
utility::pointer::shared_ptr< ConstraintSet > ConstraintSetOP
Declarations for the TorsionID class.
void set_offset(int setting)
Definition for functions used in definition of constraints.
rosetta project type declarations
static void register_options()
Template(std::string const &name, core::pose::PoseCOP, core::sequence::DerivedSequenceMapping const &mapping)
utility::vector1< Pairing > PairingsList
NamedAtomPairConstraintList cstset_
utility::pointer::shared_ptr< Obsolet_NamedAtomPairConstraint > Obsolet_NamedAtomPairConstraintOP
utility::vector1< core::scoring::constraints::Obsolet_NamedAtomPairConstraintOP > NamedAtomPairConstraintList
void reverse()
go from an A->B mapping to a B->A mapping
std::string const & name() const
core::scoring::dssp::StrandPairingSet const & strand_pairings() const
utility::pointer::shared_ptr< FragData > FragDataOP
core::pose::PoseCOP pose_
Method declarations and simple accessor definitions for the Residue class.
void get_beta_pairs(core::scoring::dssp::PairingList &) const
Size pick_large_frags(core::fragment::FragSet &frag_set, core::fragment::SingleResidueFragDataOP frag_type, core::Size ncopies=1) const
bool map_pairing(core::scoring::dssp::Pairing const &, core::scoring::dssp::Pairing &, core::sequence::DerivedSequenceMapping const &map) const
Size size1() const
size of target sequence
utility::pointer::shared_ptr< StrandPairingSet > StrandPairingSetOP
utility::pointer::shared_ptr< Frame > FrameOP
void _read_constraints(std::string const &cst_file) const
bool get_bb(Size const seqpos) const
Returns if BB torsions are movable or not for residue
void read_constraints(std::string const &cst_file)
This is quite possibly the laziest form of class naming ever. What does the name of this class tell y...
Size steal_frags(core::fragment::FrameList const &target_frames, core::fragment::FragSet &accumulator, Size ncopies=1) const
good for continuous fragments: no torsions from insertions are mapped
void map_pairings2template(core::scoring::dssp::PairingList const &in, core::scoring::dssp::PairingList &out) const
utility::pointer::shared_ptr< AtomPairConstraint const > AtomPairConstraintCOP
void dump_movemap(kinematics::MoveMap const &mm, Size nres, std::ostream &out)
void map2template(core::fragment::FrameList const &target_frames, core::fragment::FrameList &template_frames) const