Skip to content

Commit a0e6255

Browse files
committed
Apply cargo fmt formatting
1 parent f92d2cf commit a0e6255

3 files changed

Lines changed: 85 additions & 33 deletions

File tree

src/fastga_integration.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -170,11 +170,16 @@ impl FastGAIntegration {
170170
};
171171

172172
// Prepare GDB
173-
let gdb_base = orchestrator.prepare_gdb(fasta_path)
173+
let gdb_base = orchestrator
174+
.prepare_gdb(fasta_path)
174175
.map_err(|e| anyhow::anyhow!("Failed to prepare GDB: {}", e))?;
175176

176177
// Create index
177-
orchestrator.create_index(&gdb_base, self.config.adaptive_seed_cutoff.unwrap_or(10) as i32)
178+
orchestrator
179+
.create_index(
180+
&gdb_base,
181+
self.config.adaptive_seed_cutoff.unwrap_or(10) as i32,
182+
)
178183
.map_err(|e| anyhow::anyhow!("Failed to create index: {}", e))?;
179184

180185
Ok(gdb_base)
@@ -194,7 +199,8 @@ impl FastGAIntegration {
194199
};
195200

196201
// Run alignment with existing indices (returns PAF bytes directly)
197-
let paf_output = orchestrator.align_with_existing_indices(queries, targets)
202+
let paf_output = orchestrator
203+
.align_with_existing_indices(queries, targets)
198204
.map_err(|e| anyhow::anyhow!("Failed to run FastGA alignment: {}", e))?;
199205

