Skip to content

Commit 27056ba

Browse files
refactor: lint
1 parent 65a1d2b commit 27056ba

File tree

7 files changed

+22
-27
lines changed

7 files changed

+22
-27
lines changed

packages/pangraph/src/align/minimap2_lib/align_with_minimap2_lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ mod tests {
194194
orientation: Strand::Forward,
195195
new_block_id: None, // FIXME
196196
anchor_block: None, // FIXME
197-
cigar: parse_cigar_str("545M1D225M1D226M").unwrap(),
197+
cigar: parse_cigar_str("545M1D225M1D226M")?,
198198
divergence: Some(0.029058116232464903),
199199
align: Some(845.0),
200200
}];

packages/pangraph/src/align/nextclade/align/params.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,14 @@ use itertools::Itertools;
77
use serde::{Deserialize, Serialize};
88
use std::collections::BTreeMap;
99

10-
#[derive(ValueEnum, Copy, Clone, Debug, Deserialize, Serialize)]
10+
#[derive(ValueEnum, Copy, Clone, Debug, Deserialize, Serialize, Default)]
1111
#[serde(rename_all = "kebab-case")]
1212
pub enum GapAlignmentSide {
13+
#[default]
1314
Left,
1415
Right,
1516
}
1617

17-
impl Default for GapAlignmentSide {
18-
fn default() -> Self {
19-
Self::Left
20-
}
21-
}
22-
2318
#[allow(clippy::struct_excessive_bools)]
2419
#[derive(Parser, Debug, Clone, Serialize, Deserialize)]
2520
#[serde(rename_all = "camelCase")]

packages/pangraph/src/align/nextclade/alphabet/letter.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,6 @@ pub fn serde_deserialize_seq<'de, D: Deserializer<'de>, L: Letter<L>>(deserializ
3434
let seq = L::to_seq(&seq_str)
3535
.wrap_err("When deserializing nucleotide sequence")
3636
.with_section(|| seq_str.header("Sequence:"))
37-
.unwrap();
37+
.map_err(serde::de::Error::custom)?;
3838
Ok(seq)
3939
}

packages/pangraph/src/io/file.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use eyre::{Report, WrapErr};
33
use log::{info, warn};
44
use std::fs::File;
55
use std::io::{BufRead, BufReader, BufWriter, Write, stdin, stdout};
6-
use std::path::{Path, PathBuf};
6+
use std::path::Path;
77

88
use crate::io::compression::{Compressor, Decompressor};
99
#[cfg(not(target_arch = "wasm32"))]
@@ -81,10 +81,10 @@ pub fn create_file_or_stdout(filepath: impl AsRef<Path>) -> Result<Box<dyn Write
8181

8282
pub fn is_path_stdin(filepath: impl AsRef<Path>) -> bool {
8383
let filepath = filepath.as_ref();
84-
filepath == PathBuf::from("-") || filepath == PathBuf::from("/dev/stdin")
84+
filepath == Path::new("-") || filepath == Path::new("/dev/stdin")
8585
}
8686

8787
pub fn is_path_stdout(filepath: impl AsRef<Path>) -> bool {
8888
let filepath = filepath.as_ref();
89-
filepath == PathBuf::from("-") || filepath == PathBuf::from("/dev/stdout")
89+
filepath == Path::new("-") || filepath == Path::new("/dev/stdout")
9090
}

packages/pangraph/src/pangraph/graph_merging.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ mod tests {
267267
orientation: Strand::Reverse,
268268
new_block_id: None, // FIXME
269269
anchor_block: None, // FIXME
270-
cigar: parse_cigar_str("90M").unwrap(),
270+
cigar: parse_cigar_str("90M")?,
271271
divergence: Some(0.05),
272272
align: None,
273273
};
@@ -293,7 +293,7 @@ mod tests {
293293
orientation: Strand::Reverse,
294294
new_block_id: None, // FIXME
295295
anchor_block: None, // FIXME
296-
cigar: parse_cigar_str("90M").unwrap(),
296+
cigar: parse_cigar_str("90M")?,
297297
divergence: Some(0.05),
298298
align: None,
299299
};
@@ -314,7 +314,7 @@ mod tests {
314314
orientation: Strand::default(),
315315
new_block_id: None, // FIXME
316316
anchor_block: None, // FIXME
317-
cigar: parse_cigar_str("100M").unwrap(),
317+
cigar: parse_cigar_str("100M")?,
318318
divergence: Some(0.05),
319319
align: None,
320320
};
@@ -328,7 +328,7 @@ mod tests {
328328
orientation: Strand::default(),
329329
new_block_id: None, // FIXME
330330
anchor_block: None, // FIXME
331-
cigar: parse_cigar_str("100M").unwrap(),
331+
cigar: parse_cigar_str("100M")?,
332332
divergence: Some(0.02),
333333
align: None,
334334
};
@@ -342,7 +342,7 @@ mod tests {
342342
orientation: Strand::default(),
343343
new_block_id: None, // FIXME
344344
anchor_block: None, // FIXME
345-
cigar: parse_cigar_str("100M").unwrap(),
345+
cigar: parse_cigar_str("100M")?,
346346
divergence: Some(0.05),
347347
align: None,
348348
};
@@ -356,7 +356,7 @@ mod tests {
356356
orientation: Strand::default(),
357357
new_block_id: None, // FIXME
358358
anchor_block: None, // FIXME
359-
cigar: parse_cigar_str("100M").unwrap(),
359+
cigar: parse_cigar_str("100M")?,
360360
divergence: Some(0.1),
361361
align: None,
362362
};

