From 1590bea8545d36e022a20f65d6eb0b1c17dd2fd9 Mon Sep 17 00:00:00 2001 From: Thomas Eidens Date: Thu, 14 Dec 2023 12:51:47 +0100 Subject: [PATCH] Updated /v2 api and spec --- api/eeb-openapi.v2.yml | 136 +++-- api/server/setup.py | 2 +- ...> refereed_preprint_details_controller.py} | 39 +- ...ing_services_and_publishers_controller.py} | 15 +- api/server/swagger_server/models/__init__.py | 3 +- api/server/swagger_server/models/author.py | 10 + .../models/inline_response200.py | 16 +- api/server/swagger_server/models/paper.py | 487 ----------------- .../models/publisher_description.py | 92 ++++ .../models/refereed_preprint.py | 513 ++++++++++++++++++ .../swagger_server/swagger/swagger.yaml | 322 +++++++---- ...t_refereed_preprint_details_controller.py} | 22 +- ...ing_services_and_publishers_controller.py} | 16 +- neoflask/cache_warm_up.py | 9 +- neoflask/queries.py | 137 ++++- 15 files changed, 1173 insertions(+), 646 deletions(-) rename api/server/swagger_server/controllers/{paper_details_controller.py => refereed_preprint_details_controller.py} (58%) rename api/server/swagger_server/controllers/{reviewing_services_controller.py => reviewing_services_and_publishers_controller.py} (50%) delete mode 100644 api/server/swagger_server/models/paper.py create mode 100644 api/server/swagger_server/models/publisher_description.py create mode 100644 api/server/swagger_server/models/refereed_preprint.py rename api/server/swagger_server/test/{test_paper_details_controller.py => test_refereed_preprint_details_controller.py} (57%) rename api/server/swagger_server/test/{test_reviewing_services_controller.py => test_reviewing_services_and_publishers_controller.py} (54%) diff --git a/api/eeb-openapi.v2.yml b/api/eeb-openapi.v2.yml index 1ae1d0a1..4c26be6f 100644 --- a/api/eeb-openapi.v2.yml +++ b/api/eeb-openapi.v2.yml @@ -3,7 +3,7 @@ openapi: 3.0.3 info: title: Early Evidence Base API version: 2.0.0 - description: Read-only API for the Early Evidence Base platform providing collections of papers by reviewing service, automagic, and auto topics, as well as details on papers by DOI. + description: Read-only API for the Early Evidence Base platform providing collections of refereed preprints by reviewing service, automagic, and auto topics, as well as details on refereed preprints by DOI. servers: - url: https://eeb.embo.org/api/v2 @@ -14,10 +14,10 @@ servers: description: Local development server tags: - - name: Reviewing Services - description: Endpoints related to retrieving information about reviewing services. - - name: Paper Details - description: Endpoints related to retrieving paper details. + - name: Reviewing Services and Publishers + description: Endpoints related to retrieving information about reviewing services and publishers. + - name: Refereed Preprint Details + description: Endpoints related to retrieving details about refereed preprints. paths: /reviewing_services/: @@ -33,11 +33,26 @@ paths: items: $ref: "#/components/schemas/ReviewingServiceDescription" tags: - - Reviewing Services + - Reviewing Services and Publishers + + /publishers/: + get: + summary: Get information about available publishers. + responses: + "200": + description: An array of publishers. + content: + application/json: + schema: + type: array + items: + $ref: "#/components/schemas/PublisherDescription" + tags: + - Reviewing Services and Publishers /papers/: get: - summary: Get paginated collections of papers, optionally filtered by reviewing service + summary: Get paginated collections of refereed preprints, optionally filtered by reviewing service parameters: - in: query name: reviewedBy @@ -45,12 +60,19 @@ paths: type: array items: type: string - description: The IDs of the reviewing services for which papers are requested. If specified, only papers that were reviewed by at least one of the specified reviewing services are returned. Is combined with the query parameter using a logical AND. If not specified, this filter is not applied. + description: The IDs of the reviewing services for which refereed preprints are requested. If specified, only refereed preprints that were reviewed by at least one of the specified reviewing services are returned. Is combined with the query and publishedIn parameters using a logical AND. If not specified, this filter is not applied. - in: query name: query schema: type: string - description: A search string to filter the results by. The search string is matched against the paper DOI, title, abstract, and authors. The search is case-insensitive and matches partial words (e.g. the search string "covid" would match "COVID-19"). Is combined with the reviewedBy parameter using a logical AND. If not specified, this filter is not applied. + description: A search string to filter the results by. The search string is matched against the refereed preprint DOI, title, abstract, and authors. The search is case-insensitive and matches partial words (e.g. the search string "covid" would match "COVID-19"). Is combined with the reviewedBy and publishedIn parameters using a logical AND. If not specified, this filter is not applied. + - in: query + name: publishedIn + schema: + type: array + items: + type: string + description: The journals to filter the results by. If specified, only refereed preprints that were published in at least one of the specified journals are returned. Is combined with the reviewedBy and query parameters using a logical AND. If not specified, this filter is not applied. - in: query name: page schema: @@ -78,7 +100,7 @@ paths: description: The direction to sort the results in. responses: "200": - description: An array of papers, filtered, sorted, and paged by the given parameters. + description: An array of refereed preprints, filtered, sorted, and paged by the given parameters. content: application/json: schema: @@ -87,7 +109,7 @@ paths: items: type: array items: - $ref: "#/components/schemas/Paper" + $ref: "#/components/schemas/RefereedPreprint" paging: $ref: "#/components/schemas/PagingInfo" "400": @@ -97,95 +119,129 @@ paths: schema: $ref: "#/components/schemas/Error" tags: - - Paper Details + - Refereed Preprint Details + + /paper/: + get: + summary: Get details about a refereed preprint by DOI or slug. + parameters: + - in: query + name: doi + schema: + type: string + format: doi + description: The DOI of the refereed preprint. Either the DOI or the slug parameter must be specified. + - in: query + name: slug + schema: + type: string + description: The slug of the refereed preprint. Either the DOI or the slug parameter must be specified. + responses: + "200": + description: The details of the refereed preprint. + content: + application/json: + schema: + $ref: "#/components/schemas/RefereedPreprint" + "400": + description: Bad request. The request parameters are invalid. The response body contains a JSON object with a detail property describing the error. + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + "404": + description: The refereed preprint with the given DOI or slug does not exist. + tags: + - Refereed Preprint Details components: schemas: - Paper: + RefereedPreprint: type: object properties: doi: type: string format: doi - description: The DOI of the paper. + description: The DOI of the refereed preprint. example: "10.1101/2020.05.22.111161" version: type: string - description: The version of the paper. + description: The version of the refereed preprint. example: "1.0" source: type: string - description: The source of the paper. Either "bioRxiv" or "medRxiv". + description: The source of the refereed preprint. Either "bioRxiv" or "medRxiv". example: "bioRxiv" journal: type: string - description: The journal the paper was published in. + description: The journal the refereed preprint was published in. example: "bioRxiv" title: type: string - description: The title of the paper. + description: The title of the refereed preprint. example: "A SARS-CoV-2 protein interaction map reveals targets for drug repurposing" abstract: type: string - description: The abstract of the paper. + description: The abstract of the refereed preprint. example: "The COVID-19 pandemic urgently needs..." journal_doi: type: string nullable: true format: doi - description: The DOI of the published version of this paper. Null if the paper has not been published. + description: The DOI of the published version of this refereed preprint. Null if the refereed preprint has not been published. example: "10.15252/embj.20105114" published_journal_title: type: string nullable: true - description: The title of the journal the paper was published in. Null if the paper has not been published. + description: The title of the journal the refereed preprint was published in. Null if the refereed preprint has not been published. example: "EMBO Journal" pub_date: type: string format: date-time - description: The date the paper was published. + description: The date the refereed preprint was published. example: "2020-05-22T00:00:00Z" authors: type: array items: $ref: "#/components/schemas/Author" - description: The authors of the paper. - revdate: - type: string - format: date-time - nullable: true - description: The date the paper was reviewed. Null if the paper has not been reviewed. + description: The authors of the refereed preprint. + review_dates: + type: array + items: + type: string + format: date-time + description: The dates the refereed preprint was reviewed on. entities: type: array items: type: string - description: The entities (e.g. genes, proteins, diseases) mentioned in the paper's figures. + description: The entities (e.g. genes, proteins, diseases) mentioned in the refereed preprint's figures. assays: type: array items: type: string - description: The assays (e.g. ELISA, PCR) mentioned in the paper's figures. + description: The assays (e.g. ELISA, PCR) mentioned in the refereed preprint's figures. main_topics: type: array items: type: array items: type: string - description: The main topics of the paper. + description: The main topics of the refereed preprint. highlighted_entities: type: array items: type: string - description: The highlighted entities (e.g. genes, proteins, diseases) mentioned in the paper's abstract. + description: The highlighted entities (e.g. genes, proteins, diseases) mentioned in the refereed preprint's abstract. slug: type: string - description: The slug of the paper. Can be used to construct a URL to the paper's page on the Early Evidence Base platform. + description: The slug of the refereed preprint. Can be used to construct a URL to the refereed preprint's page on the Early Evidence Base platform. example: "a-sars-cov-2-protein-interaction-map-reveals-targets-for-drug-repurposing" reviewed_by: type: array items: type: string - description: The IDs of the reviewing services that reviewed this paper. + description: The IDs of the reviewing services that reviewed this refereed preprint. example: ["review commons"] Author: @@ -215,6 +271,18 @@ components: description: The given names of the author. example: "Jane John" + PublisherDescription: + type: object + properties: + id: + type: string + description: The ID of the publisher. + example: "EMBO Molecular Medicine" + n_papers: + type: integer + description: The number of refereed preprints published by the publisher. + example: 10 + ReviewingServiceDescription: type: object properties: diff --git a/api/server/setup.py b/api/server/setup.py index 6fa57c18..367d736f 100644 --- a/api/server/setup.py +++ b/api/server/setup.py @@ -31,6 +31,6 @@ entry_points={ 'console_scripts': ['swagger_server=swagger_server.__main__:main']}, long_description="""\ - Read-only API for the Early Evidence Base platform providing collections of papers by reviewing service, automagic, and auto topics, as well as details on papers by DOI. + Read-only API for the Early Evidence Base platform providing collections of refereed preprints by reviewing service, automagic, and auto topics, as well as details on refereed preprints by DOI. """ ) diff --git a/api/server/swagger_server/controllers/paper_details_controller.py b/api/server/swagger_server/controllers/refereed_preprint_details_controller.py similarity index 58% rename from api/server/swagger_server/controllers/paper_details_controller.py rename to api/server/swagger_server/controllers/refereed_preprint_details_controller.py index 02f17cec..1dfe8275 100644 --- a/api/server/swagger_server/controllers/paper_details_controller.py +++ b/api/server/swagger_server/controllers/refereed_preprint_details_controller.py @@ -1,9 +1,30 @@ +from connexion import problem from math import ceil from neoflask.cache import cache -from neoflask.queries import REFEREED_PREPRINTS_V2 +from neoflask.queries import REFEREED_PREPRINTS_V2, REFEREED_PREPRINT_V2 from neotools import ask_neo from urllib.parse import urlencode + +@cache.memoize() # memoize handles function parameters, cached does not +def paper_get(doi=None, slug=None): # noqa: E501 + """Get details about a refereed preprint by DOI or slug. + + # noqa: E501 + + :param doi: The DOI of the refereed preprint. Either the DOI or the slug parameter must be specified. + :type doi: str + :param slug: The slug of the refereed preprint. Either the DOI or the slug parameter must be specified. + :type slug: str + + :rtype: RefereedPreprint + """ + if (not doi and not slug) or (doi and slug): + return problem(status=400, title="Bad Request", detail="Must specify either doi or slug") + result = ask_neo(REFEREED_PREPRINT_V2(), doi=doi, slug=slug) + return result[0]["refereed_preprint"] if result else None + + def _to_lucene_query(user_input): # remove double quotes and backslashes from user input to prevent injection escaped = user_input.replace('"', "").replace("\\", "") @@ -28,24 +49,27 @@ def papers_url(reviewed_by=None, query=None, page=None, per_page=None, sort_by=N query_params = urlencode(query_params_list) return f"{base_url}?{query_params}" + @cache.memoize() # memoize handles function parameters, .cached does not -def papers_get(reviewed_by=None, query=None, page=None, per_page=None, sort_by=None, sort_order=None): # noqa: E501 - """Get paginated collections of papers, optionally filtered by reviewing service +def papers_get(reviewed_by=None, query=None, published_in=None, page=None, per_page=None, sort_by=None, sort_order=None): # noqa: E501 + """Get paginated collections of refereed preprints, optionally filtered by reviewing service # noqa: E501 - :param reviewed_by: The IDs of the reviewing services for which papers are requested. + :param reviewed_by: The IDs of the reviewing services for which refereed preprints are requested. If specified, only refereed preprints that were reviewed by at least one of the specified reviewing services are returned. Is combined with the query and publishedIn parameters using a logical AND. If not specified, this filter is not applied. :type reviewed_by: List[str] - :param query: A search string to filter the results by. + :param query: A search string to filter the results by. The search string is matched against the refereed preprint DOI, title, abstract, and authors. The search is case-insensitive and matches partial words (e.g. the search string \"covid\" would match \"COVID-19\"). Is combined with the reviewedBy and publishedIn parameters using a logical AND. If not specified, this filter is not applied. :type query: str + :param published_in: The journals to filter the results by. If specified, only refereed preprints that were published in at least one of the specified journals are returned. Is combined with the reviewedBy and query parameters using a logical AND. If not specified, this filter is not applied. + :type published_in: List[str] :param page: The page number of the results to retrieve. The first page is 1. :type page: int :param per_page: The number of results to return per page. :type per_page: int :param sort_by: The field to sort the results by. - :type sort_by: str + :type sort_by: dict | bytes :param sort_order: The direction to sort the results in. - :type sort_order: str + :type sort_order: dict | bytes :rtype: InlineResponse200 """ @@ -59,6 +83,7 @@ def papers_get(reviewed_by=None, query=None, page=None, per_page=None, sort_by=N db_params = dict( reviewed_by=reviewed_by, # parameterized in database query, no need to escape lucene_query=lucene_query, # user input is escaped in _to_lucene_query() + published_in=published_in, # parameterized in database query, no need to escape page=db_page, # converted from 1- to 0-indexed above per_page=per_page, # already validated, and can be passed through sort_by=db_sort_by, diff --git a/api/server/swagger_server/controllers/reviewing_services_controller.py b/api/server/swagger_server/controllers/reviewing_services_and_publishers_controller.py similarity index 50% rename from api/server/swagger_server/controllers/reviewing_services_controller.py rename to api/server/swagger_server/controllers/reviewing_services_and_publishers_controller.py index 34e86da4..6dab3c08 100644 --- a/api/server/swagger_server/controllers/reviewing_services_controller.py +++ b/api/server/swagger_server/controllers/reviewing_services_and_publishers_controller.py @@ -1,7 +1,20 @@ from neoflask.cache import cache -from neoflask.queries import DESCRIBE_REVIEWING_SERVICES_V2 +from neoflask.queries import DESCRIBE_PUBLISHERS, DESCRIBE_REVIEWING_SERVICES_V2 from neotools import ask_neo + +@cache.cached() +def publishers_get(): # noqa: E501 + """Get information about available publishers. + + # noqa: E501 + + + :rtype: List[PublisherDescription] + """ + return ask_neo(DESCRIBE_PUBLISHERS()) + + @cache.cached() def reviewing_services_get(): # noqa: E501 """Get information about available reviewing services diff --git a/api/server/swagger_server/models/__init__.py b/api/server/swagger_server/models/__init__.py index a4ed066f..30b57763 100644 --- a/api/server/swagger_server/models/__init__.py +++ b/api/server/swagger_server/models/__init__.py @@ -7,7 +7,8 @@ from swagger_server.models.error import Error from swagger_server.models.inline_response200 import InlineResponse200 from swagger_server.models.paging_info import PagingInfo -from swagger_server.models.paper import Paper from swagger_server.models.paper_sort_by import PaperSortBy +from swagger_server.models.publisher_description import PublisherDescription +from swagger_server.models.refereed_preprint import RefereedPreprint from swagger_server.models.reviewing_service_description import ReviewingServiceDescription from swagger_server.models.sort_order import SortOrder diff --git a/api/server/swagger_server/models/author.py b/api/server/swagger_server/models/author.py index a7d59d0e..f5f43cc1 100644 --- a/api/server/swagger_server/models/author.py +++ b/api/server/swagger_server/models/author.py @@ -64,6 +64,7 @@ def from_dict(cls, dikt) -> 'Author': def surname(self) -> str: """Gets the surname of this Author. + The surname of the author. # noqa: E501 :return: The surname of this Author. :rtype: str @@ -74,6 +75,7 @@ def surname(self) -> str: def surname(self, surname: str): """Sets the surname of this Author. + The surname of the author. # noqa: E501 :param surname: The surname of this Author. :type surname: str @@ -85,6 +87,7 @@ def surname(self, surname: str): def corresp(self) -> str: """Gets the corresp of this Author. + Whether the author is a corresponding author. \"yes\" if the author is a corresponding author, null otherwise. # noqa: E501 :return: The corresp of this Author. :rtype: str @@ -95,6 +98,7 @@ def corresp(self) -> str: def corresp(self, corresp: str): """Sets the corresp of this Author. + Whether the author is a corresponding author. \"yes\" if the author is a corresponding author, null otherwise. # noqa: E501 :param corresp: The corresp of this Author. :type corresp: str @@ -106,6 +110,7 @@ def corresp(self, corresp: str): def orcid(self) -> str: """Gets the orcid of this Author. + The ORCID of the author. Null if the author does not have an ORCID. # noqa: E501 :return: The orcid of this Author. :rtype: str @@ -116,6 +121,7 @@ def orcid(self) -> str: def orcid(self, orcid: str): """Sets the orcid of this Author. + The ORCID of the author. Null if the author does not have an ORCID. # noqa: E501 :param orcid: The orcid of this Author. :type orcid: str @@ -127,6 +133,7 @@ def orcid(self, orcid: str): def position_idx(self) -> int: """Gets the position_idx of this Author. + The position of the author in the list of authors. # noqa: E501 :return: The position_idx of this Author. :rtype: int @@ -137,6 +144,7 @@ def position_idx(self) -> int: def position_idx(self, position_idx: int): """Sets the position_idx of this Author. + The position of the author in the list of authors. # noqa: E501 :param position_idx: The position_idx of this Author. :type position_idx: int @@ -148,6 +156,7 @@ def position_idx(self, position_idx: int): def given_names(self) -> str: """Gets the given_names of this Author. + The given names of the author. # noqa: E501 :return: The given_names of this Author. :rtype: str @@ -158,6 +167,7 @@ def given_names(self) -> str: def given_names(self, given_names: str): """Sets the given_names of this Author. + The given names of the author. # noqa: E501 :param given_names: The given_names of this Author. :type given_names: str diff --git a/api/server/swagger_server/models/inline_response200.py b/api/server/swagger_server/models/inline_response200.py index 2d1c2534..a755b6b6 100644 --- a/api/server/swagger_server/models/inline_response200.py +++ b/api/server/swagger_server/models/inline_response200.py @@ -7,7 +7,7 @@ from swagger_server.models.base_model_ import Model from swagger_server.models.paging_info import PagingInfo # noqa: F401,E501 -from swagger_server.models.paper import Paper # noqa: F401,E501 +from swagger_server.models.refereed_preprint import RefereedPreprint # noqa: F401,E501 from swagger_server import util @@ -16,16 +16,16 @@ class InlineResponse200(Model): Do not edit the class manually. """ - def __init__(self, items: List[Paper]=None, paging: PagingInfo=None): # noqa: E501 + def __init__(self, items: List[RefereedPreprint]=None, paging: PagingInfo=None): # noqa: E501 """InlineResponse200 - a model defined in Swagger :param items: The items of this InlineResponse200. # noqa: E501 - :type items: List[Paper] + :type items: List[RefereedPreprint] :param paging: The paging of this InlineResponse200. # noqa: E501 :type paging: PagingInfo """ self.swagger_types = { - 'items': List[Paper], + 'items': List[RefereedPreprint], 'paging': PagingInfo } @@ -48,22 +48,22 @@ def from_dict(cls, dikt) -> 'InlineResponse200': return util.deserialize_model(dikt, cls) @property - def items(self) -> List[Paper]: + def items(self) -> List[RefereedPreprint]: """Gets the items of this InlineResponse200. :return: The items of this InlineResponse200. - :rtype: List[Paper] + :rtype: List[RefereedPreprint] """ return self._items @items.setter - def items(self, items: List[Paper]): + def items(self, items: List[RefereedPreprint]): """Sets the items of this InlineResponse200. :param items: The items of this InlineResponse200. - :type items: List[Paper] + :type items: List[RefereedPreprint] """ self._items = items diff --git a/api/server/swagger_server/models/paper.py b/api/server/swagger_server/models/paper.py deleted file mode 100644 index 1349381d..00000000 --- a/api/server/swagger_server/models/paper.py +++ /dev/null @@ -1,487 +0,0 @@ -# coding: utf-8 - -from __future__ import absolute_import -from datetime import date, datetime # noqa: F401 - -from typing import List, Dict # noqa: F401 - -from swagger_server.models.base_model_ import Model -from swagger_server.models.author import Author # noqa: F401,E501 -from swagger_server import util - - -class Paper(Model): - """NOTE: This class is auto generated by the swagger code generator program. - - Do not edit the class manually. - """ - def __init__(self, doi: str=None, version: str=None, source: str=None, journal: str=None, title: str=None, abstract: str=None, journal_doi: str=None, published_journal_title: str=None, pub_date: datetime=None, authors: List[Author]=None, revdate: datetime=None, entities: List[str]=None, assays: List[str]=None, main_topics: List[List[str]]=None, highlighted_entities: List[str]=None, slug: str=None, reviewed_by: List[str]=None): # noqa: E501 - """Paper - a model defined in Swagger - - :param doi: The doi of this Paper. # noqa: E501 - :type doi: str - :param version: The version of this Paper. # noqa: E501 - :type version: str - :param source: The source of this Paper. # noqa: E501 - :type source: str - :param journal: The journal of this Paper. # noqa: E501 - :type journal: str - :param title: The title of this Paper. # noqa: E501 - :type title: str - :param abstract: The abstract of this Paper. # noqa: E501 - :type abstract: str - :param journal_doi: The journal_doi of this Paper. # noqa: E501 - :type journal_doi: str - :param published_journal_title: The published_journal_title of this Paper. # noqa: E501 - :type published_journal_title: str - :param pub_date: The pub_date of this Paper. # noqa: E501 - :type pub_date: datetime - :param authors: The authors of this Paper. # noqa: E501 - :type authors: List[Author] - :param revdate: The revdate of this Paper. # noqa: E501 - :type revdate: datetime - :param entities: The entities of this Paper. # noqa: E501 - :type entities: List[str] - :param assays: The assays of this Paper. # noqa: E501 - :type assays: List[str] - :param main_topics: The main_topics of this Paper. # noqa: E501 - :type main_topics: List[List[str]] - :param highlighted_entities: The highlighted_entities of this Paper. # noqa: E501 - :type highlighted_entities: List[str] - :param slug: The slug of this Paper. # noqa: E501 - :type slug: str - :param reviewed_by: The reviewed_by of this Paper. # noqa: E501 - :type reviewed_by: List[str] - """ - self.swagger_types = { - 'doi': str, - 'version': str, - 'source': str, - 'journal': str, - 'title': str, - 'abstract': str, - 'journal_doi': str, - 'published_journal_title': str, - 'pub_date': datetime, - 'authors': List[Author], - 'revdate': datetime, - 'entities': List[str], - 'assays': List[str], - 'main_topics': List[List[str]], - 'highlighted_entities': List[str], - 'slug': str, - 'reviewed_by': List[str] - } - - self.attribute_map = { - 'doi': 'doi', - 'version': 'version', - 'source': 'source', - 'journal': 'journal', - 'title': 'title', - 'abstract': 'abstract', - 'journal_doi': 'journal_doi', - 'published_journal_title': 'published_journal_title', - 'pub_date': 'pub_date', - 'authors': 'authors', - 'revdate': 'revdate', - 'entities': 'entities', - 'assays': 'assays', - 'main_topics': 'main_topics', - 'highlighted_entities': 'highlighted_entities', - 'slug': 'slug', - 'reviewed_by': 'reviewed_by' - } - self._doi = doi - self._version = version - self._source = source - self._journal = journal - self._title = title - self._abstract = abstract - self._journal_doi = journal_doi - self._published_journal_title = published_journal_title - self._pub_date = pub_date - self._authors = authors - self._revdate = revdate - self._entities = entities - self._assays = assays - self._main_topics = main_topics - self._highlighted_entities = highlighted_entities - self._slug = slug - self._reviewed_by = reviewed_by - - @classmethod - def from_dict(cls, dikt) -> 'Paper': - """Returns the dict as a model - - :param dikt: A dict. - :type: dict - :return: The Paper of this Paper. # noqa: E501 - :rtype: Paper - """ - return util.deserialize_model(dikt, cls) - - @property - def doi(self) -> str: - """Gets the doi of this Paper. - - The DOI of the paper. # noqa: E501 - - :return: The doi of this Paper. - :rtype: str - """ - return self._doi - - @doi.setter - def doi(self, doi: str): - """Sets the doi of this Paper. - - The DOI of the paper. # noqa: E501 - - :param doi: The doi of this Paper. - :type doi: str - """ - - self._doi = doi - - @property - def version(self) -> str: - """Gets the version of this Paper. - - The version of the paper. # noqa: E501 - - :return: The version of this Paper. - :rtype: str - """ - return self._version - - @version.setter - def version(self, version: str): - """Sets the version of this Paper. - - The version of the paper. # noqa: E501 - - :param version: The version of this Paper. - :type version: str - """ - - self._version = version - - @property - def source(self) -> str: - """Gets the source of this Paper. - - The source of the paper. Either \"bioRxiv\" or \"medRxiv\". # noqa: E501 - - :return: The source of this Paper. - :rtype: str - """ - return self._source - - @source.setter - def source(self, source: str): - """Sets the source of this Paper. - - The source of the paper. Either \"bioRxiv\" or \"medRxiv\". # noqa: E501 - - :param source: The source of this Paper. - :type source: str - """ - - self._source = source - - @property - def journal(self) -> str: - """Gets the journal of this Paper. - - The journal the paper was published in. # noqa: E501 - - :return: The journal of this Paper. - :rtype: str - """ - return self._journal - - @journal.setter - def journal(self, journal: str): - """Sets the journal of this Paper. - - The journal the paper was published in. # noqa: E501 - - :param journal: The journal of this Paper. - :type journal: str - """ - - self._journal = journal - - @property - def title(self) -> str: - """Gets the title of this Paper. - - - :return: The title of this Paper. - :rtype: str - """ - return self._title - - @title.setter - def title(self, title: str): - """Sets the title of this Paper. - - - :param title: The title of this Paper. - :type title: str - """ - - self._title = title - - @property - def abstract(self) -> str: - """Gets the abstract of this Paper. - - - :return: The abstract of this Paper. - :rtype: str - """ - return self._abstract - - @abstract.setter - def abstract(self, abstract: str): - """Sets the abstract of this Paper. - - - :param abstract: The abstract of this Paper. - :type abstract: str - """ - - self._abstract = abstract - - @property - def journal_doi(self) -> str: - """Gets the journal_doi of this Paper. - - - :return: The journal_doi of this Paper. - :rtype: str - """ - return self._journal_doi - - @journal_doi.setter - def journal_doi(self, journal_doi: str): - """Sets the journal_doi of this Paper. - - - :param journal_doi: The journal_doi of this Paper. - :type journal_doi: str - """ - - self._journal_doi = journal_doi - - @property - def published_journal_title(self) -> str: - """Gets the published_journal_title of this Paper. - - - :return: The published_journal_title of this Paper. - :rtype: str - """ - return self._published_journal_title - - @published_journal_title.setter - def published_journal_title(self, published_journal_title: str): - """Sets the published_journal_title of this Paper. - - - :param published_journal_title: The published_journal_title of this Paper. - :type published_journal_title: str - """ - - self._published_journal_title = published_journal_title - - @property - def pub_date(self) -> datetime: - """Gets the pub_date of this Paper. - - - :return: The pub_date of this Paper. - :rtype: datetime - """ - return self._pub_date - - @pub_date.setter - def pub_date(self, pub_date: datetime): - """Sets the pub_date of this Paper. - - - :param pub_date: The pub_date of this Paper. - :type pub_date: datetime - """ - - self._pub_date = pub_date - - @property - def authors(self) -> List[Author]: - """Gets the authors of this Paper. - - - :return: The authors of this Paper. - :rtype: List[Author] - """ - return self._authors - - @authors.setter - def authors(self, authors: List[Author]): - """Sets the authors of this Paper. - - - :param authors: The authors of this Paper. - :type authors: List[Author] - """ - - self._authors = authors - - @property - def revdate(self) -> datetime: - """Gets the revdate of this Paper. - - - :return: The revdate of this Paper. - :rtype: datetime - """ - return self._revdate - - @revdate.setter - def revdate(self, revdate: datetime): - """Sets the revdate of this Paper. - - - :param revdate: The revdate of this Paper. - :type revdate: datetime - """ - - self._revdate = revdate - - @property - def entities(self) -> List[str]: - """Gets the entities of this Paper. - - - :return: The entities of this Paper. - :rtype: List[str] - """ - return self._entities - - @entities.setter - def entities(self, entities: List[str]): - """Sets the entities of this Paper. - - - :param entities: The entities of this Paper. - :type entities: List[str] - """ - - self._entities = entities - - @property - def assays(self) -> List[str]: - """Gets the assays of this Paper. - - - :return: The assays of this Paper. - :rtype: List[str] - """ - return self._assays - - @assays.setter - def assays(self, assays: List[str]): - """Sets the assays of this Paper. - - - :param assays: The assays of this Paper. - :type assays: List[str] - """ - - self._assays = assays - - @property - def main_topics(self) -> List[List[str]]: - """Gets the main_topics of this Paper. - - - :return: The main_topics of this Paper. - :rtype: List[List[str]] - """ - return self._main_topics - - @main_topics.setter - def main_topics(self, main_topics: List[List[str]]): - """Sets the main_topics of this Paper. - - - :param main_topics: The main_topics of this Paper. - :type main_topics: List[List[str]] - """ - - self._main_topics = main_topics - - @property - def highlighted_entities(self) -> List[str]: - """Gets the highlighted_entities of this Paper. - - - :return: The highlighted_entities of this Paper. - :rtype: List[str] - """ - return self._highlighted_entities - - @highlighted_entities.setter - def highlighted_entities(self, highlighted_entities: List[str]): - """Sets the highlighted_entities of this Paper. - - - :param highlighted_entities: The highlighted_entities of this Paper. - :type highlighted_entities: List[str] - """ - - self._highlighted_entities = highlighted_entities - - @property - def slug(self) -> str: - """Gets the slug of this Paper. - - - :return: The slug of this Paper. - :rtype: str - """ - return self._slug - - @slug.setter - def slug(self, slug: str): - """Sets the slug of this Paper. - - - :param slug: The slug of this Paper. - :type slug: str - """ - - self._slug = slug - - @property - def reviewed_by(self) -> List[str]: - """Gets the reviewed_by of this Paper. - - - :return: The reviewed_by of this Paper. - :rtype: List[str] - """ - return self._reviewed_by - - @reviewed_by.setter - def reviewed_by(self, reviewed_by: List[str]): - """Sets the reviewed_by of this Paper. - - - :param reviewed_by: The reviewed_by of this Paper. - :type reviewed_by: List[str] - """ - - self._reviewed_by = reviewed_by diff --git a/api/server/swagger_server/models/publisher_description.py b/api/server/swagger_server/models/publisher_description.py new file mode 100644 index 00000000..cae57c9b --- /dev/null +++ b/api/server/swagger_server/models/publisher_description.py @@ -0,0 +1,92 @@ +# coding: utf-8 + +from __future__ import absolute_import +from datetime import date, datetime # noqa: F401 + +from typing import List, Dict # noqa: F401 + +from swagger_server.models.base_model_ import Model +from swagger_server import util + + +class PublisherDescription(Model): + """NOTE: This class is auto generated by the swagger code generator program. + + Do not edit the class manually. + """ + def __init__(self, id: str=None, n_papers: int=None): # noqa: E501 + """PublisherDescription - a model defined in Swagger + + :param id: The id of this PublisherDescription. # noqa: E501 + :type id: str + :param n_papers: The n_papers of this PublisherDescription. # noqa: E501 + :type n_papers: int + """ + self.swagger_types = { + 'id': str, + 'n_papers': int + } + + self.attribute_map = { + 'id': 'id', + 'n_papers': 'n_papers' + } + self._id = id + self._n_papers = n_papers + + @classmethod + def from_dict(cls, dikt) -> 'PublisherDescription': + """Returns the dict as a model + + :param dikt: A dict. + :type: dict + :return: The PublisherDescription of this PublisherDescription. # noqa: E501 + :rtype: PublisherDescription + """ + return util.deserialize_model(dikt, cls) + + @property + def id(self) -> str: + """Gets the id of this PublisherDescription. + + The ID of the publisher. # noqa: E501 + + :return: The id of this PublisherDescription. + :rtype: str + """ + return self._id + + @id.setter + def id(self, id: str): + """Sets the id of this PublisherDescription. + + The ID of the publisher. # noqa: E501 + + :param id: The id of this PublisherDescription. + :type id: str + """ + + self._id = id + + @property + def n_papers(self) -> int: + """Gets the n_papers of this PublisherDescription. + + The number of refereed preprints published by the publisher. # noqa: E501 + + :return: The n_papers of this PublisherDescription. + :rtype: int + """ + return self._n_papers + + @n_papers.setter + def n_papers(self, n_papers: int): + """Sets the n_papers of this PublisherDescription. + + The number of refereed preprints published by the publisher. # noqa: E501 + + :param n_papers: The n_papers of this PublisherDescription. + :type n_papers: int + """ + + self._n_papers = n_papers diff --git a/api/server/swagger_server/models/refereed_preprint.py b/api/server/swagger_server/models/refereed_preprint.py new file mode 100644 index 00000000..19bdc5f1 --- /dev/null +++ b/api/server/swagger_server/models/refereed_preprint.py @@ -0,0 +1,513 @@ +# coding: utf-8 + +from __future__ import absolute_import +from datetime import date, datetime # noqa: F401 + +from typing import List, Dict # noqa: F401 + +from swagger_server.models.base_model_ import Model +from swagger_server.models.author import Author # noqa: F401,E501 +from swagger_server import util + + +class RefereedPreprint(Model): + """NOTE: This class is auto generated by the swagger code generator program. + + Do not edit the class manually. + """ + def __init__(self, doi: str=None, version: str=None, source: str=None, journal: str=None, title: str=None, abstract: str=None, journal_doi: str=None, published_journal_title: str=None, pub_date: datetime=None, authors: List[Author]=None, review_dates: List[datetime]=None, entities: List[str]=None, assays: List[str]=None, main_topics: List[List[str]]=None, highlighted_entities: List[str]=None, slug: str=None, reviewed_by: List[str]=None): # noqa: E501 + """RefereedPreprint - a model defined in Swagger + + :param doi: The doi of this RefereedPreprint. # noqa: E501 + :type doi: str + :param version: The version of this RefereedPreprint. # noqa: E501 + :type version: str + :param source: The source of this RefereedPreprint. # noqa: E501 + :type source: str + :param journal: The journal of this RefereedPreprint. # noqa: E501 + :type journal: str + :param title: The title of this RefereedPreprint. # noqa: E501 + :type title: str + :param abstract: The abstract of this RefereedPreprint. # noqa: E501 + :type abstract: str + :param journal_doi: The journal_doi of this RefereedPreprint. # noqa: E501 + :type journal_doi: str + :param published_journal_title: The published_journal_title of this RefereedPreprint. # noqa: E501 + :type published_journal_title: str + :param pub_date: The pub_date of this RefereedPreprint. # noqa: E501 + :type pub_date: datetime + :param authors: The authors of this RefereedPreprint. # noqa: E501 + :type authors: List[Author] + :param review_dates: The review_dates of this RefereedPreprint. # noqa: E501 + :type review_dates: List[datetime] + :param entities: The entities of this RefereedPreprint. # noqa: E501 + :type entities: List[str] + :param assays: The assays of this RefereedPreprint. # noqa: E501 + :type assays: List[str] + :param main_topics: The main_topics of this RefereedPreprint. # noqa: E501 + :type main_topics: List[List[str]] + :param highlighted_entities: The highlighted_entities of this RefereedPreprint. # noqa: E501 + :type highlighted_entities: List[str] + :param slug: The slug of this RefereedPreprint. # noqa: E501 + :type slug: str + :param reviewed_by: The reviewed_by of this RefereedPreprint. # noqa: E501 + :type reviewed_by: List[str] + """ + self.swagger_types = { + 'doi': str, + 'version': str, + 'source': str, + 'journal': str, + 'title': str, + 'abstract': str, + 'journal_doi': str, + 'published_journal_title': str, + 'pub_date': datetime, + 'authors': List[Author], + 'review_dates': List[datetime], + 'entities': List[str], + 'assays': List[str], + 'main_topics': List[List[str]], + 'highlighted_entities': List[str], + 'slug': str, + 'reviewed_by': List[str] + } + + self.attribute_map = { + 'doi': 'doi', + 'version': 'version', + 'source': 'source', + 'journal': 'journal', + 'title': 'title', + 'abstract': 'abstract', + 'journal_doi': 'journal_doi', + 'published_journal_title': 'published_journal_title', + 'pub_date': 'pub_date', + 'authors': 'authors', + 'review_dates': 'review_dates', + 'entities': 'entities', + 'assays': 'assays', + 'main_topics': 'main_topics', + 'highlighted_entities': 'highlighted_entities', + 'slug': 'slug', + 'reviewed_by': 'reviewed_by' + } + self._doi = doi + self._version = version + self._source = source + self._journal = journal + self._title = title + self._abstract = abstract + self._journal_doi = journal_doi + self._published_journal_title = published_journal_title + self._pub_date = pub_date + self._authors = authors + self._review_dates = review_dates + self._entities = entities + self._assays = assays + self._main_topics = main_topics + self._highlighted_entities = highlighted_entities + self._slug = slug + self._reviewed_by = reviewed_by + + @classmethod + def from_dict(cls, dikt) -> 'RefereedPreprint': + """Returns the dict as a model + + :param dikt: A dict. + :type: dict + :return: The RefereedPreprint of this RefereedPreprint. # noqa: E501 + :rtype: RefereedPreprint + """ + return util.deserialize_model(dikt, cls) + + @property + def doi(self) -> str: + """Gets the doi of this RefereedPreprint. + + The DOI of the refereed preprint. # noqa: E501 + + :return: The doi of this RefereedPreprint. + :rtype: str + """ + return self._doi + + @doi.setter + def doi(self, doi: str): + """Sets the doi of this RefereedPreprint. + + The DOI of the refereed preprint. # noqa: E501 + + :param doi: The doi of this RefereedPreprint. + :type doi: str + """ + + self._doi = doi + + @property + def version(self) -> str: + """Gets the version of this RefereedPreprint. + + The version of the refereed preprint. # noqa: E501 + + :return: The version of this RefereedPreprint. + :rtype: str + """ + return self._version + + @version.setter + def version(self, version: str): + """Sets the version of this RefereedPreprint. + + The version of the refereed preprint. # noqa: E501 + + :param version: The version of this RefereedPreprint. + :type version: str + """ + + self._version = version + + @property + def source(self) -> str: + """Gets the source of this RefereedPreprint. + + The source of the refereed preprint. Either \"bioRxiv\" or \"medRxiv\". # noqa: E501 + + :return: The source of this RefereedPreprint. + :rtype: str + """ + return self._source + + @source.setter + def source(self, source: str): + """Sets the source of this RefereedPreprint. + + The source of the refereed preprint. Either \"bioRxiv\" or \"medRxiv\". # noqa: E501 + + :param source: The source of this RefereedPreprint. + :type source: str + """ + + self._source = source + + @property + def journal(self) -> str: + """Gets the journal of this RefereedPreprint. + + The journal the refereed preprint was published in. # noqa: E501 + + :return: The journal of this RefereedPreprint. + :rtype: str + """ + return self._journal + + @journal.setter + def journal(self, journal: str): + """Sets the journal of this RefereedPreprint. + + The journal the refereed preprint was published in. # noqa: E501 + + :param journal: The journal of this RefereedPreprint. + :type journal: str + """ + + self._journal = journal + + @property + def title(self) -> str: + """Gets the title of this RefereedPreprint. + + The title of the refereed preprint. # noqa: E501 + + :return: The title of this RefereedPreprint. + :rtype: str + """ + return self._title + + @title.setter + def title(self, title: str): + """Sets the title of this RefereedPreprint. + + The title of the refereed preprint. # noqa: E501 + + :param title: The title of this RefereedPreprint. + :type title: str + """ + + self._title = title + + @property + def abstract(self) -> str: + """Gets the abstract of this RefereedPreprint. + + The abstract of the refereed preprint. # noqa: E501 + + :return: The abstract of this RefereedPreprint. + :rtype: str + """ + return self._abstract + + @abstract.setter + def abstract(self, abstract: str): + """Sets the abstract of this RefereedPreprint. + + The abstract of the refereed preprint. # noqa: E501 + + :param abstract: The abstract of this RefereedPreprint. + :type abstract: str + """ + + self._abstract = abstract + + @property + def journal_doi(self) -> str: + """Gets the journal_doi of this RefereedPreprint. + + The DOI of the published version of this refereed preprint. Null if the refereed preprint has not been published. # noqa: E501 + + :return: The journal_doi of this RefereedPreprint. + :rtype: str + """ + return self._journal_doi + + @journal_doi.setter + def journal_doi(self, journal_doi: str): + """Sets the journal_doi of this RefereedPreprint. + + The DOI of the published version of this refereed preprint. Null if the refereed preprint has not been published. # noqa: E501 + + :param journal_doi: The journal_doi of this RefereedPreprint. + :type journal_doi: str + """ + + self._journal_doi = journal_doi + + @property + def published_journal_title(self) -> str: + """Gets the published_journal_title of this RefereedPreprint. + + The title of the journal the refereed preprint was published in. Null if the refereed preprint has not been published. # noqa: E501 + + :return: The published_journal_title of this RefereedPreprint. + :rtype: str + """ + return self._published_journal_title + + @published_journal_title.setter + def published_journal_title(self, published_journal_title: str): + """Sets the published_journal_title of this RefereedPreprint. + + The title of the journal the refereed preprint was published in. Null if the refereed preprint has not been published. # noqa: E501 + + :param published_journal_title: The published_journal_title of this RefereedPreprint. + :type published_journal_title: str + """ + + self._published_journal_title = published_journal_title + + @property + def pub_date(self) -> datetime: + """Gets the pub_date of this RefereedPreprint. + + The date the refereed preprint was published. # noqa: E501 + + :return: The pub_date of this RefereedPreprint. + :rtype: datetime + """ + return self._pub_date + + @pub_date.setter + def pub_date(self, pub_date: datetime): + """Sets the pub_date of this RefereedPreprint. + + The date the refereed preprint was published. # noqa: E501 + + :param pub_date: The pub_date of this RefereedPreprint. + :type pub_date: datetime + """ + + self._pub_date = pub_date + + @property + def authors(self) -> List[Author]: + """Gets the authors of this RefereedPreprint. + + The authors of the refereed preprint. # noqa: E501 + + :return: The authors of this RefereedPreprint. + :rtype: List[Author] + """ + return self._authors + + @authors.setter + def authors(self, authors: List[Author]): + """Sets the authors of this RefereedPreprint. + + The authors of the refereed preprint. # noqa: E501 + + :param authors: The authors of this RefereedPreprint. + :type authors: List[Author] + """ + + self._authors = authors + + @property + def review_dates(self) -> List[datetime]: + """Gets the review_dates of this RefereedPreprint. + + The dates the refereed preprint was reviewed on. # noqa: E501 + + :return: The review_dates of this RefereedPreprint. + :rtype: List[datetime] + """ + return self._review_dates + + @review_dates.setter + def review_dates(self, review_dates: List[datetime]): + """Sets the review_dates of this RefereedPreprint. + + The dates the refereed preprint was reviewed on. # noqa: E501 + + :param review_dates: The review_dates of this RefereedPreprint. + :type review_dates: List[datetime] + """ + + self._review_dates = review_dates + + @property + def entities(self) -> List[str]: + """Gets the entities of this RefereedPreprint. + + The entities (e.g. genes, proteins, diseases) mentioned in the refereed preprint's figures. # noqa: E501 + + :return: The entities of this RefereedPreprint. + :rtype: List[str] + """ + return self._entities + + @entities.setter + def entities(self, entities: List[str]): + """Sets the entities of this RefereedPreprint. + + The entities (e.g. genes, proteins, diseases) mentioned in the refereed preprint's figures. # noqa: E501 + + :param entities: The entities of this RefereedPreprint. + :type entities: List[str] + """ + + self._entities = entities + + @property + def assays(self) -> List[str]: + """Gets the assays of this RefereedPreprint. + + The assays (e.g. ELISA, PCR) mentioned in the refereed preprint's figures. # noqa: E501 + + :return: The assays of this RefereedPreprint. + :rtype: List[str] + """ + return self._assays + + @assays.setter + def assays(self, assays: List[str]): + """Sets the assays of this RefereedPreprint. + + The assays (e.g. ELISA, PCR) mentioned in the refereed preprint's figures. # noqa: E501 + + :param assays: The assays of this RefereedPreprint. + :type assays: List[str] + """ + + self._assays = assays + + @property + def main_topics(self) -> List[List[str]]: + """Gets the main_topics of this RefereedPreprint. + + The main topics of the refereed preprint. # noqa: E501 + + :return: The main_topics of this RefereedPreprint. + :rtype: List[List[str]] + """ + return self._main_topics + + @main_topics.setter + def main_topics(self, main_topics: List[List[str]]): + """Sets the main_topics of this RefereedPreprint. + + The main topics of the refereed preprint. # noqa: E501 + + :param main_topics: The main_topics of this RefereedPreprint. + :type main_topics: List[List[str]] + """ + + self._main_topics = main_topics + + @property + def highlighted_entities(self) -> List[str]: + """Gets the highlighted_entities of this RefereedPreprint. + + The highlighted entities (e.g. genes, proteins, diseases) mentioned in the refereed preprint's abstract. # noqa: E501 + + :return: The highlighted_entities of this RefereedPreprint. + :rtype: List[str] + """ + return self._highlighted_entities + + @highlighted_entities.setter + def highlighted_entities(self, highlighted_entities: List[str]): + """Sets the highlighted_entities of this RefereedPreprint. + + The highlighted entities (e.g. genes, proteins, diseases) mentioned in the refereed preprint's abstract. # noqa: E501 + + :param highlighted_entities: The highlighted_entities of this RefereedPreprint. + :type highlighted_entities: List[str] + """ + + self._highlighted_entities = highlighted_entities + + @property + def slug(self) -> str: + """Gets the slug of this RefereedPreprint. + + The slug of the refereed preprint. Can be used to construct a URL to the refereed preprint's page on the Early Evidence Base platform. # noqa: E501 + + :return: The slug of this RefereedPreprint. + :rtype: str + """ + return self._slug + + @slug.setter + def slug(self, slug: str): + """Sets the slug of this RefereedPreprint. + + The slug of the refereed preprint. Can be used to construct a URL to the refereed preprint's page on the Early Evidence Base platform. # noqa: E501 + + :param slug: The slug of this RefereedPreprint. + :type slug: str + """ + + self._slug = slug + + @property + def reviewed_by(self) -> List[str]: + """Gets the reviewed_by of this RefereedPreprint. + + The IDs of the reviewing services that reviewed this refereed preprint. # noqa: E501 + + :return: The reviewed_by of this RefereedPreprint. + :rtype: List[str] + """ + return self._reviewed_by + + @reviewed_by.setter + def reviewed_by(self, reviewed_by: List[str]): + """Sets the reviewed_by of this RefereedPreprint. + + The IDs of the reviewing services that reviewed this refereed preprint. # noqa: E501 + + :param reviewed_by: The reviewed_by of this RefereedPreprint. + :type reviewed_by: List[str] + """ + + self._reviewed_by = reviewed_by diff --git a/api/server/swagger_server/swagger/swagger.yaml b/api/server/swagger_server/swagger/swagger.yaml index b8c21315..76d76e80 100644 --- a/api/server/swagger_server/swagger/swagger.yaml +++ b/api/server/swagger_server/swagger/swagger.yaml @@ -2,8 +2,8 @@ openapi: 3.0.3 info: title: Early Evidence Base API description: "Read-only API for the Early Evidence Base platform providing collections\ - \ of papers by reviewing service, automagic, and auto topics, as well as details\ - \ on papers by DOI." + \ of refereed preprints by reviewing service, automagic, and auto topics, as well\ + \ as details on refereed preprints by DOI." version: 2.0.0 servers: - url: https://eeb.embo.org/api/v2 @@ -13,15 +13,16 @@ servers: - url: http://localhost:5050/api/v2 description: Local development server tags: -- name: Reviewing Services - description: Endpoints related to retrieving information about reviewing services. -- name: Paper Details - description: Endpoints related to retrieving paper details. +- name: Reviewing Services and Publishers + description: Endpoints related to retrieving information about reviewing services + and publishers. +- name: Refereed Preprint Details + description: Endpoints related to retrieving details about refereed preprints. paths: /reviewing_services/: get: tags: - - Reviewing Services + - Reviewing Services and Publishers summary: Get information about available reviewing services. operationId: reviewing_services_get responses: @@ -34,21 +35,39 @@ paths: items: $ref: '#/components/schemas/ReviewingServiceDescription' x-content-type: application/json - x-openapi-router-controller: swagger_server.controllers.reviewing_services_controller + x-openapi-router-controller: swagger_server.controllers.reviewing_services_and_publishers_controller + /publishers/: + get: + tags: + - Reviewing Services and Publishers + summary: Get information about available publishers. + operationId: publishers_get + responses: + "200": + description: An array of publishers. + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/PublisherDescription' + x-content-type: application/json + x-openapi-router-controller: swagger_server.controllers.reviewing_services_and_publishers_controller /papers/: get: tags: - - Paper Details - summary: "Get paginated collections of papers, optionally filtered by reviewing\ - \ service" + - Refereed Preprint Details + summary: "Get paginated collections of refereed preprints, optionally filtered\ + \ by reviewing service" operationId: papers_get parameters: - name: reviewedBy in: query - description: "The IDs of the reviewing services for which papers are requested.\ - \ If specified, only papers that were reviewed by at least one of the specified\ - \ reviewing services are returned. Is combined with the query parameter\ - \ using a logical AND. If not specified, this filter is not applied." + description: "The IDs of the reviewing services for which refereed preprints\ + \ are requested. If specified, only refereed preprints that were reviewed\ + \ by at least one of the specified reviewing services are returned. Is combined\ + \ with the query and publishedIn parameters using a logical AND. If not\ + \ specified, this filter is not applied." required: false style: form explode: true @@ -59,15 +78,29 @@ paths: - name: query in: query description: "A search string to filter the results by. The search string\ - \ is matched against the paper DOI, title, abstract, and authors. The search\ - \ is case-insensitive and matches partial words (e.g. the search string\ - \ \"covid\" would match \"COVID-19\"). Is combined with the reviewedBy parameter\ - \ using a logical AND. If not specified, this filter is not applied." + \ is matched against the refereed preprint DOI, title, abstract, and authors.\ + \ The search is case-insensitive and matches partial words (e.g. the search\ + \ string \"covid\" would match \"COVID-19\"). Is combined with the reviewedBy\ + \ and publishedIn parameters using a logical AND. If not specified, this\ + \ filter is not applied." required: false style: form explode: true schema: type: string + - name: publishedIn + in: query + description: "The journals to filter the results by. If specified, only refereed\ + \ preprints that were published in at least one of the specified journals\ + \ are returned. Is combined with the reviewedBy and query parameters using\ + \ a logical AND. If not specified, this filter is not applied." + required: false + style: form + explode: true + schema: + type: array + items: + type: string - name: page in: query description: The page number of the results to retrieve. The first page is @@ -108,8 +141,8 @@ paths: $ref: '#/components/schemas/SortOrder' responses: "200": - description: "An array of papers, filtered, sorted, and paged by the given\ - \ parameters." + description: "An array of refereed preprints, filtered, sorted, and paged\ + \ by the given parameters." content: application/json: schema: @@ -121,88 +154,159 @@ paths: application/json: schema: $ref: '#/components/schemas/Error' - x-openapi-router-controller: swagger_server.controllers.paper_details_controller + x-openapi-router-controller: swagger_server.controllers.refereed_preprint_details_controller + /paper/: + get: + tags: + - Refereed Preprint Details + summary: Get details about a refereed preprint by DOI or slug. + operationId: paper_get + parameters: + - name: doi + in: query + description: The DOI of the refereed preprint. Either the DOI or the slug + parameter must be specified. + required: false + style: form + explode: true + schema: + type: string + format: doi + - name: slug + in: query + description: The slug of the refereed preprint. Either the DOI or the slug + parameter must be specified. + required: false + style: form + explode: true + schema: + type: string + responses: + "200": + description: The details of the refereed preprint. + content: + application/json: + schema: + $ref: '#/components/schemas/RefereedPreprint' + "400": + description: Bad request. The request parameters are invalid. The response + body contains a JSON object with a detail property describing the error. + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + "404": + description: The refereed preprint with the given DOI or slug does not exist. + x-openapi-router-controller: swagger_server.controllers.refereed_preprint_details_controller components: schemas: - Paper: + RefereedPreprint: type: object properties: doi: type: string - description: The DOI of the paper. + description: The DOI of the refereed preprint. format: doi example: 10.1101/2020.05.22.111161 version: type: string - description: The version of the paper. + description: The version of the refereed preprint. example: "1.0" source: type: string - description: The source of the paper. Either "bioRxiv" or "medRxiv". + description: The source of the refereed preprint. Either "bioRxiv" or "medRxiv". example: bioRxiv journal: type: string - description: The journal the paper was published in. + description: The journal the refereed preprint was published in. example: bioRxiv title: type: string + description: The title of the refereed preprint. + example: A SARS-CoV-2 protein interaction map reveals targets for drug repurposing abstract: type: string + description: The abstract of the refereed preprint. + example: The COVID-19 pandemic urgently needs... journal_doi: type: string + description: The DOI of the published version of this refereed preprint. + Null if the refereed preprint has not been published. format: doi nullable: true + example: 10.15252/embj.20105114 published_journal_title: type: string + description: The title of the journal the refereed preprint was published + in. Null if the refereed preprint has not been published. nullable: true + example: EMBO Journal pub_date: type: string + description: The date the refereed preprint was published. format: date-time + example: 2020-05-22T00:00:00Z authors: type: array + description: The authors of the refereed preprint. items: $ref: '#/components/schemas/Author' - revdate: - type: string - format: date-time - nullable: true + review_dates: + type: array + description: The dates the refereed preprint was reviewed on. + items: + type: string + format: date-time entities: type: array + description: "The entities (e.g. genes, proteins, diseases) mentioned in\ + \ the refereed preprint's figures." items: type: string assays: type: array + description: "The assays (e.g. ELISA, PCR) mentioned in the refereed preprint's\ + \ figures." items: type: string main_topics: type: array + description: The main topics of the refereed preprint. items: type: array items: type: string highlighted_entities: type: array + description: "The highlighted entities (e.g. genes, proteins, diseases)\ + \ mentioned in the refereed preprint's abstract." items: type: string slug: type: string + description: The slug of the refereed preprint. Can be used to construct + a URL to the refereed preprint's page on the Early Evidence Base platform. + example: a-sars-cov-2-protein-interaction-map-reveals-targets-for-drug-repurposing reviewed_by: type: array + description: The IDs of the reviewing services that reviewed this refereed + preprint. + example: + - review commons items: type: string example: reviewed_by: - - reviewed_by - - reviewed_by + - review commons assays: - assays - assays source: bioRxiv - abstract: abstract - title: title + abstract: The COVID-19 pandemic urgently needs... + title: A SARS-CoV-2 protein interaction map reveals targets for drug repurposing version: "1.0" - published_journal_title: published_journal_title - pub_date: 2000-01-23T04:56:07.000+00:00 + published_journal_title: EMBO Journal + pub_date: 2020-05-22T00:00:00Z journal: bioRxiv main_topics: - - main_topics @@ -212,46 +316,74 @@ components: entities: - entities - entities + review_dates: + - 2000-01-23T04:56:07.000+00:00 + - 2000-01-23T04:56:07.000+00:00 highlighted_entities: - highlighted_entities - highlighted_entities - revdate: 2000-01-23T04:56:07.000+00:00 - journal_doi: journal_doi - slug: slug + journal_doi: 10.15252/embj.20105114 + slug: a-sars-cov-2-protein-interaction-map-reveals-targets-for-drug-repurposing doi: 10.1101/2020.05.22.111161 authors: - - surname: surname - corresp: corresp - orcid: http://example.com/aeiou - position_idx: 0 - given_names: given_names - - surname: surname - corresp: corresp - orcid: http://example.com/aeiou - position_idx: 0 - given_names: given_names + - surname: Doe + corresp: "yes" + orcid: https://orcid.org/0000-0001-2345-6789 + position_idx: 1 + given_names: Jane John + - surname: Doe + corresp: "yes" + orcid: https://orcid.org/0000-0001-2345-6789 + position_idx: 1 + given_names: Jane John Author: type: object properties: surname: type: string + description: The surname of the author. + example: Doe corresp: type: string + description: "Whether the author is a corresponding author. \"yes\" if the\ + \ author is a corresponding author, null otherwise." nullable: true + example: "yes" orcid: type: string + description: The ORCID of the author. Null if the author does not have an + ORCID. format: uri nullable: true + example: https://orcid.org/0000-0001-2345-6789 position_idx: type: integer + description: The position of the author in the list of authors. + example: 1 given_names: type: string + description: The given names of the author. + example: Jane John + example: + surname: Doe + corresp: "yes" + orcid: https://orcid.org/0000-0001-2345-6789 + position_idx: 1 + given_names: Jane John + PublisherDescription: + type: object + properties: + id: + type: string + description: The ID of the publisher. + example: EMBO Molecular Medicine + n_papers: + type: integer + description: The number of refereed preprints published by the publisher. + example: 10 example: - surname: surname - corresp: corresp - orcid: http://example.com/aeiou - position_idx: 0 - given_names: given_names + n_papers: 10 + id: EMBO Molecular Medicine ReviewingServiceDescription: type: object properties: @@ -394,7 +526,7 @@ components: items: type: array items: - $ref: '#/components/schemas/Paper' + $ref: '#/components/schemas/RefereedPreprint' paging: $ref: '#/components/schemas/PagingInfo' example: @@ -412,17 +544,16 @@ components: sortedOrder: desc items: - reviewed_by: - - reviewed_by - - reviewed_by + - review commons assays: - assays - assays source: bioRxiv - abstract: abstract - title: title + abstract: The COVID-19 pandemic urgently needs... + title: A SARS-CoV-2 protein interaction map reveals targets for drug repurposing version: "1.0" - published_journal_title: published_journal_title - pub_date: 2000-01-23T04:56:07.000+00:00 + published_journal_title: EMBO Journal + pub_date: 2020-05-22T00:00:00Z journal: bioRxiv main_topics: - - main_topics @@ -432,36 +563,37 @@ components: entities: - entities - entities + review_dates: + - 2000-01-23T04:56:07.000+00:00 + - 2000-01-23T04:56:07.000+00:00 highlighted_entities: - highlighted_entities - highlighted_entities - revdate: 2000-01-23T04:56:07.000+00:00 - journal_doi: journal_doi - slug: slug + journal_doi: 10.15252/embj.20105114 + slug: a-sars-cov-2-protein-interaction-map-reveals-targets-for-drug-repurposing doi: 10.1101/2020.05.22.111161 authors: - - surname: surname - corresp: corresp - orcid: http://example.com/aeiou - position_idx: 0 - given_names: given_names - - surname: surname - corresp: corresp - orcid: http://example.com/aeiou - position_idx: 0 - given_names: given_names + - surname: Doe + corresp: "yes" + orcid: https://orcid.org/0000-0001-2345-6789 + position_idx: 1 + given_names: Jane John + - surname: Doe + corresp: "yes" + orcid: https://orcid.org/0000-0001-2345-6789 + position_idx: 1 + given_names: Jane John - reviewed_by: - - reviewed_by - - reviewed_by + - review commons assays: - assays - assays source: bioRxiv - abstract: abstract - title: title + abstract: The COVID-19 pandemic urgently needs... + title: A SARS-CoV-2 protein interaction map reveals targets for drug repurposing version: "1.0" - published_journal_title: published_journal_title - pub_date: 2000-01-23T04:56:07.000+00:00 + published_journal_title: EMBO Journal + pub_date: 2020-05-22T00:00:00Z journal: bioRxiv main_topics: - - main_topics @@ -471,22 +603,24 @@ components: entities: - entities - entities + review_dates: + - 2000-01-23T04:56:07.000+00:00 + - 2000-01-23T04:56:07.000+00:00 highlighted_entities: - highlighted_entities - highlighted_entities - revdate: 2000-01-23T04:56:07.000+00:00 - journal_doi: journal_doi - slug: slug + journal_doi: 10.15252/embj.20105114 + slug: a-sars-cov-2-protein-interaction-map-reveals-targets-for-drug-repurposing doi: 10.1101/2020.05.22.111161 authors: - - surname: surname - corresp: corresp - orcid: http://example.com/aeiou - position_idx: 0 - given_names: given_names - - surname: surname - corresp: corresp - orcid: http://example.com/aeiou - position_idx: 0 - given_names: given_names + - surname: Doe + corresp: "yes" + orcid: https://orcid.org/0000-0001-2345-6789 + position_idx: 1 + given_names: Jane John + - surname: Doe + corresp: "yes" + orcid: https://orcid.org/0000-0001-2345-6789 + position_idx: 1 + given_names: Jane John diff --git a/api/server/swagger_server/test/test_paper_details_controller.py b/api/server/swagger_server/test/test_refereed_preprint_details_controller.py similarity index 57% rename from api/server/swagger_server/test/test_paper_details_controller.py rename to api/server/swagger_server/test/test_refereed_preprint_details_controller.py index ff47b6ee..31257e9b 100644 --- a/api/server/swagger_server/test/test_paper_details_controller.py +++ b/api/server/swagger_server/test/test_refereed_preprint_details_controller.py @@ -8,20 +8,36 @@ from swagger_server.models.error import Error # noqa: E501 from swagger_server.models.inline_response200 import InlineResponse200 # noqa: E501 from swagger_server.models.paper_sort_by import PaperSortBy # noqa: E501 +from swagger_server.models.refereed_preprint import RefereedPreprint # noqa: E501 from swagger_server.models.sort_order import SortOrder # noqa: E501 from swagger_server.test import BaseTestCase -class TestPaperDetailsController(BaseTestCase): - """PaperDetailsController integration test stubs""" +class TestRefereedPreprintDetailsController(BaseTestCase): + """RefereedPreprintDetailsController integration test stubs""" + + def test_paper_get(self): + """Test case for paper_get + + Get details about a refereed preprint by DOI or slug. + """ + query_string = [('doi', 'doi_example'), + ('slug', 'slug_example')] + response = self.client.open( + '/api/v2/paper/', + method='GET', + query_string=query_string) + self.assert200(response, + 'Response body is : ' + response.data.decode('utf-8')) def test_papers_get(self): """Test case for papers_get - Get paginated collections of papers, optionally filtered by reviewing service + Get paginated collections of refereed preprints, optionally filtered by reviewing service """ query_string = [('reviewed_by', 'reviewed_by_example'), ('query', 'query_example'), + ('published_in', 'published_in_example'), ('page', 2), ('per_page', 100), ('sort_by', PaperSortBy()), diff --git a/api/server/swagger_server/test/test_reviewing_services_controller.py b/api/server/swagger_server/test/test_reviewing_services_and_publishers_controller.py similarity index 54% rename from api/server/swagger_server/test/test_reviewing_services_controller.py rename to api/server/swagger_server/test/test_reviewing_services_and_publishers_controller.py index de721222..8815e6d6 100644 --- a/api/server/swagger_server/test/test_reviewing_services_controller.py +++ b/api/server/swagger_server/test/test_reviewing_services_and_publishers_controller.py @@ -5,12 +5,24 @@ from flask import json from six import BytesIO +from swagger_server.models.publisher_description import PublisherDescription # noqa: E501 from swagger_server.models.reviewing_service_description import ReviewingServiceDescription # noqa: E501 from swagger_server.test import BaseTestCase -class TestReviewingServicesController(BaseTestCase): - """ReviewingServicesController integration test stubs""" +class TestReviewingServicesAndPublishersController(BaseTestCase): + """ReviewingServicesAndPublishersController integration test stubs""" + + def test_publishers_get(self): + """Test case for publishers_get + + Get information about available publishers. + """ + response = self.client.open( + '/api/v2/publishers/', + method='GET') + self.assert200(response, + 'Response body is : ' + response.data.decode('utf-8')) def test_reviewing_services_get(self): """Test case for reviewing_services_get diff --git a/neoflask/cache_warm_up.py b/neoflask/cache_warm_up.py index e1d3b767..ffc0fb85 100644 --- a/neoflask/cache_warm_up.py +++ b/neoflask/cache_warm_up.py @@ -58,11 +58,11 @@ def cache_warm_up(base_url, no_progress=False): f"/api/v2/papers/?reviewedBy={rs['id']}" for rs in reviewing_services ] + path_papers = "/api/v2/papers/" for path_reviewing_service in paths_reviewing_services: logger.info("warming up %s", path_reviewing_service) warmup_paged_method(base_url, path_papers, no_progress) - path_papers = "/api/v2/papers/" logger.info("warming up %s", path_papers) paper_ids = [ pid @@ -70,12 +70,13 @@ def cache_warm_up(base_url, no_progress=False): for pid in pids ] - logger.info("warming up /api/v1/slug/{slug}") + logger.info("warming up /api/v2/paper/ for slugs and DOIs") slugs = set([pid["slug"] for pid in paper_ids]) - warmup_individual_method(base_url, lambda slug: f"/api/v1/slug/{slug}", slugs, no_progress) + dois = set([pid["doi"] for pid in paper_ids]) + warmup_individual_method(base_url, lambda slug: f"/api/v2/paper/?slug={slug}", slugs, no_progress) + warmup_individual_method(base_url, lambda doi: f"/api/v2/paper/?doi={doi}", dois, no_progress) logger.info("warming up /api/v2/docmap/{doi}") - dois = set([pid["doi"] for pid in paper_ids]) warmup_individual_method(base_url, lambda doi: f"/api/v2/docmap/{doi}", dois, no_progress) diff --git a/neoflask/queries.py b/neoflask/queries.py index b50942a9..e1f3a7af 100644 --- a/neoflask/queries.py +++ b/neoflask/queries.py @@ -90,6 +90,113 @@ class REFEREED_PREPRINTS(Query): ] #, 'review_process'] +class REFEREED_PREPRINT_V2(Query): + code = """ +MATCH (col:VizCollection {name: "refereed-preprints"})-[:HasSubCol]->(subcol:VizSubCollection)-[:HasPaper]->(vzp:VizPaper) +WHERE ( + $doi IS NOT NULL AND vzp.doi = $doi +) OR ( + $slug IS NOT NULL AND vzp.slug = $slug +) +WITH vzp.doi AS doi +// grab the most recent version of the article +CALL { + WITH doi + MATCH (article:Article {doi: doi}) + WITH article + ORDER BY article.version DESC + return COLLECT(article)[0] AS a +} + +// need the VizPaper for the slug and the VizSubCollection for the review services +MATCH (vzp:VizPaper {doi: doi}) +MATCH (vzp)<-[:HasPaper]-(subcol:VizSubCollection)<-[:HasSubCol]-(:VizCollection {name: "refereed-preprints"}) +MATCH (vzp)-[:HasReviewDate]->(revdate:VizReviewDate) +WITH + a, + vzp, + COLLECT(DISTINCT subcol.name) AS reviewed_by, + COLLECT(DISTINCT revdate.date) AS review_dates + +OPTIONAL MATCH (a)-->(auth:Contrib) +OPTIONAL MATCH (auth)-[:has_orcid]->(auth_id:Contrib_id) +WITH + a, + vzp, + reviewed_by, + review_dates, + auth, + auth_id +ORDER BY auth.position_idx +WITH + a, + vzp, + reviewed_by, + review_dates, + COLLECT(DISTINCT auth {.surname, .given_names, .position_idx, .corresp, orcid: auth_id.text}) AS authors + +OPTIONAL MATCH (VizCollection {name: "by-auto-topics"})-->(autotopics:VizSubCollection)-[rel_autotopics_paper]->(vzp)-[:HasEntityHighlight]->(highlight:VizEntity {category: 'entity'}) +WITH + a, + vzp, + reviewed_by, + review_dates, + authors, + COLLECT(DISTINCT autotopics.topics) AS main_topics, + COLLECT(DISTINCT highlight.text) AS highlighted_entities + +OPTIONAL MATCH (vzp)-[:HasEntity]->(assay:VizEntity {category: 'assay'}) +WITH + a, + vzp, + reviewed_by, + review_dates, + authors, + main_topics, + highlighted_entities, + COLLECT(DISTINCT assay.text) AS assays + +OPTIONAL MATCH (vzp)-[:HasEntity]->(entity:VizEntity {category: 'entity'}) +// don't duplicate entities if they are in the topic highlight set +WHERE not((vzp)-[:HasEntityHighlight]->(entity)) + +WITH + a, + vzp, + reviewed_by, + review_dates, + authors, + main_topics, + highlighted_entities, + assays, + COLLECT(DISTINCT entity.text) AS entities + +RETURN { + slug: vzp.slug, + doi: a.doi, + version: a.version, + source: a.source, + journal: a.journal_title, + title: a.title, + abstract: a.abstract, + journal_doi: a.journal_doi, + published_journal_title: a.published_journal_title, + pub_date: toString(DATETIME(a.publication_date)), + review_dates: review_dates, + reviewed_by: reviewed_by, + authors: authors, + entities: entities, + assays: assays, + main_topics: main_topics, + highlighted_entities: highlighted_entities +} as refereed_preprint +""" + map = { + 'doi': {'req_param': 'doi', 'default': None}, + 'slug': {'req_param': 'slug', 'default': None} + } + returns = ['refereed_preprint'] + class REFEREED_PREPRINTS_V2(Query): code = ''' @@ -109,14 +216,20 @@ class REFEREED_PREPRINTS_V2(Query): // filter by reviewing service if requested MATCH (refprep:VizCollection {name: "refereed-preprints"})-[:HasSubCol]->(review_service:VizSubCollection) WHERE ( - $reviewed_by IS NULL OR - $reviewed_by = [] OR - review_service.name IN $reviewed_by + $reviewed_by IS NULL + OR $reviewed_by = [] + OR review_service.name IN $reviewed_by ) // filter by query if requested MATCH (review_service)-[:HasPaper]->(paper:VizPaper) -WHERE $lucene_query IS NULL OR paper.doi in doisFulltextSearch +WHERE + ($lucene_query IS NULL OR paper.doi in doisFulltextSearch) + AND ( + $published_in IS NULL + OR $published_in = [] + OR toLower(paper.published_journal_title) IN $published_in + ) // figure out how to sort based on the provided parameters MATCH (paper)-[:HasReviewDate]->(revdate:VizReviewDate) @@ -242,6 +355,7 @@ class REFEREED_PREPRINTS_V2(Query): map = { 'reviewed_by': {'req_param': 'reviewed_by', 'default': None}, 'lucene_query': {'req_param': 'lucene_query', 'default': None}, + 'published_in': {'req_param': 'published_in', 'default': None}, 'sort_by': {'req_param': 'sort_by', 'default': 'preprint_date'}, 'sort_ascending': {'req_param': 'sort_ascending', 'default': False}, @@ -994,6 +1108,21 @@ class DESCRIBE_REVIEWING_SERVICES_V2(Query): ] +class DESCRIBE_PUBLISHERS(Query): + code = ''' +MATCH (col:VizCollection {name: "refereed-preprints"})-[:HasSubCol]->(subcol:VizSubCollection)-[:HasPaper]->(vzp:VizPaper) +MATCH (a:Article {doi: vzp.doi}) +WHERE + a.published_journal_title IS NOT NULL + AND NOT isEmpty(a.published_journal_title) +RETURN + a.published_journal_title AS id, + COUNT(*) AS n_papers +ORDER BY TOLOWER(id) ASC + ''' + returns = ['id', 'n_papers'] + + class BY_REVIEWING_SERVICE(Query): code = '''