Skip to content

Commit

Permalink
Merge pull request #3 from TheJacksonLaboratory/G3-29-geneweaver-cli-…
Browse files Browse the repository at this point in the history
…client-excel-parsing-tool-2

Fixing enum str formatting and batch parsing of special cases
  • Loading branch information
bergsalex authored Dec 8, 2023
2 parents 90c40aa + f2f3085 commit 6426f87
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "geneweaver-core"
version = "0.8.0a0"
version = "0.8.0a1"
description = "The core of the Jax-Geneweaver Python library"
authors = ["Jax Computational Sciences <[email protected]>"]
readme = "README.md"
Expand Down
15 changes: 13 additions & 2 deletions src/geneweaver/core/enum.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ class GenesetScoreTypeStr(str, Enum):
CORRELATION = "correlation"
EFFECT = "effect"

def __str__(self) -> str:
"""Render as a string."""
return "-".join(part.capitalize() for part in self.name.split("_"))


class ScoreType(int, Enum):
"""Integer based Enum for the different types of geneset scores."""
Expand All @@ -31,6 +35,10 @@ class ScoreType(int, Enum):
CORRELATION = 4
EFFECT = 5

def __str__(self) -> str:
"""Render as a string."""
return "-".join(part.capitalize() for part in self.name.split("_"))


class GenesetAccess(str, Enum):
"""Enum for the different types of geneset access."""
Expand Down Expand Up @@ -72,7 +80,7 @@ class Species(int, Enum):

def __str__(self) -> str:
"""Render as a string."""
return self.name
return self.name.replace("_", " ").capitalize()


class GeneIdentifier(int, Enum):
Expand All @@ -97,6 +105,8 @@ class GeneIdentifier(int, Enum):

def __str__(self) -> str:
"""Render as a string."""
if len(self.name) > 4:
return " ".join(part.capitalize() for part in self.name.split("_"))
return self.name


Expand Down Expand Up @@ -151,4 +161,5 @@ class Microarray(int, Enum):

def __str__(self) -> str:
"""Render as a string."""
return self.name
formatted = " ".join(part.capitalize() for part in self.name.split("_"))
return f"microarray {formatted}"
4 changes: 4 additions & 0 deletions src/geneweaver/core/schema/batch.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,15 @@ def initialize_score(cls, v) -> GenesetScoreType:
"""Initialize score type."""
if isinstance(v, GenesetScoreType):
return v
elif isinstance(v, dict):
return GenesetScoreType(**v)
return parse_score(v)

@validator("private", pre=True)
def private_to_bool(cls, v) -> bool:
"""Convert private str to bool."""
if isinstance(v, bool):
return v
return v.lower() != "public"

@validator("curation_id", pre=True)
Expand Down

0 comments on commit 6426f87

Please sign in to comment.