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 generate_supply_network( parts_sequences, already_amplified_fragments, already_ordered_primers, assembly_method, ): """Build the supply network, return the main station. See the docs for an overview of the supply network. Parameters ---------- parts_sequences A dictionary {part_id: "ATGCGC..."} of the base genetic parts, which will be considered as available for free. already_amplified_fragments A dictionary {fragment_id: "ATGCTGA"} providing sequences of fragments made for previous assemblies, which will be considered as available for free. already_ordered_primers A dictionary {primer_id: "ATGCTGA"} providing sequences of primers ordered for previous assemblies, which will be considered as available for free. assembly_method Either "gibson", "golden_gate", or "any_method" (each construct will then be assembled using any method, with a preference for Golden Gate Assembly) """ # PRIMERS SUPPLIERS already_ordered_primers_library = dw.PartsLibrary( name="already_ordered_primers", parts_dict=already_ordered_primers, ) primers_company = dw.CommercialDnaOffer( name="oligo_supplier", pricing=dw.FixedCostPricing(1), lead_time=0, sequence_constraints=(dw.SequenceLengthConstraint(max_length=100),) ) primers_comparator = dw.DnaSuppliersComparator( suppliers=[primers_company, already_ordered_primers_library] ) # STATIONS FOR PARTS EXTENSION VIA PCR primer_homology_selector = dw.TmSegmentSelector( min_size=19, max_size=25, min_tm=50, max_tm=70 ) parts_pcr_station = dw.PcrExtractionStation( name="pcr_part_extension_station", primers_supplier=primers_comparator, sequences=parts_sequences, max_overhang_length=30, extra_cost=2, homology_selector=primer_homology_selector, ) already_amplified_fragments_library = dw.PartsLibrary( name="already_amplified_fragments", parts_dict=already_amplified_fragments, ) fragments_comparator = dw.DnaSuppliersComparator( name="fragments_comparator", suppliers=[parts_pcr_station, already_amplified_fragments_library], ) # ASSEMBLY STATIONS gibson_assembly_station = dw.DnaAssemblyStation( name="gibson_assembly", supplier=fragments_comparator, assembly_method=dw.GibsonAssemblyMethod( overhang_selector=dw.FixedSizeSegmentSelector(40), cost=50 ), coarse_grain=600, fine_grain=None, a_star_factor="auto" ) golden_gate_stations_comparator = dw.DnaSuppliersComparator( name="golden_gate_comparator", return_first_accepted_quote=True, suppliers=[ dw.DnaAssemblyStation( name="golden_gate_assembly_%s" % enzyme, supplier=fragments_comparator, assembly_method=dw.GoldenGateAssemblyMethod( enzyme=enzyme ), coarse_grain=600, fine_grain=None, cut_spread_radius=2, a_star_factor="auto" ) for enzyme in ["BsmBI", "BsaI", "BbsI"] ] ) # SELECT SUPPLIERS DEPENDING ON THE SELECTED ASSEMBLY METHOD suppliers = [] if assembly_method in ["golden_gate", "any_method"]: suppliers.append(golden_gate_stations_comparator) if assembly_method in ["gibson", "any_method"]: suppliers.append(gibson_assembly_station) # RETURN THE METHODS COMPARATOR main_station = dw.DnaSuppliersComparator(name="main", suppliers=suppliers) return main_station
oligo_dna_offer = dw.CommercialDnaOffer( name="OliGoo", sequence_constraints=[ dw.GcContentConstraint(min_gc=0.3, max_gc=0.7), dw.SequenceLengthConstraint(max_length=100), ], pricing=dw.PerBasepairPricing(0.07), memoize=True, ) oligo_assembly_station = dw.DnaAssemblyStation( name="Oligo Assembly Station", assembly_method=dw.OligoAssemblyMethod( overhang_selector=dw.TmSegmentSelector(min_size=15, max_size=25, min_tm=50, max_tm=70), min_segment_length=40, max_segment_length=200, sequence_constraints=[dw.SequenceLengthConstraint(max_length=1500)], duration=8, cost=30, ), supplier=oligo_dna_offer, coarse_grain=20, a_star_factor="auto", memoize=True, ) assembly_station = dw.DnaAssemblyStation( name="Gibson Assembly Station",
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')
dw.NoPatternConstraint(enzyme="BsmBI"), dw.SequenceLengthConstraint(max_length=4000), ], pricing=dw.PerBasepairPricing(0.10), ) deluxe_dna_offer = dw.CommercialDnaOffer( name="DeluxeDNA", sequence_constraints=[dw.SequenceLengthConstraint(max_length=3000)], 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()
def generate_supply_network(a_star_factor): oligo_com = dw.CommercialDnaOffer( name="Oligo.com", sequence_constraints=[dw.SequenceLengthConstraint(max_length=200)], pricing=dw.PerBasepairPricing(0.10), lead_time=7, ) deluxe_dna_com = dw.CommercialDnaOffer( name="DeluxeDNA.com", sequence_constraints=[dw.SequenceLengthConstraint(max_length=4000)], pricing=dw.PerBasepairPricing(0.20), lead_time=10, ) cheap_dna_com = dw.CommercialDnaOffer( name="CheapDNA.com", sequence_constraints=[ dw.SequenceLengthConstraint(max_length=4000), dw.NoPatternConstraint(enzyme="AarI"), dw.NoPatternConstraint(enzyme="BsaI"), lambda seq: (0.4 < gc_content(seq) < 0.6), ], pricing=dw.PerBasepairPricing(0.10), lead_time=15, ) # OLIGOS TO BLOCKS ASSEMBLY oligo_assembly_station = dw.DnaAssemblyStation( name="Oligo Assembly Station", assembly_method=dw.OligoAssemblyMethod( overhang_selector=dw.TmSegmentSelector( min_size=15, max_size=25, min_tm=50, max_tm=70 ), min_segment_length=40, max_segment_length=200, sequence_constraints=[dw.SequenceLengthConstraint(max_length=1500)], duration=8, cost=2, ), supplier=oligo_com, coarse_grain=20, fine_grain=False, a_star_factor=a_star_factor, ) # BLOCKS TO CHUNKS ASSEMBLY blocks_sources_comparator = dw.DnaSuppliersComparator( name="bs_comparator", suppliers=[oligo_assembly_station, cheap_dna_com, deluxe_dna_com], memoize=True, ) gibson_blocks_assembly_station = dw.DnaAssemblyStation( name="Gibson Blocks Assembly", assembly_method=dw.GibsonAssemblyMethod( overhang_selector=dw.FixedSizeSegmentSelector(80), min_segment_length=1000, max_segment_length=4000, duration=8, cost=16, ), supplier=blocks_sources_comparator, coarse_grain=300, fine_grain=False, memoize=True, a_star_factor=a_star_factor, ) 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=blocks_sources_comparator, coarse_grain=400, fine_grain=False, memoize=True, a_star_factor=a_star_factor, ) ecoli_genome_path = os.path.join( "..", "..", "data", "ecoli_blast_db", "ecoli" ) ecoli_genome = dw.PcrExtractionStation( "E. coli Genome (PCR)", primers_supplier=oligo_com, homology_selector=dw.TmSegmentSelector(), blast_database=ecoli_genome_path, max_amplicon_length=10000, extra_time=3, extra_cost=1, ) # CHUNKS TO MEGACHUNKS ASSEMBLY return dw.DnaAssemblyStation( name="Chunks assembly (Yeast)", assembly_method=dw.GibsonAssemblyMethod( overhang_selector=dw.FixedSizeSegmentSelector(300), min_segment_length=7000, max_segment_length=25000, duration=8, ), supplier=[ ecoli_genome, goldengate_blocks_assembly_station, gibson_blocks_assembly_station, ], coarse_grain=1000, fine_grain=None, a_star_factor=a_star_factor, memoize=True, )
dw.SequenceLengthConstraint(max_length=4000), dw.NoPatternConstraint(enzyme="AarI"), dw.NoPatternConstraint(enzyme="BsaI"), lambda seq: (0.4 < gc_content(seq) < 0.6), ], pricing=dw.PerBasepairPricing(0.10), lead_time=15, ) # OLIGOS TO BLOCKS ASSEMBLY oligo_assembly_station = dw.DnaAssemblyStation( name="Oligo Assembly Station", assembly_method=dw.OligoAssemblyMethod( overhang_selector=dw.TmSegmentSelector(min_size=15, max_size=25, min_tm=50, max_tm=70), min_segment_length=40, max_segment_length=200, sequence_constraints=[dw.SequenceLengthConstraint(max_length=1500)], duration=8, cost=2, ), supplier=oligo_com, coarse_grain=20, fine_grain=False, a_star_factor="auto", memoize=True, ) # BLOCKS TO CHUNKS ASSEMBLY
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")