Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
c84f607
fix(vrs): route allele identification through digest-clearing helper
bencap Jun 3, 2026
ad228a9
chore(AI): Add .claude to gitignore
bencap Jun 9, 2026
847bf16
feat(mapper): typed mapping outcomes and assay-level preferred layer
bencap Jun 10, 2026
07fd08a
feat(mapper): genomic-accession transcript selection and deterministi…
bencap Jun 10, 2026
805a1e4
fix(annotate): prevent null-layer re-attribution from duplicating pre…
bencap Jun 17, 2026
4d84c4d
fix(align): correct strand and hit ranges for minus-strand protein al…
bencap Jun 29, 2026
764f666
fix(annotate): return NM transcript as cdna mapped reference sequence
bencap Jun 29, 2026
5602c38
chore(schema): add MappingOutcome definition and outcome field to sup…
bencap Jun 30, 2026
b317fd3
fix: Remove underscore from check for Ensembl Protein ID
davereinhart Jul 7, 2026
432119c
Merge pull request #110 from VariantEffect/davereinhart/fix-ensembl-p…
bencap Jul 9, 2026
60dc01c
Merge pull request #106 from VariantEffect/feature/bencap/vrs-correct…
bencap Jul 9, 2026
fce7445
Merge branch 'mavedb-dev' into feature/bencap/target-variant-projection
bencap Jul 9, 2026
559c875
Merge pull request #108 from VariantEffect/feature/bencap/target-vari…
bencap Jul 9, 2026
a3aecbc
fix(transcripts): collapse all() list arg and add target local
bencap Jul 11, 2026
9b00aef
feat(transcripts): map non-RefSeq accession targets to RefSeq MANE co…
bencap Jul 21, 2026
1116463
fix(vrs): recompute allele identity from normalized content
bencap Aug 26, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -172,3 +172,6 @@ notebooks/analysis/mavedb_files
urn:*.json
tmp:*.json
*_mapping_*.json

