Beispiel #1
0
    def command(self):
        app = self.load_wsgi_app()
        storage = QLStorageSource(app.config)

        if len(self.args) < 2:
            print self.__class__.usage
            return

        for i in range(0,len(self.args)-1):
            plate_id = int(self.args[i])
            plate = dbplate_tree(plate_id)
            try:
                plate_path = storage.plate_path(plate)
            except Exception, e:
                print "Could not read plate: %s" % plate_id
                continue

            qlplate = get_plate(plate_path)
            if not qlplate:
                raise ValueError, "Could not read plate: %s" % plate_path
            else:
                print "Processing %s" % plate_path

            try:
                from qtools.lib.metrics import DEFAULT_CNV_CALC, compute_metric_foreach_qlwell
                plate_metrics = plate.metrics[0]
                compute_metric_foreach_qlwell(qlplate, plate_metrics, DEFAULT_CNV_CALC)
            except Exception, e:
                import sys, traceback
                traceback.print_exc(file=sys.stdout)
                Session.rollback()
                return
Beispiel #2
0
    def command(self):
        app = self.load_wsgi_app()

        # enforce config.ini
        if len(self.args) < 2:
            raise ValueError, self.__class__.usage
        
        plate_id = int(self.args[0])

        plate = dbplate_tree(plate_id)
        if not plate:
            raise ValueError, "Invalid plate id: %s" % plate_id
        
        storage = QLStorageSource(app.config)

        # for now, no reprocessing.
        plate_path = storage.plate_path(plate)
                                        
        qlplate = get_plate(plate_path)
        if not qlplate:
            raise ValueError, "Could not read plate: %s" % plate_path
        
        try:
            plate_metrics = plate.metrics[0]
            self.process_plate( qlplate, plate_metrics)
        except Exception, e:
            import sys, traceback
            traceback.print_exc(file=sys.stdout)
            Session.rollback()
            return
Beispiel #3
0
    def command(self):
        app = self.load_wsgi_app()

        print "Clearing NEB buffer tables..."
        # make this reversible...
        neb = Session.query(Vendor).filter_by(name='NEB').first()
        if neb:
            enzymes = neb.enzymes
            for enz in enzymes:
                Session.delete(enz)
            neb.enzymes = []

        Session.commit()

        # now go with the vendors (question: is it vendor enzyme or enzyme
        # in general subject to methylation)
        source = NEBEnzymeSource()
        if not neb:
            neb = Vendor(name="NEB", website="http://www.neb.com")
            Session.add(neb)
            Session.commit()

        try:
            for name, page_uri in source.iter_restriction_enzymes():
                print "Processing %s..." % name
                enz = Session.query(Enzyme).filter_by(name=name).first()
                if not enz:
                    enz = Enzyme(name=name)
                    Session.add(enz)
            
                details = source.enzyme_details(name, page_uri)
                if details:
                    enz.cutseq = details['sequence']
                    enz.methylation = details['methylation_sensitivity']

                    buf = Session.query(Buffer).filter_by(name=details['buffer']).first()
                    if not buf:
                        buf = Buffer(name=details['buffer'])
                        Session.add(buf)

                    ve = VendorEnzyme(enzyme=enz, vendor=neb, buffer=buf)
                    ve.unit_cost_1 = details.get('unit_cost_1', None)
                    ve.unit_cost_2 = details.get('unit_cost_2', None)
                    ve.unit_serial_1 = details.get('unit_serial_1', None)
                    ve.unit_serial_2 = details.get('unit_serial_2', None)
                    ve.vendor_serial = details.get('vendor_serial', None)
                    if ve.unit_cost_1 is not None:
                        Session.add(ve)
                # save per enzyme, interruption should be logged
                Session.commit()
        except IOError, e:
            Session.rollback()
            print "Could not communicate with NEB server"
Beispiel #4
0
    def process_plates(self, app, analysis_group, reprocess_config):
        storage = QLStorageSource(app.config)
        plates = analysis_group.plates
        for plate in plates:
            pms = [pm for pm in plate.metrics if pm.reprocess_config_id == reprocess_config.id]
            if not pms:
                print "Cannot find analysis group for plate %s" % plate.id
            else:
                pm = pms[0]
            dbplate = dbplate_tree(plate.id)

            if reprocess_config:
                data_root = app.config['qlb.reprocess_root']
                storage = QLPReprocessedFileSource(data_root, reprocess_config)
            else:
                storage = QLStorageSource(app.config)
            
            try:
                if reprocess_config:
                    plate_path = storage.full_path(analysis_group, dbplate)
                else:
                    plate_path = storage.plate_path(dbplate)
            except Exception, e:
                print "Could not read plate: %s" % plate.id
                continue
            
            qlplate = get_plate(plate_path)
            if not qlplate:
                raise ValueError, "Could not read plate: %s" % plate_path
            else:
                print "Processing %s" % plate_path
            
            try:
                self.backfill_plate(qlplate, pm)
                Session.commit()
            except Exception, e:
                print "Could not process plate %s" % dbplate.id
                import sys, traceback
                traceback.print_exc(file=sys.stdout)
                Session.rollback()
                continue