<commit_before># -*- coding: utf-8 -*-
"""
Created on Mon Jun 16 11:10:09 2014

@author: Andrew
"""
import sqlalchemy as sqla
from PyQt4 import QtGui
from multiprocessing import Pool
import numpy as np
import csv
import cPickle as pickle
from scipy import signal

class SQLConnection(object):
    '''
    Connection to the SQL database where all the afm results/file info/file
    locations are stored.
    '''
    def __init__(self):
        try:
            #ENTER DATABASE INFO HERE
            connection = 'mysql+mysqldb://%s:%s@%s:%s/afm_data'
            hostname = ''
            port = ''
            username = ''
            password = ''
            connection = connection % (username, password, hostname, port)
            self.engine = sqla.create_engine(connection)
            self.metadata = sqla.MetaData()
            self.filelist = sqla.Table('filelist', self.metadata,
                                       sqla.Column('id', sqla.Integer, primary_key=True),
                                       sqla.Column('date', sqla.String(6)),
                                       sqla.Column('number', sqla.Integer),
                                       sqla.Column('full_file_name', sqla.String(300)),
                                       sqla.Column('k', sqla.Float),
                                       sqla.Column('OLS', sqla.Float),
                                       sqla.Column('loading_rate', sqla.Numeric(10,3)),
                                       sqla.Column('touch_time', sqla.Numeric(10,3)),
                                       sqla.Column('approach_rate', sqla.Numeric(10,3)),
                                       sqla.Column('touch_strength', sqla.Numeric(10,3)),
                                       sqla.Column('number_of_cycles',sqla.Integer),
                                       sqla.Column('pipette_obj', sqla.String(300)),
                                       sqla.Column('cantilever_obj', sqla.String(300)),
                                       sqla.Column('buffer', sqla.String(300)),
                                       sqla.Column('analyzed', sqla.String(1)),
                                       sqla.Column('pressure',sqla.Float),
                                       sqla.Column('cell_num',sqla.Integer))
            self.dat = sqla.Table('dat', self.metadata,
                                  sqla.Column('id', sqla.Integer, primary_key=True),
                                  sqla.Column('file_id',  None, sqla.ForeignKey('filelist.id')),
                                  sqla.Column('cycle', sqla.Integer),
                                  sqla.Column('piezo_state', sqla.Integer),
                                  sqla.Column('location', sqla.String(300)))
            self.cell_data = sqla.Table('cell_data', self.metadata,
                                        sqla.Column('id', sqla.Integer, primary_key=True),
                                        sqla.Column('file_id',  None, sqla.ForeignKey('filelist.id')),
                                        sqla.Column('cycle', sqla.Integer),
                                        sqla.Column('forces', sqla.Float),
                                        sqla.Column('slope', sqla.Float),
                                        sqla.Column('zero_position', sqla.Float),
                                        sqla.Column('start_time', sqla.Float),
                                        sqla.Column('cyt_break_time', sqla.Float),
                                        sqla.Column('end_time', sqla.Float),
                                        sqla.Column('integral', sqla.Float),
                                        sqla.Column('tethered', sqla.String(3)))
            self.bead_data = sqla.Table('bead_data', self.metadata,
                                        sqla.Column('id', sqla.Integer, primary_key=True),
                                        sqla.Column('file_id',  None, sqla.ForeignKey('filelist.id')),
                                        sqla.Column('cycle', sqla.Integer),
                                        sqla.Column('forces', sqla.Float),
                                        sqla.Column('slope', sqla.Float),
                                        sqla.Column('zero_position', sqla.Float),
                                        sqla.Column('time', sqla.Float))
            self.metadata.create_all(self.engine)
            self.conn = self.engine.connect()
        except Exception as e:
            mb = QtGui.QMessageBox(parent=None)
            mb.setWindowTitle('ERR')
            mb.setText(str(e))
            mb.exec_()    

    def close(self):
        self.conn.close()
    
    def execute(self, s):
        return self.conn.execute(s)

