dp_input — High-Level .bin + FASTA Pipeline¶
Source: crates/fastdpplot-core/src/dp_input.rs
DpInput¶
All data needed to render a DP dotplot.
pub struct DpInput {
pub query: FastaRecord, // first record from fasta_a
pub subject: FastaRecord, // first record from fasta_b
pub matrix: BinMatrix, // loaded binary matrix
pub query_axis_label: String, // formatted Y-axis label
pub subject_axis_label: String, // formatted X-axis label
}
load_dp_input¶
pub fn load_dp_input(
matrix_path: &str,
fasta_a_path: &str,
fasta_b_path: &str,
dtype: Option<MatrixDtype>,
) -> Result<DpInput, FastDpError>
One-shot loader: parse both FASTA files and the .bin matrix, validate
dimensions, and return a [DpInput] ready for rendering.
Processing steps¶
- Parse FASTA A (
fasta_a_path) — derivequery. - Parse FASTA B (
fasta_b_path) — derivesubject. - Resolve dtype — if
dtypeisNone, callinfer_dtype_from_sizewith(query.length, subject.length). - Load matrix at
(query.length, subject.length). - Transposed fallback — if step 4 raises
SizeMismatch, retry with(subject.length, query.length)and swapquery ↔ subject. - Format axis labels —
format_axis_label(record, 80).
Errors¶
| Error | Condition |
|---|---|
FastDpError::NoRecords |
A FASTA file is empty. |
FastDpError::EmptySequence |
A FASTA record has no sequence bases. |
FastDpError::CannotInferDtype |
File size matches no dtype (dtype = auto). |
FastDpError::DimMismatch |
Matrix size does not match sequences even after transposition. |
FastDpError::Io |
File I/O failure. |
Transposed matrix warning
If the matrix is loaded with swapped dimensions a warning is printed to stderr:
This is not an error; rendering proceeds normally.dp_input_to_dotpoints¶
Convert a loaded DpInput to Vec<DotPoint> with raw, unnormalised scores.
There is no threshold parameter — all non-boundary cells are included.
Scores are cast directly from i32 to f32; sign is fully preserved
(negative penalties remain negative, zero stays zero, positive scores remain
positive).
Delegates to matrix_to_dotpoints.