Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BP011 #233

Merged
merged 13 commits into from
Mar 27, 2024
Merged

BP011 #233

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
273 changes: 158 additions & 115 deletions sbol_utilities/component.py

Large diffs are not rendered by default.

112 changes: 75 additions & 37 deletions test/test_component.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
protein_stability_element, gene, operator, engineered_region, mrna, transcription_factor, \
strain, ed_simple_chemical, ed_protein

from sbol_utilities.component import ed_restriction_enzyme, backbone, part_in_backbone, part_in_backbone_from_sbol, \
from sbol_utilities.component import ed_restriction_enzyme, backbone, backbone_from_sbol, part_in_backbone, part_in_backbone_from_sbol, \
digestion, ligation, Assembly_plan_composite_in_backbone_single_enzyme
from sbol_utilities.helper_functions import find_top_level, toplevel_named, TopLevelNotFound, outgoing_links
from sbol_utilities.sbol_diff import doc_diff
Expand Down Expand Up @@ -362,6 +362,23 @@ def test_backbone_bp011(self):
linear_backbone_component.constraints.append(backbone_dropout_meets)
doc.add([linear_backbone_component, linear_backbone_seq])
assert doc_diff(doc, hlc_doc) == 0, f'Constructor Error: Linear {backbone_identity}'

#Test backbone from SBOL
hlc_doc = sbol3.Document()
doc = sbol3.Document()
sbol3.set_namespace('http://sbolstandard.org/testfiles')
# build using backbone from SBOL
doc.add([circular_backbone_component, circular_backbone_seq])
hl_circular_backbone_component, hl_circular_backbone_seq = backbone_from_sbol(identity=backbone_identity, sbol_comp=circular_backbone_component, dropout_location=dropout_location, fusion_site_length=fusion_site_length, linear=False, description=test_description)
hlc_doc.add([hl_circular_backbone_component, hl_circular_backbone_seq])
assert doc_diff(doc, hlc_doc) == 0, f'Constructor Error: Circular {backbone_identity} from SBOL'

hlc_doc = sbol3.Document()
doc = sbol3.Document()
doc.add([linear_backbone_component, linear_backbone_seq])
hl_linear_backbone_component, hl_linear_backbone_seq = backbone_from_sbol(identity=backbone_identity, sbol_comp=linear_backbone_component, dropout_location=dropout_location, fusion_site_length=fusion_site_length, linear=True, description=test_description)
hlc_doc.add([hl_linear_backbone_component, hl_linear_backbone_seq])
assert doc_diff(doc, hlc_doc) == 0, f'Constructor Error: Linear {backbone_identity} from SBOL'

def test_part_in_backbone_bp011(self):
"""Test the part_in_backbone function"""
Expand Down Expand Up @@ -462,53 +479,74 @@ def test_assembly_plan_bp011(self):
doc.add([podd_backbone,podd_backbone_seq])
#parts in backbone
##get parts from genbank
podd1_dir = os.path.join(test_dir, 'test_files', 'podd1.gb')
j23100_b0034_dir = os.path.join(test_dir, 'test_files', 'j23100_b0034.gb')
sfgfp_dir = os.path.join(test_dir, 'test_files', 'sfgfp.gb')
rhlr_dir = os.path.join(test_dir, 'test_files', 'rhlr.gb')
b0015_dir = os.path.join(test_dir, 'test_files', 'b0015.gb')
j23100_b0034_doc = convert_from_genbank(j23100_b0034_dir, 'https://github.com/Gonza10V')
j23100_b0034_ac = [top_level for top_level in j23100_b0034_doc if type(top_level)==sbol3.Component][0]
j23100_b0034_ac_seq_str = j23100_b0034_ac.sequences[0].lookup().elements
sfgfp_doc = convert_from_genbank(sfgfp_dir, 'https://github.com/Gonza10V')
sfgfp_ce = [top_level for top_level in sfgfp_doc if type(top_level)==sbol3.Component][0]
sfgfp_ce_seq_str = sfgfp_ce.sequences[0].lookup().elements

