Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def get_uri(self, id):
if Config.getOption(ConfigOptions.VERBOSE.value) is True:
print('SBOL compliant URIs are set to ' + Config.getOption(ConfigOptions.SBOL_COMPLIANT_URIS.value))
print('SBOL typed URIs are set to ' + Config.getOption(ConfigOptions.SBOL_TYPED_URIS.value))
print('Searching for ' + id)
# Search this property's object store for the uri
object_store = self._sbol_owner.owned_objects[self._rdf_type]
for obj in object_store:
if id == obj.identity:
return obj
# If searching by the full URI fails, assume the user is searching
# for an SBOL-compliant URI using the displayId only
# Form compliant URI for child object
parent_obj = self._sbol_owner
resource_namespaces = []
resource_namespaces.append(getHomespace())
if parent_obj.doc is not None:
for ns in parent_obj.doc.resource_namespaces:
persistent_id_matches.append(obj)
# Sort objects with same persistentIdentity by version
# TODO is this right?
persistent_id_matches.sort(key=sort_version)
# If objects matching the persistentIdentity were found, return the most recent version
if len(persistent_id_matches) > 0:
return persistent_id_matches[-1]
# Assume the object is not TopLevel # TODO Not sure what this is for
if SBOL_PERSISTENT_IDENTITY in parent_obj.properties:
persistentIdentity = parent_obj.properties[SBOL_PERSISTENT_IDENTITY][0]
if SBOL_VERSION in parent_obj.properties:
version = parent_obj.properties[SBOL_VERSION][0]
compliant_uri = URIRef(os.path.join(persistentIdentity, uri, version))
else:
compliant_uri = URIRef(os.path.join(persistentIdentity, uri))
if Config.getOption(ConfigOptions.VERBOSE.value) is True:
print('Searching for non-TopLevel: ' + compliant_uri)
for obj in object_store:
if obj.identity == compliant_uri:
return obj
valid_options = {
ConfigOptions.SBOL_COMPLIANT_URIS.value: {True, False},
ConfigOptions.SBOL_TYPED_URIS.value: {True, False},
ConfigOptions.SERIALIZATION_FORMAT.value: {'sbol', 'rdfxml', 'json', 'ntriples'},
ConfigOptions.VALIDATE.value: {True, False},
ConfigOptions.LANGUAGE.value: {'SBOL2', 'FASTA', 'GenBank'},
ConfigOptions.TEST_EQUALITY.value: {True, False},
ConfigOptions.CHECK_URI_COMPLIANCE.value: {True, False},
ConfigOptions.CHECK_COMPLETENESS.value: {True, False},
ConfigOptions.CHECK_BEST_PRACTICES.value: {True, False},
ConfigOptions.FAIL_ON_FIRST_ERROR.value: {True, False},
ConfigOptions.PROVIDE_DETAILED_STACK_TRACE.value: {True, False},
ConfigOptions.INSERT_TYPE.value: {True, False},
ConfigOptions.RETURN_FILE.value: {True, False},
ConfigOptions.VERBOSE.value: {True, False}
}
extension_namespaces = {}
# The authoritative namespace for the Document. Setting the home namespace is like signing a piece of paper.
home = None
# Flag indicating whether an object's type is included in SBOL-compliant URIs.
SBOLCompliantTypes = 1
catch_exceptions = 0
file_format = 'rdfxml'
class Config:
"""A class which contains global configuration variables for the libSBOL environment.
Configuration variables are accessed through the setOptions and getOptions methods.