def test_simple_gibson_assembly_station(): dna_provider = CommercialDnaOffer( name="Company InGen", pricing=PerBasepairPricing(0.08) ) assembly_station = DnaAssemblyStation( name='Gibson Assembly Station', assembly_method=GibsonAssemblyMethod( overhang_selector=TmSegmentSelector(), min_segment_length=300, max_segment_length=1200 ), supplier=dna_provider, coarse_grain=10, ) sequence = random_dna_sequence(5000, seed=1234) quote = assembly_station.get_quote(sequence, with_assembly_plan=True) assert quote.accepted assert 405.7 < quote.price < 405.8
name="CheapDNA", pricing=PerBasepairPricing(0.08), sequence_constraints=[SequenceLengthConstraint(max_length=1000)], ) # An oligos vendor (for oligo assembly and ) company_oligo = CommercialDnaOffer( name="Oligo vendor", pricing=FixedCostPricing(5), sequence_constraints=[SequenceLengthConstraint(max_length=100)], ) mouse_pcr_station = PcrExtractionStation( name="E. coli", extra_cost=10, homology_selector=TmSegmentSelector(), primers_supplier=company_oligo, blast_database=os.path.join("..", "..", "data", "ecoli_blast_db", "ecoli"), memoize=True, ) assembly_station = DnaAssemblyStation( name="Golden Gate Station", assembly_method=GoldenGateAssemblyMethod(min_segment_length=40, max_segment_length=5000, enzyme="BsmBI"), supplier=[ company_ingen, emma_collection, mouse_pcr_station, company_tdi,
SequenceLengthConstraint(max_length=4000), NoPatternConstraint(enzyme="AarI"), NoPatternConstraint(enzyme="BsaI"), lambda seq: (0.4 < gc_content(seq) < 0.6), ], pricing=PerBasepairPricing(0.10), lead_time=15, ) # OLIGOS TO BLOCKS ASSEMBLY oligo_assembly_station = DnaAssemblyStation( name="Oligo Assembly Station", assembly_method=OligoAssemblyMethod( overhang_selector=TmSegmentSelector(min_size=15, max_size=25, min_tm=50, max_tm=70), min_segment_length=40, max_segment_length=200, sequence_constraints=[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
cheap_dna = CommercialDnaOffer( name="CheapDNA.com", sequence_constraints=[ NoPatternConstraint(enzyme="BsaI"), dnachisel.EnforceGCContent(0.3, 0.7, window=60), ], pricing=PerBasepairPricing(0.10), lead_time=15, ) # BLOCKS TO CHUNKS ASSEMBLY gibson_blocks_assembly_station = DnaAssemblyStation( name="Gibson Blocks Assembly", assembly_method=GibsonAssemblyMethod( overhang_selector=TmSegmentSelector(), min_segment_length=1000, max_segment_length=6000, duration=8, cost=16, ), supplier=[deluxe_dna, cheap_dna], coarse_grain=30, fine_grain=False, memoize=True, a_star_factor="auto", ) quote_before = gibson_blocks_assembly_station.get_quote( sequence, with_assembly_plan=True)
def test_lead_time_limit(): # OLIGO COMPANIES a_star_factor = "auto" memoize = True oligo_com = CommercialDnaOffer( name="Oligo.com", sequence_constraints=[SequenceLengthConstraint(max_length=200)], pricing=PerBasepairPricing(0.10), lead_time=7, ) deluxe_dna_com = CommercialDnaOffer( name="DeluxeDNA.com", sequence_constraints=[SequenceLengthConstraint(max_length=4000)], pricing=PerBasepairPricing(0.20), lead_time=10, ) cheap_dna_com = CommercialDnaOffer( name="CheapDNA.com", sequence_constraints=[ SequenceLengthConstraint(max_length=4000), NoPatternConstraint(enzyme="AarI"), NoPatternConstraint(enzyme="BsaI"), lambda seq: (0.4 < gc_content(seq) < 0.6), ], pricing=PerBasepairPricing(0.10), lead_time=15, ) # OLIGOS TO BLOCKS ASSEMBLY oligo_assembly_station = DnaAssemblyStation( name="Oligo Assembly Station", assembly_method=OligoAssemblyMethod( overhang_selector=TmSegmentSelector(min_size=15, max_size=25, min_tm=50, max_tm=70), min_segment_length=40, max_segment_length=200, sequence_constraints=[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 = DnaSuppliersComparator( name="bs_comparator", suppliers=[oligo_assembly_station, cheap_dna_com, deluxe_dna_com], memoize=memoize, ) gibson_blocks_assembly_station = DnaAssemblyStation( name="Gibson Blocks Assembly", assembly_method=GibsonAssemblyMethod( overhang_selector=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=memoize, a_star_factor=a_star_factor, ) goldengate_blocks_assembly_station = DnaAssemblyStation( name="Golden Gate Blocks Assembly", assembly_method=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=memoize, a_star_factor=a_star_factor, ) ecoli_genome = PcrExtractionStation( "E. coli Genome (PCR)", primers_supplier=oligo_com, homology_selector=TmSegmentSelector(min_size=18, max_size=22, min_tm=55, max_tm=65), blast_database=ECOLI_DB_PATH, max_amplicon_length=10000, extra_time=3, extra_cost=1, ) # CHUNKS TO MEGACHUNKS ASSEMBLY chunks_assembly_station = DnaAssemblyStation( name="Chunks assembly (Gibson)", assembly_method=GibsonAssemblyMethod( overhang_selector=FixedSizeSegmentSelector(300), min_segment_length=7000, max_segment_length=25000, duration=8, ), supplier=DnaSuppliersComparator([ ecoli_genome, goldengate_blocks_assembly_station, gibson_blocks_assembly_station, ]), coarse_grain=1000, fine_grain=None, a_star_factor=a_star_factor, memoize=memoize, ) with open(SEQUENCE_PATH, "r") as f: sequence = f.read() import time t0 = time.time() chunks_assembly_station.prepare_network_on_sequence(sequence) quote = chunks_assembly_station.get_quote(sequence, max_lead_time=28, with_assembly_plan=True) t1 = time.time() print("ELAPSED:", "%.02f" % (t1 - t0)) print(quote) if quote.accepted: print(quote.assembly_step_summary()) assert 5540 < quote.price < 5550