def test_assemble(self):
        doc = sbol2.Document()
        gene = sbol2.ComponentDefinition("BB0001")
        promoter = sbol2.ComponentDefinition("R0010")
        RBS = sbol2.ComponentDefinition("B0032")
        CDS = sbol2.ComponentDefinition("E0040")
        terminator = sbol2.ComponentDefinition("B0012")

        promoter.sequence = sbol2.Sequence('R0010')
        RBS.sequence = sbol2.Sequence('B0032')
        CDS.sequence = sbol2.Sequence('E0040')
        terminator.sequence = sbol2.Sequence('B0012')

        promoter.sequence.elements = 'a'
        RBS.sequence.elements = 't'
        CDS.sequence.elements = 'c'
        terminator.sequence.elements = 'g'

        promoter.roles = sbol2.SO_PROMOTER
        RBS.roles = sbol2.SO_RBS
        CDS.roles = sbol2.SO_CDS
        terminator.roles = sbol2.SO_TERMINATOR

        doc.addComponentDefinition([gene, promoter, RBS, CDS, terminator])
        gene.assemblePrimaryStructure(['R0010', 'B0032', 'E0040', 'B0012'])
        primary_structure = gene.getPrimaryStructure()
        primary_structure = [c.identity for c in primary_structure]

        self.assertEqual(primary_structure, [
            promoter.identity, RBS.identity, CDS.identity, terminator.identity
        ])
    def test_standard_assembly(self):
        doc = sbol2.Document()
        gene = sbol2.ComponentDefinition("BB0001")
        promoter = sbol2.ComponentDefinition("R0010")
        RBS = sbol2.ComponentDefinition("B0032")
        CDS = sbol2.ComponentDefinition("E0040")
        terminator = sbol2.ComponentDefinition("B0012")

        promoter.sequence = sbol2.Sequence('R0010')
        RBS.sequence = sbol2.Sequence('B0032')
        CDS.sequence = sbol2.Sequence('E0040')
        terminator.sequence = sbol2.Sequence('B0012')

        promoter.sequence.elements = 'a'
        RBS.sequence.elements = 't'
        CDS.sequence.elements = 'c'
        terminator.sequence.elements = 'g'

        promoter.roles = sbol2.SO_PROMOTER
        RBS.roles = sbol2.SO_RBS
        CDS.roles = sbol2.SO_CDS
        terminator.roles = sbol2.SO_TERMINATOR

        doc.addComponentDefinition(gene)
        gene.assemblePrimaryStructure([promoter, RBS, CDS, terminator],
                                      sbol2.IGEM_STANDARD_ASSEMBLY)
        target_seq = gene.compile()

        self.assertEqual(target_seq, 'atactagagttactagctactagagg')
    def test_assemble_with_displayIds(self):
        sbol2.Config.setOption(sbol2.ConfigOptions.SBOL_TYPED_URIS, True)

        doc = sbol2.Document()
        gene = sbol2.ComponentDefinition("BB0001")
        promoter = sbol2.ComponentDefinition("R0010")
        RBS = sbol2.ComponentDefinition("B0032")
        CDS = sbol2.ComponentDefinition("E0040")
        terminator = sbol2.ComponentDefinition("B0012")

        promoter.sequence = sbol2.Sequence('R0010')
        RBS.sequence = sbol2.Sequence('B0032')
        CDS.sequence = sbol2.Sequence('E0040')
        terminator.sequence = sbol2.Sequence('B0012')

        promoter.sequence.elements = 'a'
        RBS.sequence.elements = 't'
        CDS.sequence.elements = 'c'
        terminator.sequence.elements = 'g'

        promoter.roles = sbol2.SO_PROMOTER
        RBS.roles = sbol2.SO_RBS
        CDS.roles = sbol2.SO_CDS
        terminator.roles = sbol2.SO_TERMINATOR

        doc.addComponentDefinition([gene, promoter, RBS, CDS, terminator])
        gene.assemblePrimaryStructure(['R0010', 'B0032', 'E0040', 'B0012'])
        primary_structure = gene.getPrimaryStructure()
        primary_structure = [c.identity for c in primary_structure]
        self.assertEqual(primary_structure, [
            promoter.identity, RBS.identity, CDS.identity, terminator.identity
        ])

        target_seq = gene.compile()
        self.assertEqual(target_seq, 'atcg')
 def test_recursive_compile(self):
     doc = sbol2.Document()
     cd1 = sbol2.ComponentDefinition('cd1')
     cd2 = sbol2.ComponentDefinition('cd2')
     cd3 = sbol2.ComponentDefinition('cd3')
     cd4 = sbol2.ComponentDefinition('cd4')
     cd5 = sbol2.ComponentDefinition('cd5')
     cd1.sequence = sbol2.Sequence('cd1')
     cd2.sequence = sbol2.Sequence('cd2')
     cd3.sequence = sbol2.Sequence('cd3')
     cd4.sequence = sbol2.Sequence('cd4')
     cd5.sequence = sbol2.Sequence('cd5')
     cd1.sequence.elements = 'tt'
     cd2.sequence.elements = 'gg'
     cd3.sequence.elements = 'n'
     cd4.sequence.elements = 'aa'
     cd5.sequence.elements = 'n'
     doc.addComponentDefinition([cd1, cd2, cd3, cd4, cd5])
     cd3.assemblePrimaryStructure([cd1, cd2])
     cd5.assemblePrimaryStructure([cd4, cd3])
     cd5.compile()
     self.assertEqual(cd3.sequence.elements, 'ttgg')
     self.assertEqual(cd5.sequence.elements, 'aattgg')
     r1 = cd3.sequenceAnnotations['cd1_annotation_0'].\
         locations['cd1_annotation_0_range']
     r2 = cd3.sequenceAnnotations['cd2_annotation_0'].\
         locations['cd2_annotation_0_range']
     r4 = cd5.sequenceAnnotations['cd4_annotation_0'].\
         locations['cd4_annotation_0_range']
     self.assertEqual(r1.start, 3)
     self.assertEqual(r1.end, 4)
     self.assertEqual(r2.start, 5)
     self.assertEqual(r2.end, 6)
     self.assertEqual(r4.start, 1)
     self.assertEqual(r4.end, 2)
    def subcomponents(self):
        # if type is compdef do one thing, if combdev do another, else error
        if isinstance(self.obj, sbol2.componentdefinition.ComponentDefinition):
            self.obj.assemblePrimaryStructure(self.cell_val)
            self.obj.compile(assembly_method=None)

        elif isinstance(self.obj,
                        sbol2.combinatorialderivation.CombinatorialDerivation):
            comp_list = self.cell_val
            comp_ind = 0
            variant_comps = {}
            for ind, comp in enumerate(comp_list):
                if "," in comp:
                    comp_list[
                        ind] = f'{self.obj.displayId}_subcomponent_{comp_ind}'
                    uri = f'{self.obj.displayId}_subcomponent_{comp_ind}'
                    sub_comp = sbol2.ComponentDefinition(uri)
                    sub_comp.displayId = f'{self.obj.displayId}_subcomponent_{comp_ind}'
                    self.doc.add(sub_comp)
                    variant_comps[f'subcomponent_{comp_ind}'] = {
                        'object': sub_comp,
                        'variant_list': comp
                    }
                    comp_ind += 1

            template = sbol2.ComponentDefinition(
                f'{self.obj.displayId}_template')
            template.displayId = f'{self.obj.displayId}_template'
            self.doc.add(template)

            template.assemblePrimaryStructure(comp_list)
            template.compile(assembly_method=None)

            self.obj.masterTemplate = template
            for var in variant_comps:
                var_comp = sbol2.VariableComponent(f'var_{var}')
                var_comp.displayId = f'var_{var}'
                var_comp.variable = variant_comps[var]['object']

                var_list = re.split(",", variant_comps[var]['variant_list'])
                var_list = [
                    f'{sbol2.getHomespace()}{x.strip()}' for x in var_list
                ]
                var_comp.variants = var_list
                self.obj.variableComponents.add(var_comp)

        else:
            raise KeyError(
                f'The object type "{type(self.obj)}" does not allow subcomponents. (sheet:{self.sheet}, row:{self.sht_row}, col:{self.sht_col})'
            )
 def testCut(self):
     cd = sbol2.ComponentDefinition('cd')
     sa = cd.sequenceAnnotations.create('sa')
     c = sa.locations.createCut('c')
     self.assertEqual(type(c), sbol2.Cut)
     c = sa.locations['c']
     self.assertEqual(type(c), sbol2.Cut)
