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

Newest gocamgen fixes #532

Merged
merged 4 commits into from
Mar 9, 2021
Merged

Newest gocamgen fixes #532

merged 4 commits into from
Mar 9, 2021

Conversation

dustine32
Copy link
Collaborator

@dustine32 dustine32 commented Mar 3, 2021

@dustine32 dustine32 changed the title Gocamgen Newest gocamgen fixes Mar 3, 2021
dustine32 added a commit to geneontology/noctua-models that referenced this pull request Mar 3, 2021
kltm added a commit to geneontology/noctua-models that referenced this pull request Mar 4, 2021
self.line.append(entity)

def __str__(self):
return f"Header: {','.join(self.header)} - Line: {','.join(self.line)}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I find "string {} to format".format(foo) clearer, and you can name your arguments too: "string {foo} to format".format(foo=foo)

@@ -13,19 +11,39 @@
IPI_ECO_CODE = "ECO:0000353"


class GoAssocWithFrom:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Take a look at dataclasses like are used in the association.py module (where GoAssociation comes from). They're nice to write and read. Don't worry about fixing, but just something to look out for in the future.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, curious about what this class does/is for!

@@ -19,11 +19,11 @@
# GO:0003674-2 enabled_by WB:WBGene00001173-2
# Are there any "-"s in identifiers?


class AnnotationSubgraph(MultiDiGraph):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a design note, should AnnotationSubgraph actually be a MultiDiGraph? Like, are you going to place it in an exact context in which a MultiDiGraph will be used, taking advantage of the shared functionality (the fact that both classes have the same methods)? Or do clients/users/callers of AnnotationSubgraph actually need to know about the specific behaviors that are specialized for AnnotationSubGraph and the fact that you're using a MultiDiGraph is sort of an incendental implementation detail (for the caller)? Is AnnotationSubGraph just inheriting from MultiDiGraph out of convenience to obtain functionality of that class?

One way you can tell is if your added methods (here: add_instance_of_class) are not called by any overridden methods (here: add_edges). Do your added methods provide more interface that happen to rely on the fact that you have access to a MultiDiGraph? If your class has an instance of a MultiDiGraph as member variable, could you rewrite add_instance_of_class in terms of a member MultiDiGraph instead without any loss? Can you write your own sense of add_edge that specifies your extra relation more conretely, just forwarding what you need to an instance of MultiDiGraph?

I think in this case maybe so? This is where the "favor composition over inheritance" OOP rule comes in. Composition ends up being more flexible than inheriting generally. Inheritance is useful in only very specific situations. See: https://stackoverflow.com/questions/49002/prefer-composition-over-inheritance

Just food for thought! You don't have to change anything for your PR!

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great point! I think initially I had intended for a much more colorful class in AnnotationSubgraph, but I can just refactor to just keep a MultiDiGraph member variable and interact with it as needed.

@@ -37,7 +37,9 @@ def add_edge(self, u_for_edge, relation, v_for_edge, key=None, **attr):
# {'sparql_var': 'GO_0045944_1'}
# Returns the networkx graph node ID used in tracking instances
# Use this node ID to get instance IRI (once it's defined) and SPARQL variable name
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also just a note, these comments documenting the behavior of your method could be turned into doc comments inside the def of the method with the triple quotes:

"""
Doc String
"""

@dustine32 dustine32 merged commit 3599f9a into master Mar 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants