Skip to content

Commit 2c83723

Browse files
committed
Release v0.3.0
1 parent 23cd149 commit 2c83723

43 files changed

Lines changed: 734 additions & 1218 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.dockerignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ notebooks/
88
**/.env
99
pytest.ini
1010
docs/
11+
.ruff_cache/
1112

1213
# Common
1314
README.md

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ dev*/
44
cache/
55
webapp-*/
66
pytest.ini
7+
.ruff_cache/
78

89
# Byte-compiled / optimized / DLL files
910
__pycache__/

Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
FROM python:3.11.9-slim-bookworm
1+
FROM python:3.11-slim-bookworm
22
WORKDIR /app
33
COPY . .
4-
RUN pip install .
4+
RUN pip install --no-cache-dir .
55

66
EXPOSE 8050
77
ENV HOST=0.0.0.0

README.md

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,12 @@ NetMedEx is a Python-based tool designed to extract BioConcept entities (e.g., g
77

88
## Getting Started
99

10-
NetMedEx offers three ways for users to interact with the tool:
10+
NetMedEx offers four ways for users to interact with the tool:
1111

1212
1. [Web Application (via Docker)](#web-application-via-docker)
1313
2. [Web Application (Local)](#web-application-local)
1414
3. [Command-Line Interface (CLI)](#command-line-interface-cli)
15+
4. [Python API](#package-api)
1516

1617
For additional details, refer to the [Documentation](https://yehzx.github.io/NetMedEx/).
1718

@@ -31,7 +32,7 @@ Install NetMedEx from PyPI to use the web application locally or access the CLI:
3132
pip install netmedex
3233
```
3334

34-
*We recommend using Python version >= 3.11 for NetMedEx.*
35+
_We recommend using Python version >= 3.11 for NetMedEx._
3536

3637
## Web Application (Local)
3738

@@ -65,7 +66,7 @@ netmedex search -f examples/pmids.txt [-o OUTPUT_FILEPATH]
6566
netmedex search -q '"@DISEASE_COVID_19" AND "@GENE_PON1"' [-o OUTPUT_FILEPATH] --max_articles 100
6667
```
6768

68-
*Note: Use double quotes for keywords containing spaces and logical operators (e.g., AND/OR) to combine keywords.*
69+
_Note: Use double quotes for keywords containing spaces and logical operators (e.g., AND/OR) to combine keywords._
6970

7071
Available commands are detailed in [Search Command](#search-command).
7172

@@ -123,7 +124,7 @@ usage: netmedex search [-h] [-q QUERY] [-o OUTPUT] [-p PMIDS] [-f PMID_FILE] [-s
123124
[--use_mesh] [--debug]
124125

125126
options:
126-
-h, --help Show this help message and exit
127+
-h, --help show this help message and exit
127128
-q QUERY, --query QUERY
128129
Query string
129130
-o OUTPUT, --output OUTPUT
@@ -133,11 +134,11 @@ options:
133134
-f PMID_FILE, --pmid_file PMID_FILE
134135
Filepath to load PMIDs (one per line)
135136
-s {score,date}, --sort {score,date}
136-
Sort articles in descending order (default: date)
137+
Sort articles in descending order by (default: date)
137138
--max_articles MAX_ARTICLES
138-
Maximum articles to request (default: 1000)
139+
Maximal articles to request from the searching result (default: 1000)
139140
--full_text Collect full-text annotations if available
140-
--use_mesh Use MeSH vocabulary instead of common text
141+
--use_mesh Use MeSH vocabulary instead of the most commonly used original text in articles
141142
--debug Print debug information
142143
```
143144
@@ -148,24 +149,29 @@ usage: netmedex network [-h] [-i INPUT] [-o OUTPUT] [-w CUT_WEIGHT] [-f {xgmml,h
148149
[--weighting_method {freq,npmi}] [--pmid_weight PMID_WEIGHT] [--debug] [--community] [--max_edges MAX_EDGES]
149150

150151
options:
151-
-h, --help Show this help message and exit
152+
-h, --help show this help message and exit
152153
-i INPUT, --input INPUT
153154
Path to the pubtator file
154155
-o OUTPUT, --output OUTPUT
155156
Output path (default: [INPUT_DIR].[FORMAT_EXT])
156157
-w CUT_WEIGHT, --cut_weight CUT_WEIGHT
157-
Discard edges with weight smaller than the specified value (default: 2)
158-
-f {xgmml,html,json}, --format {xgmml,html,json}
158+
Discard the edges with weight smaller than the specified value (default: 2)
159+
-f {xgmml,html,json,pickle}, --format {xgmml,html,json,pickle}
159160
Output format (default: html)
160161
--node_type {all,mesh,relation}
161162
Keep specific types of nodes (default: all)
162163
--weighting_method {freq,npmi}
163-
Weighting method for network edges (default: freq)
164+
Weighting method for network edge (default: freq)
164165
--pmid_weight PMID_WEIGHT
165-
CSV file for the edge weight from a PMID (default: 1)
166+
CSV file for the weight of the edge from a PMID (default: 1)
166167
--debug Print debug information
167-
--community Divide nodes into communities using the Louvain method
168+
--community Divide nodes into distinct communities by the Louvain method
168169
--max_edges MAX_EDGES
169170
Maximum number of edges to display (default: 0, no limit)
170171
```
171172
173+
## Package API
174+
175+
In addition to the web interface and CLI, NetMedEx can be used programmatically as a Python library. This allows for more flexible integration into custom pipelines and analysis workflows.
176+
177+
Example usage is available in `notebooks/netmedex_usage.ipynb`.

docs/api_usage.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# Python API Usage
2+
3+
NetMedEx supports Python **3.11** and above. This page demonstrates how to use the library programmatically. The `PubTatorAPI` class retrieves articles from PubTator3, and `PubTatorGraphBuilder` constructs the co-occurrence network.
4+
5+
## Retrieve Articles
6+
7+
```python
8+
from netmedex.pubtator import PubTatorAPI
9+
10+
collection = PubTatorAPI(
11+
query='"covid-19" AND "PON1"',
12+
sort="score",
13+
max_articles=100,
14+
).run()
15+
```
16+
17+
## Save and Load Collections
18+
19+
```python
20+
import json
21+
22+
# Save to JSON
23+
with open("collection.json", "w") as f:
24+
json.dump(collection.to_json(), f)
25+
26+
# Load from JSON
27+
from netmedex.pubtator_data import PubTatorCollection
28+
with open("collection.json") as f:
29+
loaded = PubTatorCollection.from_json(json.load(f))
30+
31+
# Or load from a PubTator file
32+
from netmedex.pubtator_parser import PubTatorIO
33+
loaded = PubTatorIO.parse("collection.pubtator")
34+
```
35+
36+
## Build and Export a Network
37+
38+
```python
39+
from netmedex.graph import PubTatorGraphBuilder, save_graph
40+
41+
builder = PubTatorGraphBuilder(node_type="all")
42+
builder.add_collection(loaded)
43+
graph = builder.build(weighting_method="freq", edge_weight_cutoff=1)
44+
45+
save_graph(graph, "network.html", output_filetype="html")
46+
```
47+
48+
The notebook `notebooks/netmedex_usage.ipynb` contains a complete demonstration of these steps.

docs/cli_guides.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ netmedex search -f examples/pmids.txt [-o OUTPUT_FILEPATH]
2020
netmedex search -q '"@DISEASE_COVID_19" AND "@GENE_PON1"' [-o OUTPUT_FILEPATH] --max_articles 100
2121
```
2222

23-
*Note: Use double quotes for keywords containing spaces and logical operators (e.g., AND/OR) to combine keywords.*
23+
_Note: Use double quotes for keywords containing spaces and logical operators (e.g., AND/OR) to combine keywords._
2424

2525
Available commands are detailed in [Search Command](#search-command).
2626

@@ -76,7 +76,7 @@ usage: netmedex search [-h] [-q QUERY] [-o OUTPUT] [-p PMIDS] [-f PMID_FILE] [-s
7676
[--use_mesh] [--debug]
7777

7878
options:
79-
-h, --help Show this help message and exit
79+
-h, --help show this help message and exit
8080
-q QUERY, --query QUERY
8181
Query string
8282
-o OUTPUT, --output OUTPUT
@@ -86,11 +86,11 @@ options:
8686
-f PMID_FILE, --pmid_file PMID_FILE
8787
Filepath to load PMIDs (one per line)
8888
-s {score,date}, --sort {score,date}
89-
Sort articles in descending order (default: date)
89+
Sort articles in descending order by (default: date)
9090
--max_articles MAX_ARTICLES
91-
Maximum articles to request (default: 1000)
91+
Maximal articles to request from the searching result (default: 1000)
9292
--full_text Collect full-text annotations if available
93-
--use_mesh Use MeSH vocabulary instead of common text
93+
--use_mesh Use MeSH vocabulary instead of the most commonly used original text in articles
9494
--debug Print debug information
9595
```
9696
@@ -101,25 +101,25 @@ usage: netmedex network [-h] [-i INPUT] [-o OUTPUT] [-w CUT_WEIGHT] [-f {xgmml,h
101101
[--weighting_method {freq,npmi}] [--pmid_weight PMID_WEIGHT] [--debug] [--community] [--max_edges MAX_EDGES]
102102

103103
options:
104-
-h, --help Show this help message and exit
104+
-h, --help show this help message and exit
105105
-i INPUT, --input INPUT
106106
Path to the pubtator file
107107
-o OUTPUT, --output OUTPUT
108108
Output path (default: [INPUT_DIR].[FORMAT_EXT])
109109
-w CUT_WEIGHT, --cut_weight CUT_WEIGHT
110-
Discard edges with weight smaller than the specified value (default: 2)
111-
-f {xgmml,html,json}, --format {xgmml,html,json}
110+
Discard the edges with weight smaller than the specified value (default: 2)
111+
-f {xgmml,html,json,pickle}, --format {xgmml,html,json,pickle}
112112
Output format (default: html)
113113
--node_type {all,mesh,relation}
114114
Keep specific types of nodes (default: all)
115115
--weighting_method {freq,npmi}
116-
Weighting method for network edges (default: freq)
116+
Weighting method for network edge (default: freq)
117117
--pmid_weight PMID_WEIGHT
118-
CSV file for the article weights (default: 1)
118+
CSV file for the weight of the edge from a PMID (default: 1)
119119
--debug Print debug information
120-
--community Divide nodes into communities using the Louvain method
120+
--community Divide nodes into distinct communities by the Louvain method
121121
--max_edges MAX_EDGES
122-
Maximum number of edges (default: 0, no limit)
122+
Maximum number of edges to display (default: 0, no limit)
123123
```
124124
125-
More detailed explanation of each command is available in [Reference](reference.md).
125+
More detailed explanation of each command is available in [Reference](reference.md).

docs/img/netmedex_edge-info.png

121 KB
Loading

docs/img/netmedex_interface.jpeg

-121 KB
Binary file not shown.

docs/img/netmedex_interface.png

107 KB
Loading

docs/img/netmedex_network.png

83.5 KB
Loading

0 commit comments

Comments
 (0)