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

Change constructor arg "name" to "identity" #135

Merged
merged 1 commit into from
Jan 13, 2021
Merged
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
8 changes: 4 additions & 4 deletions sbol3/attachment.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@

class Attachment(TopLevel):

def __init__(self, name: str, source: str,
def __init__(self, identity: str, source: str,
*, type_uri: str = SBOL_ATTACHMENT):
super().__init__(name, type_uri)
super().__init__(identity, type_uri)
self.source = URIProperty(self, SBOL_SOURCE, 1, 1,
initial_value=source)
self.format = URIProperty(self, SBOL_FORMAT, 0, 1)
Expand All @@ -22,9 +22,9 @@ def validate(self) -> None:
raise ValidationError(message)


def build_attachment(name: str, *, type_uri: str = SBOL_COMPONENT) -> SBOLObject:
def build_attachment(identity: str, *, type_uri: str = SBOL_COMPONENT) -> SBOLObject:
missing = PYSBOL3_MISSING
obj = Attachment(name, missing, type_uri=type_uri)
obj = Attachment(identity, missing, type_uri=type_uri)
# Remove the dummy values
obj._properties[SBOL_SOURCE] = []
return obj
Expand Down
12 changes: 6 additions & 6 deletions sbol3/collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,21 @@

class Collection(TopLevel):

def __init__(self, name: str, *, type_uri: str = SBOL_COLLECTION) -> None:
super().__init__(name, type_uri)
def __init__(self, identity: str, *, type_uri: str = SBOL_COLLECTION) -> None:
super().__init__(identity, type_uri)
self.members = ReferencedObject(self, SBOL_ORIENTATION, 0, math.inf)


class Namespace(Collection):

def __init__(self, name: str, *, type_uri: str = SBOL_NAMESPACE) -> None:
super().__init__(name, type_uri=type_uri)
def __init__(self, identity: str, *, type_uri: str = SBOL_NAMESPACE) -> None:
super().__init__(identity, type_uri=type_uri)


class Experiment(Collection):

def __init__(self, name: str, *, type_uri: str = SBOL_EXPERIMENT) -> None:
super().__init__(name, type_uri=type_uri)
def __init__(self, identity: str, *, type_uri: str = SBOL_EXPERIMENT) -> None:
super().__init__(identity, type_uri=type_uri)


Document.register_builder(SBOL_COLLECTION, Collection)
Expand Down
8 changes: 4 additions & 4 deletions sbol3/combderiv.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@

class CombinatorialDerivation(TopLevel):

def __init__(self, name: str, template: Union[Component, str],
def __init__(self, identity: str, template: Union[Component, str],
*, type_uri: str = SBOL_MODEL) -> None:
super().__init__(name, type_uri)
super().__init__(identity, type_uri)
self.strategy = URIProperty(self, SBOL_STRATEGY, 0, 1)
self.template = ReferencedObject(self, SBOL_TEMPLATE, 1, 1,
initial_value=template)
Expand All @@ -25,10 +25,10 @@ def validate(self) -> None:
raise ValidationError(f'{self.strategy} is not a valid strategy')


def build_combinatorial_derivation(name: str,
def build_combinatorial_derivation(identity: str,
*, type_uri: str = SBOL_COMBINATORIAL_DERIVATION):
template = PYSBOL3_MISSING
return CombinatorialDerivation(name, template, type_uri=type_uri)
return CombinatorialDerivation(identity, template, type_uri=type_uri)


Document.register_builder(SBOL_COMBINATORIAL_DERIVATION, build_combinatorial_derivation)
16 changes: 4 additions & 12 deletions sbol3/component.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,9 @@

class Component(TopLevel):

@staticmethod
def build_component(name: str, *, type_uri: str = SBOL_COMPONENT) -> SBOLObject:
missing = PYSBOL3_MISSING
obj = Component(name, [missing], type_uri=type_uri)
# Remove the dummy values
obj._properties[SBOL_TYPE] = []
return obj

def __init__(self, name: str, component_type: Union[List[str], str],
def __init__(self, identity: str, component_type: Union[List[str], str],
*, type_uri: str = SBOL_COMPONENT):
super().__init__(name, type_uri)
super().__init__(identity, type_uri)
if isinstance(component_type, str):
component_type = [component_type]
self.types: Union[List, Property] = URIProperty(self, SBOL_TYPE, 1, math.inf,
Expand Down Expand Up @@ -45,9 +37,9 @@ def validate(self) -> None:
self._validate_types()


def build_component(name: str, *, type_uri: str = SBOL_COMPONENT) -> SBOLObject:
def build_component(identity: str, *, type_uri: str = SBOL_COMPONENT) -> SBOLObject:
missing = PYSBOL3_MISSING
obj = Component(name, [missing], type_uri=type_uri)
obj = Component(identity, [missing], type_uri=type_uri)
# Remove the dummy values
obj._properties[SBOL_TYPE] = []
return obj
Expand Down
8 changes: 4 additions & 4 deletions sbol3/compref.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ class ComponentReference(Feature):

def __init__(self, in_child_of: Union[SubComponent, str],
feature: Union[Feature, str],
*, name: str = None,
*, identity: str = None,
type_uri: str = SBOL_COMPONENT_REFERENCE) -> None:
super().__init__(name, type_uri)
super().__init__(identity, type_uri)
self.in_child_of = ReferencedObject(self, SBOL_IN_CHILD_OF, 1, 1,
initial_value=in_child_of)
self.feature = ReferencedObject(self, SBOL_FEATURES, 1, 1,
Expand All @@ -29,10 +29,10 @@ def validate(self) -> None:
raise ValidationError(msg)


def build_component_reference(name: str, *,
def build_component_reference(identity: str, *,
type_uri: str = SBOL_COMPONENT_REFERENCE) -> SBOLObject:
missing = PYSBOL3_MISSING
obj = ComponentReference(missing, missing, name=name, type_uri=type_uri)
obj = ComponentReference(missing, missing, identity=identity, type_uri=type_uri)
# Remove the dummy values
obj._properties[SBOL_FEATURES] = []
obj._properties[SBOL_IN_CHILD_OF] = []
Expand Down
8 changes: 4 additions & 4 deletions sbol3/constraint.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
class Constraint(Identified):

def __init__(self, restriction: str, subject: Union[Identified, str],
object: Union[Identified, str], *, name: Optional[str] = None,
object: Union[Identified, str], *, identity: Optional[str] = None,
type_uri: str = SBOL_CONSTRAINT) -> None:
super().__init__(name, type_uri)
super().__init__(identity, type_uri)
self.restriction = URIProperty(self, SBOL_RESTRICTION, 1, 1,
initial_value=restriction)
self.subject = ReferencedObject(self, SBOL_SUBJECT, 1, 1,
Expand All @@ -27,9 +27,9 @@ def validate(self) -> None:
raise ValidationError('Constraint must have an object')


def build_constraint(name: str, type_uri: str = SBOL_CONSTRAINT) -> SBOLObject:
def build_constraint(identity: str, type_uri: str = SBOL_CONSTRAINT) -> SBOLObject:
missing = PYSBOL3_MISSING
obj = Constraint(missing, missing, missing, name=name, type_uri=type_uri)
obj = Constraint(missing, missing, missing, identity=identity, type_uri=type_uri)
obj._properties[SBOL_RESTRICTION] = []
obj._properties[SBOL_SUBJECT] = []
obj._properties[SBOL_OBJECT] = []
Expand Down
8 changes: 4 additions & 4 deletions sbol3/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@

class CustomIdentified(Identified):

def __init__(self, type_uri: str = None, *, name: str = None,
def __init__(self, type_uri: str = None, *, identity: str = None,
sbol_type_uri: str = SBOL_IDENTIFIED) -> None:
super().__init__(name, type_uri)
super().__init__(identity, type_uri)
self.rdf_type = URIProperty(self, rdflib.RDF.type, 1, 1,
initial_value=sbol_type_uri)

Expand All @@ -19,9 +19,9 @@ def validate(self) -> None:

class CustomTopLevel(TopLevel):

def __init__(self, name: str = None, type_uri: str = None,
def __init__(self, identity: str = None, type_uri: str = None,
*, sbol_type_uri: str = SBOL_TOP_LEVEL) -> None:
super().__init__(name, type_uri)
super().__init__(identity, type_uri)
self.rdf_type = URIProperty(self, rdflib.RDF.type, 1, 1,
initial_value=sbol_type_uri)

Expand Down
6 changes: 3 additions & 3 deletions sbol3/document.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def _make_custom_object(self, identity: str, types: List[str]) -> Identified:
except KeyError:
logging.warning(f'No builder found for {other_type}')
builder = CustomIdentified
return builder(name=identity, type_uri=other_type)
return builder(identity=identity, type_uri=other_type)
elif SBOL_TOP_LEVEL in types:
types.remove(SBOL_TOP_LEVEL)
try:
Expand All @@ -69,7 +69,7 @@ def _make_custom_object(self, identity: str, types: List[str]) -> Identified:
except KeyError:
logging.warning(f'No builder found for {other_type}')
builder = CustomTopLevel
return builder(name=identity, type_uri=other_type)
return builder(identity=identity, type_uri=other_type)
else:
message = 'Custom types must contain either Identified or TopLevel'
raise ValidationError(message)
Expand Down Expand Up @@ -97,7 +97,7 @@ def _parse_objects(self, graph: rdflib.Graph) -> Dict[str, SBOLObject]:
except KeyError:
logging.warning(f'No builder found for {type_uri}')
raise ValidationError(f'Unknown type {type_uri}')
obj = builder(name=identity, type_uri=type_uri)
obj = builder(identity=identity, type_uri=type_uri)
elif len(types) == 2:
obj = self._make_custom_object(identity, types)
else:
Expand Down
4 changes: 2 additions & 2 deletions sbol3/expdata.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

class ExperimentalData(TopLevel):

def __init__(self, name: str, *, type_uri: str = SBOL_EXPERIMENTAL_DATA):
super().__init__(name, type_uri)
def __init__(self, identity: str, *, type_uri: str = SBOL_EXPERIMENTAL_DATA):
super().__init__(identity, type_uri)


Document.register_builder(SBOL_EXPERIMENTAL_DATA, ExperimentalData)
8 changes: 4 additions & 4 deletions sbol3/extdef.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ class ExternallyDefined(Feature):
"""

def __init__(self, types: List[str], definition: str,
*, name: str = None,
*, identity: str = None,
type_uri: str = SBOL_EXTERNALLY_DEFINED):
super().__init__(name, type_uri)
super().__init__(identity, type_uri)
self.types: uri_list = URIProperty(self, SBOL_TYPE, 1, math.inf,
initial_value=types)
self.definition: uri_singleton = URIProperty(self, SBOL_DEFINITION, 1, 1,
Expand All @@ -31,10 +31,10 @@ def validate(self):
raise ValidationError('ExternallyDefined must have a definition')


def build_externally_defined(name: str,
def build_externally_defined(identity: str,
*, type_uri: str = SBOL_EXTERNALLY_DEFINED) -> SBOLObject:
missing = PYSBOL3_MISSING
obj = ExternallyDefined([missing], missing, name=name, type_uri=type_uri)
obj = ExternallyDefined([missing], missing, identity=identity, type_uri=type_uri)
# Remove the dummy values
obj._properties[SBOL_TYPE] = []
obj._properties[SBOL_DEFINITION] = []
Expand Down
4 changes: 2 additions & 2 deletions sbol3/feature.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
class Feature(Identified, abc.ABC):
"""Feature is an abstract base class."""

def __init__(self, name: str, type_uri: str) -> None:
super().__init__(name, type_uri)
def __init__(self, identity: str, type_uri: str) -> None:
super().__init__(identity, type_uri)
self.roles = URIProperty(self, SBOL_ROLE, 0, math.inf)
self.orientation = URIProperty(self, SBOL_ORIENTATION, 0, 1)

Expand Down
4 changes: 2 additions & 2 deletions sbol3/identified.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@

class Identified(SBOLObject):

def __init__(self, name: str, type_uri: str) -> None:
super().__init__(name, type_uri)
def __init__(self, identity: str, type_uri: str) -> None:
super().__init__(identity, type_uri)
self._display_id = TextProperty(self, SBOL_DISPLAY_ID, 0, 1)
self.name = TextProperty(self, SBOL_NAME, 0, 1)
self.description = TextProperty(self, SBOL_DESCRIPTION, 0, 1)
Expand Down
4 changes: 2 additions & 2 deletions sbol3/implementation.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

class Implementation(TopLevel):

def __init__(self, name: str, *, type_uri: str = SBOL_IMPLEMENTATION) -> None:
super().__init__(name, type_uri)
def __init__(self, identity: str, *, type_uri: str = SBOL_IMPLEMENTATION) -> None:
super().__init__(identity, type_uri)
self.built = ReferencedObject(self, SBOL_BUILT, 0, 1)
self.validate()

Expand Down
8 changes: 4 additions & 4 deletions sbol3/interaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
class Interaction(Identified):

def __init__(self, interaction_types: List[str],
*, name: str = None,
*, identity: str = None,
type_uri: str = SBOL_INTERACTION) -> None:
super().__init__(name, type_uri)
super().__init__(identity, type_uri)
self.types = URIProperty(self, SBOL_TYPE, 1, math.inf,
initial_value=interaction_types)
self.participations = OwnedObject(self, SBOL_PARTICIPATIONS, 0, math.inf,
Expand All @@ -19,9 +19,9 @@ def validate(self) -> None:
super().validate()


def build_interaction(name: str, *, type_uri: str = SBOL_INTERACTION) -> SBOLObject:
def build_interaction(identity: str, *, type_uri: str = SBOL_INTERACTION) -> SBOLObject:
interaction_type = PYSBOL3_MISSING
obj = Interaction([interaction_type], name=name, type_uri=type_uri)
obj = Interaction([interaction_type], identity=identity, type_uri=type_uri)
# Remove the dummy type
obj._properties[SBOL_TYPE] = []
return obj
Expand Down
8 changes: 4 additions & 4 deletions sbol3/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@

class Interface(Identified):

def __init__(self, *, name: str = None,
def __init__(self, *, identity: str = None,
type_uri: str = SBOL_INTERFACE) -> None:
super().__init__(name, type_uri)
super().__init__(identity, type_uri)
self.input = ReferencedObject(self, SBOL_INPUT, 0, math.inf)
self.output = ReferencedObject(self, SBOL_OUTPUT, 0, math.inf)
self.non_directional = ReferencedObject(self, SBOL_NON_DIRECTIONAL, 0, math.inf)
Expand All @@ -17,8 +17,8 @@ def validate(self) -> None:
super().validate()


def build_interface(name: str, *, type_uri: str = SBOL_INTERFACE) -> SBOLObject:
return Interface(name=name, type_uri=type_uri)
def build_interface(identity: str, *, type_uri: str = SBOL_INTERFACE) -> SBOLObject:
return Interface(identity=identity, type_uri=type_uri)


Document.register_builder(SBOL_INTERFACE, build_interface)
8 changes: 4 additions & 4 deletions sbol3/localsub.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
class LocalSubComponent(Feature):

def __init__(self, types: List[str],
*, name: str = None,
*, identity: str = None,
type_uri: str = SBOL_LOCAL_SUBCOMPONENT) -> None:
super().__init__(name, type_uri)
super().__init__(identity, type_uri)
self.types: uri_list = URIProperty(self, SBOL_TYPE, 1, math.inf,
initial_value=types)
self.locations = OwnedObject(self, SBOL_LOCATION, 0, math.inf,
Expand All @@ -24,10 +24,10 @@ def validate(self):
raise ValidationError('LocalSubComponent must have at least 1 type')


def build_local_subcomponent(name: str,
def build_local_subcomponent(identity: str,
*, type_uri: str = SBOL_LOCAL_SUBCOMPONENT) -> SBOLObject:
missing = PYSBOL3_MISSING
obj = LocalSubComponent([missing], name=name, type_uri=type_uri)
obj = LocalSubComponent([missing], identity=identity, type_uri=type_uri)
# Remove the dummy values
obj._properties[SBOL_TYPE] = []
return obj
Expand Down
Loading