Metadata-Version: 2.3
Name: my-pubmed-package
Version: 0.1.2
Summary: A typed Python module and CLI to fetch PubMed papers affiliated with pharma/biotech companies.
License: MIT
Author: Deepak Singh ds4maths@gmail.com
Requires-Python: >=3.9,<4.0
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Requires-Dist: requests (>=2.31.0,<3.0.0)
Description-Content-Type: text/markdown


# 📚 My PubMed Package  

**A Python CLI & library to search PubMed, filter pharmaceutical/biotech papers, and export results to CSV.**

---

## 🚀 Features  

✅ **Search PubMed** with a query (full syntax supported).  
✅ **Fetch research papers** and extract metadata.  
✅ **Identify pharmaceutical/biotech-affiliated authors** using heuristics.  
✅ **Save results to CSV** or print them in the terminal.  
✅ **Command-line interface (CLI)** for easy execution.  
✅ **Python module for programmatic use.**  
✅ **Lightweight & easy to install** (only depends on `requests`).  

---

## 🛠 Installation  

### **Install from PyPI**  
You can install the package **directly from PyPI** using:  

```bash
pip install my-pubmed-package
```

This installs both the **Python library** and the **CLI tool** (`get-papers-list`).  

---

## 🎮 CLI Usage  

After installation, you can **run the CLI tool**:  

```bash
get-papers-list "machine learning in drug discovery" -d -f results.csv
```

### **Command Options**  
| Option | Description |
|--------|-------------|
| `query` | (Required) The PubMed search query. Full syntax supported. |
| `-d`, `--debug` | Enable verbose debug logs. |
| `-f <filename>`, `--file <filename>` | Save output to CSV. If omitted, prints results to the console. |
| `-h`, `--help` | Display help message. |

#### **Example:**
```bash
get-papers-list "cancer immunotherapy" -d -f papers.csv
```
✅ Fetches 50 papers  
✅ Filters those with pharma/biotech affiliations  
✅ Saves the output in `papers.csv`  

---

## 📄 Example Output  

### **CSV File (`results.csv`) Example:**
```
PubmedID,Title,Publication Date,Non-academic Author(s),Company Affiliation(s),Corresponding Author Email
39941149,"Discovery of TRPV4-Targeting Small Molecules",2025-Feb-06,"Yu Wang","State Key Laboratory of Pathogen and Biosecurity","coen.vanhasselt@lacdr.leidenuniv.nl"
39935140,"Disorganization of Small-World Functional Networks",2025-Feb,"","Department of Radiology, Tongde Hospital of Zhejiang Province",""
39930345,"C-H Aminoalkylation of 5-Membered Heterocycles",2025-Feb-11,"Cyndi Qixin He; Marion H Emmert","Process Research and Development, Merck & Co., Inc.","parthapatrim.roy@gcu.ac.in"
```

### **Terminal Output Example (if no `-f` is provided):**
```
--- Pharma/Biotech Papers ---
PubmedID: 39941149
Title: Discovery of TRPV4-Targeting Small Molecules
Publication Date: 2025-Feb-06
Non-academic Author(s): Yu Wang
Company Affiliation(s): State Key Laboratory of Pathogen and Biosecurity
Corresponding Author Email: coen.vanhasselt@lacdr.leidenuniv.nl
--------------------------------------------------
```

---

## 🖥 Programmatic Usage  

You can also use `my-pubmed-package` as a **Python module**:

```python
from my_pubmed_package.pubmed_module import search_pubmed_ids, fetch_pubmed_details_bulk

# Search PubMed for PMIDs
pmids = search_pubmed_ids("heart attack therapy", retmax=10, verbose=True)

# Fetch metadata
articles = fetch_pubmed_details_bulk(pmids, verbose=True)

# Print first result
print(articles[0])
```

---

## 🔄 Updating the Package  

To update to the latest version:

```bash
pip install --upgrade my-pubmed-package
```

---


## 🛠 Troubleshooting  

### **1️⃣ `get-papers-list: command not found`**
If the CLI is not recognized, try running it with:

```bash
poetry run get-papers-list "cancer immunotherapy" -d -f results.csv
```
OR:
```bash
python -m my_pubmed_package.cli "cancer immunotherapy" -d -f results.csv
```

### **2️⃣ No PMIDs found**
Try using broader search queries or visit [PubMed](https://pubmed.ncbi.nlm.nih.gov/) to refine.


---

## 📜 License  
This project is licensed under the **MIT License**.

---

## 🎉 Thank You!  
If you find this package useful, **star it on GitHub** and share it with others! 🚀

