def test_compile_autoconstruct_sequence(self): # Ensure that autoconstruction of Sequence URIs works correctly with # different configuration options root_id = 'root' sub_id = 'sub' sbol2.Config.setOption(sbol2.ConfigOptions.SBOL_COMPLIANT_URIS, True) sbol2.Config.setOption(sbol2.ConfigOptions.SBOL_TYPED_URIS, True) doc = sbol2.Document() root = doc.componentDefinitions.create(root_id) sub = doc.componentDefinitions.create(sub_id) root.compile([sub]) expected_identity = sbol2.getHomespace( ) + '/Sequence/' + root_id + '/1' self.assertEqual(root.sequence.identity, expected_identity) sbol2.Config.setOption(sbol2.ConfigOptions.SBOL_COMPLIANT_URIS, True) sbol2.Config.setOption(sbol2.ConfigOptions.SBOL_TYPED_URIS, False) doc = sbol2.Document() root = doc.componentDefinitions.create(root_id) sub = doc.componentDefinitions.create(sub_id) root.compile([sub]) expected_identity = sbol2.getHomespace() + '/' + root_id + '_seq/1' self.assertEqual(root.sequence.identity, expected_identity) sbol2.Config.setOption(sbol2.ConfigOptions.SBOL_COMPLIANT_URIS, True) sbol2.Config.setOption(sbol2.ConfigOptions.SBOL_TYPED_URIS, True)
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)
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]))
def test_replace_namespace(self): sbol.setHomespace('http://wallacecorporation.com') old_namespace = 'http://tyrellcorporation.com' old_uri = rdflib.URIRef(old_namespace + '/foo') new_uri = sbol.identified.replace_namespace(old_uri, old_namespace, sbol.SBOL_COMPONENT_DEFINITION) self.assertEqual(type(new_uri), rdflib.URIRef) self.assertEqual(new_uri, rdflib.URIRef(sbol.getHomespace() + '/foo'))
def init_tutorial(self): # Set the default namespace (e.g. "http://my_namespace.org") namespace = "http://my_namespace.org" homespace = sbol2.setHomespace(namespace) # Test homespace self.assertIsNone(homespace) self.assertEqual(sbol2.getHomespace(), namespace) # Create a new SBOL document doc = sbol2.Document() # Test empty document self.assertIsInstance(doc, sbol2.Document) self.assertEqual(len(doc), 0) return doc
# import sbol3 import sbol2 # doc = sbol3.Document() # colec = sbol3.Collection('FinalProducts', name='FinalProducts') # doc.add(colec) # # print(sbol3.get_namespace()) # sbol_objs = doc.objects # sbol_objs_names = [x.name for x in sbol_objs] # if 'FinalProducts' not in sbol_objs_names: # colec = sbol3.Collection('FinalProducts', name='FinalProducts') # # colec.members.append('test') # doc.add(colec) # else: # colec = sbol_objs[sbol_objs_names.index('FinalProducts')] # colec.members.append('this') sbol2.CombinatorialDerivation() sbol2.ComponentDefinition() sbol2.getHomespace() sbol2.URIRef
default=True, help= 'Default submits DNA parts to SynBioHub staging server. Set to False to submit to SynBioHub production server.' ) args = arg_parser.parse_args() path_to_build_request = args.build_request_excel SBH_USER = args.sbh_username SBH_PASSWORD = args.sbh_password spoof_bool = args.spoof # Load and parse build request build_excel = pd.ExcelFile(path_to_build_request) build_request = pd.read_excel(build_excel, 'Design', index_col=0, header=None) ontology_terms = pd.read_excel(build_excel, 'Ontology Terms', index_col=0) # create parts Document parts_doc = make_parts_doc(build_request) # connect to SBH server and set Homespace sbh_server = sbh_login(SBH_USER, SBH_PASSWORD, spoof_bool, parts_doc) # parse build request and add parts to parts Document parse_parts_to_sbh(build_request, ontology_terms, parts_doc) # submit parts Document to SBH server sbh_server.submit(parts_doc, sbol.getHomespace(), 1)