def test_emma_construct(): emma_collection = GoldenGatePartsLibrary("EMMA", fasta_file=EMMA_PATH, memoize=True) company_ingen = CommercialDnaOffer( name="InGen", pricing=PerBasepairPricing(0.14), sequence_constraints=[SequenceLengthConstraint(max_length=2400)]) company_tdi = CommercialDnaOffer( name="TDI", pricing=PerBasepairPricing(0.08), sequence_constraints=[SequenceLengthConstraint(max_length=600)]) assembly_station = DnaAssemblyStation( name='GoldenGate Assembly Station', assembly_method=GoldenGateAssemblyMethod( min_segment_length=40, max_segment_length=5000, enzyme='BsmBI', # max_fragments=8 ), supplier=[company_ingen, emma_collection, company_tdi], coarse_grain=100, fine_grain=10, logger='bar', a_star_factor='auto') record = load_record(SEQUENCE_PATH) sequence = str(record.seq) quote = assembly_station.get_quote(sequence, with_assembly_plan=True) emma_parts = [ p for p in list(quote.assembly_plan.values()) if p.source.name == 'EMMA' ] assert len(emma_parts) == 6
def test_circular_gibson(): record = dw.load_record(plasmid_path) sequence = dw.SequenceString.from_record(record) assert sequence.metadata['topology'] == "circular" assert dw.get_sequence_topology(sequence) == "circular" commercial_provider = dw.CommercialDnaOffer( name="supplier", pricing=dw.PerBasepairPricing(0.1), ) assembly_station = dw.DnaAssemblyStation( name="golden_gate", supplier=commercial_provider, assembly_method=dw.GibsonAssemblyMethod( overhang_selector=dw.TmSegmentSelector(), max_segment_length=3000 ), coarse_grain=600, fine_grain=None, cut_spread_radius=2, ) quote = assembly_station.get_quote(sequence) assert quote.accepted assert 1200 < quote.price < 1220 # ROUND TRIP: SIMULATE CLONING TO CHECK ASSEMBLY PLAN VALIDITY part_names, repo = extract_records_from_quote(quote) quote = assembly_station.get_quote(sequence) assembly = dc.GibsonAssembly(parts=part_names) simulation = assembly.simulate(repo) assert len(simulation.construct_records) == 1 simulated_record = simulation.construct_records[0] print (len(record), len(simulated_record)) assert sequences_are_circularly_equal([record, simulated_record])
def test_example_with_adapters(): oligo_com = dw.CommercialDnaOffer( name="Oligo.com", sequence_constraints=[dw.SequenceLengthConstraint(max_length=200)], pricing=dw.PerBasepairPricing(0.10), lead_time=7, ) plasmideroo = dw.CommercialDnaOffer( name="Plasmideroo", sequence_constraints=[dw.SequenceLengthConstraint(max_length=4000)], pricing=dw.PerBasepairPricing(0.20), lead_time=10, ) plasmideroo_linearization = dw.PcrLinearizationStation( name="Gibson Linearization", supplier=plasmideroo, primers_supplier=oligo_com, homology_selector=dw.TmSegmentSelector(), ) gibson_blocks_assembly_station = dw.DnaAssemblyStation( name="Gibson Assembly", assembly_method=dw.GibsonAssemblyMethod( overhang_selector=dw.FixedSizeSegmentSelector(80), min_segment_length=1000, max_segment_length=4000, duration=8, cost=16, ), supplier=plasmideroo_linearization, coarse_grain=100, fine_grain=False, a_star_factor="auto", ) gibson_station_adapter = dw.SequenceAdapter( name="Gibson Adapter", supplier=gibson_blocks_assembly_station, left_addition="TAAGACTAGTGCACATAATACGG", right_addition="ATTGTCACACTACAAACATGAC", ) goldengate_blocks_assembly_station = dw.DnaAssemblyStation( name="Golden Gate Blocks Assembly", assembly_method=dw.GoldenGateAssemblyMethod( enzyme="BsmBI", wildcard_basepair="A", min_segment_length=1000, max_segment_length=4000, duration=5, cost=6, ), supplier=plasmideroo, coarse_grain=100, fine_grain=False, a_star_factor="auto", ) golden_gate_station_adapter = dw.SequenceAdapter( name="Golden Gate Adapter", supplier=goldengate_blocks_assembly_station, left_addition="TAGG", right_addition="ACGA", ) main_source = dw.DnaSuppliersComparator( [gibson_station_adapter, golden_gate_station_adapter] ) # RESOLUTION print("\n\nSEQUENCE WITHOUT BMSBI SITES:\n") path = os.path.join(this_directory, "sequence_no_bsmbi.fa") sequence = dw.load_record(path) quote = main_source.get_quote(sequence, with_assembly_plan=True) assert quote.source == goldengate_blocks_assembly_station print(quote.assembly_step_summary()) assert 2000 < quote.price < 2020 print("\n\nSEQUENCE WITH BMSBI SITES:\n") path = os.path.join(this_directory, "sequence_bsmbi.fa") sequence = dw.load_record(path) quote = main_source.get_quote(sequence, with_assembly_plan=True) print(quote.assembly_step_summary()) assert quote.source == gibson_blocks_assembly_station assert 2050 < quote.price < 2100 # FOR COVERAGE assembly_report = quote.to_assembly_plan_report() assembly_report.write_full_report('@memory')
pricing=dw.PerBasepairPricing(0.20), ) assembly_station = dw.DnaAssemblyStation( name="Gibson Assembly Station", assembly_method=dw.GibsonAssemblyMethod( overhang_selector=dw.TmSegmentSelector(min_tm=55, max_tm=70), min_segment_length=500, max_segment_length=4000, ), supplier=[cheap_dna_offer, deluxe_dna_offer], logger="bar", coarse_grain=20, fine_grain=1, ) # 2. FIND AN ASSEMBLY PLAN AND CREATE A REPORT. sequence = dw.load_record("sequence_with_bsmbi_sites.fa") quote = assembly_station.get_quote(sequence, with_assembly_plan=True) print(quote.assembly_step_summary()) assembly_report = quote.to_assembly_plan_report() _, ax = assembly_report.plot_supply_network() ax.figure.savefig("supply_network_2_vendors.pdf", bbox_inches="tight") figure, ax = plt.subplots(1, figsize=(7, 3)) assembly_report.plot_assembly_blocks(ax=ax, parts_offset=0.1, plot_top_assembly=False, legend=True) figure.savefig("fragments_from_2_vendors.pdf", bbox_inches="tight")
enzyme="BsmBI"), supplier=[ company_ingen, emma_collection, mouse_pcr_station, company_tdi, ], coarse_grain=100, fine_grain=None, logger="bar", ) for station, color in [ (company_ingen, "#fdfdb3"), (company_oligo, "#b8b6e6"), (company_tdi, "#c8f8c4"), (mouse_pcr_station, "#eff5f5"), (emma_collection, "#f8c3c3"), ]: station.report_color = color # LOAD THE SEQUENCE AND PREPARE THE NETWORK FOR IT. HERE THE # PREPARATION WILL ONLY MAKE THE PCR STATION PRE-BLAST THE SEQUENCE record = load_record("example_sequence.gb") assembly_station.prepare_network_on_sequence(record) quote = assembly_station.get_quote(record, with_assembly_plan=True) assembly_report = quote.to_assembly_plan_report() assembly_report.write_full_report("EMMA_assembly_report") print("Success! See figure assembly_plans.png.")
fine_grain=False, a_star_factor="auto") golden_gate_station_adapter = dw.SequenceAdapter( name="Golden Gate Adapter", supplier=goldengate_blocks_assembly_station, left_addition="TAGG", right_addition="ACGA", ) main_source = dw.DnaSuppliersComparator( [gibson_station_adapter, golden_gate_station_adapter]) # RESOLUTION print("\n\nSEQUENCE WITHOUT BMSBI SITES:\n") sequence = dw.load_record("sequence_no_bsmbi.fa") quote = main_source.get_quote(sequence, with_assembly_plan=True) print(quote.assembly_step_summary()) print("\n\nSEQUENCE WITH BMSBI SITES:\n") sequence = dw.load_record("sequence_bsmbi.fa") quote = main_source.get_quote(sequence, with_assembly_plan=True) print(quote.assembly_step_summary()) # PLOT THE SUPPLY GRAPH assembly_report = quote.to_assembly_plan_report() _, ax = assembly_report.plot_supply_network() ax.figure.savefig("supply_network.pdf", bbox_inches="tight")
pricing=dw.PerBasepairPricing(0.1)) ecoli_db_path = os.path.join('..', '..', 'data', 'ecoli_blast_db', 'ecoli') pcr_station = dw.PcrExtractionStation(name="PCR station", max_overhang_length=50, homology_selector=dw.TmSegmentSelector(), primers_supplier=oligos_company, blast_database=ecoli_db_path, extra_cost=5) assembly_station = dw.DnaAssemblyStation( name="Golden Gate assembly", assembly_method=dw.GoldenGateAssemblyMethod(enzyme='BsaI'), supplier=pcr_station, coarse_grain=100, fine_grain=0, logger='bar') # LOAD THE (SITE-FREE) DESIRED SEQUENCE desired_sequence = str(dw.load_record("desired_sequence.gb").seq) # THIS LINE WILL PRE-BLAST THE SEQUENCE TO ACCELERATE COMPUTATIONS. assembly_station.prepare_network_on_sequence(desired_sequence) # FIND AN ASSEMBLY PLAN AND PRINT IT. quote = assembly_station.get_quote(desired_sequence, with_assembly_plan=True) print(quote.assembly_step_summary()) quote.compute_fragments_final_locations() report = quote.to_assembly_plan_report() report.write_full_report("report.zip") print("Done! (see report.zip)")
import os import dnaweaver as dw import json ecoli_db_path = os.path.join("..", "..", "data", "ecoli_blast_db", "ecoli") dw.PcrExtractionStation.dna_banks = {"e_coli": ecoli_db_path} dw.PartsLibrary.collections_by_id["EMMA"] = dict(library_class="golden_gate", fasta_file="emma_parts.fa") sequence = dw.load_record("sequence_with_emma_and_ecoli_parts.fa") main_station = dw.DnaSupplier.from_json_data("state_from_web_app.json") main_station.prepare_network_on_sequence(sequence) quote = main_station.get_quote(sequence) print(quote.assembly_step_summary())