Debian Codegraph @

Python/README.md

raw
1 This provides a basic Python API for pgenlib; see [python_api.txt](python_api.txt) for details.
2
3
4 ### Build instructions
5 PyPI:
6 ```
7 pip install 'pip>=20.3'
8 pip install Pgenlib
9 ```
10
11 To build from GitHub instead, clone the repository:
12
13 ```
14 # clone repo
15 git clone https://github.com/chrchang/plink-ng
16 # go to python folder
17 cd plink-ng/2.0/Python
18 ```
19
20 Then install Cython and NumPy:
21 ```
22 pip3 install "cython>=0.29.21" "numpy>=1.19.0"
23 ```
24
25 and then build and install the package
26 ```
27 python3 setup.py build_clib build_ext -i
28 python3 setup.py install
29 ```
30
31 You can test the package with `pytest`.
32
33 ##### Example usage:
34 ```
35 #write a 2 sample file
36 import numpy as np
37 import pgenlib as pg
38
39 with pg.PgenWriter("test.pgen".encode("utf-8"), 2, variant_ct=3, nonref_flags=False) as writer:
40 writer.append_alleles(np.array([0,1,1,1],dtype=np.int32))
41 writer.append_alleles(np.array([0,1,0,0],dtype=np.int32))
42 writer.append_alleles(np.array([0,0,0,0],dtype=np.int32))
43
44 ```
45
46 See tests/test_pgenlib.py for more sophisticated examples.