Skip to content

Commit 29ed12a

Browse files
committed
sc2 subtype handling
1 parent acd8f64 commit 29ed12a

File tree

2 files changed

+31
-7
lines changed

2 files changed

+31
-7
lines changed

src/processes/prepare_mira_reports.rs

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ pub fn prepare_mira_reports_process(args: ReportsArgs) -> Result<(), Box<dyn Err
148148
let vtype_data = create_vtype_data(&read_data);
149149
let allele_data = allele_data_collection(&args.irma_path)?;
150150
let indel_data = indels_data_collection(&args.irma_path)?;
151-
//let seq_data = amended_consensus_data_collection(&args.irma_path, virus);
151+
let seq_data = amended_consensus_data_collection(&args.irma_path, &args.virus);
152152
let ref_lengths = match get_reference_lens(&args.irma_path) {
153153
Ok(data) => data,
154154
Err(e) => {
@@ -172,7 +172,7 @@ pub fn prepare_mira_reports_process(args: ReportsArgs) -> Result<(), Box<dyn Err
172172
dais_ref_data = dais_ref_seq_data_collection(&args.workdir_path, "sc2")?;
173173
}
174174
//TODO: remove print statements at end
175-
//println!("{vtype_data:?}");
175+
println!("{vtype_data:?}");
176176
//println!("{qc_config:?}")
177177
//println!("cov data: {coverage_data:?}");
178178
//println!("Allele data: {allele_data:?}");
@@ -218,8 +218,17 @@ pub fn prepare_mira_reports_process(args: ReportsArgs) -> Result<(), Box<dyn Err
218218
process_position_coverage_data(&coverage_data, &ref_lengths, 21563, 25384);
219219
}
220220

221-
let subtype_data = extract_subtype_flu(&dais_vars_data)?;
222-
let irma_summary = create_irma_summary(
221+
//Gather subtype information
222+
//todo: add rsv handling
223+
let mut subtype_data: Vec<Subtype> = Vec::new();
224+
if args.virus.to_lowercase() == "flu" {
225+
subtype_data = extract_subtype_flu(&dais_vars_data)?;
226+
} else if args.virus.to_lowercase() == "sc2-wgs" || args.virus.to_lowercase() == "sc2-spike" {
227+
subtype_data = extract_subtype_sc2(&dais_vars_data)?;
228+
}
229+
//Build prelim irma summary "dataframe"
230+
//More will be added and analyzed before final irma summary created
231+
let irma_summary = create_prelim_irma_summary_df(
223232
&sample_list,
224233
&melted_reads_df,
225234
&calculated_cov_df,
@@ -228,11 +237,12 @@ pub fn prepare_mira_reports_process(args: ReportsArgs) -> Result<(), Box<dyn Err
228237
&subtype_data,
229238
)?;
230239

240+
//todo:remove before end
231241
//println!("{dais_vars_data:?}");
232242
//println!("{melted_reads_df:?}");
233243
//println!("{calculated_cov_df:?}");
234244
//println!("{calculated_position_cov_df:?}");
235-
println!("{irma_summary:?}");
245+
//println!("{irma_summary:?}");
236246

237247
/////////////////////////////////////////////////////////////////////////////
238248
/////////////// Write the structs to JSON files and CSV files ///////////////

src/utils/data_processing.rs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ pub struct ProcessedCoverage {
4747
pub percent_reference_covered: Option<f64>,
4848
}
4949

50-
/// vtype struct
50+
/// IRMA struct
5151
#[derive(Serialize, Debug, Clone)]
5252
pub struct IRMASummary {
5353
pub sample_id: Option<String>,
@@ -525,6 +525,20 @@ pub fn extract_subtype_flu(dais_vars: &Vec<DaisVarsData>) -> Result<Vec<Subtype>
525525
Ok(subtype_data)
526526
}
527527

528+
pub fn extract_subtype_sc2(dais_vars: &Vec<DaisVarsData>) -> Result<Vec<Subtype>, Box<dyn Error>> {
529+
let mut subtype_data: Vec<Subtype> = Vec::new();
530+
531+
for entry in dais_vars {
532+
println!("{}", entry.reference_id);
533+
subtype_data.push(Subtype {
534+
sample_id: entry.sample_id.clone(),
535+
subtype: entry.reference_id.clone(),
536+
})
537+
}
538+
539+
Ok(subtype_data)
540+
}
541+
528542
//////////////// Functions used to create irma_summary ///////////////
529543
/// Flip orientation of the reads structs
530544
pub fn melt_reads_data(records: &Vec<ReadsData>) -> Vec<MeltedRecord> {
@@ -776,7 +790,7 @@ pub fn count_minority_indels(data: &Vec<IndelsData>) -> Vec<VariantCountData> {
776790
}
777791

778792
/// Combine all df to create IRMA summary
779-
pub fn create_irma_summary(
793+
pub fn create_prelim_irma_summary_df(
780794
sample_list: &Vec<String>,
781795
reads_count_df: &Vec<MeltedRecord>,
782796
calc_cov_df: &Vec<ProcessedCoverage>,

0 commit comments

Comments
 (0)