Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
PdbIdChunkFilter.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 // This file is part of the Rosetta software suite and is made available under license.
5 // The Rosetta software is developed by the contributing members of the Rosetta Commons consortium.
6 // (C) 199x-2009 Rosetta Commons participating institutions and developers.
7 // For more information, see http://www.rosettacommons.org/.
8 
9 /// @file protocols/frag_picker/VallChunkFilter.cc
10 /// @brief defines two basic chunk filters based on pdb id
11 /// @author Dominik Gront (dgront@chem.uw.edu.pl)
12 
13 // package headers
15 
16 // mini
17 #include <utility/exit.hh>
18 #include <utility/io/izstream.hh>
19 #include <basic/Tracer.hh>
20 
21 
22 // C++ stuff
23 #include <string>
24 #include <map>
25 
27 #include <utility/vector1.hh>
28 
29 
30 namespace protocols {
31 namespace frag_picker {
32 
33 static basic::Tracer trPdbFilter("protocols.frag_picker.PdbIdChunkFilter");
34 
36 
37  utility::io::izstream data(file_name.c_str());
38  trPdbFilter.Info << "read allowed PDB ids from: " << file_name
39  << std::endl;
40  if (!data)
41  utility_exit_with_message("[ERROR] Unable to open a file fith allowed PDB ids: "
42  + file_name);
43  std::string line, pdb_id;
44  while (getline(data, line)) {
45  if (line.size() && line[0] == '#') continue;
46  std::istringstream line_stream( line );
47  line_stream >> pdb_id;
48  add_pdb_id(pdb_id);
49 
50  if (pdb_id.size() > 4 && pdb_id[4] == '_') {
51  pdb_id[4] = 'A';
52  add_pdb_id(pdb_id);
53  }
54  }
55  data.close();
56 }
57 
58 void PdbIdChunkFilter::show_pdb_ids(std::ostream& out) {
59 
60  Size cnt = 0;
61  std::map<std::string, bool>::iterator iter;
62  out << '\n';
63  for (iter = pdb_hash_.begin(); iter != pdb_hash_.end(); ++iter) {
64  out << iter->first << " ";
65  cnt++;
66  if (cnt % 12 == 0)
67  out << '\n';
68  }
69  out << std::endl;
70 }
71 
73 
74  std::string id = a_chunk->get_pdb_id() + a_chunk->get_chain_id();
75  trPdbFilter.Debug << "Testing " << id << " ... ";
76  if (pdb_hash_.find(id) != pdb_hash_.end()) {
77  trPdbFilter.Debug << "FAILED" << std::endl;
78  return false;
79  }
80  if (pdb_hash_.find(a_chunk->get_pdb_id()) != pdb_hash_.end()) {
81  trPdbFilter.Debug << "FAILED" << std::endl;
82  return false;
83  }
84  trPdbFilter.Debug << "OK" << std::endl;
85  return true;
86 }
87 
89 
90  std::string id = a_chunk->get_pdb_id() + a_chunk->get_chain_id();
91  trPdbFilter.Debug << "Testing " << id << " ... ";
92  if (pdb_hash_.find(id) != pdb_hash_.end()) {
93  trPdbFilter.Debug << "OK" << std::endl;
94  return true;
95  }
96  if (pdb_hash_.find(a_chunk->get_pdb_id()) != pdb_hash_.end()) {
97  trPdbFilter.Debug << "OK" << std::endl;
98  return true;
99  }
100  trPdbFilter.Debug << "FAILED" << std::endl;
101  return false;
102 }
103 } // frag_picker
104 } // protocols
105 
106