Pn/another interpretation refactor#499
Conversation
| let (allele_one_col, allele_two_col) = match linked_hgvs_cols.len() { | ||
| 0 => (None, None), | ||
| 1 => (Some(linked_hgvs_cols[0]), None), | ||
| 2 => (Some(linked_hgvs_cols[0]), Some(linked_hgvs_cols[1])), | ||
| n => { | ||
| return Err(CollectorError::ExpectedAtMostNLinkedColumnWithContexts { | ||
| table_name: patient_cdf.context().name().to_string(), | ||
| bb_id: bb_id.to_string(), | ||
| contexts: vec![Context::Hgvs], | ||
| n_found: n, | ||
| n_expected: 2, | ||
| }); | ||
| } | ||
| }; |
There was a problem hiding this comment.
I think, this is a simpler, but im unsure if it does the same.
| let (allele_one_col, allele_two_col) = match linked_hgvs_cols.len() { | |
| 0 => (None, None), | |
| 1 => (Some(linked_hgvs_cols[0]), None), | |
| 2 => (Some(linked_hgvs_cols[0]), Some(linked_hgvs_cols[1])), | |
| n => { | |
| return Err(CollectorError::ExpectedAtMostNLinkedColumnWithContexts { | |
| table_name: patient_cdf.context().name().to_string(), | |
| bb_id: bb_id.to_string(), | |
| contexts: vec![Context::Hgvs], | |
| n_found: n, | |
| n_expected: 2, | |
| }); | |
| } | |
| }; | |
| if linked_hgvs_cols.len() > 2 { | |
| return Err(CollectorError::ExpectedAtMostNLinkedColumnWithContexts { | |
| table_name: patient_cdf.context().name().to_string(), | |
| bb_id: bb_id.to_string(), | |
| contexts: vec![Context::Hgvs], | |
| n_found: linked_hgvs_cols.len(), | |
| n_expected: 2, | |
| }); | |
| } | |
| let (allele_one_col, allele_two_col) = ( | |
| linked_hgvs_cols.first().copied(), | |
| linked_hgvs_cols.last().copied(), | |
| ); | |
There was a problem hiding this comment.
Your version will return two of the same column when len = 1 which isn't what we want (we want (col, None)).
But I've done something similar now with
let allele_one_col = linked_hgvs_cols.get(0).copied();
let allele_two_col = linked_hgvs_cols.get(1).copied();
| let linked_hgnc_col = | ||
| patient_cdf.get_single_linked_column_as_str(Some(bb_id), &[Context::Hgnc])?; |
There was a problem hiding this comment.
I'm not sure, I understand this. You are picking a single row and then you always pick row 1 and 2.
This does not seem robust. What if there are three values and the first one is empty?
There was a problem hiding this comment.
I don't understand what you mean.
What happens is this: we allow one linked gene column, and up to two linked HGVS columns. Then we go row by row and collect
gene = Option<&str>, hgvs1 = Option<&str>, hgvs2 = Option<&str>e
It's almost exactly the same as how we do collection for phenotypes and diseases etc. The only difference is there can be between 0 and 2 HGVS columns
This PR is broken, because I have not implemented the methods on GIBuilder yet.
What does this PR do?
Still to do: