Skip to content

Commit

Permalink
fix: don't require queried for HGNC IDs to be present (#418)
Browse files Browse the repository at this point in the history
  • Loading branch information
holtgrewe committed Mar 1, 2024
1 parent a0ec18e commit 18894ba
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 17 deletions.
20 changes: 11 additions & 9 deletions src/server/actix_server/genes_clinvar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,17 @@ async fn handle(
let mut genes = indexmap::IndexMap::new();
if let Some(hgnc_id) = query.hgnc_id.as_ref() {
for hgnc_id in hgnc_id {
let raw_buf = db_clinvar
.get_cf(&cf_genes, hgnc_id)
.map_err(|e| CustomError::new(anyhow::anyhow!("problem querying database: {}", e)))?
.ok_or_else(|| CustomError::new(anyhow::anyhow!("no such gene: {}", hgnc_id)))?;
let record = crate::pbs::clinvar::per_gene::ClinvarPerGeneRecord::decode(
std::io::Cursor::new(raw_buf),
)
.map_err(|e| CustomError::new(anyhow::anyhow!("problem decoding value: {}", e)))?;
genes.insert(hgnc_id.to_string(), record);
if let Some(raw_buf) = db_clinvar.get_cf(&cf_genes, hgnc_id).map_err(|e| {
CustomError::new(anyhow::anyhow!("problem querying database: {}", e))

Check warning on line 59 in src/server/actix_server/genes_clinvar.rs

View check run for this annotation

Codecov / codecov/patch

src/server/actix_server/genes_clinvar.rs#L58-L59

Added lines #L58 - L59 were not covered by tests
})? {
let record = crate::pbs::clinvar::per_gene::ClinvarPerGeneRecord::decode(
std::io::Cursor::new(raw_buf),

Check warning on line 62 in src/server/actix_server/genes_clinvar.rs

View check run for this annotation

Codecov / codecov/patch

src/server/actix_server/genes_clinvar.rs#L62

Added line #L62 was not covered by tests
)
.map_err(|e| CustomError::new(anyhow::anyhow!("problem decoding value: {}", e)))?;
genes.insert(hgnc_id.to_string(), record);

Check warning on line 65 in src/server/actix_server/genes_clinvar.rs

View check run for this annotation

Codecov / codecov/patch

src/server/actix_server/genes_clinvar.rs#L64-L65

Added lines #L64 - L65 were not covered by tests
} else {
tracing::debug!("no such gene: {}", hgnc_id);

Check warning on line 67 in src/server/actix_server/genes_clinvar.rs

View check run for this annotation

Codecov / codecov/patch

src/server/actix_server/genes_clinvar.rs#L67

Added line #L67 was not covered by tests
}
}
}

Expand Down
19 changes: 11 additions & 8 deletions src/server/actix_server/genes_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,17 @@ async fn handle(
let mut genes = indexmap::IndexMap::new();
if let Some(hgnc_id) = query.hgnc_id.as_ref() {
for hgnc_id in hgnc_id {
let raw_buf = genes_db
.db
.get_cf(&cf_genes, hgnc_id)
.map_err(|e| CustomError::new(anyhow::anyhow!("problem querying database: {}", e)))?
.ok_or_else(|| CustomError::new(anyhow::anyhow!("no such gene: {}", hgnc_id)))?;
let record = genes::base::Record::decode(std::io::Cursor::new(raw_buf))
.map_err(|e| CustomError::new(anyhow::anyhow!("problem decoding value: {}", e)))?;
genes.insert(hgnc_id.to_string(), record);
if let Some(raw_buf) = genes_db.db.get_cf(&cf_genes, hgnc_id).map_err(|e| {
CustomError::new(anyhow::anyhow!("problem querying database: {}", e))

Check warning on line 54 in src/server/actix_server/genes_info.rs

View check run for this annotation

Codecov / codecov/patch

src/server/actix_server/genes_info.rs#L53-L54

Added lines #L53 - L54 were not covered by tests
})? {
let record =

Check warning on line 56 in src/server/actix_server/genes_info.rs

View check run for this annotation

Codecov / codecov/patch

src/server/actix_server/genes_info.rs#L56

Added line #L56 was not covered by tests
genes::base::Record::decode(std::io::Cursor::new(raw_buf)).map_err(|e| {
CustomError::new(anyhow::anyhow!("problem decoding value: {}", e))

Check warning on line 58 in src/server/actix_server/genes_info.rs

View check run for this annotation

Codecov / codecov/patch

src/server/actix_server/genes_info.rs#L58

Added line #L58 was not covered by tests
})?;
genes.insert(hgnc_id.to_string(), record);

Check warning on line 60 in src/server/actix_server/genes_info.rs

View check run for this annotation

Codecov / codecov/patch

src/server/actix_server/genes_info.rs#L60

Added line #L60 was not covered by tests
} else {
tracing::debug!("no such gene: {}", hgnc_id);

Check warning on line 62 in src/server/actix_server/genes_info.rs

View check run for this annotation

Codecov / codecov/patch

src/server/actix_server/genes_info.rs#L62

Added line #L62 was not covered by tests
}
}
}

Expand Down

0 comments on commit 18894ba

Please sign in to comment.