Ejemplo n.º 1
0
def neutralize_get_rules():
	conn=mysql.connect2server('', 'webuser','purchasable')
	cursor = conn.cursor ()
	command = "SELECT smirks, type, pka, comment, id FROM purchasable.definition_neutralize_compounds order by id"
	print (command)
	cursor.execute(command)
	rows = cursor.fetchall ()

	rules = []
	for row in rows:
		rules.append([[row[0]],row[1],float(row[2]),row[3]])

	#OPENEYE has got a problem with writting [NH3+], ...
	rule_counter = 0
	for rule in rules:
		trans_counter = 0
		for transformation in rule[0]:
			educt, product = transformation.split('>>')
			#primary amines
			product = product.replace('[NH3+]', '[N+]([H])([H])[H]')
			#secundary amines
			product = product.replace('[NH2+]', '[N+]([H])([H])')
			#tertary amines
			product = product.replace('[NH+]', '[N+]([H])')
			product = product.replace('[nH+]', '[n+]([H])')
			product = product.replace('[nH]', '[n]([H])')
			reaction = educt + '>>' + product
			#print reaction
			rules[rule_counter][0][trans_counter] = reaction
			trans_counter = trans_counter + 1
		rule_counter = rule_counter + 1
	return rules
Ejemplo n.º 2
0
def get_smartslist(table):
	conn=mysql.connect2server('', 'webuser', 'purchasable')  			  
	cursor = conn.cursor ()
	rule = []
	command = 'select smarts_string, name from purchasable.' + table + ' order by name'
	print (command)
	cursor.execute(command)	
	rules = cursor.fetchall()
	for i in rules:
		smarts = i[0]
		name = i[1]
		name = name.replace(' ', '_')
		name = name.replace('-', '_')
		name = name.replace('/', '_')
		name = name.replace(',', '_')
		name = name.replace('=', '_')
		rule.append([smarts,name])
	return rule
Ejemplo n.º 3
0
    if username == 'webuser' or password == '':
        print('need username and password to load compounds')
        failed = True
    if not project:
        print('need project to upload compounds')
        failed = True
    if not initial:
        print('need initial to upload compounds')
        failed = True

    if failed:
        sys.exit()

#check db

conn = mysql.connect2server(password, username, 'purchasable')
cursor = conn.cursor()

if load:
    #check project
    command = 'select unique_compounds, supplier_info_table, supplier_table from projects where project = "' + project + '"'
    #print (command)
    cursor.execute(command)
    results = cursor.fetchall()
    if len(results) == 0:
        print('project not valid')
        conn.close()
        sys.exit(1)
conn.close()

path_cpd_upload = path.replace(