def example1(): '''Simple example.''' setHomespace("http://sys-bio.org") doc = Document() gene = ComponentDefinition("BB0001") promoter = ComponentDefinition("R0010") cds = ComponentDefinition("B0032") rbs = ComponentDefinition("E0040") terminator = ComponentDefinition("B0012") promoter.roles.set(SO_PROMOTER) cds.roles.set(SO_CDS) rbs.roles.set(SO_RBS) terminator.roles.set(SO_TERMINATOR) doc.addComponentDefinition(gene) doc.addComponentDefinition(promoter) doc.addComponentDefinition(cds) doc.addComponentDefinition(rbs) doc.addComponentDefinition(terminator) gene.assemble([promoter, rbs, cds, terminator]) first = gene.getFirstComponent() print first.identity.get() last = gene.getLastComponent() print last.identity.get() # promoter_seq = Sequence("R0010", "ggctgca") # rbs_seq = Sequence("B0032", "aattatataaa") # cds_seq = Sequence("E0040", "atgtaa") # terminator_seq = Sequence("B0012", "attcga") # gene_seq = Sequence("BB0001") # doc.addSequence(promoter_seq) # doc.addSequence(cds_seq) # doc.addSequence(rbs_seq) # doc.addSequence(terminator_seq) # doc.addSequence(gene_seq) # promoter.sequence.set(promoter_seq.identity.get()) # cds.sequence.set(cds_seq.identity.get()) # rbs.sequence.set(rbs_seq.identity.get()) # terminator.sequence.set(terminator_seq.identity.get()) # gene.sequence.set(gene_seq.identity.get()) # gene_seq.assemble() # print gene_seq.elements.get() doc.write("gene_cassette.xml") # Round trip... doc.write('gene_cassette.xml') new_doc = Document() new_doc.read('gene_cassette.xml') new_doc.write('gene_cassette_out.xml')
def test1(): sbol.setHomespace('http://sbol_prefix.org') doc = sbol.Document() pTetR = sbol.ComponentDefinition("test_promoter_1", sbol.BIOPAX_DNA) pTetR.roles = sbol.SO_PROMOTER doc.addComponentDefinition(pTetR) results = doc.write("pysbol_output.xml") return results
def _UploadDoc(doc, registry='https://synbiohub.org'): """ A tabular csv file containing columns: Name, Type, Part is read and each part in added to the SBOL doc. Part type should is overriden by the ontology definition in the registry """ namespace = "http://synbiochem.co.uk" sbol.setHomespace(namespace) repo = sbol.PartShop(registry) repo.login(os.getenv('IBISBA_SYNBIOHUB_USERNAME'), os.getenv('IBISBA_SYNBIOHUB_PASSWORD')) doc.displayId = 'E_coli_Parts' doc.name = 'A collection of genetic parts for engineering E. coli' doc.description = 'Standard regulatory genetic parts for building E. coli combinatorial libraries in the Galaxy-SynbioCAD. The collection contains a selection of commonly-used origins of replication, resistance cassettes, and inducible promoters.' repo.submit(doc)
def crispr_test(): '''Simple example.''' setHomespace('http://sys-bio.org') doc = Document() mkate, _ = _add_comp_def(doc, 'mKate') gal4vp16, _ = _add_comp_def(doc, 'gal4vp16') pconst, _ = _add_comp_def(doc, 'pconst', SO_PROMOTER, 'atgtaa') mkate_cds, _ = _add_comp_def(doc, 'mkate_cds', SO_CDS, 'attcga') gal4vp16_cds, _ = _add_comp_def(doc, 'gal4vp16_cds', SO_CDS, 'attcga') mkate_gene, mkate_gene_seq = _add_comp_def(doc, 'mkate_gene') gal4vp16_gene, gal4vp16_gene_seq = _add_comp_def(doc, 'gal4vp16_gene') mkate_gene.assemble([pconst, mkate_cds]) gal4vp16_gene.assemble([pconst, gal4vp16_cds]) mkate_gene_seq.assemble() print mkate_gene_seq.elements.get() gal4vp16_gene_seq.assemble() print gal4vp16_gene_seq.elements.get() doc.write('crispr.xml')
def _convert(rct_uniprot, tirs, max_prot_per_react): '''Convert.''' setHomespace('http://liverpool.ac.uk') doc = Document() for rct, uniprot_ids_set in rct_uniprot.items(): # Specify uniprot-specific assembly region placeholders: # (Provides consistent assembly sequence for each reaction group.) _5p_assembly = ComponentDefinition('%s_5_prime_assembly' % rct) _5p_assembly.roles = dna_utils.SO_ASS_COMP _3p_assembly = ComponentDefinition('%s_3_prime_assembly' % rct) _3p_assembly.roles = dna_utils.SO_ASS_COMP doc.addComponentDefinition([_5p_assembly, _3p_assembly]) for uniprot_id in uniprot_ids_set[:max_prot_per_react]: if tirs: for tir in tirs: _add_gene(doc, uniprot_id, tir, _5p_assembly, _3p_assembly) else: _add_gene(doc, uniprot_id, None, _5p_assembly, _3p_assembly) return doc
def crispr_tutorial_short(): sbol.setHomespace('http://sbols.org/CRISPR_Example') doc = sbol.Document() target_gene = sbol.ComponentDefinition("target_gene", sbol.BIOPAX_DNA) target_gene.roles = sbol.SO_PROMOTER doc.addComponentDefinition(target_gene) target = sbol.ComponentDefinition("target", sbol.BIOPAX_PROTEIN) doc.addComponentDefinition(target) CRISPR_Template = sbol.ModuleDefinition("CRISPR_Template") doc.addModuleDefinition(CRISPR_Template) target_gene_fc = CRISPR_Template.functionalComponents.create("target_gene_fc") target_gene_fc.definition = target_gene.identity target_gene_fc.access = sbol.SBOL_ACCESS_PUBLIC target_gene_fc.direction = sbol.SBOL_DIRECTION_IN_OUT target_fc = CRISPR_Template.functionalComponents.create("target_fc") target_fc.definition = target.identity target_fc.access = sbol.SBOL_ACCESS_PUBLIC target_fc.direction = sbol.SBOL_DIRECTION_IN_OUT target_generic_gene_inhibition = CRISPR_Template.interactions.create("target_gene_inhibition_interaction") target_generic_gene_inhibition.types = sbol.SBO_GENETIC_PRODUCTION target_gene_participation = target_generic_gene_inhibition.participations.create("target_gene_participation") target_gene_participation.roles = sbol.SBO_PROMOTER target_gene_participation.participant = target_gene_fc.identity target_participation = target_generic_gene_inhibition.participations.create("target_participation") target_participation.roles = sbol.SBO_PRODUCT target_participation.participant = target_fc.identity gRNA_gene = sbol.ComponentDefinition("gRNA_gene",sbol.BIOPAX_DNA) gRNA_gene.roles = sbol.SO_PROMOTER doc.addComponentDefinition(gRNA_gene) gRNA_b = sbol.ComponentDefinition("gRNA_b",sbol.BIOPAX_RNA) gRNA_b.roles = sbol.SO_SGRNA doc.addComponentDefinition(gRNA_b) CRPb_circuit = sbol.ModuleDefinition("CRPb_characterization_Circuit") doc.addModuleDefinition(CRPb_circuit) gRNA_b_fc = CRPb_circuit.functionalComponents.create("gRNA_b_fc") gRNA_b_fc.definition = gRNA_b.identity gRNA_b_fc.access = sbol.SBOL_ACCESS_PUBLIC gRNA_b_fc.direction = sbol.SBOL_DIRECTION_NONE gRNA_b_fc.version = 1 gRNA_gene_fc = CRPb_circuit.functionalComponents.create("gRNA_gene_fc") gRNA_gene_fc.definition = gRNA_gene.identity gRNA_gene_fc.access = sbol.SBOL_ACCESS_PUBLIC gRNA_gene_fc.direction = sbol.SBOL_DIRECTION_NONE gRNA_gene_fc.version = 1 gRNA_b_production = CRPb_circuit.interactions.create("gRNA_b_production") gRNA_b_production.types = sbol.SBO_GENETIC_PRODUCTION gRNA_b_gene_participant = gRNA_b_production.participations.create("gRNA_b_gene") gRNA_b_gene_participant.roles = sbol.SBO_PROMOTER gRNA_b_gene_participant.participant = gRNA_gene_fc.identity gRNA_b_participant = gRNA_b_production.participations.create("gRNA_b") gRNA_b_participant.roles = sbol.SBO_PRODUCT gRNA_b_participant.participant = gRNA_b_fc.identity gRNA_b_BFP_deg = CRPb_circuit.interactions.create("gRNA_b_BFP_deg") gRNA_b_BFP_deg.types = sbol.SBO_DEGRADATION gRNA_b_BFP_participant = gRNA_b_BFP_deg.participations.create("gRNA_b_BFP") gRNA_b_BFP_participant.roles = sbol.SBO_REACTANT gRNA_b_BFP_participant.participant = gRNA_b_fc.identity Template_Module = CRPb_circuit.modules.create("CRISPR_Template") Template_Module.definition = CRISPR_Template.identity gRNA_b_map = Template_Module.mapsTos.create("gRNA_b_map") gRNA_b_map.refinement = sbol.SBOL_REFINEMENT_USE_LOCAL gRNA_b_map.local = gRNA_b_fc.identity gRNA_b_map.remote = gRNA_gene_fc.identity gRNA_b_map.name = "Hnelo" results = doc.write("CRISPR_example_short_2.xml") print(results)
def __init__(self, *, namespace: str, trace: ProvenanceTrace = None): # TODO: is it sufficient for homespace to be set at document init? setHomespace(namespace) self.doc = Document() super().__init__(trace)