Esempio n. 7
0
    def test_import_into_typed_namespace_from_nontyped_namespace(self):

        # Copy an sbol-typed URI to a non-typed, sbol-compliant URI
        sbol.setHomespace('http://examples.org')
        sbol.Config.setOption(sbol2.ConfigOptions.SBOL_TYPED_URIS, False)
        sbol.Config.setOption(sbol2.ConfigOptions.SBOL_COMPLIANT_URIS, True)

        doc = sbol.Document()
        comp = sbol.ComponentDefinition('cd')
        seq = sbol.Sequence('seq')
        comp.sequences = seq.identity
        doc.addComponentDefinition(comp)
        doc.addSequence(seq)

        # Import the object into the new namespace
        sbol.Config.setOption(sbol2.ConfigOptions.SBOL_TYPED_URIS, True)
        old_homespace = sbol.getHomespace()
        sbol.setHomespace('http://acme.com')
        comp_copy = comp.copy(None, old_homespace)

        # Verify new namespace was correctly substituted and type token was successfully
        # added
        self.assertEqual(comp_copy.identity,
                         'http://acme.com/ComponentDefinition/cd/1')
        self.assertEqual(comp_copy.persistentIdentity,
                         'http://acme.com/ComponentDefinition/cd')
        self.assertEqual(comp_copy.sequences[0],
                         'http://acme.com/Sequence/seq/1')

        # Verify wasDerivedFrom relationship
        self.assertEqual(comp_copy.wasDerivedFrom[0], comp.identity)
