aoptk.literature.databases.europepmc ==================================== .. py:module:: aoptk.literature.databases.europepmc Classes ------- .. autoapisummary:: aoptk.literature.databases.europepmc.EuropePMC Functions --------- .. autoapisummary:: aoptk.literature.databases.europepmc._get_publication_id Module Contents --------------- .. py:class:: EuropePMC(storage: pathlib.Path, figure_storage: pathlib.Path, query: aoptk.literature.query.Query | None = None) Bases: :py:obj:`aoptk.literature.get_abstract.GetAbstract`, :py:obj:`aoptk.literature.get_pdf.GetPDF`, :py:obj:`aoptk.literature.get_id.GetID`, :py:obj:`aoptk.literature.get_publication.GetPublication`, :py:obj:`aoptk.literature.get_metadata.GetMetadata` Class to get data from Europe PMC based on a query. .. py:attribute:: page_size :value: 1000 .. py:attribute:: timeout :value: 30 .. py:attribute:: headers :type: ClassVar .. py:attribute:: image_extensions :value: ('.jpg', '.jpeg', '.png', '.bmp', '.tiff', '.tif') .. py:attribute:: unified_image_format :value: 'png' .. py:attribute:: search_term .. py:attribute:: storage .. py:attribute:: figure_storage .. py:attribute:: _session .. py:attribute:: retry_strategy .. py:attribute:: adapter .. py:method:: build_search_term(query: aoptk.literature.query.Query) -> str Convert Query to Europe PMC search syntax. .. py:method:: update_retry_strategy(strategy: urllib3.util.retry.Retry) -> None Update the retry strategy - allows customizing retry behaviour. This function updates the adapter and the session to ensure the new retry strategy is used for future requests. :param strategy: Strategy to use. :type strategy: Retry .. py:method:: _get_license_filter(licensing: str) -> str Get the license filter string for a given licensing type. :param licensing: The licensing type. :type licensing: str :returns: The license filter string for Europe PMC search. :rtype: str .. py:method:: get_pdfs(ids: list[aoptk.literature.id.ID]) -> list[aoptk.literature.pdf.PDF] Retrieve PDFs. .. py:method:: get_abstracts(ids: list[aoptk.literature.id.ID]) -> list[aoptk.literature.abstract.Abstract] Retrieve Abstracts. .. py:method:: get_publications(ids: list[aoptk.literature.id.ID], download_figures_enabled: bool = True) -> list[aoptk.literature.publication.Publication] Retrieve Publications. :param ids: A list of publication IDs to retrieve. :type ids: list[ID] :param download_figures_enabled: Whether to download figures and :type download_figures_enabled: bool :param include their paths in the Publication objects.: .. py:method:: get_publications_metadata(ids: list[aoptk.literature.id.ID]) -> list[aoptk.literature.metadata.Metadata] Retrieve Publication metadata. .. py:method:: get_ids() -> list[aoptk.literature.id.ID] Get a list of publication IDs from EuropePMC based on the search term. .. py:method:: _get_pdf(publication_id: aoptk.literature.id.ID) -> aoptk.literature.pdf.PDF Retrieve the PDF for a given publication ID. :param publication_id: The ID of the publication for which to retrieve the PDF. :type publication_id: ID :returns: The PDF object if successful, None otherwise. :rtype: PDF | None .. py:method:: _write_pdf(publication_id: aoptk.literature.id.ID, response: requests.Response) -> aoptk.literature.pdf.PDF Write the PDF content to a file and return a PDF object. :param publication_id: The ID of the publication for which the PDF is being written. :type publication_id: ID :param response: The HTTP response containing the PDF content. :type response: requests.Response .. py:method:: _get_abstract(publication_id: aoptk.literature.id.ID) -> aoptk.literature.abstract.Abstract | None Return abstract from Europe PMC for a given publication ID. :param publication_id: The ID of the publication for which to retrieve the abstract. :type publication_id: ID :returns: The abstract object if successful, None otherwise. :rtype: Abstract .. py:method:: _call_api(cursor_mark: str, result_type: str, query: str | aoptk.literature.id.ID) -> dict Call the EuropePMC web api to query the search. :param cursor_mark: Parameter for pagination. :type cursor_mark: str :param result_type: Whether to search for idlists or core. :type result_type: str :param query: main query to carry out - default self._query :type query: str | ID :returns: JSON response :rtype: dict .. py:method:: _get_publication_metadata(publication_id: aoptk.literature.id.ID) -> aoptk.literature.metadata.Metadata | None Return abstract from Europe PMC for a given publication ID. :param publication_id: The ID of the publication to retrieve metadata for. :type publication_id: ID .. py:method:: _get_publication(publication_id: aoptk.literature.id.ID, download_figures_enabled: bool = True) -> aoptk.literature.publication.Publication | None Return a Publication object for a given publication ID. :param publication_id: The ID of the publication to retrieve. :type publication_id: ID :param download_figures_enabled: Whether to download figures :type download_figures_enabled: bool :param and include their paths in the Publication object.: .. py:method:: _parse_xml_abstract(root: xml.etree.ElementTree.Element) -> str Return the full text content of the first element as a single string. :param root: The root element of the XML tree. :type root: ET.Element .. py:method:: _parse_xml_full_text(root: xml.etree.ElementTree.Element) -> str Parse the XML content to extract the full text. :param root: The root element of the XML tree. :type root: ET.Element .. py:method:: _parse_xml_figure_descriptions(root: xml.etree.ElementTree.Element) -> str Parse the XML content to extract the figure descriptions. :param root: The root element of the XML tree. :type root: ET.Element .. py:method:: _parse_xml_tables(root: xml.etree.ElementTree.Element) -> list[pandas.DataFrame] Parse the XML content to extract tables as a list of DataFrames, preserving order. :param root: The root element of the XML tree. :type root: ET.Element .. py:method:: _extract_rows(table_elem: xml.etree.ElementTree.Element) -> list[list[str]] Extract rows from a table element, preserving order. :param table_elem: The XML element representing the table. :type table_elem: ET.Element .. py:method:: _get_xml(publication_id: aoptk.literature.id.ID) -> xml.etree.ElementTree.Element | None Retrieve the XML root element for a given publication ID. :param publication_id: The ID of the publication to retrieve XML for. :type publication_id: ID .. py:method:: _get_figures(publication_id: aoptk.literature.id.ID) -> list[pathlib.Path] Retrieve the figure file paths for a given publication ID. :param publication_id: The ID of the publication to retrieve figures for. :type publication_id: ID .. py:method:: _get_supplementary_zip_path(publication_id: aoptk.literature.id.ID) -> pathlib.Path | None Download the supplementary files ZIP for a given publication ID and return the path to the ZIP file. :param publication_id: The ID of the publication to retrieve supplementary files for. :type publication_id: ID .. py:function:: _get_publication_id(result: dict) -> aoptk.literature.id.ID Extract the publication ID from the API result, checking for 'pmcid', 'pmid', and 'id' in order. Args: result (dict): The API result containing publication information.