Skip to content
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

fix: Apply latest clippy lints #227

Merged
merged 1 commit into from
Dec 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/bcf/match_variants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ pub fn match_variants<P: AsRef<Path>>(matchbcf: P, max_dist: u32, max_len_diff:
.iter()
.map(|a| {
if let Some(range) = index.range(chrom, pos as u64) {
for v in range.map(|(_, idx_vars)| idx_vars).flatten() {
for v in range.flat_map(|(_, idx_vars)| idx_vars) {
if let Some(id) = var.matches(v, a, max_dist, max_len_diff) {
return id as i32;
}
Expand Down
50 changes: 23 additions & 27 deletions src/bcf/report/oncoprint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -953,8 +953,8 @@ pub fn oncoprint(
let html = templates.render("report.html.tera", &context)?;
let js = templates.render("plots.js.tera", &context)?;

let index = format!("{}/index{}.html", index_path, page.to_string());
let js_index = format!("{}/plot{}.js", index_path, page.to_string());
let index = format!("{}/index{}.html", index_path, page);
let js_index = format!("{}/plot{}.js", index_path, page);
let mut file = File::create(index)?;
let mut js_file = File::create(js_index)?;
file.write_all(html.as_bytes())?;
Expand Down Expand Up @@ -1046,15 +1046,13 @@ impl FromStr for Impact {
type Err = ();

fn from_str(s: &str) -> Result<Self, Self::Err> {
let impact;
match s {
"HIGH" => impact = Impact::High,
"MODERATE" => impact = Impact::Moderate,
"MODIFIER" => impact = Impact::Modifier,
"LOW" => impact = Impact::Low,
_ => impact = Impact::Unknown,
"HIGH" => Ok(Impact::High),
"MODERATE" => Ok(Impact::Moderate),
"MODIFIER" => Ok(Impact::Modifier),
"LOW" => Ok(Impact::Low),
_ => Ok(Impact::Unknown),
}
Ok(impact)
}
}

Expand Down Expand Up @@ -1082,28 +1080,26 @@ impl FromStr for ClinSig {
type Err = ();

fn from_str(s: &str) -> Result<Self, Self::Err> {
let clin_sig;
match s {
"pathogenic" => clin_sig = ClinSig::Pathogenic,
"likely_pathogenic/pathogenic" => clin_sig = ClinSig::LikelyPathogenicPathogenic,
"likely_pathogenic" => clin_sig = ClinSig::LikelyPathogenic,
"risk_factor" => clin_sig = ClinSig::RiskFactor,
"drug_response" => clin_sig = ClinSig::DrugResponse,
"affects" => clin_sig = ClinSig::Affects,
"association" => clin_sig = ClinSig::Association,
"uncertain_significance" => clin_sig = ClinSig::UncertainSignificance,
"pathogenic" => Ok(ClinSig::Pathogenic),
"likely_pathogenic/pathogenic" => Ok(ClinSig::LikelyPathogenicPathogenic),
"likely_pathogenic" => Ok(ClinSig::LikelyPathogenic),
"risk_factor" => Ok(ClinSig::RiskFactor),
"drug_response" => Ok(ClinSig::DrugResponse),
"affects" => Ok(ClinSig::Affects),
"association" => Ok(ClinSig::Association),
"uncertain_significance" => Ok(ClinSig::UncertainSignificance),
"conflicting_interpretations_of_pathogenicity" => {
clin_sig = ClinSig::ConflictingInterpretationsOfPathogenicity
Ok(ClinSig::ConflictingInterpretationsOfPathogenicity)
}
"protective" => clin_sig = ClinSig::Protective,
"likely_benign" => clin_sig = ClinSig::LikelyBenign,
"benign/likely_benign" => clin_sig = ClinSig::BenignLikelyBenign,
"benign" => clin_sig = ClinSig::Benign,
"other" => clin_sig = ClinSig::Other,
"not_provided" => clin_sig = ClinSig::NotProvided,
_ => clin_sig = ClinSig::Unknown,
"protective" => Ok(ClinSig::Protective),
"likely_benign" => Ok(ClinSig::LikelyBenign),
"benign/likely_benign" => Ok(ClinSig::BenignLikelyBenign),
"benign" => Ok(ClinSig::Benign),
"other" => Ok(ClinSig::Other),
"not_provided" => Ok(ClinSig::NotProvided),
_ => Ok(ClinSig::Unknown),
}
Ok(clin_sig)
}
}

Expand Down
18 changes: 8 additions & 10 deletions src/bcf/report/table_report/alignment_reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -404,17 +404,15 @@ fn make_markers(
match_start: i64,
match_count: i64,
) -> (Option<AlignmentMatch>, AlignmentNucleobase) {
let marker: Marker;

match base {
let marker: Marker = match base {
// Mismatch
'A' => marker = Marker::A,
'T' => marker = Marker::T,
'C' => marker = Marker::C,
'N' => marker = Marker::N,
'G' => marker = Marker::G,
_ => marker = Marker::Deletion,
}
'A' => Marker::A,
'T' => Marker::T,
'C' => Marker::C,
'N' => Marker::N,
'G' => Marker::G,
_ => Marker::Deletion,
};

let position = snip.pos as i64 + read_offset;
let flags = snip.flags;
Expand Down
2 changes: 1 addition & 1 deletion src/bcf/report/table_report/create_report_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ pub(crate) fn make_table_report(
}

fn escape_hgvsg(hgvsg: &str) -> String {
hgvsg.replace(".", "_").replace(">", "_").replace(":", "_")
hgvsg.replace('.', "_").replace('>', "_").replace(':', "_")
}

pub(crate) fn get_ann_description(
Expand Down
3 changes: 1 addition & 2 deletions src/bcf/split.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,14 +97,13 @@ impl BreakendGroup {
if mates.len() > 2 {
return Box::new(
(2..mates.len())
.map(move |k| {
.flat_map(move |k| {
if let BreakendGroup::Mates(mates) = self {
mates.iter().cloned().combinations(k)
} else {
unreachable!();
}
})
.flatten()
.map(BreakendGroup::Mates),
);
}
Expand Down
9 changes: 4 additions & 5 deletions src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,11 @@ pub trait CalcConsensus<'a, R: SequenceRead> {
// new qual: (1 - MAP)
let qual = (likelihoods[max_posterior] - marginal).ln_one_minus_exp();
// Assume the maximal quality, if the likelihood is infinite
let truncated_quality: f64;
if (*PHREDProb::from(qual)).is_infinite() {
truncated_quality = 93.0;
let truncated_quality: f64 = if (*PHREDProb::from(qual)).is_infinite() {
93.0
} else {
truncated_quality = *PHREDProb::from(qual);
}
*PHREDProb::from(qual)
};
// Truncate quality values to PHRED+33 range
consensus_qual
.push(cmp::min(93 + offset as u64, (truncated_quality + offset) as u64) as u8);
Expand Down
4 changes: 2 additions & 2 deletions src/fastq/collapse_reads_to_fragments/pipeline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ pub trait CallConsensusReads<'a, R: io::Read + io::BufRead + 'a, W: io::Write +
// prepare spinner for user feedback
let pb = indicatif::ProgressBar::new_spinner();
pb.set_style(spinner_style.clone());
pb.set_prefix(&"[1/2] Clustering input reads by UMI using starcode.".to_string());
pb.set_prefix("[1/2] Clustering input reads by UMI using starcode.");

loop {
// update spinner
Expand Down Expand Up @@ -197,7 +197,7 @@ pub trait CallConsensusReads<'a, R: io::Read + io::BufRead + 'a, W: io::Write +
let mut j = 0;
let pb = indicatif::ProgressBar::new_spinner();
pb.set_style(spinner_style);
pb.set_prefix(&"[1/2] Clustering input reads by UMI using starcode.".to_string());
pb.set_prefix("[1/2] Clustering input reads by UMI using starcode.");
// read clusters identified by the first starcode run
// the first run clustered by UMI, hence all reads in
// the clusters handled here had similar UMIs
Expand Down
6 changes: 3 additions & 3 deletions tests/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ fn compare_bam(result: &str, expected: &str) {
let mut result_reader = bam::Reader::from_path(result).unwrap();
let mut result_recs: Vec<bam::Record> =
result_reader.records().filter_map(Result::ok).collect();
result_recs.sort_by_key(|x| x.seq().as_bytes().to_owned());
result_recs.sort_by_key(|x| x.seq().as_bytes());
let mut expected_reader = bam::Reader::from_path(expected).unwrap();
let mut expected_recs: Vec<bam::Record> =
expected_reader.records().filter_map(Result::ok).collect();
expected_recs.sort_by_key(|x| x.seq().as_bytes().to_owned());
expected_recs.sort_by_key(|x| x.seq().as_bytes());
for (result, expected) in result_recs.iter().zip(expected_recs.iter()) {
assert_eq!(result.seq().as_bytes(), expected.seq().as_bytes());
assert_eq!(result.qual(), expected.qual());
Expand Down Expand Up @@ -232,7 +232,7 @@ fn test_csv_report() {

let result = "tests/test-csv-report/data/index1.js";
let expected = "tests/expected/csv-report/data/index1.js";
test_output(&result, &expected);
test_output(result, expected);

fs::remove_dir_all("tests/test-csv-report").unwrap();
}
Expand Down