Esempio n. 8
0
def sbol_component():
    # invoked once per test function
    comp_nm = 'test_comp_name'
    sbol2.Config.setOption('sbol_typed_uris', False)
    comp = sbol2.ComponentDefinition(comp_nm, sbol2.BIOPAX_DNA)
    comp.name = comp_nm
    yield comp
Esempio n. 9
0
 def test_five_arg_constructor_values(self):
     cd = sbol2.ComponentDefinition()
     type_uri = 'http://example.com/test#testText'
     initial_value = ['alpha', 'bravo', 'charlie']
     prop = sbol2.TextProperty(cd, type_uri, '0', '*', initial_value)
     self.assertEqual(initial_value, prop.value)
     self.assertEqual([], prop._validation_rules)
Esempio n. 10
0
 def test_six_arg_constructor_none(self):
     cd = sbol2.ComponentDefinition()
     type_uri = 'http://example.com/test#testText'
     initial_value = 'omega'
     prop = sbol2.TextProperty(cd, type_uri, '0', '1', None, initial_value)
     self.assertEqual(initial_value, prop.value)
     self.assertEqual([], prop._validation_rules)
Esempio n. 11
0
    def test_add_extension_object(self):
        # We need to construct and add an extension object
        # It should then be accessible via getExtensionObject
        # We can also peel back the curtain and make sure the object
        #  is in doc.SBOLObjects and the URI is not in doc.OwnedObjects
        # Three kinds of things to add:
        #  1. An existing type, like ComponentDefinition
        cd = sbol2.ComponentDefinition('cd')
        doc = sbol2.Document()
        doc.addExtensionObject(cd)
        self.assertEqual(1, len(doc.componentDefinitions))
        obj = doc.getExtensionObject(cd.identity)
        self.assertEqual(cd, obj)

        #  2. A new type that is a TopLevel
        tle = TopLevelExtension('tle')
        doc = sbol2.Document()
        doc.addExtensionObject(tle)
        obj = doc.getExtensionObject(tle.identity)
        self.assertEqual(tle, obj)

        #  3. A new type that is not a TopLevel
        # This object won't be found. There is no way for the document to
        # hold on to the object if it isn't a TopLevel
        ntle = NonTopLevelExtension('ntle')
        doc = sbol2.Document()
        doc.addExtensionObject(ntle)
        with self.assertRaises(sbol2.SBOLError) as cm:
            doc.getExtensionObject(ntle.identity)
        raised = cm.exception
        self.assertEqual(sbol2.SBOLErrorCode.SBOL_ERROR_NOT_FOUND,
                         raised.error_code())
        obj = doc.find(ntle.identity)
        self.assertIsNone(obj)
