API reference¶
risearch ¶
Python interface to RIsearch.
TargetRegistry ¶
An mmap-backed target index for interaction search.
Build once with risearch.index(), then reuse across many search() calls.
Source code in risearch/_native.pyi
open
staticmethod
¶
Load a pre-built index from disk.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str | PathLike
|
Path to the |
required |
Raises:
| Type | Description |
|---|---|
FileNotFoundError
|
No file at |
ValueError
|
The file is not an index this version can read. |
Source code in risearch/_native.pyi
index ¶
index(
fasta: str | PathLike[str],
output: str | PathLike[str],
*,
threads: int | None = None,
) -> None
Build a reusable target index from a FASTA file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
fasta
|
str | PathLike[str]
|
Target sequences, FASTA or FASTQ, plain or gzip-compressed. T and U are the same base, so DNA and RNA input give the same index. |
required |
output
|
str | PathLike[str]
|
Where to write the index. |
required |
threads
|
int | None
|
Threads for building the index; only builds with the |
None
|
Raises:
| Type | Description |
|---|---|
ValueError
|
Input that cannot be indexed: unparsable FASTA/FASTQ, empty or duplicate IDs, or a file whose sequences are all empty. |
(FileNotFoundError, PermissionError, OSError)
|
A file that is missing, unreadable, or cannot be written. |
Notes
An index records its format version. Opening one written by an
incompatible release raises ValueError; build it again. Building
releases the GIL, so other Python threads keep running.
Source code in risearch/_api.py
search ¶
search(
query: str | PathLike[str] | list[str | PathLike[str]],
target: TargetRegistry,
*,
seed_length: int | None = None,
seed_start: int | None = None,
seed_end: int | None = None,
energy_threshold: float = -20.0,
mismatches: int = 0,
mismatch_prefix: int = 1,
mismatch_suffix: int = 1,
seed_wobble: bool = False,
matrix: str | PathLike[str] = "t04",
penalty: float = 0.0,
temperature: int | None = None,
max_extension: int = 20,
seed_energy: float = 0.0,
no_max_prune: bool = False,
no_dedup: bool = False,
alignment: bool = True,
threads: int | None = None,
) -> pl.DataFrame
Search for RNA and DNA interactions and return one row per hit.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
query
|
str | PathLike[str] | list[str | PathLike[str]]
|
One query file or a list of them, FASTA or FASTQ. IDs must be unique across all files. |
required |
target
|
TargetRegistry
|
An index opened with |
required |
seed_length
|
int | None
|
Minimum length of a complementary seed; |
None
|
seed_start
|
int | None
|
Only look for seeds inside these query positions (1-based; |
None
|
seed_end
|
int | None
|
Only look for seeds inside these query positions (1-based; |
None
|
energy_threshold
|
float
|
Report hits with free energy at or below this, in kcal/mol. |
-20.0
|
mismatches
|
int
|
Mismatches allowed inside a seed. |
0
|
mismatch_prefix
|
int
|
Matches required at the 5' and 3' end of a mismatched seed. |
1
|
mismatch_suffix
|
int
|
Matches required at the 5' and 3' end of a mismatched seed. |
1
|
seed_wobble
|
bool
|
Allow G-U pairs inside seeds. |
False
|
matrix
|
str | PathLike[str]
|
Energy model id ( |
't04'
|
penalty
|
float
|
kcal/mol added per extended nucleotide; included in the reported energy. |
0.0
|
temperature
|
int | None
|
Temperature in °C, 0 to 50; |
None
|
max_extension
|
int
|
Extend at most this many nucleotides on each side of the seed; |
20
|
seed_energy
|
float
|
Accepted for compatibility; the search does not use it yet. |
0.0
|
no_max_prune
|
bool
|
Keep seeds that could be extended by one more pair. |
False
|
no_dedup
|
bool
|
Report every seed's hit instead of one best hit per duplex. |
False
|
alignment
|
bool
|
Fill the |
True
|
threads
|
int | None
|
Worker threads for this search; |
None
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
One row per hit; see Notes for the columns. |
Raises:
| Type | Description |
|---|---|
ValueError
|
Invalid options, including |
(FileNotFoundError, PermissionError, OSError)
|
A query file that is missing or cannot be read. |
RuntimeError
|
The worker threads cannot be started. |
Notes
Columns of the result:
query_idx,target_idx(UInt64): position of the query in the input and of the target in the index.query_name,target_name(String): FASTA identifiers.q_start,q_end,t_start,t_end(UInt64): 0-based, inclusive coordinates; target coordinates refer to the target as written.strand(String):+or-.energy(Float64): free energy in kcal/mol.alignment(String, nullable): pairing string, one character per alignment column, query 5' to 3'.
The pairing string uses P for a Watson-Crick pair, W for a G-U
wobble pair, U for a mismatch, T for an extra base on the target
side and Q for an extra base on the query side.
The row order can change between runs; sort when you need a stable order. The search releases the GIL, so other Python threads keep running.
Source code in risearch/_api.py
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 | |