Find Neighbour 5
Spiritual successor to Find Neighbour 4 - continuing the work of David Wyllie.
SNP matrix generation with caching to disk to allow fast reloading.
Install
As this is compiled client side, ensure you have a functional C++ compiler such as GCC installed. Currently only tested on Linux
# Optional virtual environment
python -m virtualenv env
souce env/bin/activate
# Install via pip
pip install fn5
Notes
This provides some of the bindings to the underlying FN5 library, but has some limitations. Most of the functionality should be exposed via the Python bindings though.
Read FASTA files
Firstly, you'll need a reference genome, and a list of positions to mask within it. The mask is optional, but can be used to mask homoplastic or phylogenetic regions which aren't of epidemialogical interest. The mask should be line separated genome positions.
import fn5
reference = fn5.load_reference("<path to your reference>")
mask = fn5.load_mask("<path to your mask>")
# Alternatively ignore the mask
mask = set()
Then, samples can be parsed from FASTA files
sample1 = fn5.Sample("<path to sample1's FASTA>", reference, mask, "sample1")
sample2 = fn5.Sample("<path to sample2's FASTA>", reference, mask, "sample2")
...
Save samples
For the sake of efficency, a sample can be written to (and subsequently loaded from) disk.
Note that the fn5.save method writes 5 files to the specified direction. <path>/<sample ID>.A, <path>/<sample ID>.C. ...
fn5.save("<some output directory>", sample1)
Load samples
Load pre-saved samples from disk. This should be significantly faster than re-parsing the FASTA files.
sample1 = fn5.load("<some output directory>/sample1")
Compute distances
Distances can be computed with arbitrary SNP cuttoffs.
Single distance
If a returned distance == your cutoff + 1, the two samples are further away than the SNP cutoff.
sample1.dist(sample2, <some cutoff>)
Distance matrix
By default this method uses 4 threads, and no cutoff. If a pair of samples is missing from the returned distance list, they are further away than the given cutoff.
samples = [fn5.load("<some directory>/"+f) for f in <existing filepaths>]
fn5.compute(samples)
# With more/less threads
fn5.compute(samples, thread_count=12)
fn5.compute(samples, thread_count=1)
# With a SNP cutoff
fn5.compute(samples, cutoff=12)
Metadata
Release files for fn5 2.0.7
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| fn5-2.0.7.tar.gz | 3.2 MB | Without provenance | Details for fn5-2.0.7.tar.gz |
Release files / fn5-2.0.7.tar.gz
| Download URL | fn5-2.0.7.tar.gz |
|---|---|
| Size | 3.2 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
67c0a65874445dc321c58ab1017ef926573e8f1fca28519e02bbd64aff49dcb7
|
|
BLAKE2b-256 checksum How to use checksums |
606ce7832b201b2c8cb0e4aa0925740c847afc47935a365b2b6978a4ff43b3f8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.12.7
|
Security for fn5 2.0.7
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.