# Agent settings
.claude/
22 changes: 22 additions & 0 deletions schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,17 @@
"title": "MappedReferenceSequence",
"type": "object"
},
"MappingOutcome": {
"description": "Per-record outcome for one (variant, annotation level) pair.\n\nThe mapper's output is a complete accounting: for every variant and every\nannotation level in that variant's deterministically-reachable set, there is one\nrecord carrying its outcome -- never a silent omission. This field is uniform across\nmeasured (assay-level) and projected (deterministic non-assay) records so the two can\nbe treated identically by consumers; it distinguishes a benign absence from a genuine\nfailure, which a populated ``error_message`` alone cannot.\n\n- ``MAPPED`` -- a VRS allele was produced (``pre_mapped``/``post_mapped`` populated).\n- ``INTRONIC`` -- the variant's coding projection is intronic: no VRS-representable\n coding form and no protein consequence. Benign (``error_message`` is ``None``).\n- ``NO_PROTEIN_CONSEQUENCE`` -- the protein layer was reachable but yields no\n projectable protein change (e.g. UTR). Benign (``error_message`` is ``None``).\n- ``FAILED`` -- the mapping/projection genuinely failed (mis-selected transcript,\n projection error, unresolvable reference contig). ``error_message`` carries detail.",
"enum": [
"mapped",
"intronic",
"no_protein_consequence",
"failed"
],
"title": "MappingOutcome",
"type": "string"
},
"Number": {
"description": "Define VRS 1.3 Number.",
"properties": {
Expand Down Expand Up @@ -295,6 +306,17 @@
"default": null,
"title": "Near Gap"
},
"outcome": {
"anyOf": [
{
"$ref": "#/$defs/MappingOutcome"
},
{
"type": "null"
}
],
"default": null
},
"post_mapped": {
"anyOf": [
{
Expand Down
15 changes: 14 additions & 1 deletion src/api/routers/map.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,23 @@ async def map_scoreset(urn: str, store_path: Path | None = None) -> JSONResponse
protein_align_results: dict[str, AlignmentResult | None] = {}
try:
for target_gene in metadata.target_genes:
target_records = records.get(target_gene)

# e.g. base-editor score sets that declare separate protein and
# cDNA accession targets for the same variant: every row's hgvs_nt
# prefix groups under the cDNA target, so the protein target has no
# record group of its own and contributes nothing independently.
if target_records is None:
_logger.info(
"No score records reference target %s directly; skipping standalone VRS mapping for this target.",
target_gene,
)
continue

vrs_map_result = vrs_map(
metadata=metadata.target_genes[target_gene],
align_result=alignment_results[target_gene],
records=records[target_gene],
records=target_records,
transcript=transcripts[target_gene],
silent=True,
)
Expand Down
47 changes: 36 additions & 11 deletions src/dcd_mapping/align.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,12 @@ def _run_blat(
cmd.extend(shlex.split(target_args))

cmd.extend(
[f"-minScore={min_score}", f"-out={out_format}", str(query_file), out_file]
[
f"-minScore={min_score}",
f"-out={out_format}",
str(query_file),
out_file,
]
)
_logger.debug("Running BLAT command: %s", " ".join(cmd))

Expand Down Expand Up @@ -914,7 +919,22 @@ def _get_best_match(
tcoords = coords[0]
qcoords = coords[1]

strand = Strand.POSITIVE if int(qcoords[0]) <= int(qcoords[-1]) else Strand.NEGATIVE
protein_vs_dna = "-q=prot" in blat_params.get("target_args", "")

# For cDNA queries the strand is read from qcoords direction: cDNA on the
# negative strand is reverse-complemented, so its qcoords decrease.
# For protein queries qcoords always increase (protein reads N→C regardless
# of genome strand), so qcoords direction is uninformative — use tcoords
# instead (they decrease when the gene is on the minus strand).
if protein_vs_dna:
strand = (
Strand.POSITIVE if int(tcoords[0]) <= int(tcoords[-1]) else Strand.NEGATIVE
)
else:
strand = (
Strand.POSITIVE if int(qcoords[0]) <= int(qcoords[-1]) else Strand.NEGATIVE
)

q_start = int(qcoords.min())
q_end = int(qcoords.max())

Expand All @@ -938,10 +958,9 @@ def _get_best_match(
if ts == te or qs == qe:
continue

hit_subranges.append(SequenceRange(start=ts, end=te))
hit_subranges.append(SequenceRange(start=min(ts, te), end=max(ts, te)))
query_subranges.append(SequenceRange(start=min(qs, qe), end=max(qs, qe)))

protein_vs_dna = "-q=prot" in blat_params.get("target_args", "")
alignment_qc = _build_alignment_qc(best_aln, protein_vs_dna=protein_vs_dna)

return AlignmentResult(
Expand All @@ -953,7 +972,10 @@ def _get_best_match(
coverage=coverage,
query_range=SequenceRange(start=q_start, end=q_end),
query_subranges=query_subranges,
hit_range=SequenceRange(start=int(tcoords[0]), end=int(tcoords[-1])),
hit_range=SequenceRange(
start=min(int(tcoords[0]), int(tcoords[-1])),
end=max(int(tcoords[0]), int(tcoords[-1])),
),
hit_subranges=hit_subranges,
score=float(_scores[id(best_aln)]),
next_best_score=next_best,
Expand Down Expand Up @@ -1155,7 +1177,7 @@ def build_alignment_result(
if score_set_type == "sequence":
try:
alignment_result = align(metadata, silent)
except AlignmentError as e:
except AlignmentError:
failed_at_nucleotide_level = any(
target_gene.target_sequence_type == TargetSequenceType.DNA
for target_gene in metadata.target_genes.values()
Expand All @@ -1165,7 +1187,7 @@ def build_alignment_result(
msg = f"BLAT alignment failed for {metadata.urn} at the nucleotide level. This alignment will be retried at the protein level."
_logger.warning(msg)
else:
raise AlignmentError from e
raise

# So long as force=True, the content of the records dict is irrelevant.
try:
Expand All @@ -1178,10 +1200,10 @@ def build_alignment_result(
metadata.urn,
)

except AlignmentError as e2:
except AlignmentError as e:
msg = f"BLAT alignment failed for {metadata.urn} at the protein level after failing at the nucleotide level."
_logger.error(msg)
raise AlignmentError(msg) from e2
raise AlignmentError(msg) from e

else:
alignment_result = fetch_alignment(metadata, silent)
Expand Down Expand Up @@ -1246,7 +1268,7 @@ def align_target_to_protein(
qs, qe = int(qcoords[i]), int(qcoords[i + 1])
if ts == te or qs == qe:
continue
hit_subranges.append(SequenceRange(start=ts, end=te))
hit_subranges.append(SequenceRange(start=min(ts, te), end=max(ts, te)))
query_subranges.append(SequenceRange(start=min(qs, qe), end=max(qs, qe)))

# Attach full sequences so _build_alignment_qc can do per-base mismatch
Expand All @@ -1260,7 +1282,10 @@ def align_target_to_protein(
result = AlignmentResult(
query_range=SequenceRange(start=int(qcoords.min()), end=int(qcoords.max())),
query_subranges=query_subranges,
hit_range=SequenceRange(start=int(tcoords[0]), end=int(tcoords[-1])),
hit_range=SequenceRange(
start=min(int(tcoords[0]), int(tcoords[-1])),
end=max(int(tcoords[0]), int(tcoords[-1])),
),
hit_subranges=hit_subranges,
percent_identity=_blat_style_identity(
best_counts.identities,
Expand Down
Loading
Loading