Skip to content

Commit 210b5d6

Browse files
committed
Updated docs and tests
1 parent d17873a commit 210b5d6

File tree

7 files changed

+53
-51
lines changed

7 files changed

+53
-51
lines changed

docs/assets/images/splash.png

-126 KB
Binary file not shown.

docs/assets/images/splash1.png

97.9 KB
Loading

docs/docs/API.md

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -203,13 +203,10 @@ Draw the visualization to the raster surface. Caches state for using with intera
203203
**Returns:**
204204
- `Gw`: Self for method chaining
205205

206-
### `draw_image(stream=True)`
206+
### `draw_image()`
207207

208208
Draw the visualization and return it as a PIL Image.
209209

210-
**Parameters:**
211-
- `stream` (bool, optional): Whether to use streaming mode for drawing
212-
213210
**Returns:**
214211
- `PIL.Image`: The visualization as a PIL Image
215212

docs/docs/Install.md

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,26 @@ nav_order: 2
1313
pip install gwplot
1414
```
1515

16-
### Building from Source (macOS)
16+
### Building from Source
1717

18+
#### MacOS
19+
20+
Install dependencies using homebrew (shown), or conda.
1821
```bash
19-
# Install dependencies with Homebrew
2022
brew install fontconfig freetype glfw htslib jpeg-turbo libpng xz
23+
```
2124

22-
# Clone repository with submodules
25+
Clone repository with GW submodule, install using pip
26+
```bash
2327
git clone --recursive https://github.com/kcleal/gwplot
2428
cd gwplot
29+
pip install -e . -v # Use editable mode for development
2530

26-
# Install development version
27-
pip install -r requirements.txt
28-
pip install -e . -v
29-
30-
# Run tests
31+
# Run tests, need -e option when using pip install
3132
python -m unittest discover -s ./tests
3233
```
34+
35+
#### Linux
36+
37+
For linux users, building is more convoluted. You will need to install htslib, glfw and freetype. An
38+
example build script can be found in `ci/manylinux-build-deps`

docs/index.md

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,22 @@ description: "gwplot: a python library for plotting genomic sequencing data"
99

1010
`gwplot` is a plotting library for genomics data and a Python interface to GW, a high-performance interactive genome browser.
1111

12+
Install using:
13+
14+
```bash
15+
pip install gwplot
16+
```
17+
1218
<br>
1319

14-
![Alt text](/assets/images/splash.png "Gwplot")
20+
![Alt text](/assets/images/splash1.png "Gwplot")
1521

1622

1723
## Features
1824

1925
- **High-performance visualization** of genomic data including BAM files, VCF, BED, and other formats
20-
- **Customizable themes and colors** for creating publication-quality visualizations
21-
- **Multi-region support** for comparative genomics
26+
- **Customizable themes and colors** for creating high-quality visualizations
27+
- **Multi-regions and data tracks** for comparative genomics
2228
- **Interactive mode** for dynamic exploration of genomic regions
2329
- **Flexible output formats** including PNG, JPEG, and NumPy arrays for further processing
2430
- **Built-in access** to common reference genomes
@@ -36,5 +42,5 @@ gw.add_bam("sample.bam")
3642
gw.add_region("chr1", 1000000, 1100000)
3743

3844
# Draw and save an image
39-
gw.draw().save_png("visualization.png")
45+
gw.draw().save_png("region.png")
4046
```

gwplot/interface.pyx

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1673,27 +1673,19 @@ cdef class Gw:
16731673
self.thisptr.runDrawNoBuffer()
16741674
return self
16751675

1676-
def draw_image(self, stream=True):
1676+
def draw_image(self):
16771677
"""
16781678
Draw the visualization and return it as a PIL Image.
16791679
1680-
Parameters
1681-
----------
1682-
stream : bool, optional
1683-
Whether to use streaming mode for drawing
1684-
16851680
Returns
16861681
-------
16871682
PIL.Image
16881683
The visualization as a PIL Image
16891684
"""
1690-
if stream:
1691-
self.draw_stream()
1692-
else:
1693-
if not self.raster_surface_created:
1694-
self.make_raster_surface()
1695-
self.thisptr.processed = False
1696-
self.runDraw()
1685+
if not self.raster_surface_created:
1686+
self.make_raster_surface()
1687+
self.thisptr.processed = False
1688+
self.thisptr.runDrawNoBuffer()
16971689
return Image.fromarray(self.array())
16981690

16991691
def view_region(self, chrom, start, end):

tests/test.py

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
import unittest
33
import os
4-
from gwplot import Gw, GwPaint
4+
from gwplot import Gw, GwPalette
55
import numpy as np
66
import matplotlib.pyplot as plt
77
from PIL import Image
@@ -62,7 +62,7 @@ def test_remove_region(self):
6262

6363
def test_run_save_png(self):
6464
gw.draw()
65-
gw.raster_to_png("out.png")
65+
gw.save_png("out.png")
6666
print("test_run_save_png done")
6767

6868
def test_to_ndarray(self):
@@ -72,7 +72,8 @@ def test_to_ndarray(self):
7272

7373
def test_run_draw_no_buffer(self):
7474
gw.apply_command("ylim 30")
75-
gw.draw_stream()
75+
gw.set_low_memory(1)
76+
gw.draw()
7677
img = Image.fromarray(gw.array())
7778
plt.figure()
7879
plt.imshow(img)
@@ -87,31 +88,31 @@ def test_run_draw_image(self):
8788
print("test_run_draw_image done")
8889

8990
def test_set_paint(self):
90-
gw.set_paint_ARBG(GwPaint.fcNormal, 255, 0, 0, 255)
91+
gw.set_paint_ARBG(GwPalette.NORMAL_READ, 255, 0, 0, 255)
9192
print("test_set_paint done")
9293

9394
def test_set_repaint(self):
94-
gw.set_paint_ARBG(GwPaint.bgPaint, 55, 255, 0, 0)
95+
gw.set_paint_ARBG(GwPalette.BACKGROUND, 55, 255, 0, 0)
9596
gw.draw()
96-
gw.raster_to_png("out2.png")
97+
gw.save_png("out2.png")
9798
print("test_set_repaint done")
9899

99-
def test_pysam(self):
100-
if not have_pysam:
101-
return
102-
af = pysam.AlignmentFile(root + "/small.bam")
103-
region = ("chr1", 1, 20000)
104-
bam_itr = af.fetch(*region)
105-
106-
gw.clear_alignments()
107-
gw.clear_regions()
108-
gw.add_region(*region)
109-
110-
gw.add_pysam_alignments(bam_itr)
111-
112-
print(dir(bam_itr))
113-
print(bam_itr)
114-
print("test_pysam done")
100+
# def test_pysam(self):
101+
# if not have_pysam:
102+
# return
103+
# af = pysam.AlignmentFile(root + "/small.bam")
104+
# region = ("chr1", 1, 20000)
105+
# bam_itr = af.fetch(*region)
106+
#
107+
# gw.clear_alignments()
108+
# gw.clear_regions()
109+
# gw.add_region(*region)
110+
#
111+
# gw.add_pysam_alignments(bam_itr)
112+
#
113+
# print(dir(bam_itr))
114+
# print(bam_itr)
115+
# print("test_pysam done")
115116

116117
def main():
117118
unittest.main()

0 commit comments

Comments
 (0)