cgevans / mixes

BSD 3-Clause "New" or "Revised" License
0 stars 1 forks source link

support "enzyme units" #19

Open dave-doty opened 2 years ago

dave-doty commented 2 years ago

Some enzymes such as T4 DNA ligase use strange units of concentration such as "Weiss units" (https://www.thermofisher.com/document-connect/document-connect.html?url=https://assets.thermofisher.com/TFS-Assets%2FLSG%2Fmanuals%2FMAN0011987_T4_DNA_Ligase_5_Weiss_1000_Weiss_U_UG.pdf).

pint seems to support these units for concentration:

from pint import Quantity

q = Quantity('2 U/uL')
print(q)

prints 2.0 enzyme_unit / microliter

But alhambra_mixes doesn't:

mix_vol = 10
t4_ligase_2U = Component('T4 DNA ligase 2U/uL', concentration='2 U/uL')
atp_7p5mM_ligase_mix = mix = Mix(
    actions=[
        FixedConcentration(components=[atp_stock], fixed_concentration="7.5 mM"),
        FixedConcentration(components=[t4_ligase_2U], fixed_concentration=f"1 U/uL"),
    ],
    name=f'lig; atp 7.5mM',
    test_tube_name='lig; atp 7.5mM',
    fixed_total_volume=f"{mix_vol} uL",
    min_volume="1 uL",
)

which generates this error:

ValueError: 2 U/uL is not a valid quantity here (should be molarity).

cgevans commented 2 years ago

This may be a tricky issue. Units like Weiss units seem to not be strictly concentrations, but instead are based on enzyme activity. They're not equivalent or easily convertible to molarity..

This distinction doesn't necessarily matter for much of the mixes code, so long as the different units don't touch: eg, you wouldn't be able to specify a FixedConcentration(t4_ligase, "10 mM"). But at the moment, the code checks to ensure that concentrations are molarities. These checks could be removed, and mixes should work. This would be a good idea in general: it might also give a way to specify even more vague things, like N×.

Where this runs into problems is that the code for recursively getting the concentrations of each component, and the code for references, both do assume molarity, and don't keep unit information for each component. They could be changed to do so, but this might slow them down quite a bit.

dave-doty commented 2 years ago

They're not equivalent or easily convertible to molarity.

I assume they are actually equivalent to some sort of Molarity, but it is not easy to find any source that will state what it is. If even pint doesn't do it, then maybe this is quite difficult to do.