200206
eprintln!(

src/main.rs

Lines changed: 72 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1070,11 +1070,7 @@ fn detect_genome_groups(fasta_path: &Path) -> Result<Vec<String>> {
10701070
}
10711071

10721072
/// Write sequences belonging to a specific genome group to a new FASTA file
1073-
fn write_genome_fasta(
1074-
input_path: &Path,
1075-
output_path: &Path,
1076-
genome_prefix: &str,
1077-
) -> Result<usize> {
1073+
fn write_genome_fasta(input_path: &Path, output_path: &Path, genome_prefix: &str) -> Result<usize> {
10781074
use std::io::{BufRead, BufReader, Write};
10791075

10801076
let file = File::open(input_path)?;
@@ -1130,7 +1126,10 @@ fn align_multiple_fastas(
11301126
let groups = detect_genome_groups(path)?;
11311127
num_genomes += groups.len();
11321128
if !quiet {
1133-
timing.log("detect", &format!("{}: {} genome groups", fasta_file, groups.len()));
1129+
timing.log(
1130+
"detect",
1131+
&format!("{}: {} genome groups", fasta_file, groups.len()),
1132+
);
11341133
}
11351134
}
11361135

@@ -1152,14 +1151,23 @@ fn align_multiple_fastas(
11521151
let effective_frequency = if let Some(f) = frequency {
11531152
// User specified -f, use it as-is
11541153
if !quiet {
1155-
timing.log("align", &format!("Using user-specified frequency threshold: {}", f));
1154+
timing.log(
1155+
"align",
1156+
&format!("Using user-specified frequency threshold: {}", f),
1157+
);
11561158
}
11571159
Some(f)
11581160
} else if num_genomes > 1 {
11591161
// Auto-set frequency to at least num_genomes to avoid filtering out valid k-mers
11601162
let auto_freq = num_genomes;
11611163
if !quiet {
1162-
timing.log("align", &format!("Setting frequency threshold to {} (number of genome groups)", auto_freq));
1164+
timing.log(
1165+
"align",
1166+
&format!(
1167+
"Setting frequency threshold to {} (number of genome groups)",
1168+
auto_freq
1169+
),
1170+
);
11631171
}
11641172
Some(auto_freq)
11651173
} else {
@@ -1168,7 +1176,10 @@ fn align_multiple_fastas(
11681176
};
11691177

11701178
if !quiet {
1171-
timing.log("align", &format!("Aligning {} genomes in single FastGA run", num_genomes));
1179+
timing.log(
1180+
"align",
1181+
&format!("Aligning {} genomes in single FastGA run", num_genomes),
1182+
);
11721183
}
11731184

11741185
// Create FastGA integration with effective frequency
@@ -1181,7 +1192,10 @@ fn align_multiple_fastas(
11811192

11821193
if !quiet {
11831194
let alignment_count = std::fs::read_to_string(temp_paf.path())?.lines().count();
1184-
timing.log("align", &format!("FastGA produced {} alignments", alignment_count));
1195+
timing.log(
1196+
"align",
1197+
&format!("FastGA produced {} alignments", alignment_count),
1198+
);
11851199
}
11861200

11871201
Ok(temp_paf)
@@ -1213,7 +1227,10 @@ fn align_all_pairs_mode(
12131227
std::fs::create_dir_all(&temp_genome_dir)?;
12141228

12151229
if !quiet {
1216-
timing.log("split", &format!("Using temp directory: {}", temp_genome_dir.display()));
1230+
timing.log(
1231+
"split",
1232+
&format!("Using temp directory: {}", temp_genome_dir.display()),
1233+
);
12171234
}
12181235

12191236
// Collect all genome groups from all input files
@@ -1239,15 +1256,18 @@ fn align_all_pairs_mode(
12391256
let genome_name = genome_prefix.trim_end_matches('#').replace('#', "_");
12401257
let genome_path = temp_genome_dir.join(format!("{genome_name}.fa"));
12411258

1242-
let seq_count = write_genome_fasta(
1243-
Path::new(source_file),
1244-
&genome_path,
1245-
genome_prefix,
1246-
)?;
1259+
let seq_count = write_genome_fasta(Path::new(source_file), &genome_path, genome_prefix)?;
12471260

12481261
if !quiet {
1249-
timing.log("split", &format!("Wrote {} sequences for {} to {}",
1250-
seq_count, genome_prefix, genome_path.display()));
1262+
timing.log(
1263+
"split",
1264+
&format!(
1265+
"Wrote {} sequences for {} to {}",
1266+
seq_count,
1267+
genome_prefix,
1268+
genome_path.display()
1269+
),
1270+
);
12511271
}
12521272

12531273
genome_files.insert(genome_prefix.clone(), genome_path);
@@ -1258,7 +1278,10 @@ fn align_all_pairs_mode(
12581278
genome_prefixes.sort();
12591279

12601280
if !quiet {
1261-
timing.log("index", &format!("Building indices for {} genomes", genome_prefixes.len()));
1281+
timing.log(
1282+
"index",
1283+
&format!("Building indices for {} genomes", genome_prefixes.len()),
1284+
);
12621285
}
12631286

12641287
// Create FastGA integration
@@ -1269,8 +1292,10 @@ fn align_all_pairs_mode(
12691292
let fasta_path = &genome_files[genome_prefix];
12701293

12711294
if !quiet {
1272-
timing.log("index", &format!("Building index for {}",
1273-
genome_prefix.trim_end_matches('#')));
1295+
timing.log(
1296+
"index",
1297+
&format!("Building index for {}", genome_prefix.trim_end_matches('#')),
1298+
);
12741299
}
12751300

12761301
// Create .gdb and .gix files
@@ -1279,7 +1304,10 @@ fn align_all_pairs_mode(
12791304
}
12801305

12811306
if !quiet {
1282-
timing.log("align", &format!("Aligning {} genomes pairwise", genome_prefixes.len()));
1307+
timing.log(
1308+
"align",
1309+
&format!("Aligning {} genomes pairwise", genome_prefixes.len()),
1310+
);
12831311
}
12841312

12851313
// Create merged PAF output file
@@ -1304,9 +1332,14 @@ fn align_all_pairs_mode(
13041332
let fasta_j = &genome_files[genome_j];
13051333

13061334
if !quiet {
1307-
timing.log("align", &format!("Aligning {} vs {}",
1308-
genome_i.trim_end_matches('#'),
1309-
genome_j.trim_end_matches('#')));
1335+
timing.log(
1336+
"align",
1337+
&format!(
1338+
"Aligning {} vs {}",
1339+
genome_i.trim_end_matches('#'),
1340+
genome_j.trim_end_matches('#')
1341+
),
1342+
);
13101343
}
13111344

13121345
// Align using pre-built GDB/GIX indices (FastGA auto-detects them)
@@ -1328,8 +1361,10 @@ fn align_all_pairs_mode(
13281361
let fasta_i = &genome_files[genome_i];
13291362

13301363
if !quiet {
1331-
timing.log("align", &format!("Self-aligning {}",
1332-
genome_i.trim_end_matches('#')));
1364+
timing.log(
1365+
"align",
1366+
&format!("Self-aligning {}", genome_i.trim_end_matches('#')),
1367+
);
13331368
}
13341369

13351370
let temp_paf = fastga.align_to_temp_paf(fasta_i, fasta_i)?;
@@ -1348,7 +1383,12 @@ fn align_all_pairs_mode(
13481383
merged_output.flush()?;
13491384

13501385
if !quiet {
1351-
timing.log("align", &format!("Completed {total_pairs} pairwise alignments, {total_alignments} total alignments"));
1386+
timing.log(
1387+
"align",
1388+
&format!(
1389+
"Completed {total_pairs} pairwise alignments, {total_alignments} total alignments"
1390+
),
1391+
);
13521392
}
13531393

13541394
// Cleanup temp genome files and indices
@@ -1425,7 +1465,10 @@ fn main() -> Result<()> {
14251465

14261466
// Check if all files are FASTA
14271467
let all_fasta = file_types.iter().all(|ft| *ft == FileType::Fasta);
1428-
let fasta_count = file_types.iter().filter(|ft| **ft == FileType::Fasta).count();
1468+
let fasta_count = file_types
1469+
.iter()
1470+
.filter(|ft| **ft == FileType::Fasta)
1471+
.count();
14291472

14301473
match (args.files.len(), all_fasta) {
14311474
(1, true) => {

tests/test_centromere_plane_sweep.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,5 +111,8 @@ fn test_reverse_vs_forward_scaffold_scoring() {
111111

112112
// In an ideal world, only the reverse would be kept
113113
// But at minimum, the reverse MUST be present
114-
eprintln!("Has forward: {}, Has reverse: {}", _has_forward, _has_reverse);
114+
eprintln!(
115+
"Has forward: {}, Has reverse: {}",
116+
_has_forward, _has_reverse
117+
);
115118
}

0 commit comments

Comments
 (0)