def test_reagent_get_maker_attr_3(mock_plugins): db = Database() db['x1'] = x1 = MockReagent( synthesis=Fields(['m'], {'conc': '1 nM'}), cleanups=[ Fields(['m'], {}), Fields(['m'], {}), ], ) assert x1.get_maker_attr('product_conc') == Quantity(1, 'nM') assert x1.get_maker_attr('product_conc', None) == Quantity(1, 'nM')
def test_intermediate(mock_plugins): db = Database() db['x1'] = x1 = MockMolecule( synthesis=Fields('m', {'conc': '1 nM'}), cleanups=[ Fields('m', {'conc': '2 nM'}), Fields('m', {'conc': '3 nM'}), ], ) # Access the concentration before creating the intermediates so that a # concentration value is cached. The intermediates will need to forget # this value: assert x1.conc == Quantity(3, 'nM') i1 = x1.make_intermediate(0) i2 = x1.make_intermediate(1) i3 = x1.make_intermediate(2) with pytest.raises(QueryError) as err: x1.make_intermediate(3) assert err.match("x1: intermediate 3 doesn't exist") assert err.match("intermediates:") assert err.match("0: m conc='1 nM'") assert err.match("1: m conc='2 nM'") assert err.match("2: m conc='3 nM'") # Access the concentration again after creating the intermediates, to make # sure that doing so does not somehow re-establish the cache: assert x1.conc == Quantity(3, 'nM') # Test that precursors are correct: assert i2.precursor is i1 assert i3.precursor is i2 # Test that fields are correct: assert i1.maker_args[0] == 'm' assert i1.maker_args['conc'] == '1 nM' assert i2.maker_args[0] == 'm' assert i2.maker_args['conc'] == '2 nM' assert i3.maker_args[0] == 'm' assert i3.maker_args['conc'] == '3 nM' # Test that makers are correct: assert i1.maker.product_conc == Quantity(1, 'nM') assert i2.maker.product_conc == Quantity(2, 'nM') assert i3.maker.product_conc == Quantity(3, 'nM') # Test that properties depending on fields are re-evaluated correctly. assert i1.conc == Quantity(1, 'nM') assert i2.conc == Quantity(2, 'nM') assert i3.conc == Quantity(3, 'nM')
def test_reagent_get_maker_attr_4(mock_plugins): db = Database() db['x1'] = x1 = MockReagent( synthesis=Fields(['m'], {}), cleanups=[ Fields(['m'], {}), Fields(['m'], {}), ], ) with pytest.raises(QueryError, match='product_conc'): x1.get_maker_attr('product_conc') assert x1.get_maker_attr('product_conc', None) == None
def test_reagent_maker_err_2(mock_plugins): db = Database() db['x1'] = x1 = MockReagent( # no synthesis cleanups=[ Fields(['m'], {'conc': '2 nM'}), Fields(['m'], {'conc': '3 nM'}), ], ) with pytest.raises(QueryError, match="no synthesis specified"): x1.cleanup_args with pytest.raises(QueryError, match="no synthesis specified"): x1.cleanup_makers
def test_reagent_intermediate_repr(): x1 = MockReagent(synthesis=Fields(['m'], {}), ) i1 = x1.make_intermediate(0) assert repr(x1) == "MockReagent(synthesis=Fields(['m'], {}))" assert repr( i1) == "MockReagentIntermediate(step=0, synthesis=Fields(['m'], {}))"
def test_reagent_maker_args_2(): db = Database() db['x1'] = x1 = MockReagent( synthesis=lambda: Fields(['m'], {'conc': '1 nM'}), cleanups=lambda: [ Fields(['m'], {'conc': '2 nM'}), Fields(['m'], {'conc': '3 nM'}), ], ) assert x1.synthesis_args[0] == 'm' assert x1.synthesis_args['conc'] == '1 nM' assert x1.cleanup_args[0][0] == 'm' assert x1.cleanup_args[0]['conc'] == '2 nM' assert x1.cleanup_args[1][0] == 'm' assert x1.cleanup_args[1]['conc'] == '3 nM'
def test_reagent_makers(mock_plugins): db = Database() db['x1'] = x1 = MockReagent( synthesis=Fields(['m'], {'conc': '1 nM'}), cleanups=[ Fields(['m'], {'conc': '2 nM'}), Fields(['m'], {'conc': '3 nM'}), ], ) m1 = x1.synthesis_maker m2 = x1.cleanup_makers[0] m3 = x1.cleanup_makers[1] assert isinstance(m1, MockMaker) assert m1.product_conc == Quantity(1, 'nM') assert isinstance(m2, MockMaker) assert m2.product_conc == Quantity(2, 'nM') assert isinstance(m3, MockMaker) assert m3.product_conc == Quantity(3, 'nM')
def test_f9(db, tag='f9'): assert isinstance(db[tag], NucleicAcid) assert db[tag].desc == "conc from cleanup" assert db[tag].synthesis_args == Fields(['mock'], {}) assert db[tag].cleanup_args == [Fields(['mock'], {'conc': '50nM'})] assert db[tag].conc_nM == 50
def test_f5(db, tag='f5'): assert isinstance(db[tag], NucleicAcid) assert db[tag].desc == "sequence from synthesis" assert db[tag].synthesis_args == Fields(['mock'], {'seq': 'GGTCTC'}) assert db[tag].seq == 'GGTCTC'
def test_f15(db, tag='f15'): assert isinstance(db[tag], NucleicAcid) assert db[tag].desc == "circular from synthesis" assert db[tag].synthesis_args == Fields(['mock'], {'circular': 'y'}) assert db[tag].is_circular == True
def test_f11(db, tag='f11'): assert isinstance(db[tag], NucleicAcid) assert db[tag].desc == "molecule from synthesis" assert db[tag].synthesis_args == Fields(['mock'], {'molecule': 'ssRNA'}) assert db[tag].molecule == 'RNA' assert db[tag].is_single_stranded == True