def addAnalysisMetrics(beadMetrics, BaseCallerMetrics, res): #print 'addAnalysisMetrics' analysis_metrics_map = { 'libLive': 0, 'libKp': 0, 'libFinal': 0, 'tfLive': 0, 'tfKp': 0, 'tfFinal': 0, 'lib_pass_basecaller': 0, 'lib_pass_cafie': 0, 'empty': 0, 'bead': 0, 'live': 0, 'dud': 0, 'amb': 0, 'tf': 0, 'lib': 0, 'pinned': 0, 'ignored': 0, 'excluded': 0, 'washout': 0, 'washout_dud': 0, 'washout_ambiguous': 0, 'washout_live': 0, 'washout_test_fragment': 0, 'washout_library': 0, 'keypass_all_beads': 0, 'sysCF': 0.0, 'sysIE': 0.0, 'sysDR': 0.0, 'libFinal': 0, 'tfFinal': 0, } bead_metrics_map = { 'empty': 'Empty Wells', 'bead': 'Bead Wells', 'live': 'Live Beads', 'dud': 'Dud Beads', 'amb': 'Ambiguous Beads', 'tf': 'Test Fragment Beads', 'lib': 'Library Beads', 'pinned': 'Pinned Wells', 'ignored': 'Ignored Wells', 'excluded': 'Excluded Wells', 'washout': 'Washout Wells', 'washout_dud': 'Washout Dud', 'washout_ambiguous': 'Washout Ambiguous', 'washout_live': 'Washout Live', 'washout_test_fragment': 'Washout Test Fragment', 'washout_library': 'Washout Library', 'keypass_all_beads': 'Keypass Beads' } kwargs = { 'report': res, 'libMix': 0, 'tfMix': 0, 'sysCF': 0.0, 'sysIE': 0.0, 'sysDR': 0.0 } if BaseCallerMetrics: try: analysis_metrics_map["libFinal"] = BaseCallerMetrics["Filtering"][ "ReadDetails"]["lib"]["valid"] analysis_metrics_map["tfFinal"] = BaseCallerMetrics["Filtering"][ "ReadDetails"]["tf"]["valid"] except Exception as err: print( "During AnalysisMetrics creation, reading from BaseCaller.json: %s", err) kwargs.update(analysis_metrics_map) if beadMetrics: for dbname, key in bead_metrics_map.iteritems(): kwargs[dbname] = set_type(beadMetrics.get(key, 0)) if BaseCallerMetrics: try: kwargs['sysCF'] = 100.0 * BaseCallerMetrics['Phasing']['CF'] kwargs['sysIE'] = 100.0 * BaseCallerMetrics['Phasing']['IE'] kwargs['sysDR'] = 100.0 * BaseCallerMetrics['Phasing']['DR'] except Exception as err: print( "During AnalysisMetrics creation, reading from BaseCaller.json: %s", err) analysismetrics = res.analysismetrics or models.AnalysisMetrics() for key, value in kwargs.items(): setattr(analysismetrics, key, value) analysismetrics.save() res.analysismetrics = analysismetrics res.save()
def addAnalysisMetrics(beadMetrics, BaseCallerMetrics, res): # print 'addAnalysisMetrics' kwargs = { "report": res, "libLive": 0, "libKp": 0, "libFinal": 0, "tfLive": 0, "tfKp": 0, "tfFinal": 0, "lib_pass_basecaller": 0, "lib_pass_cafie": 0, "empty": 0, "bead": 0, "live": 0, "dud": 0, "amb": 0, "tf": 0, "lib": 0, "pinned": 0, "ignored": 0, "excluded": 0, "washout": 0, "washout_dud": 0, "washout_ambiguous": 0, "washout_live": 0, "washout_test_fragment": 0, "washout_library": 0, "keypass_all_beads": 0, "sysCF": 0.0, "sysIE": 0.0, "sysDR": 0.0, "libFinal": 0, "tfFinal": 0, "libMix": 0, "tfMix": 0, "total": 0, "adjusted_addressable": 0, "loading": 0.0, } bead_metrics_map = { "empty": "Empty Wells", "bead": "Bead Wells", "live": "Live Beads", "dud": "Dud Beads", "amb": "Ambiguous Beads", "tf": "Test Fragment Beads", "lib": "Library Beads", "pinned": "Pinned Wells", "ignored": "Ignored Wells", "excluded": "Excluded Wells", "washout": "Washout Wells", "washout_dud": "Washout Dud", "washout_ambiguous": "Washout Ambiguous", "washout_live": "Washout Live", "washout_test_fragment": "Washout Test Fragment", "washout_library": "Washout Library", "keypass_all_beads": "Keypass Beads", "total": "Total Wells", "adjusted_addressable": "Adjusted Addressable Wells", } if BaseCallerMetrics: try: kwargs["libFinal"] = BaseCallerMetrics["Filtering"]["ReadDetails"][ "lib"]["valid"] kwargs["tfFinal"] = BaseCallerMetrics["Filtering"]["ReadDetails"][ "tf"]["valid"] except Exception as err: print( "During AnalysisMetrics creation, reading from BaseCaller.json: %s", err) if beadMetrics: for dbname, key in bead_metrics_map.items(): kwargs[dbname] = set_type(beadMetrics.get(key, 0)) if not kwargs["adjusted_addressable"]: kwargs[ "adjusted_addressable"] = kwargs["total"] - kwargs["excluded"] if kwargs["adjusted_addressable"]: kwargs["loading"] = (100 * float(kwargs["bead"]) / kwargs["adjusted_addressable"]) if BaseCallerMetrics: try: kwargs["sysCF"] = 100.0 * BaseCallerMetrics["Phasing"]["CF"] kwargs["sysIE"] = 100.0 * BaseCallerMetrics["Phasing"]["IE"] kwargs["sysDR"] = 100.0 * BaseCallerMetrics["Phasing"]["DR"] except Exception as err: print( "During AnalysisMetrics creation, reading from BaseCaller.json: %s", err) analysismetrics = res.analysismetrics or models.AnalysisMetrics() for key, value in list(kwargs.items()): setattr(analysismetrics, key, value) analysismetrics.save() res.analysismetrics = analysismetrics res.save()