Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
MotifLibrary.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/motifs/MotifLibrary.cc
11 /// @brief Implementation of interaction motifs
12 /// @author havranek, sthyme (sthyme@gmail.com)
13 
14 // Unit Headers
16 
17 // Package Headers
21 
22 // Project Headers
23 
24 // Utility Headers
25 #include <utility/file/file_sys_util.hh>
26 #include <utility/file/FileName.hh>
27 
28 // C++ Headers
29 #include <fstream>
30 #include <iostream>
31 
32 #include <utility/vector1.hh>
33 
34 
35 namespace protocols {
36 namespace motifs {
37 
39 {}
40 
42 {}
43 
45  FileNames & motif_filenames
46 )
47 {
48  for ( FileNames::const_iterator filename( motif_filenames.begin() );
49  filename != motif_filenames.end(); ++filename ) {
51  continue;
52  }
54  add_to_library( *new_motif );
55  }
56 }
57 
59  std::istream & motif_info
60 )
61 {
62  std::string key_in;
63  while( motif_info >> key_in ) {
64  if( key_in == "SINGLE" ) {
65  SingleMotifOP new_motif = single_motif_from_stream( motif_info );
66  add_to_library( *new_motif );
67  } else {
68  std::cout << "ERROR - BAD MOTIF KEY " << key_in << "\n";
69  }
70  }
71 }
72 
74  std::istream & motif_info, core::Size
75 )
76 {
77  //std::cout << "In MotifLibrary.cc, in LigandMotifLibrary istream function" << std::endl;
78  std::string key_in;
79  while( motif_info >> key_in ) {
80  if( key_in == "SINGLE" ) {
81  //std::cout << "In MotifLibrary.cc, about to make single motif OP" << std::endl;
82 
83  SingleMotifOP new_motif = single_ligand_motif_from_stream( motif_info );
84  add_to_library( *new_motif );
85  } else {
86  //std::cout << "ERROR - BAD MOTIF KEY " << key_in << "\n";
87  }
88  }
89 }
90 
91 void
93 {
94  library_.push_back( add_me.clone() );
95 }
96 
99 {
100  return library_.size();
101 }
102 
103 void
104 MotifLibrary::add_from_file( std::string const & motif_filename )
105 {
106  // Try to open the file
107  std::ifstream motif_file;
108  motif_file.open( motif_filename.c_str() );
109  if( !motif_file ) {
110  std::cout << "ERROR: No motif file " << motif_filename << " - FAILING!\n";
111  return;
112  }
113 
114  // Attempt to read in motifs until exhausted
115  MotifLibrary new_library( motif_file );
116 
117  // Add to this library
118  for( MotifCOPs::const_iterator pmot = new_library.begin() ; pmot != new_library.end() ; ++pmot ) {
119  add_to_library( **pmot );
120  }
121 }
122 
123 std::ostream & operator <<(
124  std::ostream & os, MotifLibrary const & mlib
125 )
126 {
127  for( MotifCOPs::const_iterator pmot = mlib.begin() ; pmot != mlib.end() ; ++pmot ) {
128  os << (*pmot)->print();
129  }
130  return os;
131 }
132 
133 void
135 {
136  std::ifstream motif_file;
137  motif_file.open( motif_filename.c_str() );
138  if( !motif_file ) {
139  std::cout << "ERROR: No motif file " << motif_filename << " - FAILING!\n";
140  return;
141  }
142 
143  // Attempt to read in motifs until exhausted
144  core::Size ligand_marker = 1;
145  MotifLibrary new_library( motif_file, ligand_marker );
146 
147  // Add to this library
148  for( MotifCOPs::const_iterator pmot = new_library.begin() ; pmot != new_library.end() ; ++pmot ) {
149  add_to_library( **pmot );
150  }
151 }
152 
153 } // namespace motifs
154 } // namespace protocols