Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
mol_util.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 src/core/chemical/sdf/mol_util.cc
11 /// @author Sam DeLuca
12 
14 #include <utility/vector1.hh>
15 #include <utility/string_util.hh>
16 #include <map>
17 #include <set>
18 #include <core/types.hh>
19 
20 namespace core {
21 namespace chemical {
22 namespace sdf {
23 
25 {
26  bondType = type;
27  if(index1 <= index2)
28  {
29  lower=index1;
30  upper=index2;
31  }
32  else
33  {
34  lower=index2;
35  upper=index1;
36  }
37 }
38 
40 {
41  return (this->lower < other.lower) || (this->upper < other.upper);
42 }
43 
45 {
46  return (this->lower == other.lower) && (this->upper == other.upper) && (this->bondType == other.bondType);
47 }
48 
49 std::set<BondData> parse_bond_type_data(std::string raw_data)
50 {
51  std::set<BondData> bond_set;
52  if(raw_data == "")
53  {
54  return bond_set;
55  }
56  utility::vector1<std::string> tokens(utility::string_split(raw_data,'\n'));
57  if(tokens.size() == 0 )
58  {
59  return bond_set;
60  }
61  for(core::Size index = 1; index <= tokens.size();++index)
62  {
63  utility::vector1<std::string> current_token(utility::split(tokens[index]));
64  if(current_token.size() < 3)
65  {
66  continue;
67  }
68 
69  core::Size lower_id = utility::from_string(current_token[1],core::Size(0));
70  core::Size upper_id = utility::from_string(current_token[2],core::Size(0));
71  core::Size type = utility::from_string(current_token[3],core::Size(0));
72 
73  bond_set.insert(BondData(lower_id,upper_id,type));
74  }
75  return bond_set;
76 }
77 
78 std::map<core::Size,std::string> parse_atom_type_data(std::string raw_data)
79 {
80  std::map<core::Size, std::string> data_map;
81  if(raw_data == "")
82  {
83  return data_map;
84  }
85  utility::vector1<std::string> tokens(utility::string_split(raw_data,' '));
86  if(tokens.size() == 0)
87  {
88  return data_map;
89  }
90  else
91  {
92  //utility::vector1<std::string> tokens=utility::split(atom_type_data);
93  for(core::Size index = 1; index <= tokens.size();++index)
94  {
95 
96  std::string current_token = tokens[index];
97  if(current_token.size() <=1)
98  {
99  continue;
100  }
101  utility::vector1<std::string> token_split=utility::string_split(current_token,',');
102  utility::trim(token_split[1],"(");
103  utility::trim(token_split[2],")");
104  //std::cout << current_token<<std::endl;
105  core::Size atomno = atoi(token_split[1].c_str());
106  std::pair<core::Size, std::string> atom_type_point(atomno,token_split[2]);
107  data_map.insert(atom_type_point);
108  }
109 
110  }
111  return data_map;
112 }
113 
114 
115 }
116 }
117 }