Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
FragSetLoader.cc
Go to the documentation of this file.
1 // -*- mode:c++;tab-width:2;indent-tabs-mode:t;show-trailing-whitespace:t;rm-trailing-spaces:t -*-
2 // vi: set ts=2 noet:
3 //
4 // (c) Copyright Rosetta Commons Member Institutions.
5 // (c) This file is part of the Rosetta software suite and is made available under license.
6 // (c) The Rosetta software is developed by the contributing members of the Rosetta Commons.
7 // (c) For more information, see http://www.rosettacommons.org. Questions about this can be
8 // (c) addressed to University of Washington UW TechTransfer, email: license@u.washington.edu.
9 
10 /// @file protocols/jd2/parser/DataLoader.cc
11 /// @brief Implementation of the XML parser's DataLoader base class (ctor & dstor)
12 /// @author Nobuyasu Koga ( nobuyasu@uw.edu )
13 
14 // Unit Headers
17 
18 // for fragments
19 #include <core/fragment/FragSet.hh>
23 
24 #include <basic/Tracer.hh>
25 
26 // Utility headers
27 #include <utility/tag/Tag.hh>
28 #include <utility/string_util.hh>
29 
30 // Basic headers
31 
32 // Boost Headers
33 #include <boost/foreach.hpp>
34 
36 #include <utility/vector0.hh>
37 #include <utility/vector1.hh>
38 
39 #define foreach BOOST_FOREACH
40 
41 static basic::Tracer TR( "protocols.jd2.parser.FragSetLoader" );
42 
43 namespace protocols {
44 namespace jd2 {
45 namespace parser {
46 
49 
51  core::pose::Pose const &,
52  utility::tag::TagPtr const tag,
53  moves::DataMap & data
54 ) const
55 {
56  using namespace utility::tag;
58 
61  typedef std::map< std::string, FragmentReaderOP > FragmentReaderMap;
62 
63  FragmentReaderMap frag_readers_map;
64  if ( tag->hasTag( "FRAGMENTS" ) ) {
65  foreach(TagPtr tag, tag->getTag( "FRAGMENTS" )->getTags()){
66  std::string const name ( tag->getName() ); // this name is used when fragsets are defined later.
67  runtime_assert( !name.empty() );
68  FragmentReaderOP frop = new FragmentReader( tag );
69  frag_readers_map[ name ] = frop;
70  }
71  } else {
72  TR << "No tag of FRAGMENTS" << std::endl;
73  runtime_assert( false );
74  }
75 
76  foreach( TagPtr tag, tag->getTags() ){
77  std::string const name ( tag->getName() );
78  if( name == "FRAGMENTS" ) continue;
79 
80  std::string const frag_name ( tag->getOption<std::string>( "frag_name", "" ) );
81  std::string const output ( tag->getOption<std::string>( "output", "" ) );
82  runtime_assert( !name.empty() && frag_name != "" );
83 
85  utility::vector1< std::string > fnames ( utility::string_split( frag_name, ',' ) );
86  foreach(std::string fname, fnames){
87  std::map< std::string, FragmentReaderOP >::const_iterator itr;
88  itr = frag_readers_map.find( fname );
89  if ( itr != frag_readers_map.end() ){
90  FragmentReaderOP frop ( frag_readers_map[ fname ] );
91  frop->apply( fragset );
92  }else{
93  TR << "frag_name " << fname << " does not exist." << std::endl;
94  runtime_assert( false );
95  }
96  }
97  runtime_assert( ! fragset->nr_frames() == 0 );
98  data.add( "fragsets", name, fragset );
99  // output flagments to fyile
100  if( !output.empty() ){
101  core::fragment::FragmentIO().write_data( output, *fragset );
102  }
103  }
104 
105 }
106 
109 
111 FragSetLoaderCreator::keyname() const { return "FRAGSETS"; }
112 
113 
114 } //namespace parser
115 } //namespace jd2
116 } //namespace protocols