Links Module¶
External database link generation
Module for adding configurable links to output tables.
This module provides functionality to add new columns containing URL links to each variant line in the final output. The URLs and their substitution logic are defined in the configuration file (config.json) under “links”.
For example, if you have a link defined as: “links”: {
“SpliceAI”: “https://spliceailookup.broadinstitute.org/#variant={CHROM}-{POS}-{REF}-{ALT}&hg=38&bc=basic&distance=500&mask=0&ra=0”
}
This will create a new column named “SpliceAI” with a URL where {CHROM}, {POS}, {REF}, {ALT} are replaced by the corresponding values from each row.
- variantcentrifuge.links.add_links_to_table(lines, link_configs)[source]¶
Add link columns to the table lines based on provided link configurations.
- Parameters:
lines (list of str) – The lines of the final table (including header).
link_configs (dict of str to str) – A dictionary where keys are link column names and values are URL templates. URL templates contain placeholders like {CHROM}, {POS}, {REF}, {ALT} that are replaced with values from the corresponding columns.
- Returns:
The modified lines with new link columns appended.
- Return type:
Notes
Assumes the first line is a header line.
Each link column is appended to the end of the table.
Placeholders in the link template must match header column names exactly (case-sensitive).
If a placeholder column doesn’t exist in the header, the link will be empty.