Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
FragmentIO.hh
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 // :noTabs=false:tabSize=4:indentSize=4:
4 //
5 // (c) Copyright Rosetta Commons Member Institutions.
6 // (c) This file is part of the Rosetta software suite and is made available under license.
7 // (c) The Rosetta software is developed by the contributing members of the Rosetta Commons.
8 // (c) For more information, see http://www.rosettacommons.org. Questions about this can be
9 // (c) addressed to University of Washington UW TechTransfer, email: license@u.washington.edu.
10 
11 /// @brief some utilities for fragments
12 /// @author Oliver Lange (olange@u.washington.edu)
13 /// @author Christopher Miles (cmiles@uw.edu)
14 
15 #ifndef INCLUDED_core_fragment_FragmentIO_HH
16 #define INCLUDED_core_fragment_FragmentIO_HH
17 
18 // Project Headers
19 #include <core/types.hh>
24 
25 // Utility headers
26 #include <utility/vector1.fwd.hh>
27 
28 // C/C++
29 // AUTO-REMOVED #include <iostream>
30 #include <map>
31 
32 //Auto Headers
33 namespace core {
34 namespace fragment {
35 
36 class FragFactory {
37  typedef std::map< std::string, SingleResidueFragDataOP > SRFD_Types;
38  typedef std::map< std::string, FrameOP > FrameTypes;
39 
40  public:
41  FragFactory(void);
42 
43  void add_frag_type(std::string const& type_name,
45 
46  void add_frame_type( std::string const& type_name, FrameOP new_frag );
47 
48  FrameOP frame( std::string const& frame_name ) const;
49  SingleResidueFragDataOP frag_type( std::string const& frag_name ) const;
50 
51 private:
54 }; // class FragFactory
55 
56 
57 class FragmentIO {
58  typedef std::map< std::string, FragSetOP > FragFileCache;
59 
60  public:
61  FragmentIO() : top_( 0 ), ncopies_( 1 ), bAnnotate_( true ) {};
62  FragmentIO( Size top, Size ncopies = 1, bool bAnnotate = true ) :
63  top_( top ),
64  ncopies_( ncopies ),
65  bAnnotate_( bAnnotate )
66  {};
67 
68  /// @brief read a FragSet... note that this function caches the fragment set.
69  /// i.e., if you read the same set from multiple positions in the code you get
70  /// the same set. if you read a new file ... we'll check the cache for stale
71  /// references and delete them...
73 
74  void read_data( std::string const& filename, FrameList& );
75 
76  void read_data( std::istream& data, FrameList& );
77 
78  void write_data( std::string const& file, FragSet const& frags );
79 
81 
82  /// @brief Updates the number of distinct fragments to keep
83  void set_top_frag_num( Size setting ) {
84  top_ = setting;
85  }
86 
87  /// @brief Updates the number of copies of each fragment to keep (default 1)
88  void set_ncopies( Size setting ) {
89  ncopies_ = setting;
90  }
91 
92  /// @brief Toggles between reading annotated (true) and non-annotated (false)
93  // fragment files
94  void set_read_annotation( bool setting = true ) {
95  bAnnotate_ = setting;
96  }
97 
98  /// @brief remove all FragSets that are not referenced outside the cache.
99  void clean_frag_cache();
100 
101 private:
102  void read_next_frames(std::istream& data,
103  std::string& next_line,
104  FrameList &next_frames);
105 
106  void read_frag_data(std::istream& data,
107  std::string& next_line,
108  FrameList &next_frames );
109 
112 
113  // Number of distinct fragments to keep
115 
116  // Number of times each of the <top_> distinct fragments is included in the
117  // result. At the conclusion of file I/O, there will be an equal number of
118  // distinct fragments. The total size of the list is <top_> * <copies_>.
120 
121  // Toggles between reading fragment files in annotated format (includes PDB id
122  // and chain) and non-annotated format
124 };
125 
126 } // fragment
127 } // core
128 
129 #endif