def __init__(self): """ Get all needed values from the store""" store = get_store() # The length of the capillary (centimeter) self.total_length = LengthUnits.convert_unit(float(store.get('Capillary')["value"]), store.get('Capillary')["unit"], u"cm") # The window length (centimeter) self.to_window_length = LengthUnits.convert_unit(float(store.get('Towindow')["value"]), store.get('Towindow')["unit"], u"cm") # The capillary inside diameter (micrometer) #PROBLEM WITH UNICODE NON ASCII self.diameter = LengthUnits.convert_unit(float(store.get('Idiameter')["value"]), store.get('Idiameter')["unit"], u"µm") # The pressure drop across the capillary (mbar) self.pressure = PressureUnits.convert_unit(float(store.get('Pressure')["value"]), store.get('Pressure')["unit"], u"mbar") # The time the pressure is applied (second) self.duration = TimeUnits.convert_unit(float(store.get('Time')["value"]), store.get('Time')["unit"], u"s") # The buffer viscosity (cp) self.viscosity = float(store.get('Viscosity')["value"]) #molecular weight (g/mol) self.molweight = float(store.get("Molweight")["value"]) # Analyte concentration (g/L) if store.get('Concentration')["unit"] == u"mmol/L": tmpconcetration = MolConcentrationUnits.convert_unit(float(store.get('Concentration')["value"]), store.get('Concentration')["unit"], u"mol/L") self.concentration = self.molweight * tmpconcetration else: self.concentration = float(store.get('Concentration')["value"]) # The voltage applied to the capillary (volt) self.voltage = VoltUnits.convert_unit(float(store.get('Voltage')["value"]), store.get('Voltage')["unit"], u"V") # The current applied to the capillary (microampere) self.electric_current = float(store.get('Electriccurrent')["value"]) # The detection time (s) self.detection_time = TimeUnits.convert_unit(float(store.get('Detectiontime')["value"]), store.get('Detectiontime')["unit"], u"s") # The electro-osmosis time (s) self.electro_osmosis_time = TimeUnits.convert_unit(float(store.get('Electroosmosis')["value"]), store.get('Electroosmosis')["unit"], u"s")
def save_mobility_result(self): '''Compute and save the result for the mobility result ''' store = get_store() if self.electro_osmosis_time == 0: self.electro_osmosis_time = 1000000 self.capillary = Capillary(self.total_length, self.to_window_length, self.diameter, self.pressure, self.duration, self.viscosity, self.molweight, self.concentration, self.voltage, self.electric_current, self.detection_time, self.electro_osmosis_time) self.electro_osmosis_time = 0.0 try : microeof = self.micro_eof() except ZeroDivisionError: if self.voltage == 0: return 1, "The voltage cannot be null" if self.to_window_length > self.total_length: return 1, "The length to window cannot be greater than the capillary length" #saving store.put("MicroEOF", value=microeof, unit="cm²/V/s") for i in range(1, store.get('Nbtimecompound')["value"]+1): keystore = "Timecompound"+str(i) time = TimeUnits.convert_unit(float(store.get(keystore)["value"]), store.get(keystore)["unit"], u"s") if time == 0: return 1, "The time for compound " + str(i) + " cannot be null" microep = self.micro_ep(time) store.put("MicroEP"+str(i), value=microep, unit="cm²/V/s") return 0, ""
def save_mobility_result(self): """ compute and save the result for the mobility result """ store = get_store() try : microeof = self.micro_eof() except ZeroDivisionError: if self.electro_osmosis_time == 0: return 1, "The EOF Time cannot be null" else: return 1, "The voltage cannot be null" if self.to_window_length > self.total_length: return 1, "The length to window cannot be greater than the capillary length" #saving store.put("MicroEOF", value=microeof, unit="cm²/V/s") for i in range(1, store.get('Nbtimecompound')["value"]+1): keystore = "Timecompound"+str(i) time = TimeUnits.convert_unit(float(store.get(keystore)["value"]), store.get(keystore)["unit"], u"s") microep = self.micro_ep(time) store.put("MicroEP"+str(i), value=microep, unit="cm²/V/s") return 0, ""
def save_injection_result(self): """ compute and save the result for the injection screen """ store = get_store() try: hydroinj = self.delivered_volume() capilaryvol = self.capillary_volume() capilaryvoltowin = self.to_window_volume() pluglen = self.injection_plug_length() plugpertotallen = ((pluglen/10)/self.total_length)*100 plugpertowinlen = ((pluglen/10)/self.to_window_length)*100 timetoonevols = self.time_to_replace_volume() timetoonevolm = TimeUnits.convert_unit(timetoonevols, u's', u'min') analyteinjng = self.analyte_injected_ng() analyteinjpmol = self.analyte_injected_pmol() injpressure = self.injection_pressure() strengh = self.field_strength() flowrate = self.flow_rate_inj() except ZeroDivisionError: if self.viscosity == 0: return 1, "The viscosity cannot be null" elif self.total_length == 0: return 1, "The capillary length cannot be null" elif self.to_window_length == 0: return 1, "The length to window cannot be null" elif self.diameter == 0: return 1, "The diameter cannot be null" elif self.pressure == 0: return 1, "The pressure cannot be null" elif self.duration == 0: return 1, "The time cannot be null" else : return 1, "The molecular weight cannot be null" if self.to_window_length > self.total_length: return 1, "The length to window cannot be greater than the capillary length" #special warning if plugpertowinlen > 100.: ret = (2, "The capillary is full") else: ret = (0, "") #floor for values if hydroinj > capilaryvol: hydroinj = capilaryvol if plugpertotallen > 100.: plugpertotallen = 100. if plugpertowinlen > 100.: plugpertowinlen = 100. #saving store.put("Hydrodynamicinjection", value=hydroinj, unit="nL") store.put("Capillaryvolume", value=capilaryvol, unit="nL") store.put("Capillaryvolumetowin", value=capilaryvoltowin, unit="nL") store.put("Injectionpluglen", value=pluglen, unit="mm") store.put("Pluglenpertotallen", value=plugpertotallen, unit="%") store.put("Pluglenperlentowin", value=plugpertowinlen, unit="%") #store.put("Timetoreplaces", value=timetoonevols, unit="s") #store.put("Timetoreplacem", value=timetoonevolm, unit="min") store.put("Injectedanalyteng", value=analyteinjng, unit="ng") store.put("Injectedanalytepmol", value=analyteinjpmol, unit="pmol") store.put("Injectionpressure", value=injpressure, unit="psi/s") store.put("Fieldstrength", value=strengh, unit="V/cm") store.put("Flowrate", value=flowrate, unit="nL/min") return ret
def flow_rate_inj(self): """Return the flow rate for the flow rate screen """ onevol = self.time_to_replace_volume() flow_rate = self.capillary_volume()/TimeUnits.convert_unit(onevol, u's', u'min') return flow_rate
def flow_rate_inj(self): '''Return the flow rate for the flow rate screen ''' flow_rate_inj_per_second = self.capillary.flow_rate_inj() return flow_rate_inj_per_second / TimeUnits.convert_unit(1, u"s", u"min")
def test_convert_hour_to_minute(self): value = TimeUnits.convert_unit(2, 'h', 'min') self.assertEqual(value, 120)
def test_convert_minute_to_second(self): value = TimeUnits.convert_unit(1.5, 'min', 's') self.assertEqual(value, 90)
def test_convert_second_to_second(self): value = TimeUnits.convert_unit(10, 's', 's') self.assertEqual(value, 10)