A command-line tool to fetch research papers from PubMed based on a user query and identify papers with at least one author affiliated with a pharmaceutical or biotech company.
The results can be printed to the console or saved to a CSV file.
✅ Fetches papers from PubMed API using full query syntax
✅ Filters papers to detect non-academic authors and company affiliations (pharma/biotech)
✅ Outputs to console or CSV file
✅ Optional debug mode to show API flow and intermediate data
✅ Built with Poetry for dependency management & packaging
pubmed-cli-tool/
│
├── pubmed\_cli/ # Core package
│ ├── fetcher.py # PubMed API calls (Entrez E-utilities)
│ ├── filters.py # Logic for parsing & identifying pharma/biotech authors
│ ├── utils.py # CSV saving utilities
│ └── **init**.py
│
├── scripts/ # CLI entry point
│ ├── cli.py # Main CLI logic (argparse)
│ └── **init**.py
│
├── tests/ # Pytest test suite
│ ├── test\_cli.py
│ ├── test\_fetcher.py
│ └── test\_filter.py
│
├── dist/ # (auto-generated) build artifacts for TestPyPI/PyPI
├── pyproject.toml # Poetry config (dependencies, CLI command)
├── README.md # Documentation
└── ...
Clone the repo & install dependencies:
git clone https://github.com/<your-username>/pubmed-cli-tool.git
cd pubmed-cli-tool
poetry installRun tests to verify everything works:
poetry run pytestRun the CLI command:
poetry run get-papers-list "<your-query>"-d, --debug Enable debug output
-f, --file <name> Save results to CSV (instead of printing to console)
-h, --help Show help message
1️⃣ Print to console:
poetry run get-papers-list "cancer immunotherapy" --debug2️⃣ Save to CSV:
poetry run get-papers-list "cancer immunotherapy" -f results.csvThis generates results.csv with columns:
- PubmedID
- Title
- Publication Date
- Non-academic Authors
- Company Affiliations
- Corresponding Author Email
- Affiliations containing university, college, institute, hospital = academic
- Affiliations containing pharma, biotech, inc, ltd, corp, therapeutics = industry
- Poetry – Dependency management & packaging
- Biopython – PubMed API access (via Bio.Entrez)
- Requests – API calls
- argparse – CLI parsing
- pytest – Testing framework
- ML-based affiliation classification
- More robust handling of missing metadata
- Better CSV formatting options
- Continuous integration tests
The package is live on TestPyPI for preview.
pip install -i https://test.pypi.org/simple/pubmed-paper-fetcher-clThen run:
get-papers-list "CRISPR" --debug