Beispiel #1
0
def add_qlp_plate_record(qlplate, qlbfile):
    """
    Create a QLBPlate object based off a new QLBFile.  Adds to
    the current SQLAlchemy Session object, but does not commit (will
    rollback, however, if there is a problem)
    """
    valid_plate = True
    plate = None
    
    try:
        plate = QLBPlate()
        set_qlp_plate_record_attrs(plate, qlplate)
        plate.file = qlbfile
        Session.add(plate)
    except Exception, e:
        print e
        Session.rollback()
        valid_plate = False
Beispiel #2
0
def plate_events_for_range(start, end):
    plate_query = QLBPlate.filter_by_host_datetime(Session.query(QLBPlate,
                                                                 func.sum(QLBWell.event_count).label('total_count')).
                                                           join(QLBWell).\
                                                           join(QLBPlate.plate).\
                                                           join(Plate.box2).\
                                                           filter(and_(QLBPlate.plate_id != None,
                                                                       QLBWell.file_id != None)),
                                                   start, end).group_by(QLBWell.plate_id)
    return plate_query.all()
Beispiel #3
0
def time_events(start, end):
    plate_query = QLBPlate.filter_by_host_datetime(Session.query(QLBPlate,
                                                                 func.sum(QLBWell.event_count).label('total_count')).
                                                           join(QLBWell).\
                                                           join(QLBPlate.plate).\
                                                           join(Plate.box2).\
                                                           filter(and_(QLBPlate.plate_id != None,
                                                                       QLBWell.file_id != None)),
                                                    start, end)
    
    if wowo('contractor'):
        plate_query = plate_query.filter(Box2.prod_query())
    return sum([total_count or 0 for plate, total_count in plate_query.all()])
Beispiel #4
0
def plate_runtimes_for_operator_range(start, end):
    plate_query = QLBPlate.filter_by_host_datetime(Session.query(QLBPlate,
                                                                 func.count(QLBWell).label('wells'),
                                                                 func.sum(func.if_(QLBWell.event_count >= 1000, 1, 0)).label('data_wells'),
                                                                 func.sum(QLBWell.event_count).label('data_well_events')).
                                                           join(QLBWell).\
                                                           join(QLBPlate.plate).\
                                                           join(Plate.box2).\
                                                           filter(and_(QLBPlate.plate_id != None,
                                                                       QLBWell.file_id != None)),
                                                   start, end).group_by(QLBWell.plate_id).options(joinedload_all('plate.box2', innerjoin=True),
                                                                                                  joinedload_all('plate.operator'))
    if wowo('contractor'):
        plate_query = plate_query.filter(Box2.prod_query())
    return plate_query.all()
Beispiel #5
0
def plate_runtimes_for_box_range(start, end):
    plate_query = QLBPlate.filter_by_host_datetime(Session.query(QLBPlate,
                                                                 func.min(QLBWell.host_datetime).label('start_time'),
                                                                 func.max(QLBWell.host_datetime).label('end_time')).
                                                           join(QLBWell).\
                                                           join(QLBPlate.plate).\
                                                           join(Plate.box2).\
                                                           filter(and_(QLBPlate.plate_id != None,
                                                                       QLBWell.file_id != None)),
                                                   start, end).group_by(QLBWell.plate_id).options(joinedload_all('plate.box2', innerjoin=True),
                                                                                                  joinedload_all('plate.operator'))
    if wowo('contractor'):
        plate_query = plate_query.filter(Box2.prod_query())
    runtimes = plate_query.all()
    # TODO: engineer quick fix for this
    return [runtime for runtime in runtimes if runtime.start_time and runtime.end_time]