Esempio n. 12
0
    def test_import_object_into_new_namespace(self):
        # When copying an object into a new namespace, confirm that it's URI is copied
        # into the new namespace. Also confirm that any ReferencedObject attributes
        # whose values point to an object in the old namespace are also copied into the
        # new namespace
        sbol.setHomespace('http://examples.org')
        sbol.Config.setOption(sbol2.ConfigOptions.SBOL_COMPLIANT_URIS, True)
        sbol.Config.setOption(sbol2.ConfigOptions.SBOL_TYPED_URIS, False)
        doc = sbol.Document()
        comp = sbol.ComponentDefinition('cd')
        seq = sbol.Sequence('seq')
        doc.addComponentDefinition(comp)
        doc.addSequence(seq)
        comp.sequences = seq.identity

        # Import from old homespace into new homespace
        old_homespace = sbol.getHomespace()
        sbol.setHomespace('http://acme.com')
        comp_copy = comp.copy(None, old_homespace)

        # Verify new namespace was correctly substituted
        self.assertEqual(comp_copy.identity, 'http://acme.com/cd/1')
        self.assertEqual(comp_copy.persistentIdentity, 'http://acme.com/cd')
        self.assertEqual(comp_copy.sequences[0], 'http://acme.com/seq/1')

        # Verify wasDerivedFrom relationship
        self.assertEqual(comp_copy.wasDerivedFrom[0], comp.identity)

        # Ensure these are equal under the covers
        self.assertEqual(type(comp.properties[sbol.SBOL_SEQUENCE_PROPERTY][0]),
                         rdflib.URIRef)
        self.assertEqual(type(comp.properties[sbol.SBOL_SEQUENCE_PROPERTY][0]),
                         type(comp_copy.properties[sbol.SBOL_SEQUENCE_PROPERTY][0]))
Esempio n. 13
0
 def test_six_arg_constructor(self):
     cd = sbol2.ComponentDefinition()
     type_uri = 'http://example.com/test#testInt'
     initial_value = 32
     prop = sbol2.IntProperty(cd, type_uri, '0', '1', [], initial_value)
     self.assertEqual(initial_value, prop.value)
     self.assertEqual([], prop._validation_rules)
Esempio n. 14
0
 def test_five_arg_constructor_validators(self):
     cd = sbol2.ComponentDefinition()
     type_uri = 'http://example.com/test#testText'
     validation_rules = [print]
     prop = sbol2.TextProperty(cd, type_uri, '0', '*', validation_rules)
     self.assertEqual([], prop.value)
     self.assertEqual(validation_rules, prop._validation_rules)
