Beispiel #1
0
def test_master_mix_replace_text():
    mm = MasterMix.from_text("""\
Reagent    Stock    Volume  MM?
=========  =====  ========  ===
water             to 10 µL  yes
long name    10x      1 µL  yes
""")

    assert str(mm) == """\
Reagent    Stock    Volume
──────────────────────────
water              9.00 µL
long name    10x   1.00 µL
──────────────────────────
                  10.00 µL"""

    mm.replace_text('long ', '')

    assert str(mm) == """\
Reagent  Stock    Volume
────────────────────────
water            9.00 µL
name       10x   1.00 µL
────────────────────────
                10.00 µL"""

    mm.replace_text('name', 'extra long name')

    assert str(mm) == """\
Beispiel #2
0
def test_master_mix_format_text_0_volume_reagent():
    mm = MasterMix.from_text("""\
Reagent   Stock   Volume  MM?
========  =====  =======  ===
water            to 3 µL  yes
buffer       3x     1 µL  yes
cofactor     3x     1 µL  yes
enzyme       3x     1 µL   no
""")
    mm.num_reactions = 2
    mm.extra_fraction = 0
    mm.extra_reactions = 0
    assert str(mm) == """\
Reagent   Stock   Volume       2x
─────────────────────────────────
buffer       3x  1.00 µL  2.00 µL
cofactor     3x  1.00 µL  2.00 µL
enzyme       3x  1.00 µL
─────────────────────────────────
                 3.00 µL  2.00 µL/rxn"""

    mm['buffer'].volume = 0.001, 'µL'
    assert str(mm) == """\
Reagent   Stock   Volume       2x
─────────────────────────────────
water            1.00 µL  2.00 µL
cofactor     3x  1.00 µL  2.00 µL
enzyme       3x  1.00 µL
─────────────────────────────────
                 3.00 µL  2.00 µL/rxn"""

    mm['buffer'].volume = -0.001, 'µL'
    assert str(mm) == """\
Beispiel #3
0
def test_master_mix_format_text(format):
    mm = MasterMix.from_text("""\
Reagent  Stock    Volume  MM?
=======  =====  ========  ===
water           to 10 µL  yes
buffer     10x      1 µL  yes
enzyme      5x      2 µL   no
""")

    mm.num_reactions = 1
    assert format(mm) == """\
Reagent  Stock    Volume
────────────────────────
water            7.00 µL
buffer     10x   1.00 µL
enzyme      5x   2.00 µL
────────────────────────
                10.00 µL"""

    mm.num_reactions = 2
    mm.extra_fraction = 0
    mm.extra_reactions = 0
    assert format(mm) == """\
Reagent  Stock    Volume        2x
──────────────────────────────────
water            7.00 µL  14.00 µL
buffer     10x   1.00 µL   2.00 µL
enzyme      5x   2.00 µL
──────────────────────────────────
                10.00 µL   8.00 µL/rxn"""

    mm.show_master_mix = False
    mm.show_1x = True
    mm.show_totals = True
    assert format(mm) == """\
Reagent  Stock    Volume
────────────────────────
water            7.00 µL
buffer     10x   1.00 µL
enzyme      5x   2.00 µL
────────────────────────
                10.00 µL"""

    mm.show_master_mix = True
    mm.show_1x = False
    mm.show_totals = True
    assert format(mm) == """\
Reagent  Stock        2x
────────────────────────
water           14.00 µL
buffer     10x   2.00 µL
enzyme      5x
────────────────────────
                 8.00 µL/rxn"""

    mm.show_master_mix = True
    mm.show_1x = True
    mm.show_totals = False
    assert format(mm) == """\
Beispiel #4
0
def test_master_mix_format_text_scale_header():
    mm = MasterMix.from_text("""\
Reagent  Stock    Volume  MM?
=======  =====  ========  ===
water           to 10 µL  yes
buffer     10x      1 µL  yes
enzyme      5x      2 µL   no
""")

    # Scale is an exact integer ending with zero.
    mm.num_reactions = 10
    mm.extra_percent = 0
    assert str(mm) == """\
Reagent  Stock    Volume       10x
──────────────────────────────────
water            7.00 µL  70.00 µL
buffer     10x   1.00 µL  10.00 µL
enzyme      5x   2.00 µL
──────────────────────────────────
                10.00 µL   8.00 µL/rxn"""

    # Scale is an exact integer not ending with zero.
    mm.extra_percent = 10
    assert str(mm) == """\
Reagent  Stock    Volume       11x
──────────────────────────────────
water            7.00 µL  77.00 µL
buffer     10x   1.00 µL  11.00 µL
enzyme      5x   2.00 µL
──────────────────────────────────
                10.00 µL   8.00 µL/rxn"""

    # Scale is exactly represented with one decimal point.
    mm.extra_percent = 11
    assert str(mm) == """\
Reagent  Stock    Volume     11.1x
──────────────────────────────────
water            7.00 µL  77.70 µL
buffer     10x   1.00 µL  11.10 µL
enzyme      5x   2.00 µL
──────────────────────────────────
                10.00 µL   8.00 µL/rxn"""

    # Scale is not exactly represented with one decimal point.
    mm.extra_percent = 11.1
    assert str(mm) == """\
Beispiel #5
0
def test_master_mix_format_text_no_solvent():
    mm = MasterMix.from_text("""\
Reagent   Stock   Volume  MM?
========  =====  =======  ===
buffer       3x     1 µL  yes
cofactor     3x     1 µL  yes
enzyme       3x     1 µL   no
""")

    mm.num_reactions = 1
    assert str(mm) == """\
Reagent   Stock   Volume
────────────────────────
buffer       3x  1.00 µL
cofactor     3x  1.00 µL
enzyme       3x  1.00 µL
────────────────────────
                 3.00 µL"""

    mm.num_reactions = 2
    mm.extra_fraction = 0
    mm.extra_reactions = 0
    assert str(mm) == """\
Beispiel #6
0
args = docopt.docopt(__doc__)
try:
    n = float(args['<num_rxns>'])
    templates_str = 'DNA'
except ValueError:
    templates = args['<num_rxns>'].split(',')
    templates_str = ','.join(templates)
    n = len(templates)

n_aliquots = int(ceil(n / 2))

s30 = MasterMix.from_text("""\
Reagent  Stock  Volume  MM?
=======  =====  ======  ===
water           1.2 µL  yes
A          10x    1 µL  yes
B         2.5x    4 µL  yes
C        3.33x    3 µL  yes
DNA      75 nM  0.8 µL
""")
s30.num_reactions = n
s30['DNA'].name = templates_str

protocol = Protocol()

protocol += f"""\
Thaw {plural(n_aliquots):# S30 extract aliquot/s} [1].
"""

protocol += f"""\
Setup the S30 extract reaction: