From fbd09d4da2476d07e8ddbd277251d308bed08af2 Mon Sep 17 00:00:00 2001 From: Alexander Berger Date: Thu, 21 Mar 2024 21:55:18 -0400 Subject: [PATCH 1/4] Making optional publication fields optional, updating pubmed publication info factory --- src/geneweaver/core/publication/pubmed.py | 4 ++++ src/geneweaver/core/schema/publication.py | 10 +++++----- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/geneweaver/core/publication/pubmed.py b/src/geneweaver/core/publication/pubmed.py index b5af933..1d92936 100644 --- a/src/geneweaver/core/publication/pubmed.py +++ b/src/geneweaver/core/publication/pubmed.py @@ -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) @@ -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 diff --git a/src/geneweaver/core/schema/publication.py b/src/geneweaver/core/schema/publication.py index c4194fa..8e1f903 100644 --- a/src/geneweaver/core/schema/publication.py +++ b/src/geneweaver/core/schema/publication.py @@ -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): From 4dd8f20c3369d153d069f497dc309fc1d11e23cf Mon Sep 17 00:00:00 2001 From: Alexander Berger Date: Thu, 21 Mar 2024 21:55:50 -0400 Subject: [PATCH 2/4] Making requests a core dependency --- poetry.lock | 4 ++-- pyproject.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/poetry.lock b/poetry.lock index cb81595..335eb5a 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1,4 +1,4 @@ -# This file is automatically @generated by Poetry 1.5.1 and should not be changed by hand. +# This file is automatically @generated by Poetry 1.8.2 and should not be changed by hand. [[package]] name = "astroid" @@ -1088,4 +1088,4 @@ files = [ [metadata] lock-version = "2.0" python-versions = "^3.9" -content-hash = "f480ccc7998b020887accecfd7b7ad74313ea258337f0b88ce53b7ae8284a400" +content-hash = "d0f2225c6035e97c4160aa42b10f62e3f715e90a971edd43e323744a3bb7bfbf" diff --git a/pyproject.toml b/pyproject.toml index e82d5d8..eabbe85 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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" From 516e7644ead728141269517ae9e057d47377cb85 Mon Sep 17 00:00:00 2001 From: Alexander Berger Date: Thu, 21 Mar 2024 21:56:56 -0400 Subject: [PATCH 3/4] Bumping version --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index eabbe85..b4e04a1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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 "] readme = "README.md" From d508253caf4edb4d60bb0193ce07abfd61fb713f Mon Sep 17 00:00:00 2001 From: Alexander Berger Date: Fri, 22 Mar 2024 09:29:10 -0400 Subject: [PATCH 4/4] Fixing tests and formatting --- src/geneweaver/core/publication/pubmed.py | 2 +- tests/unit/publication/pubmed/test_extract_authors.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/geneweaver/core/publication/pubmed.py b/src/geneweaver/core/publication/pubmed.py index 1d92936..a60a313 100644 --- a/src/geneweaver/core/publication/pubmed.py +++ b/src/geneweaver/core/publication/pubmed.py @@ -43,7 +43,7 @@ def get_publication(pubmed_id: str) -> PublicationInfo: publication_fields = extract_fields(publication_xml) - publication_fields['pubmed_id'] = pubmed_id + publication_fields["pubmed_id"] = pubmed_id return PublicationInfo(**publication_fields) diff --git a/tests/unit/publication/pubmed/test_extract_authors.py b/tests/unit/publication/pubmed/test_extract_authors.py index 2800e5c..6bb894e 100644 --- a/tests/unit/publication/pubmed/test_extract_authors.py +++ b/tests/unit/publication/pubmed/test_extract_authors.py @@ -16,13 +16,13 @@ "" "JohnDoe" "", - {"authors": ["John Doe"]}, + {"authors": "John Doe"}, ), ( "" "JohnDoe" "", - {"authors": ["John Doe", "et al."]}, + {"authors": "John Doe, et al."}, ), ("", {}), ( @@ -31,7 +31,7 @@ "" "JaneDoe" "", - {"authors": ["John Doe", "Jane Doe"]}, + {"authors": "John Doe, Jane Doe"}, ), ]