11/// Comprehensive integration tests for FastGA-RS
22/// These tests verify that FastGA correctly generates alignments from FASTA inputs
3-
43use std:: fs;
54use std:: path:: Path ;
65use std:: process:: Command ;
@@ -59,21 +58,21 @@ fn test_fastga_self_alignment() {
5958 "-o" , output_path. to_str ( ) . unwrap ( ) ,
6059 ] ) ;
6160
62- assert ! ( result. is_ok( ) , "FastGA self-alignment failed: {:?}" , result ) ;
61+ assert ! ( result. is_ok( ) , "FastGA self-alignment failed: {result :?}" ) ;
6362 assert ! ( output_path. exists( ) , "Output PAF not created" ) ;
6463
6564 let line_count = count_lines ( & output_path) ;
6665 assert ! ( line_count > 0 , "No alignments produced" ) ;
6766 // With 8 yeast genomes, we expect at least the self-mappings for each chromosome
6867 // There are ~17 chromosomes per genome, so 8 * 17 = ~136 minimum
69- assert ! ( line_count > 100 , "Too few alignments for yeast self-alignment (got {})" , line_count ) ;
68+ assert ! ( line_count > 100 , "Too few alignments for yeast self-alignment (got {line_count })" ) ;
7069
7170 assert ! ( has_extended_cigar( & output_path) , "Missing extended CIGAR format" ) ;
7271}
7372
7473#[ test]
7574fn test_fastga_pairwise_alignment ( ) {
76- // Import from parent module (tests/)
75+ // Import from synthetic_genomes module
7776 #[ path = "synthetic_genomes.rs" ]
7877 mod synthetic_genomes;
7978 use synthetic_genomes:: generate_test_pair;
@@ -87,15 +86,15 @@ fn test_fastga_pairwise_alignment() {
8786
8887 // Generate related sequences (20kb with 1% divergence for better alignment)
8988 let ( seq1, seq2) = generate_test_pair ( 20000 , 0.01 ) ;
90- fs:: write ( & fasta1, format ! ( ">seq1\n {}\n " , seq1 ) ) . unwrap ( ) ;
91- fs:: write ( & fasta2, format ! ( ">seq2\n {}\n " , seq2 ) ) . unwrap ( ) ;
89+ fs:: write ( & fasta1, format ! ( ">seq1\n {seq1 }\n " ) ) . unwrap ( ) ;
90+ fs:: write ( & fasta2, format ! ( ">seq2\n {seq2 }\n " ) ) . unwrap ( ) ;
9291
9392 // Debug: Check if files were created correctly
9493 assert ! ( fasta1. exists( ) && fasta2. exists( ) , "Input files not created" ) ;
9594 let seq1_size = fs:: metadata ( & fasta1) . unwrap ( ) . len ( ) ;
9695 let seq2_size = fs:: metadata ( & fasta2) . unwrap ( ) . len ( ) ;
9796 // Sequences should be around 10kb (with header, at least 9.5kb)
98- assert ! ( seq1_size > 9500 && seq2_size > 9500 , "Input files too small: {} and {}" , seq1_size , seq2_size ) ;
97+ assert ! ( seq1_size > 9500 && seq2_size > 9500 , "Input files too small: {seq1_size } and {seq2_size}" ) ;
9998
10099 // Run pairwise alignment
101100 eprintln ! ( "Running alignment: {} vs {}" , fasta1. display( ) , fasta2. display( ) ) ;
@@ -107,18 +106,18 @@ fn test_fastga_pairwise_alignment() {
107106 ] ) ;
108107
109108 if let Err ( ref e) = result {
110- eprintln ! ( "Alignment error: {}" , e ) ;
109+ eprintln ! ( "Alignment error: {e}" ) ;
111110 // Try to preserve the files for debugging
112111 let _ = fs:: copy ( & fasta1, "/tmp/debug_seq1.fa" ) ;
113112 let _ = fs:: copy ( & fasta2, "/tmp/debug_seq2.fa" ) ;
114113 }
115114
116- assert ! ( result. is_ok( ) , "Pairwise alignment failed: {:?}" , result ) ;
115+ assert ! ( result. is_ok( ) , "Pairwise alignment failed: {result :?}" ) ;
117116 assert ! ( output. exists( ) , "Output not created" ) ;
118117
119118 // Should produce at least one alignment between similar sequences
120119 let content = fs:: read_to_string ( & output) . unwrap_or_else ( |e| {
121- panic ! ( "Failed to read output file: {}" , e ) ;
120+ panic ! ( "Failed to read output file: {e}" ) ;
122121 } ) ;
123122 assert ! ( !content. is_empty( ) , "No alignments produced (file has {} bytes)" , content. len( ) ) ;
124123 assert ! ( content. contains( "seq1" ) , "Missing query sequence name" ) ;
@@ -159,7 +158,7 @@ fn test_thread_parameter() {
159158 // Results should be deterministic (same number of alignments)
160159 let lines1 = count_lines ( & output1) ;
161160 let lines4 = count_lines ( & output4) ;
162- assert_eq ! ( lines1, lines4, "Thread count affected output ({} vs {})" , lines1 , lines4 ) ;
161+ assert_eq ! ( lines1, lines4, "Thread count affected output ({lines1 } vs {lines4 })" ) ;
163162}
164163
165164#[ test]
@@ -191,8 +190,7 @@ fn test_filtering_with_fastga() {
191190 let strict_count = count_lines ( & strict) ;
192191
193192 assert ! ( strict_count < loose_count,
194- "Strict filter should produce fewer alignments ({} >= {})" ,
195- strict_count, loose_count) ;
193+ "Strict filter should produce fewer alignments ({strict_count} >= {loose_count})" ) ;
196194 assert ! ( strict_count > 0 , "Strict filter removed all alignments" ) ;
197195}
198196
@@ -270,7 +268,7 @@ fn test_large_sequence_handling() {
270268 let base = generate_base_sequence ( 50000 , 999 ) ;
271269 // Duplicate part of it to create self-similarity
272270 let seq = format ! ( "{}{}" , & base[ ..25000 ] , & base) ;
273- fs:: write ( & large_fa, format ! ( ">large_seq\n {}\n " , seq ) ) . unwrap ( ) ;
271+ fs:: write ( & large_fa, format ! ( ">large_seq\n {seq }\n " ) ) . unwrap ( ) ;
274272
275273 // Should handle without hanging or crashing
276274 let result = run_sweepga ( & [
@@ -307,8 +305,7 @@ fn test_multisequence_fasta() {
307305 let seq3 = mutate_sequence ( & base, 400 , 125 ) ; // 2% divergence (400/20000)
308306
309307 fs:: write ( & multi_fa, format ! (
310- ">seq1\n {}\n >seq2\n {}\n >seq3\n {}\n " ,
311- seq1, seq2, seq3
308+ ">seq1\n {seq1}\n >seq2\n {seq2}\n >seq3\n {seq3}\n "
312309 ) ) . unwrap ( ) ;
313310
314311 let result = run_sweepga ( & [
@@ -327,7 +324,7 @@ fn test_multisequence_fasta() {
327324
328325 // Check that we found alignments between sequences
329326 let lines: Vec < & str > = content. lines ( ) . collect ( ) ;
330- assert ! ( lines. len ( ) > 0 , "Should have at least one alignment" ) ;
327+ assert ! ( ! lines. is_empty ( ) , "Should have at least one alignment" ) ;
331328 }
332329}
333330
@@ -354,10 +351,10 @@ fn test_performance_regression() {
354351
355352 // Yeast self-alignment should complete in reasonable time
356353 assert ! ( duration. as_secs( ) < 60 ,
357- "Alignment took too long: {:?}" , duration ) ;
354+ "Alignment took too long: {duration :?}" ) ;
358355
359356 // Should produce expected number of alignments
360357 let line_count = count_lines ( & output) ;
361358 assert ! ( line_count > 1000 && line_count < 5000 ,
362- "Unexpected alignment count: {}" , line_count ) ;
359+ "Unexpected alignment count: {line_count}" ) ;
363360}
0 commit comments