-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add Library Source Material - CDE 14808227 #118
base: main
Are you sure you want to change the base?
Changes from all commits
ee6ea39
5c124f0
57d8e5c
366f93b
3b84eb4
730b00e
120f691
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,184 @@ | ||
use introspect::Introspect; | ||
use rand::distributions::Standard; | ||
use rand::prelude::Distribution; | ||
use serde::Deserialize; | ||
use serde::Serialize; | ||
use utoipa::ToSchema; | ||
|
||
use crate::CDE; | ||
|
||
/// **`caDSR CDE 14808227 v1.00`** | ||
/// | ||
/// This metadata element is defined by the caDSR as "The cellular source of | ||
/// the double stranded DNA fragments analyzed by high-throughput sequencing.". | ||
/// | ||
/// Link: | ||
/// <https://cadsr.cancer.gov/onedata/dmdirect/NIH/NCI/CO/CDEDD?filter=CDEDD.ITEM_ID=14808227%20and%20ver_nr=1> | ||
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize, ToSchema, Introspect)] | ||
#[schema(as = cde::v1::sample::LibrarySourceMaterial)] | ||
pub enum LibrarySourceMaterial { | ||
/// `Bulk Cells` | ||
/// | ||
/// * **VM Long Name**: Bulk Cell Specimen | ||
/// * **VM Public ID**: 7592130 | ||
/// * **Concept Code**: C178223 | ||
/// * **Begin Date**: 03/12/2024 | ||
/// | ||
/// A biospecimen consisting of multiple cells intended to be analyzed as a pool. | ||
#[serde(rename = "Bulk-Cells")] | ||
BulkCells, | ||
|
||
/// `Bulk-Nuclei` | ||
/// | ||
/// * **VM Long Name**: Bulk Nucleus Specimen | ||
/// * **VM Public ID**: 7592129 | ||
/// * **Concept Code**: C178224 | ||
/// * **Begin Date**: 02/28/2024 | ||
/// | ||
/// A biospecimen consisting of multiple nuclei intended to be analyzed as a pool. | ||
#[serde(rename = "Bulk-Nuclei")] | ||
BulkNuclei, | ||
|
||
/// `Bulk-Tissue` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should be |
||
/// | ||
/// * **VM Long Name**: Bulk Tissue Specimen | ||
/// * **VM Public ID**: 7592128 | ||
/// * **Concept Code**: C178225 | ||
/// * **Begin Date**: 02/28/2024 | ||
/// | ||
/// A biospecimen either derived from a whole tissue specimen or tissue section, which may consist of heterogeneous cells or tissues. | ||
#[serde(rename = "Bulk-Tissue")] | ||
BulkTissue, | ||
|
||
/// `Single-cells` | ||
/// | ||
/// * **VM Long Name**: Single Cell Suspension | ||
/// * **VM Public ID**: 14838800 | ||
/// * **Concept Code**: C204464 | ||
/// * **Begin Date**: 03/12/2024 | ||
/// | ||
/// A dilute suspension of cells intended to be further fractionated for assays focused on single-cells. | ||
#[serde(rename = "Single-cells")] | ||
SingleCells, | ||
|
||
/// `Single-nuclei` | ||
/// | ||
/// * **VM Long Name**: Single Nucleus Suspension | ||
/// * **VM Public ID**: 14838802 | ||
/// * **Concept Code**: C204465 | ||
/// * **Begin Date**: 03/12/2024 | ||
/// | ||
/// A dilute suspension comprised of isolated intact cell nuclei intended to be further fractionated for assays focused on single-nuclei. | ||
#[serde(rename = "Single-nuclei")] | ||
SingleNuclei, | ||
|
||
/// `Not-Reported` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should be |
||
/// | ||
/// * **VM Long Name**: Not Reported | ||
/// * **VM Public ID**: 5612322 | ||
/// * **Concept Code**: C43234 | ||
/// * **Begin Date**: 03/01/2024 | ||
/// | ||
/// Not provided or available. | ||
#[serde(rename = "Not-Reported")] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For all of these, please make sure that the permissible value exactly matches what is in the caDSR field: both for the comment above and for the serde rename. |
||
NotReported, | ||
|
||
/// `Other` | ||
/// | ||
/// * **VM Long Name**: Other Library strategy | ||
/// * **VM Public ID**: 6273371 | ||
/// * **Concept Code**: C17649 | ||
/// * **Begin Date**: 05/11/2018 | ||
/// | ||
/// Different than the one(s) previously specified or mentioned. | ||
#[serde(rename = "Other")] | ||
Other, | ||
} | ||
|
||
impl CDE for LibrarySourceMaterial {} | ||
|
||
impl std::fmt::Display for LibrarySourceMaterial { | ||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
match self { | ||
LibrarySourceMaterial::BulkCells => write!(f, "Bulk Cells"), | ||
LibrarySourceMaterial::BulkNuclei => write!(f, "Bulk Nuclei"), | ||
LibrarySourceMaterial::BulkTissue => write!(f, "Bulk Tissue"), | ||
LibrarySourceMaterial::SingleCells => write!(f, "Single-cells"), | ||
LibrarySourceMaterial::SingleNuclei => write!(f, "Single-nuclei"), | ||
LibrarySourceMaterial::NotReported => write!(f, "Not Reported"), | ||
LibrarySourceMaterial::Other => write!(f, "Other"), | ||
} | ||
} | ||
} | ||
|
||
impl Distribution<LibrarySourceMaterial> for Standard { | ||
fn sample<R: rand::Rng + ?Sized>(&self, rng: &mut R) -> LibrarySourceMaterial { | ||
match rng.gen_range(0..7) { | ||
0 => LibrarySourceMaterial::BulkCells, | ||
1 => LibrarySourceMaterial::BulkNuclei, | ||
2 => LibrarySourceMaterial::BulkTissue, | ||
3 => LibrarySourceMaterial::SingleCells, | ||
4 => LibrarySourceMaterial::SingleNuclei, | ||
5 => LibrarySourceMaterial::NotReported, | ||
6 => LibrarySourceMaterial::Other, | ||
_ => LibrarySourceMaterial::Other, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This can be 0..6 and just |
||
} | ||
} | ||
} | ||
|
||
#[cfg(test)] | ||
mod tests { | ||
use super::*; | ||
|
||
#[test] | ||
fn it_converts_to_string_correctly() { | ||
assert_eq!(LibrarySourceMaterial::BulkCells.to_string(), "Bulk Cells"); | ||
assert_eq!(LibrarySourceMaterial::BulkNuclei.to_string(), "Bulk Nuclei"); | ||
assert_eq!(LibrarySourceMaterial::BulkTissue.to_string(), "Bulk Tissue"); | ||
assert_eq!( | ||
LibrarySourceMaterial::SingleCells.to_string(), | ||
"Single-cells" | ||
); | ||
assert_eq!( | ||
LibrarySourceMaterial::SingleNuclei.to_string(), | ||
"Single-nuclei" | ||
); | ||
assert_eq!( | ||
LibrarySourceMaterial::NotReported.to_string(), | ||
"Not Reported" | ||
); | ||
assert_eq!(LibrarySourceMaterial::Other.to_string(), "Other"); | ||
} | ||
|
||
#[test] | ||
fn it_serializes_to_json_correctly() { | ||
assert_eq!( | ||
serde_json::to_string(&LibrarySourceMaterial::BulkCells).unwrap(), | ||
"\"Bulk-Cells\"" | ||
); | ||
assert_eq!( | ||
serde_json::to_string(&LibrarySourceMaterial::BulkNuclei).unwrap(), | ||
"\"Bulk-Nuclei\"" | ||
); | ||
assert_eq!( | ||
serde_json::to_string(&LibrarySourceMaterial::BulkTissue).unwrap(), | ||
"\"Bulk-Tissue\"" | ||
); | ||
assert_eq!( | ||
serde_json::to_string(&LibrarySourceMaterial::SingleCells).unwrap(), | ||
"\"Single-cells\"" | ||
); | ||
assert_eq!( | ||
serde_json::to_string(&LibrarySourceMaterial::SingleNuclei).unwrap(), | ||
"\"Single-nuclei\"" | ||
); | ||
assert_eq!( | ||
serde_json::to_string(&LibrarySourceMaterial::NotReported).unwrap(), | ||
"\"Not-Reported\"" | ||
); | ||
assert_eq!( | ||
serde_json::to_string(&LibrarySourceMaterial::Other).unwrap(), | ||
"\"Other\"" | ||
); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be
Bulk Nuclei
(no dash).