Skip to content

Commit df66f24

Browse files
author
Johanna
committed
clean up code
1 parent 04ecd37 commit df66f24

File tree

3 files changed

+20
-61
lines changed

3 files changed

+20
-61
lines changed

src/lib.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -493,20 +493,21 @@ pub fn main() -> Result<(), Error> {
493493

494494
log::info!("Reaging input genomes");
495495
let path = Path::new(genome_ids);
496-
let file = File::open(&path)?;
496+
let file = File::open(path)?;
497497
let reader = std::io::BufReader::new(file);
498498

499499
// Read in genomes to
500-
let ids: Vec<String> = reader.lines().filter_map(|line| line.ok()).collect();
501-
500+
// let ids: Vec<String> = reader.lines().filter_map(|line| line.ok()).collect();
501+
let ids: Vec<String> = reader.lines().map_while(Result::ok).collect();
502+
502503
log::info!("Reading input metadata");
503504
let mut sketches: MultiSketch = MultiSketch::load(ref_db)
504505
.unwrap_or_else(|_| panic!("Could not read sketch metadata from {}.skm", ref_db));
505506

506507

507508
println!("BLUB");
508509
// write new .skm
509-
sketches.remove_metadata(ref_db, output_file, &ids);
510+
let _ = sketches.remove_metadata(output_file, &ids);
510511

511512
// remove samples from .skd file
512513
log::info!("Remove genomes and writing output");

src/multisketch.rs

+1-19
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,6 @@ impl MultiSketch {
193193
}
194194
pub fn remove_metadata(
195195
&mut self,
196-
input_prefix: &str,
197196
output_file_name: &str,
198197
genome_ids_to_remove: &[String],
199198
) -> std::io::Result<()> {
@@ -207,7 +206,7 @@ impl MultiSketch {
207206
}
208207
}
209208
self.sketch_metadata = new_sketch_metadata;
210-
self.save_metadata(output_file_name);
209+
let _ = self.save_metadata(output_file_name);
211210
Ok(())
212211
}
213212

@@ -255,23 +254,6 @@ impl MultiSketch {
255254
Ok(())
256255
}
257256

258-
// pub fn get_genome_positions(&self, genome_ids: &[String], positions: &mut Vec<usize>) {
259-
// let mut missing_ids = Vec::new();
260-
261-
// for id in genome_ids {
262-
// if let Some(&position) = self.name_map.get(id) {
263-
// positions.push(position);
264-
// } else {
265-
// missing_ids.push(id.clone());
266-
// }
267-
// }
268-
269-
// if !missing_ids.is_empty() {
270-
// panic!("The following genome IDs were not found: {:?}", missing_ids);
271-
// }
272-
273-
// positions.sort();
274-
// }
275257

276258
// This function is called when sketches are merged, not when they are
277259
// first sketched (this is handled by sketch::sketch_files())

tests/common/mod.rs

+14-38
Original file line numberDiff line numberDiff line change
@@ -37,44 +37,20 @@ impl TestSetup {
3737
pub fn setup() -> Self {
3838
let wd = assert_fs::TempDir::new().unwrap();
3939

40-
println!("Current working directory: {:?}", std::env::current_dir().unwrap());
41-
42-
// Debug: Print FILE_IN and FILE_TEST paths
43-
println!("FILE_IN constant value: {:?}", FILE_IN);
44-
println!("FILE_TEST constant value: {:?}", FILE_TEST);
45-
46-
let file_in_path = Path::new(FILE_IN);
47-
let file_test_path = Path::new(FILE_TEST);
48-
49-
println!("FILE_IN absolute path: {:?}", file_in_path.canonicalize());
50-
println!("FILE_TEST absolute path: {:?}", file_test_path.canonicalize());
51-
52-
// Check if the directories exist
53-
println!("FILE_IN exists: {}", file_in_path.exists());
54-
println!("FILE_TEST exists: {}", file_test_path.exists());
55-
56-
// Attempt to create symlink for SYM_IN
57-
match wd.child(SYM_IN).symlink_to_dir(file_in_path.canonicalize().unwrap_or_else(|e| {
58-
panic!("Failed to canonicalize FILE_IN path: {:?}. Error: {:?}", file_in_path, e);
59-
})) {
60-
Ok(_) => println!("Successfully created symlink for {}", SYM_IN),
61-
Err(e) => println!("Failed to create symlink for {}: {:?}", SYM_IN, e),
62-
}
63-
64-
// Attempt to create symlink for SYM_TEST
65-
match wd.child(SYM_TEST).symlink_to_dir(file_test_path.canonicalize().unwrap_or_else(|e| {
66-
panic!("Failed to canonicalize FILE_TEST path: {:?}. Error: {:?}", file_test_path, e);
67-
})) {
68-
Ok(_) => println!("Successfully created symlink for {}", SYM_TEST),
69-
Err(e) => println!("Failed to create symlink for {}: {:?}", SYM_TEST, e),
70-
}
71-
72-
// Debug: Print contents of temporary directory
73-
println!("Contents of temporary directory:");
74-
for entry in std::fs::read_dir(&wd.path()).unwrap() {
75-
let entry = entry.unwrap();
76-
println!(" {:?}", entry.path());
77-
}
40+
wd.child(SYM_IN)
41+
.symlink_to_dir(
42+
Path::new(FILE_IN)
43+
.canonicalize()
44+
.expect("Could not link expected files"),
45+
)
46+
.unwrap();
47+
wd.child(SYM_TEST)
48+
.symlink_to_dir(
49+
Path::new(FILE_TEST)
50+
.canonicalize()
51+
.expect("Could not link expected files"),
52+
)
53+
.unwrap();
7854

7955
Self { wd }
8056
}

0 commit comments

Comments
 (0)