"""Test assembly plan class"""
doc = sbol3.Document()
sbol3.set_namespace('http://sbolstandard.org/testfiles')
# Assembly plan setup
bsai = ed_restriction_enzyme('BsaI')
#lvl1 acceptor
podd1_dir = os.path.join(test_dir, 'test_files', 'podd1.gb')
podd_doc = convert_from_genbank(podd1_dir, 'https://github.com/Gonza10V')
podd_af = [top_level for top_level in podd_doc if type(top_level)==sbol3.Component][0]
podd_backbone, podd_backbone_seq = backbone_from_sbol('pOdd_bb', podd_af, [680,1770], 4, False, name='pOdd_bb')
doc.add([podd_backbone,podd_backbone_seq])
#parts in backbone
##get parts from genbank
j23100_dir = os.path.join(test_dir, 'test_files', 'ab_j23100.gb')
j23101_dir = os.path.join(test_dir, 'test_files', 'ab_j23101.gb')
b0034_dir = os.path.join(test_dir, 'test_files', 'bc_b0034.gb')
gfp_dir = os.path.join(test_dir, 'test_files', 'ce_gfp.gb')
rfp_dir = os.path.join(test_dir, 'test_files', 'ce_mrfp1.gb')
cfp_dir = os.path.join(test_dir, 'test_files', 'ce_ecfp.gb')
b0015_dir = os.path.join(test_dir, 'test_files', 'ef_b0015.gb')
j23100_doc = convert_from_genbank(j23100_dir, 'https://github.com/Gonza10V')
j23100_ab = [top_level for top_level in j23100_doc if type(top_level)==sbol3.Component][0]
j23101_doc = convert_from_genbank(j23101_dir, 'https://github.com/Gonza10V')
j23101_ab = [top_level for top_level in j23101_doc if type(top_level)==sbol3.Component][0]
b0034_doc = convert_from_genbank(b0034_dir, 'https://github.com/Gonza10V')
b0034_bc = [top_level for top_level in b0034_doc if type(top_level)==sbol3.Component][0]
gfp_doc = convert_from_genbank(gfp_dir, 'https://github.com/Gonza10V')
gfp_ce = [top_level for top_level in gfp_doc if type(top_level)==sbol3.Component][0]
rfp_doc = convert_from_genbank(rfp_dir, 'https://github.com/Gonza10V')
rfp_ce = [top_level for top_level in rfp_doc if type(top_level)==sbol3.Component][0]
cfp_doc = convert_from_genbank(cfp_dir, 'https://github.com/Gonza10V')
cfp_ce = [top_level for top_level in cfp_doc if type(top_level)==sbol3.Component][0]
b0015_doc = convert_from_genbank(b0015_dir, 'https://github.com/Gonza10V')
b0015_ef = [top_level for top_level in b0015_doc if type(top_level)==sbol3.Component][0]
b0015_ef_seq_str = b0015_ef.sequences[0].lookup().elements
##SBOL parts in backbone
j23100_b0034_ac_in_bb, j23100_b0034_ac_in_bb_seq = part_in_backbone_from_sbol('j23100_b0034_ac_in_bb', j23100_b0034_ac, [476,545], [sbol3.SO_PROMOTER, sbol3.SO_RBS], 4, False, name='j23100_b0034_ac_in_bb')
doc.add([j23100_b0034_ac_in_bb, j23100_b0034_ac_in_bb_seq])
sfgfp_ce_in_bb, sfgfp_ce_in_bb_seq = part_in_backbone_from_sbol('sfgfp_ce_in_bb', sfgfp_ce, [130,854], [sbol3.SO_CDS], 4, False, name='sfgfp_ce_in_bb')
doc.add([sfgfp_ce_in_bb, sfgfp_ce_in_bb_seq])
j23100_ab_in_bb, j23100_ab_in_bb_seq = part_in_backbone_from_sbol('j23100_ab_in_bb', j23100_ab, [479,513], [sbol3.SO_PROMOTER], 4, False, name='j23100_ab_in_bb')
doc.add([j23100_ab_in_bb, j23100_ab_in_bb_seq])
j23101_ab_in_bb, j23101_ab_in_bb_seq = part_in_backbone_from_sbol('j23101_ab_in_bb', j23101_ab, [479,513], [sbol3.SO_PROMOTER], 4, False, name='j23101_ab_in_bb')
doc.add([j23101_ab_in_bb, j23101_ab_in_bb_seq])
b0034_bc_in_bb, b0034_bc_in_bb_seq = part_in_backbone_from_sbol('b0034_bc_in_bb', b0034_bc, [479,499], [sbol3.SO_RBS], 4, False, name='b0034_bc_in_bb')
doc.add([b0034_bc_in_bb, b0034_bc_in_bb_seq])
gfp_ce_in_bb, gfp_ce_in_bb_seq = part_in_backbone_from_sbol('gfp_ce_in_bb', gfp_ce, [479,1195], [sbol3.SO_CDS], 4, False, name='gfp_ce_in_bb')
doc.add([gfp_ce_in_bb, gfp_ce_in_bb_seq])
rfp_ce_in_bb, rfp_ce_in_bb_seq = part_in_backbone_from_sbol('rfp_ce_in_bb', rfp_ce, [479,1156], [sbol3.SO_CDS], 4, False, name='rfp_ce_in_bb')
doc.add([rfp_ce_in_bb, rfp_ce_in_bb_seq])
cfp_ce_in_bb, cfp_ce_in_bb_seq = part_in_backbone_from_sbol('cfp_ce_in_bb', cfp_ce, [479,1198], [sbol3.SO_CDS], 4, False, name='cfp_ce_in_bb')
doc.add([cfp_ce_in_bb, cfp_ce_in_bb_seq])
b0015_ef_in_bb, b0015_ef_in_bb_seq = part_in_backbone_from_sbol('b0015_ef_in_bb', b0015_ef, [518,646], [sbol3.SO_TERMINATOR], 4, False, name='b0015_ef_in_bb')
doc.add([b0015_ef_in_bb, b0015_ef_in_bb_seq])


