Skip to content

Commit

Permalink
Merge pull request #15 from TheJacksonLaboratory/task/update-publicat…
Browse files Browse the repository at this point in the history
…ion-info-schema

Task/update publication info schema
  • Loading branch information
bergsalex authored Mar 22, 2024
2 parents c1c0999 + d508253 commit 5dde516
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 12 deletions.
4 changes: 2 additions & 2 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "geneweaver-core"
version = "0.9.0a7"
version = "0.9.0a8"
description = "The core of the Jax-Geneweaver Python library"
authors = ["Jax Computational Sciences <[email protected]>"]
readme = "README.md"
Expand All @@ -17,12 +17,12 @@ pydantic = { extras = ["dotenv"], version = "^1.10" }
openpyxl = "^3.1.2"
numpy = ">=1.22,<2"
pandas = ">=1.5,<3"
requests = "^2.31.0"

[tool.poetry.group.dev.dependencies]
pylint = "^2.15.4"
pytest = "^7.1.3"
pydocstyle = "^6.1.1"
requests = "^2.28.1"
pytest-cov = "^4.0.0"
geneweaver-testing = "^0.1.0"

Expand Down
4 changes: 4 additions & 0 deletions src/geneweaver/core/publication/pubmed.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ def get_publication(pubmed_id: str) -> PublicationInfo:

publication_fields = extract_fields(publication_xml)

publication_fields["pubmed_id"] = pubmed_id

return PublicationInfo(**publication_fields)


Expand Down Expand Up @@ -173,6 +175,8 @@ def extract_authors(publication_xml: ElementTree.XML) -> dict:
if not authors_are_complete(author_list_node):
authors.append("et al.")

authors = ", ".join(authors)

add_to_dict_if_not_none(publication_authors, "authors", authors)

return publication_authors
Expand Down
10 changes: 5 additions & 5 deletions src/geneweaver/core/schema/publication.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@
class PublicationInfo(BaseModel):
"""Publication upload schema (no ID)."""

pubmed_id: int
authors: str
title: str
abstract: str
abstract: str = ""
journal: Optional[str] = None
volume: Optional[str] = None
pages: str
month: str
year: int
pubmed_id: int
pages: Optional[str] = None
month: Optional[str] = None
year: Optional[int] = None


class Publication(PublicationInfo):
Expand Down
6 changes: 3 additions & 3 deletions tests/unit/publication/pubmed/test_extract_authors.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@
"<root><AuthorList CompleteYN='Y'><Author>"
"<ForeName>John</ForeName><LastName>Doe</LastName>"
"</Author></AuthorList></root>",
{"authors": ["John Doe"]},
{"authors": "John Doe"},
),
(
"<root><AuthorList CompleteYN='N'><Author>"
"<ForeName>John</ForeName><LastName>Doe</LastName>"
"</Author></AuthorList></root>",
{"authors": ["John Doe", "et al."]},
{"authors": "John Doe, et al."},
),
("<root></root>", {}),
(
Expand All @@ -31,7 +31,7 @@
"</Author><Author>"
"<ForeName>Jane</ForeName><LastName>Doe</LastName>"
"</Author></AuthorList></root>",
{"authors": ["John Doe", "Jane Doe"]},
{"authors": "John Doe, Jane Doe"},
),
]

Expand Down

0 comments on commit 5dde516

Please sign in to comment.