import sys, os sys.path.append(os.path.dirname(os.path.dirname(sys.argv[0]))) import openbabel as ob from libmymoldb import sdf, mymol, sql from libmymoldb.functions import md5 from settings import ENVS if __name__ == "__main__": savedir = 'sqls' if len(sys.argv) < 2: print "useage: python " + sys.argv[ 0] + " input.sdf [database name] [save dir]" sys.exit(1) elif len(sys.argv) < 3: db = raw_input('Choose a database: ' + ', '.join(ENVS.keys()) + ': ') elif len(sys.argv) == 4: savedir = sys.argv[3] else: db = sys.argv[2] try: sdf_file = sys.argv[1] if not os.path.exists(sdf_file): print "sdf input file not exist" sys.exit(1) if not os.path.exists(ENVS[db]['DEF_FILE']): print "def file not exist" sys.exit(1) except: print "useage: python " + sys.argv[
# Author: xiooli <xioooli[at]yahoo.com.cn> # Site: http://joolix.com # Licence: GPLv3 # Version: 100908 import sys, os sys.path.append(os.path.dirname(os.path.dirname(sys.argv[0]))) from libmymoldb import sql from settings import ENVS if len(sys.argv) < 2: print 'Useage: ' + sys.argv[0] + ' output.sql' sys.exit(1) else: dbs = [] for k, v in ENVS.items(): if v.has_key('DEF_FILE'): dbs.append(k) db = None while not db in dbs: db = raw_input('Please choose db in ( %s ): ' %', '.join(dbs)) if not db in dbs: print 'Error, db name not valid!' try: f = open(sys.argv[1], 'w') sql_obj = sql(ENVS[db]) for v in sql_obj.gen_sql_head().values(): f.write(v + '\n') f.close() print '%s successfully generated! Now you can execute the generated sql file to create a new database.' %sys.argv[1] except Exception, e:
'''parse the pubchem sdf file and translate it into sql file according to the def file''' import sys, os sys.path.append(os.path.dirname(os.path.dirname(sys.argv[0]))) import openbabel as ob from libmymoldb import sdf, mymol, sql from libmymoldb.functions import md5 from settings import ENVS if __name__ == "__main__": savedir = 'sqls' if len(sys.argv) < 2: print "useage: python " + sys.argv[0] + " input.sdf [database name] [save dir]" sys.exit(1) elif len(sys.argv) < 3: db = raw_input('Choose a database: ' + ', '.join(ENVS.keys()) + ': ') elif len(sys.argv) == 4: savedir = sys.argv[3] else: db = sys.argv[2] try: sdf_file = sys.argv[1] if not os.path.exists(sdf_file): print "sdf input file not exist" sys.exit(1) if not os.path.exists(ENVS[db]['DEF_FILE']): print "def file not exist" sys.exit(1) except: print "useage: python " + sys.argv[0] + " input.sdf [database name] [save dir]"
# Author: xiooli <xioooli[at]yahoo.com.cn> # Site: http://joolix.com # Licence: GPLv3 # Version: 100908 import sys, os sys.path.append(os.path.dirname(os.path.dirname(sys.argv[0]))) from libmymoldb import sql from settings import ENVS if len(sys.argv) < 2: print 'Useage: ' + sys.argv[0] + ' output.sql' sys.exit(1) else: dbs = [] for k, v in ENVS.items(): if v.has_key('DEF_FILE'): dbs.append(k) db = None while not db in dbs: db = raw_input('Please choose db in ( %s ): ' % ', '.join(dbs)) if not db in dbs: print 'Error, db name not valid!' try: f = open(sys.argv[1], 'w') sql_obj = sql(ENVS[db]) for v in sql_obj.gen_sql_head().values(): f.write(v + '\n') f.close() print '%s successfully generated! Now you can execute the generated sql file to create a new database.' % sys.argv[ 1]