#!/usr/bin/python import string, os, sys from openeye.oechem import * import MySQLdb # #-------------------------------------------- def compare_2dbs(table1, table2, pat): db = MySQLdb.connect(host='newelvis.ucsf.edu',passwd='secret',db='joha') c = db.cursor() c.execute('select '+pat+' from '+table1) raw_curr_db_content = c.fetchall() table1_content = [] for tup in raw_curr_db_content: table1_content.append(tup[0]) c.execute('select '+pat+' from '+table2) raw_curr_db_content = c.fetchall() table2_content = [] for tup in raw_curr_db_content: table2_content.append(tup[0]) c.close() db.close() resf = open('comp_'+table1+'_w_'+table2+'_on_'+pat+'.txt', 'w') written = [] for code in table1_content: if code not in table2_content and code not in written: resf.write(code+' not in '+table2+' but in '+table1+'\n') written.append(code) written = [] for code in table2_content: if code not in table1_content and code not in written: resf.write(code+' not in '+table1+' but in '+table2+'\n') written.append(code) resf.close() #------------------------------------------------------------ table1, table2 = sys.argv[1], sys.argv[2] pat = sys.argv[3] compare_2dbs(table1, table2, pat)