PEATDB/zodbtest.py
def createdb(local=None, server=None, project=None, username=None, norecs=1000):
    """Create and add some test data"""
    if local != None:
        if os.path.exists(local):
            for i in ['.lock','.index','']:
                try:
                    os.remove(local+i)
                except:
                    pass
        DB = PDatabase(local=local)
    elif server!=None:
        DB = PDatabase(server=server, username=username,
                    password='123', project=project)

    import string
    import DNAtool.mutation as mutation
    
    choices = ['a','b','c','d']
    DB.addField('choice', 'text')
    DB.addField('stab', 'text')
    DB.addField('activity', 'text')
    #DB.addField('ekin', 'General')
    E = EkinProject()
    data=E.readDataset('Ekin/test.Ekindat')
    E.insertDataset(data['data'], 'test', fit=data['fit'])
    print 'creating dummy data..'
    j=0
    count=0
    for i in range(norecs):
        if j>3: j=0
        c=''
        for k in range(10):
            c += random.choice(string.letters)
        DB.add(c)
        DB.data[c].choice = choices[j]
        DB.data[c].DNASeq = simulate_sequence(300)
        AAseqs3,AAseqs1 = mutation.translate(DB.data[c].DNASeq)
        DB.addProtseq(c, AAseqs3[1][5:80], 1)
        DB.data[c].stab = str(round(random.normalvariate(1,2),3))
        DB.data[c].activity = str(round(random.normalvariate(30,4),3))
        #DB.data[c].ekin = E
        j+=1
        count+=1
        if count>3000:
            print 'saving..'
            DB.commit()
            DB.db.cacheMinimize()
            count=0

    DB.commit()
    return DB
Create and add some test data
Create and add some test data
Create and add some test data
def createdb(local=None, server=None, project=None, username=None, norecs=1000):
    if local != None:
        if os.path.exists(local):
            for i in ['.lock','.index','']:
                try:
                    os.remove(local+i)
                except:
                    pass
        DB = PDatabase(local=local)
    elif server!=None:
        DB = PDatabase(server=server, username=username,
                    password='123', project=project)
    import string
    import DNAtool.mutation as mutation
    choices = ['a','b','c','d']
    DB.addField('choice', 'text')
    DB.addField('stab', 'text')
    DB.addField('activity', 'text')
    E = EkinProject()
    data=E.readDataset('Ekin/test.Ekindat')
    E.insertDataset(data['data'], 'test', fit=data['fit'])
    print 'creating dummy data..'
    j=0
    count=0
    for i in range(norecs):
        if j>3: j=0
        c=''
        for k in range(10):
            c += random.choice(string.letters)
        DB.add(c)
        DB.data[c].choice = choices[j]
        DB.data[c].DNASeq = simulate_sequence(300)
        AAseqs3,AAseqs1 = mutation.translate(DB.data[c].DNASeq)
        DB.addProtseq(c, AAseqs3[1][5:80], 1)
        DB.data[c].stab = str(round(random.normalvariate(1,2),3))
        DB.data[c].activity = str(round(random.normalvariate(30,4),3))
        j+=1
        count+=1
        if count>3000:
            print 'saving..'
            DB.commit()
            DB.db.cacheMinimize()
            count=0
    DB.commit()
    return DB
def createdb ( local = None , server = None , project = None , username = None , norecs = 1000 ) : if local != None : if os . path . exists ( local ) : for i in [ '.lock' , '.index' , '' ] : try : os . remove ( local + i ) except : pass DB = PDatabase ( local = local ) elif server != None : DB = PDatabase ( server = server , username = username , password = '123' , project = project ) import string import DNAtool . mutation as mutation choices = [ 'a' , 'b' , 'c' , 'd' ] DB . addField ( 'choice' , 'text' ) DB . addField ( 'stab' , 'text' ) DB . addField ( 'activity' , 'text' ) E = EkinProject ( ) data = E . readDataset ( 'Ekin/test.Ekindat' ) E . insertDataset ( data [ 'data' ] , 'test' , fit = data [ 'fit' ] ) print 'creating dummy data..' j = 0 count = 0 for i in range ( norecs ) : if j > 3 : j = 0 c = '' for k in range ( 10 ) : c += random . choice ( string . letters ) DB . add ( c ) DB . data [ c ] . choice = choices [ j ] DB . data [ c ] . DNASeq = simulate_sequence ( 300 ) AAseqs3 , AAseqs1 = mutation . translate ( DB . data [ c ] . DNASeq ) DB . addProtseq ( c , AAseqs3 [ 1 ] [ 5 : 80 ] , 1 ) DB . data [ c ] . stab = str ( round ( random . normalvariate ( 1 , 2 ) , 3 ) ) DB . data [ c ] . activity = str ( round ( random . normalvariate ( 30 , 4 ) , 3 ) ) j += 1 count += 1 if count > 3000 : print 'saving..' DB . commit ( ) DB . db . cacheMinimize ( ) count = 0 DB . commit ( ) return DB
Create and add some test data
Create and add some test data
"""Create and add some test data""" #DB.addField('ekin', 'General') #DB.data[c].ekin = E
local
server
project
username
norecs