Esempio n. 15
0
    def test_referenced_object(self):
        # Test referenced object property is initialized to correct types
        cd0 = sbol.ComponentDefinition('cd0')
        self.assertEqual(type(cd0.sequences), list)

        c = cd0.components.create('c')
        self.assertEqual(c.definition, None)

        # Test assignment
        cd1 = sbol.ComponentDefinition('cd1')
        c.definition = cd1.identity
        self.assertEqual(c.definition, cd1.identity)

        seq0a = sbol.Sequence('seq0a')
        seq0b = sbol.Sequence('seq0b')
        cd0.sequences = [seq0a.identity, seq0b.identity]
        self.assertEqual(cd0.sequences, [seq0a.identity, seq0b.identity])

        c.definition = cd1
        self.assertEqual(c.definition, cd1.identity)

        # Test conversion to URIRef
        c.definition = str(cd1.identity)
        self.assertEqual(type(c.definition), str)

        cd0.sequences = [str(seq0a.identity), str(seq0b.identity)]
        self.assertEqual([type(s) for s in cd0.sequences], [str, str])

        # Test unset
        c.definition = None
        self.assertEqual(c.definition, None)

        c.definition = cd1.identity
        c.definition = ''
        self.assertEqual(c.definition, None)

        cd0.sequences = []
        self.assertEqual(cd0.sequences, [])

        cd0.sequences = [seq0a.identity, seq0b.identity]
        cd0.sequences = None
        self.assertEqual(cd0.sequences, [])

        with self.assertRaises(TypeError):
            cd0.sequences = [seq0a.identity, seq0b.identity]
            cd0.sequences = [None, None]
            self.assertEqual(cd0.sequences, [])
    def testPrimaryStructureIteration(self):
        list_cd = []
        list_cd_true = ["R0010", "E0040", "B0032", "B0012"]
        doc = sbol2.Document()
        gene = sbol2.ComponentDefinition("BB0001")
        promoter = sbol2.ComponentDefinition("R0010")
        rbs = sbol2.ComponentDefinition("B0032")
        cds = sbol2.ComponentDefinition("E0040")
        terminator = sbol2.ComponentDefinition("B0012")

        doc.addComponentDefinition([gene, promoter, rbs, cds, terminator])

        gene.assemblePrimaryStructure([promoter, rbs, cds, terminator])
        primary_sequence = gene.getPrimaryStructure()
        for component in primary_sequence:
            list_cd.append(component.displayId)
        self.assertCountEqual(list_cd, list_cd_true)
Esempio n. 17
0
 def test_duplicate_uri_no_doc(self):
     cd = sbol2.ComponentDefinition('cd')
     cd.sequenceAnnotations.create('sa')
     with self.assertRaises(sbol2.SBOLError) as cm:
         cd.sequenceAnnotations.create('sa')
     raised = cm.exception
     self.assertEqual(raised.error_code(),
                      sbol2.SBOLErrorCode.SBOL_ERROR_URI_NOT_UNIQUE)
Esempio n. 18
0
 def test_type(self):
     cd = sbol.ComponentDefinition('foo')
     expected = sbol.SBOL_COMPONENT_DEFINITION
     self.assertEqual(cd.type, expected)
     doc = sbol.Document()
     md = doc.moduleDefinitions.create('bar')
     expected = sbol.SBOL_MODULE_DEFINITION
     self.assertEqual(md.type, expected)
 def testRemoveComponentDefinition(self):
     test_CD = sbol2.ComponentDefinition("BB0001")
     doc = sbol2.Document()
     doc.addComponentDefinition(test_CD)
     doc.componentDefinitions.remove(0)
     # NOTE: changed the test to expect the 'sbol error type'
     # as opposed to a RuntimeError.
     with self.assertRaises(sbol2.SBOLError):
         doc.componentDefinitions.get("BB0001")
 def test_nonexistent_sequence(self):
     # If a ComponentDefinition is in a Document and has a URI in
     # sequences that is not in the document,
     # ComponentDefinition.sequence should return None.
     doc = sbol2.Document()
     cd = sbol2.ComponentDefinition('cd')
     doc.add(cd)
     cd.sequences = ['http://example.com/sbol2/sequence/1']
     self.assertIsNone(cd.sequence)
