def insert_into_db(self, **args): # create instance of database db = RemoteDB() # add process to db db.add_updated_process(args['r'], args['s'], args['p'], args['m'], args['ma'], self.current_o_pro_pk) # Indicate that the process was inserted successfully. print "good update"
def populate_kdb(self): conn = self.connect_db(db=backup_db_name) conn.execute( '''SELECT pro_id, reactant_id, saddle_id, product_id FROM Process''' ) process_list = conn.fetchall() conn.close() db = RemoteDB() params = db.get_params() if len(process_list) == 0: print "No items in database to update." return print "Updating", db_name, "database." for process in process_list: reactant = db.get_atoms(process[1], db=backup_db_name) saddle = db.get_atoms(process[2], db=backup_db_name) product = db.get_atoms(process[3], db=backup_db_name) mode = db.get_mode(process[1], db=backup_db_name) self.current_o_pro_pk = process[0] self.insert(reactant, saddle, product, mode=mode, nf=params['nf'], dc=params['dc'], mac=params['mac'])
def populate_kdb(self): conn = self.connect_db(db=backup_db_name) conn.execute('''SELECT pro_id, reactant_id, saddle_id, product_id FROM Process''') process_list = conn.fetchall() conn.close() db = RemoteDB() params = db.get_params() if len(process_list) == 0: print "No items in database to update." return print "Updating", db_name, "database." for process in process_list: reactant = db.get_atoms(process[1], db=backup_db_name) saddle = db.get_atoms(process[2], db=backup_db_name) product = db.get_atoms(process[3], db=backup_db_name) mode = db.get_mode(process[1], db=backup_db_name) self.current_o_pro_pk = process[0] self.insert(reactant, saddle, product, mode=mode, nf=params['nf'], dc=params['dc'], mac=params['mac'])
def insert_into_db(self, **args): #create database instance db = RemoteDB() # test if process is already in database name = db.get_name(args['s'].get_chemical_symbols()) saddle_list = db.get_saddles(name) for db_saddle in saddle_list: if len(args['s']) != len(db_saddle[0]): continue if self.getMappings(args['s'], db_saddle[0], args['nf'], args['dc']) is not None: #print "SQL duplicate of", name, "with id:", db_saddle[1] return "SQL duplicate of " + name + " with id: " + str( db_saddle[1]) # add process to db try: db.add_process(args['or'], args['os'], args['op'], args['om'], args['r'], args['s'], args['p'], args['m'], args['ma'], self.email, self.password) except TypeError: print "Account info in user_config.py is not valid. Try running remote_config.py to set up account" return # Indicate that the process was inserted successfully. #print "good" return "good"
def insert_into_db(self, **args): #create database instance db = RemoteDB() # test if process is already in database name = db.get_name(args['s'].get_chemical_symbols()) saddle_list = db.get_saddles(name) for db_saddle in saddle_list: if len(args['s']) != len(db_saddle[0]): continue if self.getMappings(args['s'], db_saddle[0], args['nf'], args['dc']) is not None: print "SQL duplicate of", name, "with id:", db_saddle[1] return "SQL duplicate of " + name + " with id: " + str(db_saddle[1]) # add process to db try: db.add_process(args['or'], args['os'], args['op'], args['om'], args['r'], args['s'], args['p'], args['m'], args['ma'], self.email, self.password) except TypeError: print "Account info in user_config.py is not valid. Try running remote_config.py to set up account" return # Indicate that the process was inserted successfully. print "good" return "good"
def query_db(self, **args): db = RemoteDB() name = db.get_name(args['reactant'].get_chemical_symbols()) entries = db.get_process(name) return entries, name
# overloads KdbQuery.query_db() def query_db(self, **args): db = RemoteDB() name = db.get_name(args['reactant'].get_chemical_symbols()) entries = db.get_process(name) return entries, name def output_query(self, outpurdir, numMatches, suggestion, sugproduct, modeTemp=None): self.return_dict[numMatches] = [suggestion, sugproduct] if modeTemp is not None: self.return_dict[numMatches].append(modeTemp) if __name__ == "__main__": # Parse command line options. parser = OptionParser(usage = "%prog [options] reactant.con") parser.add_option("--nodupes", dest = "nodupes", action="store_true", help = "detect and remove duplicate suggestions (can be expensive)") options, args = parser.parse_args() # Make sure we get the reactant file name. if len(args) < 1: parser.print_help() sys.exit() # Load the reactant con file. reactant = read_any(args[0]) db = RemoteDB() params = db.get_params() query_sub_class = RemoteQuery() query_sub_class.query(reactant, "./kdbmatches_remote", dc=params['dc'], nf=params['nf'], nodupes=options.nodupes, kdbname=db_name)
default=None) options, args = parser.parse_args() # Make sure we get the reactant, saddle, product, and mode files. if len(args) < 3: parser.print_help() sys.exit() # Load the reactant, saddle, product, and mode files. reactant = read_any(args[0]) saddle = read_any(args[1]) product = read_any(args[2]) mode = None if options.mode is not None: mode = insert_sub_class.load_mode(options.mode) # load previous params db = RemoteDB() params = db.get_params() nf = params['nf'] dc = params['dc'] mac = params['mac'] insert_sub_class.insert(reactant, saddle, product, mode, nf=nf, dc=dc, mac=mac)