def test_algorithm(autoplanner, session): browser = Browser(session) sample_composition = nx.DiGraph() edges = [ ("DTBA_backboneA_splitAMP", "pyMOD-URA-URA3.A.1-pGPD-yeVenus-tCYC1"), ("T1MC_NatMX-Cassette_MCT2 (JV)", "pyMOD-URA-URA3.A.1-pGPD-yeVenus-tCYC1"), ( "BBUT_URA3.A.0_homology1_UTP1 (from genome)", "pyMOD-URA-URA3.A.1-pGPD-yeVenus-tCYC1", ), ("MCDT_URA3.A.1_homology2_DTBA", "pyMOD-URA-URA3.A.1-pGPD-yeVenus-tCYC1"), ("DH5alpha", "pyMOD-URA-URA3.A.1-pGPD-yeVenus-tCYC1"), ("TP-IRES-EGFP-TS", "pyMOD-URA-URA3.A.1-pGPD-yeVenus-tCYC1"), ( "BBUT_URA3.A.1_homology1_UTP1 (from_genome) (new fwd primer))", "pyMOD-URA-URA3.A.1-pGPD-yeVenus-tCYC1", ), ] for n1, n2 in edges: s1 = browser.find_by_name(n1) s2 = browser.find_by_name(n2) sample_composition.add_node(s1.id, sample=s1) sample_composition.add_node(s2.id, sample=s2) sample_composition.add_edge(s1.id, s2.id) algorithm = NetworkOptimizer(browser, sample_composition, autoplanner.template_graph) algorithm.print_sample_composition() algorithm.run(session.ObjectType.find_by_name("Plasmid Stock"))
def test_cache_where_name(session): browser = Browser(session) primers = browser.cached_where({"sample_type_id": 1}, "Sample") primer1 = primers[0] id1 = id(primer1) primer2 = browser.find_by_name(primer1.name, "Sample", primary_key="id") id2 = id(primer2) assert id1 == id2
def test_get_sisters_for_run_gel(autoplan_model, session): browser = Browser(session) sample_composition = nx.DiGraph() edges = [ # ('DTBA_backboneA_splitAMP', 'pyMOD-URA-URA3.A.1-pGPD-yeVenus-tCYC1'), ("T1MC_NatMX-Cassette_MCT2 (JV)", "pyMOD-URA-URA3.A.1-pGPD-yeVenus-tCYC1"), ( "BBUT_URA3.A.0_homology1_UTP1 (from genome)", "pyMOD-URA-URA3.A.1-pGPD-yeVenus-tCYC1", ), ("DH5alpha", "pyMOD-URA-URA3.A.1-pGPD-yeVenus-tCYC1"), ("TP-IRES-EGFP-TS", "pyMOD-URA-URA3.A.1-pGPD-yeVenus-tCYC1") # ('MCDT_URA3.A.1_homology2_DTBA', 'pyMOD-URA-URA3.A.1-pGPD-yeVenus-tCYC1'), # ('BBUT_URA3.A.1_homology1_UTP1 (from_genome) (new fwd primer))', 'pyMOD-URA-URA3.A.1-pGPD-yeVenus-tCYC1') ] for n1, n2 in edges: s1 = browser.find_by_name(n1) s2 = browser.find_by_name(n2) sample_composition.add_node(s1.id, sample=s1) sample_composition.add_node(s2.id, sample=s2) sample_composition.add_edge(s1.id, s2.id) # s = production.Sample.find_by_name('MCDT-LEU-LEU.A.1_homology2_ampR-Split_A') # sample_composition.add_node(s.id, sample=s) # nx.draw(sample_composition) network = NetworkOptimizer(browser, sample_composition, autoplan_model.template_graph) solution = network.run( session.ObjectType.find_by_name("Plasmid Glycerol Stock")) run_gels = [] for n, ndata in solution["graph"].iter_model_data( model_class="AllowableFieldType"): aft = ndata["model"] if aft.field_type.operation_type.name == "Run Gel": if aft.field_type.role == "input": run_gels.append((n, ndata)) run_gels
sample_composition = nx.DiGraph() edges = [ ('DTBA_backboneA_splitAMP', 'pyMOD-URA-URA3.A.1-pGPD-yeVenus-tCYC1'), ('T1MC_NatMX-Cassette_MCT2 (JV)', 'pyMOD-URA-URA3.A.1-pGPD-yeVenus-tCYC1'), ('BBUT_URA3.A.0_homology1_UTP1 (from genome)', 'pyMOD-URA-URA3.A.1-pGPD-yeVenus-tCYC1'), ('DH5alpha', 'pyMOD-URA-URA3.A.1-pGPD-yeVenus-tCYC1'), ('TP-IRES-EGFP-TS', 'pyMOD-URA-URA3.A.1-pGPD-yeVenus-tCYC1' ), ('MCDT_URA3.A.1_homology2_DTBA', 'pyMOD-URA-URA3.A.1-pGPD-yeVenus-tCYC1'), # ('pyMOD-URA-URA3.A.1-pGPD-yeVenus-tCYC1', 'CEN.PK2 - MAT alpha | his-pGRR-W5-W8-RGR-W36') ('BBUT_URA3.A.1_homology1_UTP1 (from_genome) (new fwd primer))', 'pyMOD-URA-URA3.A.1-pGPD-yeVenus-tCYC1') ] for n1, n2 in edges: s1 = browser.find_by_name(n1) s2 = browser.find_by_name(n2) sample_composition.add_node(s1.id, sample=s1) sample_composition.add_node(s2.id, sample=s2) sample_composition.add_edge(s1.id, s2.id) # s = production.Sample.find_by_name('MCDT-LEU-LEU.A.1_homology2_ampR-Split_A') # sample_composition.add_node(s.id, sample=s) # nx.draw(sample_composition) alg = NetworkOptimization(browser, sample_composition, ap.template_graph) alg.set_verbose(True) # alg.update_sample_composition cost, paths, graph = alg.run(production.ObjectType.find_by_name('Plasmid Glycerol Stock'))