Esempio n. 21
0
 def test_lower_bound_math_inf(self):
     # test that math.inf can not be used as a lower bound
     cd = sbol.ComponentDefinition('cd')
     annotation_uri = rdflib.URIRef(
         'http://examples.org#annotation_property')
     with self.assertRaises(ValueError):
         cd.annotation = sbol.property.OwnedObject(cd, annotation_uri,
                                                   sbol.Identified,
                                                   math.inf, 1, None)
 def test_add_remove_type(self):
     cd = sbol2.ComponentDefinition('c1')
     self.assertEqual([sbol2.BIOPAX_DNA], cd.types)
     cd.addType(sbol2.BIOPAX_RNA)
     self.assertEqual([sbol2.BIOPAX_DNA, sbol2.BIOPAX_RNA], cd.types)
     cd.addType(sbol2.BIOPAX_COMPLEX)
     expected = [sbol2.BIOPAX_DNA, sbol2.BIOPAX_RNA, sbol2.BIOPAX_COMPLEX]
     self.assertEqual(expected, cd.types)
     cd.removeType(1)
     self.assertEqual([sbol2.BIOPAX_DNA, sbol2.BIOPAX_COMPLEX], cd.types)
Esempio n. 23
0
 def test_upper_bound_math_inf(self):
     # test that math.inf can be used as an upper bound
     cd = sbol.ComponentDefinition('cd')
     annotation_uri = rdflib.URIRef(
         'http://examples.org#annotation_property')
     cd.annotation = sbol.property.OwnedObject(cd, annotation_uri,
                                               sbol.Identified, 0, math.inf,
                                               None)
     # By getting here, the test has passed
     self.assertEqual(0, len(cd.annotation))
 def testAddComponentDefinition(self):
     sbol2.setHomespace('http://sbols.org/CRISPR_Example')
     sbol2.Config.setOption(sbol2.ConfigOptions.SBOL_COMPLIANT_URIS, True)
     sbol2.Config.setOption(sbol2.ConfigOptions.SBOL_TYPED_URIS, False)
     expected = 'BB0001'
     test_CD = sbol2.ComponentDefinition(expected)
     doc = sbol2.Document()
     doc.addComponentDefinition(test_CD)
     self.assertIsNotNone(doc.componentDefinitions.get(expected))
     displayId = doc.componentDefinitions.get(expected).displayId
     self.assertEqual(displayId, expected)
Esempio n. 25
0
 def test_owned_object_multiple(self):
     cd = sbol.ComponentDefinition('cd')
     annotation_uri = rdflib.URIRef(
         'http://examples.org#annotation_property')
     cd.annotations = sbol.property.OwnedObject(cd, annotation_uri,
                                                sbol.Identified, '0', '*',
                                                None)
     self.assertEqual(type(cd.annotations), sbol.property.OwnedObject)
     cd.annotations.add(sbol.Identified(uri='foo_0'))
     cd.annotations.add(sbol.Identified(uri='foo_1'))
     self.assertEqual(type(cd.annotations), sbol.property.OwnedObject)
