Пример #1
0
def main():
    global output_file
    global db_file
    global db
    
    #Connect to our sqlite database. 
    if os.path.isfile(db_file):
        conn = sqlite3.connect(db_file)
        conn.row_factory = sqlite3.Row #Allows us to access rows by column name
        db = conn.cursor()
    else:
        print 'Database file not found: '+db_file
        exit()
    
    f = file(output_file, 'w')
    #f.write("eto_molecule_placements = [\n")
    #Make a table of the best score in each category:
    for each_num_mol in range(0,19): #0 to 18
        #db.execute('SELECT * FROM surf_configuration WHERE num_mol = ? ORDER BY score DESC LIMIT 1', (each_num_mol,))
        db.execute('''
            SELECT * FROM surf_configuration
            WHERE num_mol = ?
            ORDER BY score ASC
            LIMIT 1
            ''', (each_num_mol,))
        row = db.fetchone()
        
        print row['config']

        #Uncomment if want twisted EtOH:
        twisted_rep = create_twists.create_twists( \
            convert_bin_string_to_list(row['config']) \
            )
        #Comment out below since we want 6 in horizontal
        #twisted_rep = transpose_list(twisted_rep)
        #Now go in and do string replaces for -1 entries:
        #twisted_rep = str(twisted_rep)
        #twisted_rep = twisted_rep.replace('-1', "[1,5,'z',180]")
        #f.write(twisted_rep+", \n")

        f.write(str(each_num_mol)+" EtOH: \n")
        for row in twisted_rep:
            for each_spot in row:
                if each_spot == -1:
                    each_spot = 2 #Do this for now so that ASCII output can be all aligned
                f.write(str(each_spot))
            f.write("\n")
        f.write("\n")       
        
        #Uncomment if want non-twisted EtOH:
        #f.write(str(convert_bin_string_to_list(row['config']))+", \n")

    #f.write("]\n")
    f.close()
    
    db.close()
    conn.close()
def main():
	global output_file
	global db_file
	global db
	
	#Connect to our sqlite database. 
	if os.path.isfile(db_file):
		conn = sqlite3.connect(db_file)
		conn.row_factory = sqlite3.Row #Allows us to access rows by column name
		db = conn.cursor()
	else:
		print 'Database file not found: '+db_file
		exit()
	
	f = file(output_file, 'w')
	f.write("eto_molecule_placements = [\n")
	##Make a table of the best score in each category:
	#for each_num_mol in range(0,19): #0 to 18
   	
   	db.execute('''
   		SELECT * FROM surf_configuration
   	    WHERE num_mol = 15
		AND score = 132
   		ORDER BY Random()
   		LIMIT 10
   		''')
	for row in db:
		#Uncomment if want twisted EtOH:
   		twisted_rep = create_twists.create_twists( \
   			convert_bin_string_to_list(row['config']) \
   			)
   		twisted_rep = transpose_list(twisted_rep)
   		#Now go in and do string replaces for -1 entries:
   		twisted_rep = str(twisted_rep)
   		twisted_rep = twisted_rep.replace('-1', "[1,5,'z',180]")
   		f.write(twisted_rep+", \n")
   	
		#Uncomment if want non-twisted EtOH:
		#f.write(str(convert_bin_string_to_list(row['config']))+", \n")

	f.write("]\n")
	f.close()
	
	db.close()
	conn.close()
Пример #3
0
def main():
    global output_file
    global db_file
    global db

    #Connect to our sqlite database.
    if os.path.isfile(db_file):
        conn = sqlite3.connect(db_file)
        conn.row_factory = sqlite3.Row  #Allows us to access rows by column name
        db = conn.cursor()
    else:
        print 'Database file not found: ' + db_file
        exit()

    f = file(output_file, 'w')
    f.write("eto_molecule_placements = [\n")
    ##Make a table of the best score in each category:
    #for each_num_mol in range(0,19): #0 to 18

    db.execute('''
   		SELECT * FROM surf_configuration
   	    WHERE num_mol = 15
		AND score = 132
   		ORDER BY Random()
   		LIMIT 10
   		''')
    for row in db:
        #Uncomment if want twisted EtOH:
        twisted_rep = create_twists.create_twists( \
         convert_bin_string_to_list(row['config']) \
         )
        twisted_rep = transpose_list(twisted_rep)
        #Now go in and do string replaces for -1 entries:
        twisted_rep = str(twisted_rep)
        twisted_rep = twisted_rep.replace('-1', "[1,5,'z',180]")
        f.write(twisted_rep + ", \n")

    #Uncomment if want non-twisted EtOH:
    #f.write(str(convert_bin_string_to_list(row['config']))+", \n")

    f.write("]\n")
    f.close()

    db.close()
    conn.close()