seedmatch
seedmatch is a Python port of the R package SeedMatchR, ready for AI agent sandboxes. It finds the seed matches of an siRNA guide strand in transcript sequences. It then joins the matches with the results of a differential expression (DE) analysis. Thus you can see which genes with a seed match go down.
The output is the same as the output of SeedMatchR on the core paths. R golden files in tests/golden/ keep this true. The installed package holds these documents, and importlib.resources.files("seedmatch").joinpath(name).read_text() reads each one without network:
guide.md: the options, the limits, and the edge cases of each function.r-map.md: the Python name of each R function, and the changes of the arguments.divergences.md: each change of behavior from R, with its IDD-NNN.
Installation
Python 3.12 or later is necessary. Install seedmatch from PyPI:
uv pip install seedmatch
To draw the figures of seedmatch.plot, install the extra plot:
uv pip install "seedmatch[plot]"
PyPI has a wheel for Linux x86_64 and Linux aarch64 (glibc 2.28 or later), and for macOS arm64. On a different platform, the install builds the Rust extension from the sdist. To install the code of main, use uv pip install git+https://github.com/inflexa-ai/seedmatch.git. A build from the source needs rustup and a C linker. CONTRIBUTING.md gives the setup of the build.
A part of an agentic toolchain for bioinformatics
Inflexa, Inc. builds an agentic toolchain for bioinformatics. The toolchain ports existing tools to languages and architectures that an agent sandbox can run. An example of such a sandbox is the sandbox of Inflexa. seedmatch is a tool of this toolchain.
A sandbox such as the Inflexa sandbox has no network egress, and an agent corrects its calls from the error messages. Thus seedmatch obeys these rules:
- No network in the core. The core modules never use the network. Each function reads its input from a path or an object that you give. The separate module
seedmatch.fetchdownloads the resources (see Resources). - No R and no system library. The package is Python on numpy, pandas, and scipy, with a compiled extension for the search kernels. It does not use R or a system library. The extra
plotadds matplotlib. - Errors that an agent can use. Each
InputErrornames the bad value and the expected value. Thus an agent can correct the call. Each error class that seedmatch defines is aSeedMatchError, andInputErroris also aValueError. If a file does not exist, the function raisesFileNotFoundError.
Example
from seedmatch import (
Guide,
SearchOptions,
Seed,
annotate_seed_counts,
count_matches,
filter_de,
find_matches,
read_deseq2_table,
read_fasta,
seed_match_report,
)
# The ID of each FASTA record is the gene ID of its sequence.
sequences = read_fasta("transcripts.fa")
# The guide strand, 5' to 3'. The target is the DNA site that the seed pairs with.
guide = Guide("UUAUAGAGCAAGAACACUGUUUU")
target = guide.target(Seed.MER7M8)
# The number of matches in each sequence, and the 1-based range of each match.
counts = count_matches(target, sequences)
ranges = find_matches(target, sequences, SearchOptions(max_mismatch=1))
# A DESeq2 table with 8 columns, filtered as filter_res does it in R.
de = filter_de(read_deseq2_table("deseq2_results.tsv"))
# Add the column "mer7m8": the count of the seed matches of each gene.
de = annotate_seed_counts(de, sequences, target)
# The SeedMatchReport of R: the genes of each match class, and the off-targets among them.
report = seed_match_report(de, sequences, guide)
summary = report.report
matches = report.matches
ecdf_test compares the log2FoldChange values of two gene sets. This example compares the genes with a seed match to the genes without a match. With the default KS test, a small p-value shows that the genes with a seed match go down.
from seedmatch import ecdf_test
# The genes with a seed match, and the genes without a match.
seed_genes = de.loc[de["mer7m8"] >= 1, "gene_id"]
background = de.loc[de["mer7m8"] == 0, "gene_id"]
# The KS test of R. The default alternative is GREATER, as in R.
ecdf_result = ecdf_test(de, target=seed_genes, background=background)
print(ecdf_result.statistic, ecdf_result.p_value)
To get the sequences from an annotation, open a Reference. A Reference joins an EnsDb file and a genome file of the same build.
from seedmatch import FeatureType, Reference, count_matches
with Reference.from_paths(ensdb="ensdb.sqlite", genome="genome.2bit") as ref:
# The 3' UTR of each canonical protein-coding transcript.
# The ID of a sequence is its transcript ID.
utr3 = ref.sequences(FeatureType.UTR3)
# The number of seed matches in each 3' UTR, with the target of the example above.
utr3_counts = count_matches(target, utr3)
Other analyses
Each example uses the objects of the examples above. guide.md gives the options and the edge cases of each function.
kmer_counts counts the k-mers of each sequence, and kmer_gene_counts gives the number of genes that have each k-mer.
from seedmatch import kmer_counts, kmer_gene_counts
# The 7-mers of the sequences. The default k is 7, the default of R.
kmers = kmer_counts(sequences)
# The number of genes with each 7-mer, as a Series. The index is the 7-mer.
genes_with_kmer = kmer_gene_counts(kmers)
# The number of genes that have the 7-mer of the target.
print(genes_with_kmer[target.sequence])
alignment_text shows how the guide pairs with the sequence at one match.
from seedmatch import alignment_text
# The three lines: the guide, the pairs, and the sequence. The default seed is Seed.MER7M8.
alignment = alignment_text(find_matches(target, sequences).iloc[0], guide, sequences)
print(alignment)
match_distances gives the distance between each pair of matches in one sequence.
from seedmatch import match_distances
# One row for each pair of matches in a sequence. A sequence with one match has no row (D-011).
distances = match_distances(find_matches(guide.target(Seed.MER6), sequences))
print(distances.head())
e_values gives the e-value of the seed count of each gene against a null of shuffled guides from e_value_null.
from seedmatch import e_value_null, e_values
# The null: the seed count of each gene for each of 100 shuffles of the guide.
null = e_value_null(guide, sequences, rng=1, n_random=100)
# The e-value of the column "mer7m8". A small e-value shows a count that shuffles rarely reach.
scored = e_values(de, null, column="mer7m8")
print(scored[["gene_id", "mer7m8", "e_value"]].head())
benchmark_predictions scores the seed counts against a gold standard of genes that go down.
from seedmatch import benchmark_predictions
# The scores are the seed counts of the column "mer7m8". The cutoffs are the R defaults: 0.15 and 0.
benchmark = benchmark_predictions(de)
print(benchmark.pr.auc_integral, benchmark.roc.auc)
read_mirdb reads the miRDB table of predicted miRNA targets. This example keeps the rows of the rat, which has the species code rno.
from seedmatch import read_mirdb
# The columns: mirdb_id, target_refseq_id, target_score, species, and mirna_name.
rat_targets = read_mirdb("miRDB_v6.0_prediction_result.txt.gz", species="rno")
print(rat_targets.head())
wobble_bulge_matches finds the sites that have G:U pairs or a bulge in the seed region.
from seedmatch import annotate_wobble_bulge_counts, wobble_bulge_matches
# One row for each distinct start of a site, with the place and the size of its bulge.
wobble_matches = wobble_bulge_matches(guide, sequences)
print(wobble_matches.head())
# The column "overall_matches": for each gene, the largest number of rows of one of its sequences (D-003).
wobble_de = annotate_wobble_bulge_counts(de, sequences, guide)
print(wobble_de[["gene_id", "overall_matches"]].head())
compensatory_sites finds the sites with a seed match and a second region of the guide that pairs with the sequence before the match.
from seedmatch import compensatory_sites, ecdf_test
# One row for each pair of a seed match and a region of one sequence.
sites = compensatory_sites(guide, sequences)
print(sites.head())
# As in the R vignette: the genes with a site against the other genes of the DE table.
site_genes = sites["gene_id"].unique()
other_genes = de.loc[~de["gene_id"].isin(site_genes), "gene_id"]
site_result = ecdf_test(de, target=site_genes, background=other_genes)
print(site_result.p_value)
read_trrust reads the TRRUST table of regulators and their targets. trrust_scores gives each gene of the table a repression score and an activation score.
from seedmatch import read_trrust, trrust_scores
# The columns: source, target, edge_type, and evidence.
trrust = read_trrust("trrust_rawdata.human.tsv")
# TRRUST names a gene by its symbol, not by its Ensembl gene ID.
# Replace the symbols of the example with the symbols of your seed genes.
trrust_result = trrust_scores(trrust, ["TFA", "GC", "TFC"])
print(trrust_result.head())
read_string_links reads the STRING protein links. string_gene_network maps the proteins to genes, and string_scores gives each gene of the network a score.
import pandas as pd
from seedmatch import Reference, read_string_links, string_gene_network, string_scores
# The links with a score of 400 or more, and then the links above the 95th percentile of these scores.
links = read_string_links("10116.protein.links.v12.5.txt.gz")
# The EnsDb of the same species and build gives the gene of each protein.
with Reference.from_paths(ensdb="ensdb.sqlite", genome="genome.2bit") as ref:
network = string_gene_network(links.links, ref)
# The seed count of each 3' UTR, with the gene ID of the UTR. A gene with more than one row keeps the highest count (D-062).
utr3_de = pd.DataFrame({"gene_id": utr3.gene_ids, "mer7m8": utr3_counts})
string_result = string_scores(network.edges, utr3_de, column="mer7m8")
print(string_result.head())
Plots and the HTML report
The functions of seedmatch.plot work only with the extra plot. A plot function returns a matplotlib.figure.Figure, and report_html returns the report table as HTML.
from pathlib import Path
from seedmatch import report_html
from seedmatch.plot import (
plot_alignment,
plot_benchmark,
plot_ecdf,
plot_kmer_histogram,
plot_ranges,
plot_wasserstein,
)
# The ECDF of the two gene sets of the ecdf_test example, with the result of the test.
ecdf_figure = plot_ecdf(de, {"Background": background, "mer7m8": seed_genes}, ecdf_result)
ecdf_figure.savefig("ecdf.png", dpi=300)
# The density, the ECDF, and the ECDF difference of the Wasserstein areas.
wasserstein_figure = plot_wasserstein(
de.loc[de["mer7m8"] >= 1, "log2FoldChange"], de.loc[de["mer7m8"] == 0, "log2FoldChange"]
)
# The number of genes with each 7-mer, with a line at the target.
kmer_figure = plot_kmer_histogram(genes_with_kmer, target.sequence)
# The alignment text of the example above.
alignment_figure = plot_alignment(alignment)
# One bar for each match range of the first example.
ranges_figure = plot_ranges(ranges)
# The PR curve and the ROC curve of the benchmark example.
benchmark_figure = plot_benchmark(benchmark)
# The SeedMatchReport table as HTML.
Path("report.html").write_text(report_html(report, guide), encoding="utf-8")
Resources
The sandbox of an agent has no network access. Thus a machine with network access runs seedmatch-fetch, and the sandbox reads the files from a path. The registry in seedmatch.resources pins the URL, the size, and the SHA-256 digest of each file.
# The 2bit file and the EnsDb file of one genome build.
seedmatch-fetch reference rnor7 refs/rnor7
# The DESeq2 tables of the siRNA example (GEO series GSE184929).
seedmatch-fetch example sirna data/sirna
# The miRDB v6.0 predictions.
seedmatch-fetch mirdb data/mirdb
# The TRRUST table of human or mouse.
seedmatch-fetch trrust human data/trrust
# The STRING protein links of one NCBI taxon.
seedmatch-fetch string 10116 data/string
# One line for each file: group, key, file name, version, size in bytes, SHA-256 digest, URL, license, and description.
seedmatch-fetch list
guide.md gives the output and the exit status of the command, and the Python API of the registry.
Differences from SeedMatchR
seedmatch corrects the defects of SeedMatchR that it finds. These changes are the most important for a user:
- The ranges of a search obey the same rules as the counts. In R,
vmatchPattern2uses the indel algorithm also whenwith.indelsisFALSE, if the pattern is longer thanmax.mismatch. Thus the ranges and the counts do not agree (D-001). - A result for a gene uses all the sequences of the gene. R uses the first sequence for the seed count, and it counts each sequence in the report (D-003).
full_search_rangesgives a result for each input. R stops if each search finds a match, or if no search finds a match (D-022).wobble=Truewithfixed_pattern=TrueraisesInputError, because a fixed pattern matches the wobble letter R only to the letter R (D-026).- A sequence from an annotation keeps its transcript ID and its gene ID. In R,
load_annotationsgives the nameNAto each sequence of a gene union (D-002), andtx.namesisNULL(D-009). ecdf_testdrops the rows without a fold change for each test. R drops them for the KS and Wilcoxon tests only, and it stops for DTS and Wasserstein (D-036).ecdf_testraisesInputErrorfor analternativewith DTS or Wasserstein, but R ignores it without a message (D-035).kmer_gene_countscounts the genes with a k-mer. The histogram of R counts the sequences, but its label says genes (D-042).benchmark_predictionsapplies thepadjcutoff. In R,padj <= padjcompares the column with itself, thus each row with apadjpasses. R also gives the labels to the ROC curve as the scores of the negative class (D-006).alignment_textshows the full guide, from g1 to the last base. In R, the guide line ofplotAlignmenthas no g1, and the function stops for the default positions (D-045).- The wobble and bulge search runs. In R, each call of
run_wobble_bulges_pipelinestops with an error. The port counts each distinct start of a site one time, and a bulge is a run of extra target bases (D-005). - The 3' compensatory search runs. R returns 0 rows for each input. Without the early return, its code stops at the first site. The port gives each pair of a seed match and a region (D-004).
trrust_scorestakes the messages of a gene from its regulators. R takes them from the targets of the gene (D-007).plot_ecdfgives a figure for each p-value, and its legend counts the values of each line. R stops for a p-value of 0.01, and its legend counts the gene lists (D-063, D-064).- An input that R accepts in silence, but that gives a wrong result, raises
InputError. The message gives the bad value. Examples are a gap letter in a sequence (D-017), a DESeq2 table with the wrong columns (D-021), and a NaN cutoff (D-024).
Performance
seedmatch is faster than SeedMatchR, and its process uses less memory. The table gives the values of seed_match_report with the default options, on the canonical 3' UTRs of the rat genome build rnor7. This input has 18,614 sequences and 17,913,962 bases. The machine is an Apple M2 Max with 12 CPUs. Each run makes three calls in one process, and a cell gives the range of two runs. SeedMatchR uses one thread.
| Measure | seedmatch, all CPUs | seedmatch, 1 thread | SeedMatchR |
|---|---|---|---|
| Time of one call | 0.18 to 0.20 s | 1.19 to 1.22 s | 9.32 to 9.63 s |
| Speedup over SeedMatchR | 47× to 54× | 7.6× to 8.1× | 1× |
| Peak resident memory of the process | 137 to 140 MiB | 135 to 136 MiB | 432 to 443 MiB |
docs/performance.md gives the versions, the commands that measure these values, and the time of each search of full_search.
Development
CONTRIBUTING.md gives the setup, the checks, and the rules for a contribution. To report a security problem, obey SECURITY.md.
License
seedmatch uses the MIT License, the same license as SeedMatchR. See LICENSE.
Metadata
Release files for seedmatch 0.1.2
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 |
|---|---|---|---|---|
| seedmatch-0.1.2.tar.gz | 223.6 kB | With provenance | Details for seedmatch-0.1.2.tar.gz |
Built distributions (wheels)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| seedmatch-0.1.2-cp312-abi3-manylinux_2_28_x86_64.whl | CPython 3.12 | abi3 | Linux glibc 2.28+ x86-64 | Details for seedmatch-0.1.2-cp312-abi3-manylinux_2_28_x86_64.whl |
| seedmatch-0.1.2-cp312-abi3-manylinux_2_28_aarch64.whl | CPython 3.12 | abi3 | Linux glibc 2.28+ ARM64 | Details for seedmatch-0.1.2-cp312-abi3-manylinux_2_28_aarch64.whl |
| seedmatch-0.1.2-cp312-abi3-macosx_11_0_arm64.whl | CPython 3.12 | abi3 | macOS 11.0+ ARM64 | Details for seedmatch-0.1.2-cp312-abi3-macosx_11_0_arm64.whl |
Total release size: 1.8 MB
Release files / seedmatch-0.1.2.tar.gz
| Download URL | seedmatch-0.1.2.tar.gz |
|---|---|
| Size | 223.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2277c7b4e4ec20799c982c2313ddf3122919d2906b5a774f0d37e9e33bf9c418
|
|
BLAKE2b-256 checksum How to use checksums |
8904de59ba225b6bebec5fdc16e18a8d683a87099d083f33a32de0927c69bbe5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 29, 2026.
Transparency logRelease files / seedmatch-0.1.2-cp312-abi3-manylinux_2_28_x86_64.whl
| Download URL | seedmatch-0.1.2-cp312-abi3-manylinux_2_28_x86_64.whl |
|---|---|
| Size | 557.4 kB |
| Tags | CPython 3.12 Linux glibc 2.28+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
4735100633a8990e6597726850079565a0524a20060eb2b64c7f77e4774e0126
|
|
BLAKE2b-256 checksum How to use checksums |
cfab7be70aabd58daecd4c66570dda5a1beccea223dcaffd27416aeacaec4d9c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 29, 2026.
Transparency logRelease files / seedmatch-0.1.2-cp312-abi3-manylinux_2_28_aarch64.whl
| Download URL | seedmatch-0.1.2-cp312-abi3-manylinux_2_28_aarch64.whl |
|---|---|
| Size | 547.0 kB |
| Tags | CPython 3.12 Linux glibc 2.28+ ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
b2579bd1d1bfc599c5c600176a0eb0b064a88fd8206ffd68fcb5c454c48984d4
|
|
BLAKE2b-256 checksum How to use checksums |
bf84fe54cda905162c9d23383e2916ac163d9da257a71d0b3c75e6c127c765b1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 29, 2026.
Transparency logRelease files / seedmatch-0.1.2-cp312-abi3-macosx_11_0_arm64.whl
| Download URL | seedmatch-0.1.2-cp312-abi3-macosx_11_0_arm64.whl |
|---|---|
| Size | 515.9 kB |
| Tags | CPython 3.12 abi3 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
12aadb0befe4a490a77130aa33141200276ddca4c72e976b0662eb8b19155601
|
|
BLAKE2b-256 checksum How to use checksums |
c62a5b28597cf3ee105cb588d467090999f92978bde315a9861d6b2d50e12fb3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 29, 2026.
Transparency logSecurity for seedmatch 0.1.2
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.
Full provenance
All 4 files in this release have been uploaded with provenance metadata.
Attestation for seedmatch-0.1.2.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 29, 2026.
Transparency logA 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.