Esempio n. 26
0
    def create_synbiohub_entry(self, sbol_type, sbol_type_map, display_id,
                               item_type, item_name, item_definition_uri,
                               item_lab_ids, item_lab_id_tag):

        document = sbol.Document()
        document.addNamespace('http://sd2e.org#', 'sd2')
        document.addNamespace('http://purl.org/dc/terms/', 'dcterms')
        document.addNamespace('http://www.w3.org/ns/prov#', 'prov')
        document.displayId = 'foo'
        document.version = '1'

        if sbol_type == 'component':
            if item_type == 'CHEBI':
                item_sbol_type = item_definition_uri
            else:
                item_sbol_type = sbol_type_map[item_type]

            component = sbol.ComponentDefinition(display_id, item_sbol_type)
            sbol.TextProperty(component, 'http://sd2e.org#stub_object', '0',
                              '1', 'true')
            self.set_item_properties(component, item_type, item_name,
                                     item_definition_uri, item_lab_ids,
                                     item_lab_id_tag)
            document.addComponentDefinition(component)
        elif sbol_type == 'module':
            module = sbol.ModuleDefinition(display_id)
            sbol.TextProperty(module, 'http://sd2e.org#stub_object', '0', '1',
                              'true')

            module.roles = sbol_type_map[item_type]
            self.set_item_properties(module, item_type, item_name,
                                     item_definition_uri, item_lab_ids,
                                     item_lab_id_tag)
            document.addModuleDefinition(module)
        elif sbol_type == 'external':
            top_level = sbol.TopLevel('http://sd2e.org/types/#attribute',
                                      display_id)
            self.set_item_properties(top_level, item_type, item_name,
                                     item_definition_uri, item_lab_ids,
                                     item_lab_id_tag)
            document.add(top_level)
        elif sbol_type == 'collection':
            collection = sbol.Collection(display_id)
            self.set_item_properties(collection, item_type, item_name,
                                     item_definition_uri, item_lab_ids,
                                     item_lab_id_tag)
            document.addCollection(collection)
        else:
            raise IntentParserException(
                'Failed to create a SynBioHub entry: %s as a supported sbol type in Intent Parser'
                % sbol_type)

        return document
 def test_add_remove_role(self):
     cd = sbol2.ComponentDefinition('c1')
     self.assertEqual([], cd.roles)
     cd.addRole(sbol2.SO_PROMOTER)
     self.assertEqual([sbol2.SO_PROMOTER], cd.roles)
     cd.addRole(sbol2.SO_MISC)
     self.assertEqual([sbol2.SO_PROMOTER, sbol2.SO_MISC], cd.roles)
     cd.addRole(sbol2.SO_CDS)
     self.assertEqual([sbol2.SO_PROMOTER, sbol2.SO_MISC, sbol2.SO_CDS],
                      cd.roles)
     cd.removeRole(1)
     self.assertEqual([sbol2.SO_PROMOTER, sbol2.SO_CDS], cd.roles)
Esempio n. 28
0
 def test_containers(self):
     # Note: Alphabetical Order
     x = sbol.Activity()
     x = sbol.CombinatorialDerivation()
     x = sbol.Component()
     x = sbol.ComponentDefinition()
     x = sbol.Document()
     x = sbol.Interaction()
     x = sbol.Module()
     x = sbol.ModuleDefinition()
     x = sbol.Participation()
     x = sbol.SequenceAnnotation()
    def testInsertDownstream(self):
        doc = sbol2.Document()
        gene = sbol2.ComponentDefinition("BB0001")
        promoter = sbol2.ComponentDefinition("R0010")
        rbs = sbol2.ComponentDefinition("B0032")
        cds = sbol2.ComponentDefinition("E0040")
        terminator = sbol2.ComponentDefinition("B0012")

        doc.addComponentDefinition([gene, promoter, rbs, cds, terminator])
        gene.assemblePrimaryStructure([promoter, rbs, cds])
        primary_structure_components = gene.getPrimaryStructureComponents()
        c_promoter = primary_structure_components[0]
        c_rbs = primary_structure_components[1]
        c_cds = primary_structure_components[2]
        gene.insertDownstreamComponent(c_cds, terminator)
        primary_structure = gene.getPrimaryStructure()
        primary_structure = [cd.identity for cd in primary_structure]
        valid_primary_structure = [
            promoter.identity, rbs.identity, cds.identity, terminator.identity
        ]
        self.assertListEqual(primary_structure, valid_primary_structure)
 def testOwnedLocation(self):
     cd = sbol2.ComponentDefinition('cd')
     sa = cd.sequenceAnnotations.create('sa')
     r = sa.locations.createRange('r')
     self.assertEqual(type(r), sbol2.Range)
     r = sa.locations['r']
     self.assertEqual(type(r), sbol2.Range)
     gl = sa.locations.createGenericLocation('gl')
     self.assertEqual(type(gl), sbol2.GenericLocation)
     gl = sa.locations['gl']
     self.assertEqual(type(gl), sbol2.GenericLocation)
     self.assertEqual(len(sa.locations), 2)