class FeatureInfo(object):
    '''
    Class used by the _build_classification_features method of the SQLData class.
    '''<commit_msg>Update afmsqlcode.py<commit_after># -*- coding: utf-8 -*-
"""
Created on Mon Jun 16 11:10:09 2014

@author: Andrew
"""
import sqlalchemy as sqla
from PyQt4 import QtGui
from multiprocessing import Pool
import numpy as np
import csv
import cPickle as pickle
from scipy import signal

class SQLConnection(object):
    '''
    Connection to the SQL database where all the afm results/file info/file
    locations are stored.
    '''
    def __init__(self):
        try:
            #ENTER DATABASE INFO HERE
            connection = 'mysql+mysqldb://%s:%s@%s:%s/afm_data'
            hostname = ''
            port = ''
            username = ''
            password = ''
            connection = connection % (username, password, hostname, port)
            self.engine = sqla.create_engine(connection)
            self.metadata = sqla.MetaData()
            self.filelist = sqla.Table('filelist', self.metadata,
                                       sqla.Column('id', sqla.Integer, primary_key=True),
                                       sqla.Column('date', sqla.String(6)),
                                       sqla.Column('number', sqla.Integer),
                                       sqla.Column('full_file_name', sqla.String(300)),
                                       sqla.Column('k', sqla.Float),
                                       sqla.Column('OLS', sqla.Float),
                                       sqla.Column('loading_rate', sqla.Numeric(10,3)),
                                       sqla.Column('touch_time', sqla.Numeric(10,3)),
                                       sqla.Column('approach_rate', sqla.Numeric(10,3)),
                                       sqla.Column('touch_strength', sqla.Numeric(10,3)),
                                       sqla.Column('number_of_cycles',sqla.Integer),
                                       sqla.Column('pipette_obj', sqla.String(300)),
                                       sqla.Column('cantilever_obj', sqla.String(300)),
                                       sqla.Column('buffer', sqla.String(300)),
                                       sqla.Column('analyzed', sqla.String(1)),
                                       sqla.Column('pressure',sqla.Float),
                                       sqla.Column('cell_num',sqla.Integer))
            self.dat = sqla.Table('dat', self.metadata,
                                  sqla.Column('id', sqla.Integer, primary_key=True),
                                  sqla.Column('file_id',  None, sqla.ForeignKey('filelist.id')),
                                  sqla.Column('cycle', sqla.Integer),
                                  sqla.Column('piezo_state', sqla.Integer),
                                  sqla.Column('location', sqla.String(300)))
            self.cell_data = sqla.Table('cell_data', self.metadata,
                                        sqla.Column('id', sqla.Integer, primary_key=True),
                                        sqla.Column('file_id',  None, sqla.ForeignKey('filelist.id')),
                                        sqla.Column('cycle', sqla.Integer),
                                        sqla.Column('forces', sqla.Float),
                                        sqla.Column('slope', sqla.Float),
                                        sqla.Column('zero_position', sqla.Float),
                                        sqla.Column('start_time', sqla.Float),
                                        sqla.Column('cyt_break_time', sqla.Float),
                                        sqla.Column('end_time', sqla.Float),
                                        sqla.Column('integral', sqla.Float),
                                        sqla.Column('tethered', sqla.String(3)))
            self.metadata.create_all(self.engine)
            self.conn = self.engine.connect()
        except Exception as e:
            mb = QtGui.QMessageBox(parent=None)
            mb.setWindowTitle('ERR')
            mb.setText(str(e))
            mb.exec_()    

    def close(self):
        self.conn.close()
    
    def execute(self, s):
        return self.conn.execute(s)

class FeatureInfo(object):
    '''
    Class used by the _build_classification_features method of the SQLData class.
    '''
{'fraction_non_alphanumeric': 0.11231764834923769, 'fraction_numerical': 0.009652297905012614, 'mean_word_length': 1.2120329936923824, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 73, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2069440', 'n_tokens_mistral': 2329, 'n_tokens_neox': 2209, 'n_words': 392}