-
Notifications
You must be signed in to change notification settings - Fork 1
/
clinvar.rs
46 lines (43 loc) · 1.53 KB
/
clinvar.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
use crate::seqvars::query::{
annonars::Annotator,
schema::{CaseQuery, SequenceVariant},
};
use annonars::clinvar_minimal::pbs::ClinicalSignificance::{self, *};
/// Determine whether the `SequenceVariant` passes the clinvar filter.
pub fn passes(
query: &CaseQuery,
annotator: &Annotator,
seqvar: &SequenceVariant,
) -> Result<bool, anyhow::Error> {
if !query.require_in_clinvar {
return Ok(true);
}
if let Ok(record) = annotator.query_clinvar_minimal(seqvar) {
let clinical_significance: ClinicalSignificance =
record
.clinical_significance
.try_into()
.map_err(|e| anyhow::anyhow!("could not convert clinical significance: {}", e))?;
let result = match clinical_significance {
Benign => query.clinvar_include_benign,
LikelyBenign => query.clinvar_include_likely_benign,
UncertainSignificance => query.clinvar_include_uncertain_significance,
LikelyPathogenic => query.clinvar_include_likely_pathogenic,
Pathogenic => query.clinvar_include_pathogenic,
};
if !result {
tracing::trace!(
"variant {:?} fails clinvar filter from query {:?}",
seqvar,
query
);
}
Ok(result)
} else {
// Because of the annonars API, we currently need to swallow any error,
// as "not found" currently maps to an error.
//
// TODO: fix annonars
Ok(true)
}
}