packages/pangraph/src/pangraph/reweave.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -834,7 +834,7 @@ mod tests {
834834
assert_eq!(h[0].block.id(), BlockId(42));
835835
assert_eq!(h[0].is_anchor, true);
836836
assert_eq!(h[0].orientation, Forward);
837-
assert_eq!(h[0].cigar, Some(Cigar::from_str("10I10M10D40M").unwrap()));
837+
assert_eq!(h[0].cigar, Some(Cigar::from_str("10I10M10D40M")?));
838838
assert_eq!(h[1].block.id(), BlockId(43));
839839
assert_eq!(h[1].is_anchor, false);
840840
assert_eq!(h[1].orientation, Reverse);
@@ -1071,7 +1071,7 @@ mod tests {
10711071
assert_eq!(p1.append_block.consensus(), &O.blocks[&BlockId(40)].consensus()[0..200]);
10721072
assert_eq!(p1.append_block.id(), G.nodes[&nid_300_1].block_id());
10731073
// CIGAR modified by left 10 bp overhands in ref and qry
1074-
assert_eq!(p1.cigar, Cigar::from_str("10I20D170M10I10M").unwrap());
1074+
assert_eq!(p1.cigar, Cigar::from_str("10I20D170M10I10M")?);
10751075

10761076
let bid40_3 = G.nodes[&nid_300_3].block_id();
10771077
let p2 = &p_dict[&bid40_3];
@@ -1082,7 +1082,7 @@ mod tests {
10821082
);
10831083
assert_eq!(p2.append_block.id(), G.nodes[&nid_200_4].block_id());
10841084
assert_eq!(p2.append_block.consensus(), &O.blocks[&BlockId(20)].consensus()[0..200]);
1085-
assert_eq!(p2.cigar, Cigar::from_str("200M").unwrap());
1085+
assert_eq!(p2.cigar, Cigar::from_str("200M")?);
10861086

10871087
let bid50_1 = G.nodes[&nid_200_2].block_id();
10881088
let p3 = &p_dict[&bid50_1];
@@ -1095,7 +1095,7 @@ mod tests {
10951095
&O.blocks[&BlockId(20)].consensus()[300..400]
10961096
);
10971097
// CIGAR modified by right 50 bp overhang in ref
1098-
assert_eq!(p3.cigar, Cigar::from_str("100M50D").unwrap());
1098+
assert_eq!(p3.cigar, Cigar::from_str("100M50D")?);
10991099

11001100
let bid50_2 = G.nodes[&nid_100_2].block_id();
11011101
let p4 = &p_dict[&bid50_2];
@@ -1107,7 +1107,7 @@ mod tests {
11071107
);
11081108
assert_eq!(p4.append_block.id(), G.nodes[&nid_300_5].block_id());
11091109
assert_eq!(p4.append_block.consensus(), &O.blocks[&BlockId(30)].consensus()[0..100]);
1110-
assert_eq!(p4.cigar, Cigar::from_str("80M10I10M10D").unwrap());
1110+
assert_eq!(p4.cigar, Cigar::from_str("80M10I10M10D")?);
11111111

11121112
// assert_eq!(p1.append_block.id(), p1.anchor_block.id());
11131113
// assert_eq!(p2.append_block.id(), p2.anchor_block.id());

packages/pangraph/src/pangraph/split_matches.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -196,14 +196,14 @@ pub fn side_patches(aln: &mut Alignment, args: &AlignmentArgs) -> Result<(), Rep
196196
let delta_l = rs;
197197
aln.reff.interval.start = 0;
198198
aln.length += delta_l;
199-
ops = add_flanking_indel(&ops, Kind::Deletion, delta_l, &Side::Leading).unwrap();
199+
ops = add_flanking_indel(&ops, Kind::Deletion, delta_l, &Side::Leading)?;
200200
}
201201
if (re < rL) && (rL - re < args.indel_len_threshold) {
202202
// Append right reference patch
203203
let delta_l = rL - re;
204204
aln.reff.interval.end = rL;
205205
aln.length += delta_l;
206-
ops = add_flanking_indel(&ops, Kind::Deletion, delta_l, &Side::Trailing).unwrap();
206+
ops = add_flanking_indel(&ops, Kind::Deletion, delta_l, &Side::Trailing)?;
207207
}
208208

209209
// Check query
@@ -217,7 +217,7 @@ pub fn side_patches(aln: &mut Alignment, args: &AlignmentArgs) -> Result<(), Rep
217217
Strand::Forward => Side::Leading,
218218
Strand::Reverse => Side::Trailing,
219219
};
220-
ops = add_flanking_indel(&ops, Kind::Insertion, delta_l, &side).unwrap();
220+
ops = add_flanking_indel(&ops, Kind::Insertion, delta_l, &side)?;
221221
}
222222
if (qe < qL) && (qL - qe < args.indel_len_threshold) {
223223
// Append query end
@@ -228,7 +228,7 @@ pub fn side_patches(aln: &mut Alignment, args: &AlignmentArgs) -> Result<(), Rep
228228
Strand::Forward => Side::Trailing,
229229
Strand::Reverse => Side::Leading,
230230
};
231-
ops = add_flanking_indel(&ops, Kind::Insertion, delta_l, &side).unwrap();
231+
ops = add_flanking_indel(&ops, Kind::Insertion, delta_l, &side)?;
232232
}
233233

234234
aln.cigar = ops;

0 commit comments

Comments
 (0)