BALL  1.4.79
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
molDB.h
Go to the documentation of this file.
1 // ----------------------------------------------------
2 // $Maintainer: Marcel Schumann $
3 // $Authors: Marcel Schumann, Marc Röttig $
4 // ----------------------------------------------------
5 
6 #ifndef MOLDB_H
7 #define MOLDB_H
8 
9 #include <QtSql/QtSql>
10 #include <BALL/COMMON/exception.h>
11 #include <BALL/KERNEL/bond.h>
12 #include <BALL/KERNEL/atom.h>
13 #include <BALL/KERNEL/molecule.h>
14 #include <BALL/KERNEL/PTE.h>
15 #include <BALL/DATATYPE/string.h>
16 
17 #include <BALL/KERNEL/forEach.h>
19 #include <set>
21 
22 #if defined BALL_HAS_OPENBABEL || defined BALL_HAS_OPENEYE
23  #include <BALL/STRUCTURE/logP.h>
24  #ifdef BALL_HAS_OPENEYE
25  #include <oechem/graphmol.h>
26  #endif
27 #endif
28 
29 
30 namespace BALL
31 {
49  {
50  public:
51 
52  struct VendorInfo
53  {
58  };
59 
60  // static function for creating a new database
61  static void createNewDatabase(String& host, String& user, String& password, String& db_name, int port=0);
62 
65  int getVersion();
66 
73  MolDB(String hostname,String user, String password, String db, int port=3306);
74 
75  virtual ~MolDB();
76 
81  void getDatasetSummary(vector<String>& dataset_names, vector<Size>& no_isomers, vector<Size>& no_conformations);
82 
83  void searchMoleculesByUCK(String uck, list<LongSize>& conformation_IDs);
84 
85  Molecule* fetchMoleculeById(LongSize conformation_id);
86 
87  vector<Molecule*> fetchMoleculeById(vector<LongSize>& conformation_ids);
88 
89  LongSize storeMolecule(Molecule *mol, String* conformation_hash);
90 
92  {
93  return storeMolecule(mol,0);
94  };
95 
96  void deleteIsomer(LongSize isomer_id);
97 
98  void deleteConformation(LongSize conformation_id);
99 
100  void storeResult(Result* result, String& target_name);
101 
102  vector<Result*> fetchResults(list<String>& conformation_hashs, String target_name="");
103 
105  void searchMoleculesByLogP(const double& min_logP, const double& max_logP, list<LongSize>& conformation_IDs, const list<LongSize>* conformation_IDs_to_check, bool input_isomer_IDs=0, bool output_isomer_IDs=0);
106 
108  void searchMoleculesByMW(const double& min_MW, const double& max_MW, list<LongSize>& conformation_IDs, const list<LongSize>* conformation_IDs_to_check, bool input_isomer_IDs, bool output_isomer_IDs);
109 
111  void fetchDatasetConformationIDs(String& target_name, list<LongSize>& conformation_IDs, const list<LongSize>* conformation_IDs_to_check=0, bool input_isomer_IDs=0, bool output_isomer_IDs=0);
112 
114  void searchSimilarMoleculesByFingerprint(list<vector<bool> >& query_fingerprints, const float& minimal_similarity, const float& maximal_similarity, list<LongSize>& conformation_IDs, const list<LongSize>* conformation_IDs_to_check=0, bool input_isomer_IDs=0, bool output_isomer_IDs=0);
115 
116  #if defined BALL_HAS_OPENBABEL || defined BALL_HAS_OPENEYE
117 
118  void searchMoleculesBySmarts(const list<String>& smarts, list<LongSize>& conformation_IDs, const list<LongSize>* conformation_IDs_to_check=0, const list<Size>* no_of_matches=0, bool intersection=1, bool input_isomer_IDs=0, bool output_isomer_IDs=0);
119  #endif
120 
124  void fetchVendorInformation(Molecule* mol, list<VendorInfo>& vendor_info);
125 
128  bool hasResults();
129 
131  void disableFunctionalGroupCounting();
132 
133  void setVendorPropertyNames(String vendor_name, String vendors_compound_id_tag, bool fetch_vendorname_from_prop, String vendor_version, String url);
134 
135 
136  private:
137  MolDB(const MolDB& /*tc*/){};
138 
139  static const Size VERSION;
140  QSqlDatabase database_;
141  String dbtype_;
142  String hostname_;
143  String user_;
144  String password_;
145  String db_name_;
146  bool fg_counting_disabled_;
147 
148  bool save_vendor_information_;
149  bool fetch_vendorname_from_prop_;
150  String property_vendorname_;
151  String vendorname_;
152  String vendorversion_;
153  String vendorurl_;
154  String property_vendorID_;
155 
158  void searchMoleculesByIsomerColumn_(const String prop_name, const double& min_value, const double& max_value, list<LongSize>& conformation_IDs, const list<LongSize>* conformation_IDs_to_check, bool input_isomer_IDs, bool output_isomer_IDs);
159 
161  void buildProperties(Molecule* mol, LongSize ID, list<String>& property_columns);
162 
163  MolecularSimilarity* molecular_similarity_;
164 
165  #if defined BALL_HAS_OPENBABEL || defined BALL_HAS_OPENEYE
166  LogP logP_;
167  #endif
168 
169  void bitvectorToBytearray_(const vector<bool>& bitvector, QByteArray& bytearray);
170 
171  void bytearrayToBitvector_(const QByteArray& bytearray, vector<bool>& bitvector);
172 
173  public:
178  static void buildTopology(Molecule& mol, QByteArray &data);
179 
184  static void getTopology(Molecule& mol, QDataStream &ds);
185 
190  static void buildCoordinates(Molecule& mol, QByteArray &data);
191 
196  static void getCoordinates(Molecule& mol, QDataStream &ds);
197 
202  static void buildCharges(Molecule& mol, QByteArray &data);
203 
208  static void getCharges(Molecule& mol, QDataStream &ds);
209  };
210 }
211 
212 #endif /* MOLDB_H */
String vendors_compound_ID
Definition: molDB.h:56
BALL_ULONG64_TYPE LongSize
String database_compound_ID
Definition: molDB.h:54
BALL_SIZE_TYPE Size
LongSize storeMolecule(Molecule *mol)
Definition: molDB.h:91
#define BALL_EXPORT
Definition: COMMON/global.h:50
double molecular_weight
Definition: molDB.h:57