npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

pubmed-fetch

v1.0.3

Published

Typescript version of Bio.Entrez; automating PubMed article and manuscript data retrivial.

Downloads

179

Readme

pubmed-fetch

an npm package which acts as a typescript version of Bio.Entrez -- automating PubMed article and manuscript data retrivial.
the majority of functions are asynchronous, using axios to perform the fetches from pubmed.

the main purpose of this package is to grab pubmed data to move into a database, which is why all of it pertains to logging in the console.

all functions can be found in src/index.ts.

installation

through npm package manager -- please make sure you have Node.js installed before installation.

npm i pubmed-fetch

getting started

you will need to create an NCBI account to obtain an API key from them if you would like to fetch papers quicker; also apparently this is needed if you don't want to get IP banned from fetching too many papers too fast.

key typically found at: https://account.ncbi.nlm.nih.gov/settings/

const api_key = process.env.NCBI_API_KEY
NCBI_API_KEY = "your_api_key"

NOTE: currently an NCBI API key is needed for the functions to work

  • if you are having issues with environment variables in your project, consider installing dotenv npm package.

building a query using buildQuery()

at the top of your file, you will need to define three consts, a string[] of author names, a string[] of topics, and a string for the date range

const authors = ['']
const topics = ['']
const dateRange = ''

these can all be left empty, however here is an example:

const authors = ["Luca Pinello", "David Stein", "Huidong Chen"]
const topics = ["cells", "scRNA", "bioinformatics"]
const dateRange = '("2024/09/19"[Date - Create] : "2024/10/15"[Date - Create])'

buildQuery() is simply concatenating them together using pubmed search logic to add into an eventual query command:

const query = buildQuery(authors, topics, dateRange);

a console.log(query) should result in something like this:

(Luca Pinello[Author] OR David Stein[Author] OR Huidong Chen[Author]) AND (cells[Title/Abstract] OR scRNA[Title/Abstract] OR bioinformatics[Title/Abstract]) AND ("2024/09/19"[Date - Create] : "2024/10/15"[Date - Create])

obtaining fully formatted paper results using getIDsAndData()

can be called in your file like in this:

const ret = getIDsAndData(query, 15, api_key, true);

where 15 would the maximum number of returned papers (i think the maximum currently is 10,000), and true indicates that you want the results to be logged to the console.

calling this function will use pubmed's esearch and efetch functions based of your query, then the outputted console xml is formatted into an array of PaperData objects (see processData() for formatting details).

here is what an example would look like in your console:

[
  {
      PMID: 39406691,
      title: 'Azithromycin induces liver injury in mice by targeting the AMPK/Nrf2 pathway.',
      slug: 'azithromycin-induces-liver-injury-in-mice-by-targeting-the-ampknrf2-pathway',
      abstract: "Azithromycin is an antibacterial and anti-inflammatory drug widely used for the treatment of various diseases, including those caused by atypical pathogens, bacterial or viral infections, chronic sinusitis, and bronchial asthma, particularly in pediatric patients. However, concerns have emerged regarding its hepatotoxicity and its precise mechanism of action remains unclear. To investigate the molecular mechanisms responsible for azithromycin-induced acute liver injury to advance our understanding of the progression and pathogenesis of antibiotic-induced liver damage, and to improve prevention and treatment strategies. C57BL/6 mice, Nrf2 mice, and primary hepatocytes were used. Primary hepatocytes from mice were isolated using a two-step perfusion method and cultured  the 'sandwich' culture model. The exposure to azithromycin resulted in increased apoptosis and reactive oxygen species (ROS) levels. In mouse models, intraperitoneal administration of azithromycin at varying concentrations and time points substantially induced hepatic disarray, swelling, and dysfunction. Azithromycin markedly upregulated the mRNA and protein levels of phosphorylated adenosine-activated protein kinase (AMPK) while downregulating nuclear factor erythroid 2-related factor 2 (Nrf2), heme oxygenase 1 (HO-1), and NADPH: quinone oxidoreductase 1 (NQO-1). Moreover, HO-1 and NQO-1 protein levels remained largely unaffected in primary hepatocytes co-cultured with azithromycin in Nrf2 mice. Our findings suggest that azithromycin-induced acute liver injury is mediated by suppression of Nrf2 activation and ROS production. This sheds light on the potential mechanisms involved in azithromycin-induced liver damage, underscoring the importance of exploring targeted interventions to mitigate the hepatotoxic effects.",
      authors: [
        'Xu Qixiang',
        'Zhang Cuifeng',
        'Lu Jingwen',
        'Qian Haiyi',
        'Wang Xiaodong',
        'Guo Wenjun',
        'Cheng Huixian'
      ],
      journal: 'Immunopharmacology and immunotoxicology',
      pubdate: 2024-10-14T16:00:00.000Z,
      keywords: [
        'Azithromycin',
        'acute liver injury',
        'adenosine-activated protein kinase',
        'nuclear factor erythroid 2-related factor 2',
        'primary hepatocytes'
      ],
      url: 'https://www.ncbi.nlm.nih.gov/pubmed/39406691',
      affiliations: [ 'School of Pharmacology, Wannan Medical College, Wuhu, China.' ]
    }
]

getting a list of PMIDs with fetchIDs()

a function that is called within getIDsAndData(), returns a list of PMIDs based off the query utilizing pubmed's esearch fetching option. here as an example:

const idList = fetchIDs(query, 15, api_key, true)

where console.log(idList) could look something like:

<eSearchResult>
  <IdList>
    <Id>38390375</Id>
    <Id>39418647</Id>
    <Id>39418644</Id>
    <Id>39418643</Id>
    <Id>39418642</Id>
  </IdList>
</eSearchResult> 

getting raw xml from idList using fetchData()

a function that is called within getIDsAndData(), returns raw xml data from list of PMIDs utilizing pubmed's efetch fetching option. unfortunately for the pubmed database, the only data format that can be outputted is xml, so i have used xml2js to format it slightly before actually processing it. here is an example:

const rawData = fetchData(idList, api_key, true)

where console.log(rawData) could look something like:

{
  PubmedArticleSet: {
    PubmedArticle: { MedlineCitation: [Object], PubmedData: [Object] }
  }
}

understanding processData()

this function takes the rawData outputted by fetchData() and processes each item into each attribute of the PaperData object:

PMID: number;
title: string;
slug: string;
abstract: string;
authors: string[];
journal: string;
pubdate: Date;
keywords: string[];
url: string;
affiliations: string[];

example output can be viewed under getIDsandData() output


v1.0 of pubmed-fetch!

i am open to all pull requests, suggestions, or improvements to my code. it is in part of a larger project i am doing for university, so i may not get back in a timely manner as long as the package is working for my current needs.
thank you for your support :) -- rebecca