#Assembly plan
test_assembly_plan = Assembly_plan_composite_in_backbone_single_enzyme(
name='constitutive_gfp_tu',
parts_in_backbone=[j23100_b0034_ac_in_bb, sfgfp_ce_in_bb, b0015_ef_in_bb],
combinatorial_assembly_plan = Assembly_plan_composite_in_backbone_single_enzyme(
name='combinatorial_rgb_transcriptional_units',
parts_in_backbone=[j23100_ab_in_bb, j23101_ab_in_bb, b0034_bc_in_bb, gfp_ce_in_bb, rfp_ce_in_bb, cfp_ce_in_bb, b0015_ef_in_bb],
acceptor_backbone=podd_backbone,
restriction_enzyme=bsai,
document=doc)
test_assembly_plan.run()
#Check assembly plan
expected_assembled_j23100_b0034_ac_seq_str = j23100_b0034_ac_seq_str[475:545]
assembled_j23100_b0034_ac_seq_str = test_assembly_plan.extracted_parts[0].sequences[0].lookup().elements
assert expected_assembled_j23100_b0034_ac_seq_str==assembled_j23100_b0034_ac_seq_str, 'Constructor Error: First extracted part sequence does not match expected sequence'

expected_assembled_sfgfp_ce_seq_str = sfgfp_ce_seq_str[129:854]
assembled_sfgfp_ce_seq_str = test_assembly_plan.extracted_parts[1].sequences[0].lookup().elements
assert expected_assembled_sfgfp_ce_seq_str==assembled_sfgfp_ce_seq_str, 'Constructor Error: Second extracted part sequence does not match expected sequence'

expected_assembled_b0015_ef_seq_str = b0015_ef_seq_str[513:650]
assembled_b0015_ef_seq_str = test_assembly_plan.extracted_parts[2].sequences[0].lookup().elements
assert expected_assembled_b0015_ef_seq_str==assembled_b0015_ef_seq_str, 'Constructor Error: Third extracted part sequence does not match expected sequence'

expected_assembled_open_backbone_seq_str = lvl1_pOdd_acceptor_seq[2255:] + lvl1_pOdd_acceptor_seq[:1172]
assembled_open_backbone_seq_str = test_assembly_plan.extracted_parts[-1].sequences[0].lookup().elements
assert expected_assembled_open_backbone_seq_str==assembled_open_backbone_seq_str, 'Constructor Error: Last extracted part (open backbone) sequence does not match expected sequence'

expected_composite_seq_str = expected_assembled_open_backbone_seq_str[:-4] + expected_assembled_j23100_b0034_ac_seq_str[:-4] + expected_assembled_sfgfp_ce_seq_str[:-4] + expected_assembled_b0015_ef_seq_str[:-4]
assembled_composite_seq_str = test_assembly_plan.composites[0][0].sequences[0].lookup().elements
assert expected_composite_seq_str==assembled_composite_seq_str, 'Constructor Error: Composite sequence does not match expected sequence'

combinatorial_assembly_plan.run()
for obj in combinatorial_assembly_plan.document.objects:
if obj.identity =='http://sbolstandard.org/testfiles/composite_3_part_8_part_1_j23100_ab_in_bb_part_3_b0034_bc_in_bb_part_6_cfp_ce_in_bb_part_7_b0015_ef_in_bb':
obtained_sequence = obj.sequences[0].lookup().elements
target_sequence = 'cgctgcatgaagagcctgcagtccggcaaaaaagggcaaggtgtcaccaccctgccctttttctttaaaaccgaaaagattacttcgcgttatgcaggcttcctcgctcactgactcgctgcgctcggtcgttcggctgcggcgagcggtatcagctcactcaaaggcggtaatacggttatccacagaatcaggggataacgcaggaaagaacatgtgagcaaaaggccagcaaaaggccaggaaccgtaaaaaggccgcgttgctggcgtttttccacaggctccgcccccctgacgagcatcacaaaaatcgacgctcaagtcagaggtggcgaaacccgacaggactataaagataccaggcgtttccccctggaagctccctcgtgcgctctcctgttccgaccctgccgcttaccggatacctgtccgcctttctcccttcgggaagcgtggcgctttctcatagctcacgctgtaggtatctcagttcggtgtaggtcgttcgctccaagctgggctgtgtgcacgaaccccccgttcagcccgaccgctgcgccttatccggtaactatcgtcttgagtccaacccggtaagacacgacttatcgccactggcagcagccactggtaacaggattagcagagcgaggtatgtaggcggtgctacagagttcttgaagtggtggcctaactacggctacactagaagaacagtatttggtatctgcgctctgctgaagccagttaccttcggaaaaagagttggtagctcttgatccggcaaacaaaccaccgctggtagcggtggtttttttgtttgcaagcagcagattacgcgcagaaaaaaaggatctcaagaagatcctttgatcttttctacggggtctgacgctcagtggaacgaaaactcacgttaagggattttggtcatgagattatcaaaaaggatcttcacctagatccttttaaattaaaaatgaagttttaaatcaatctaaagtatatatgagtaaacttggtctgacagctcgagtcccgtcaagtcagcgtaatgctctgccagtgttacaaccaattaaccaattctgattagaaaaactcatcgagcatcaaatgaaactgcaatttattcatatcaggattatcaataccatatttttgaaaaagccgtttctgtaatgaaggagaaaactcaccgaggcagttccataggatggcaagatcctggtatcggtctgcgattccgactcgtccaacatcaatacaacctattaatttcccctcgtcaaaaataaggttatcaagtgagaaatcaccatgagtgacgactgaatccggtgagaatggcaaaagcttatgcatttctttccagacttgttcaacaggccagccattacgctcgtcatcaaaatcactcgcatcaaccaaaccgttattcattcgtgattgcgcctgagcgagacgaaatacgcgatcgctgttaaaaggacaattacaaacaggaatcgaatgcaaccggcgcaggaacactgccagcgcatcaacaatattttcacctgaatcaggatattcttctaatacctggaatgctgttttcccggggatcgcagtggtgagtaaccatgcatcatcaggagtacggataaaatgcttgatggtcggaagaggcataaattccgtcagccagtttagtctgaccatctcatctgtaacatcattggcaacgctacctttgccatgtttcagaaacaactctggcgcatcgggcttcccatacaatcgatagattgtcgcacctgattgcccgacattatcgcgagcccatttatacccatataaatcagcatccatgttggaatttaatcgcggcctggagcaagacgtttcccgttgaatatggctcataacaccccttgtattactgtttatgtaagcagacagttttattgttcatgatgatatatttttatcttgtgcaatgtaacatcagagattttgagacacaacgtggctttgttgaataaatcgaacttttgctgagttgaaggatcagctcgagtgccacctgacgtctaagaaaccattattatcatgacattaacctataaaaataggcgtatcacgaggcagaatttcagataaaaaaaatccttagctttcgctaaggatgatttctggaattcgctcttcaatgGGAGttgacggctagctcagtcctaggtacagtgctagcTACTagagaaagaggagaaatactaaatggtgagcaagggcgaggagctgttcaccggggtggtgcccatcctggtcgagctggacggcgacgtgaacggccacaagttcagcgtgtccggcgagggcgagggcgatgccacctacggcaagctgaccctgaagttcatctgcaccaccggcaagctgcccgtgccctggcccaccctcgtgaccaccctgacctggggcgtgcagtgcttcagccgctaccccgaccacatgaagcagcacgacttcttcaagtccgccatgcccgaaggctacgtccaggagcgcaccatcttcttcaaggacgacggcaactacaagacccgcgccgaggtgaagttcgagggcgacaccctggtgaaccgcatcgagctgaagggcatcgacttcaaggaggacggcaacatcctggggcacaagctggagtacaactacatcagccacaacgtctatatcaccgccgacaagcagaagaacggcatcaaggccaacttcaagatccgccacaacatcgaggacggcagcgtgcagctcgccgaccactaccagcagaacacccccatcggcgacggccccgtgctgctgcccgacaaccactacctgagcacccagtccgccctgagcaaagaccccaacgagaagcgcgatcacatggtcctgctggagttcgtgaccgccgccgggatcactctcggcatggacgagctgtacaagtaataaGCTTccaggcatcaaataaaacgaaaggctcagtcgaaagactgggcctttcgttttatctgttgtttgtcggtgaacgctctctactagagtcacactggctcaccttcgggtgggcctttctgcgtttata'
if __name__ == '__main__':
unittest.main()
80 changes: 80 additions & 0 deletions test/test_files/ab_j23100.gb
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
LOCUS AB_J23100 2095 bp ds-DNA linear 25-OCT-2023
DEFINITION .
FEATURES Location/Qualifiers
misc_feature 346..365
/label="VF Primer binding site"
/ApEinfo_revcolor="#b7e6d7"
/ApEinfo_fwdcolor="#b7e6d7"
misc_feature complement(422..466)
/label="Terminator"
/ApEinfo_revcolor="#c7b0e3"
/ApEinfo_fwdcolor="#c7b0e3"
BioBrick 468..473
/label="BsaI Site"
/ApEinfo_revcolor="#f58a5e"
/ApEinfo_fwdcolor="#f58a5e"
misc_feature 475..478
/label="A"
/ApEinfo_revcolor="#ff9ccd"
/ApEinfo_fwdcolor="#ff9ccd"
misc_feature 479..513
/label="J23100"
/ApEinfo_revcolor="#b1ff67"
/ApEinfo_fwdcolor="#b1ff67"
misc_feature 514..517
/label="B"
/ApEinfo_revcolor="#f8d3a9"
/ApEinfo_fwdcolor="#f8d3a9"
misc_feature 531..602
/label="His Terminator"
/ApEinfo_revcolor="#ffef86"
/ApEinfo_fwdcolor="#ffef86"
misc_feature complement(666..685)
/label="VR Primer binding site"
/ApEinfo_revcolor="#b1ff67"
/ApEinfo_fwdcolor="#b1ff67"
misc_feature complement(770..1384)
/label="rep (pMB1)"
/ApEinfo_revcolor="#85dae9"
/ApEinfo_fwdcolor="#85dae9"
misc_feature complement(1551..1656)
/label="Terminator T0"
/ApEinfo_revcolor="#c6c9d1"
/ApEinfo_fwdcolor="#c6c9d1"
ORIGIN
1 tcattgccat acgaaattcc ggatgagcat tcatcaggcg ggcaagaatg tgaataaagg
61 ccggataaaa cttgtgctta tttttcttta cggtctttaa aaaggccgta atatccagct
121 gaacggtctg gttataggta cattgagcaa ctgactgaaa tgcctcaaaa tgttctttac
181 gatgccattg ggatatatca acggtggtat atccagtgat ttttttctcc attttagctt
241 ccttagctcc tgaaaatctc gataactcaa aaaatacgcc cggtagtgat cttatttcat
301 tatggtgaaa gttggaacct cttacgtgcc cgatcaactc gagtgccacc tgacgtctaa
361 gaaaccatta ttatcatgac attaacctat aaaaataggc gtatcacgag gcagaatttc
421 agataaaaaa aatccttagc tttcgctaag gatgatttct ggaattcggt ctcgGGAGtt
481 gacggctagc tcagtcctag gtacagtgct agcTACTCGA Gaccctgcag tccggcaaaa
541 aagggcaagg tgtcaccacc ctgccctttt tctttaaaac cgaaaagatt acttcgcgtt
601 atgcaggctt cctcgctcac tgactcgctg cgctcggtcg ttcggctgcg gcgagcggta
661 tcagctcact caaaggcggt aatacggtta tccacagaat caggggataa cgcaggaaag
721 aacatgtgag caaaaggcca gcaaaaggcc aggaaccgta aaaaggccgc gttgctggcg
781 tttttccaca ggctccgccc ccctgacgag catcacaaaa atcgacgctc aagtcagagg
841 tggcgaaacc cgacaggact ataaagatac caggcgtttc cccctggaag ctccctcgtg
901 cgctctcctg ttccgaccct gccgcttacc ggatacctgt ccgcctttct cccttcggga
961 agcgtggcgc tttctcatag ctcacgctgt aggtatctca gttcggtgta ggtcgttcgc
1021 tccaagctgg gctgtgtgca cgaacccccc gttcagcccg accgctgcgc cttatccggt
1081 aactatcgtc ttgagtccaa cccggtaaga cacgacttat cgccactggc agcagccact
1141 ggtaacagga ttagcagagc gaggtatgta ggcggtgcta cagagttctt gaagtggtgg
1201 cctaactacg gctacactag aagaacagta tttggtatct gcgctctgct gaagccagtt
1261 accttcggaa aaagagttgg tagctcttga tccggcaaac aaaccaccgc tggtagcggt
1321 ggtttttttg tttgcaagca gcagattacg cgcagaaaaa aaggatctca agaagatcct
1381 ttgatctttt ctacggggtc tgacgctcag tggaacgaaa actcacgtta agggattttg
1441 gtcatgagat tatcaaaaag gatcttcacc tagatccttt taaattaaaa atgaagtttt
1501 aaatcaatct aaagtatata tgagtaaact tggtctgaca gctcgaggct tggattctca
1561 ccaataaaaa acgcccggcg gcaaccgagc gttctgaaca aatccagatg gagttctgag
1621 gtcattactg gatctatcaa caggagtcca agcgagctcg atatcaaatt acgccccgcc
1681 ctgccactca tcgcagtact gttgtaattc attaagcatt ctgccgacat ggaagccatc
1741 acaaacggca tgatgaacct gaatcgccag cggcatcagc accttgtcgc cttgcgtata
1801 atatttgccc atggtgaaaa cgggggcgaa gaagttgtcc atattggcca cgtttaaatc
1861 aaaactggtg aaactcaccc agggattggc tgagacgaaa aacatattct caataaaccc
1921 tttagggaaa taggccaggt tttcaccgta acacgccaca tcttgcgaat atatgtgtag
1981 aaactgccgg aaatcgtcgt ggtattcact ccagagcgat gaaaacgttt cagtttgctc
2041 atggaaaacg gtgtaacaag ggtgaacact atcccatatc accagctcac cgtct
//
Loading
Loading