def modelStats(request): user = request.authenticated_userid return { 'numModels': Models.numModels(), 'correctModels': Models.numCorrectModels(), 'user': user }
def checkForMoreJobs(task): txn = db.getTxn() problem = task['problem'] modelSums = db.ModelSummaries(task['user'], task['hub'], task['track'], problem['chrom'], problem['chromStart']).get(txn=txn, write=True) Models.checkGenerateModels(modelSums, problem, task, txn=txn) txn.commit()
def removeLabel(data): toRemove = pd.Series({ 'chrom': data['ref'], 'chromStart': data['start'], 'chromEnd': data['end'] }) txn = db.getTxn() labels = db.Labels(data['user'], data['hub'], data['track'], data['ref']) removed, after = labels.remove(toRemove, txn=txn) db.Prediction('changes').increment(txn=txn) Models.updateAllModelLabels(data, after) txn.commit() return removed.to_dict()
def updateLabel(data): label = data['label'] updateLabel = pd.Series({ 'chrom': data['ref'], 'chromStart': data['start'], 'chromEnd': data['end'], 'annotation': label }) txn = db.getTxn() labelDb = db.Labels(data['user'], data['hub'], data['track'], data['ref']) item, labels = labelDb.add(updateLabel, txn=txn) db.Prediction('changes').increment(txn=txn) Models.updateAllModelLabels(data, labels) txn.commit() return item.to_dict()
def submitPregenWithData(doPregen, user, hub, track, coverageUrl, txn=None): recs = doPregen.to_dict('records') for problem in recs: penalties = Models.getPrePenalties() job = Jobs.PregenJob(user, hub, track['track'], problem, penalties, trackUrl=coverageUrl) job.putNewJob(checkExists=False)
def addLabel(data): label = 'unknown' for i in range(100): print("#################################################") print("THIS IS THE DATA", data) for i in range(10): print("#################################################") # Duplicated because calls from updateLabel are causing freezing newLabel = pd.Series({ 'chrom': data['ref'], 'chromStart': data['start'], 'chromEnd': data['end'], 'annotation': label }) txn = db.getTxn() item, labels = db.Labels(data['user'], data['hub'], data['track'], data['ref']).add(newLabel, txn=txn) db.Prediction('changes').increment(txn=txn) Models.updateAllModelLabels(data, labels) txn.commit() return data
def stats(request): numLabeledChroms, numLabels = Labels.stats() currentJobStats = Jobs.stats() user = request.authenticated_userid return { 'numModels': Models.numModels(), 'numLabeledChroms': numLabeledChroms, 'numLabels': numLabels, 'numJobs': currentJobStats['numJobs'], 'newJobs': currentJobStats['newJobs'], 'queuedJobs': currentJobStats['queuedJobs'], 'processingJobs': currentJobStats['processingJobs'], 'doneJobs': currentJobStats['doneJobs'], 'avgTime': currentJobStats['avgTime'], 'user': user }