@@ -191,7 +191,7 @@ pub fn run_uniwig(matches: &ArgMatches) {
191
191
}
192
192
193
193
/// Ensures that the start position is at a minimum equal to `1`
194
- fn clamped_start_position ( start : i32 , smoothsize : i32 , wig_shift : i32 ) -> i32 {
194
+ fn clamped_start_position ( start : i32 , smoothsize : i32 , wig_shift : i32 ) -> i32 {
195
195
std:: cmp:: max ( 1 , start - smoothsize + wig_shift)
196
196
}
197
197
/// Ensure that the start position is at a minimum equal to `0`
@@ -222,7 +222,6 @@ pub fn uniwig_main(
222
222
. build ( )
223
223
. unwrap ( ) ;
224
224
225
-
226
225
// Determine Input File Type
227
226
let input_filetype = FileType :: from_str ( filetype. to_lowercase ( ) . as_str ( ) ) ;
228
227
// Set up output file names
@@ -319,7 +318,7 @@ pub fn uniwig_main(
319
318
clamped_start_position (
320
319
primary_start. 0 ,
321
320
smoothsize,
322
- 1 //must shift wiggle starts and core by 1 since it is 1 based
321
+ 1 , //must shift wiggle starts and core by 1 since it is 1 based
323
322
) ,
324
323
stepsize,
325
324
current_chrom_size,
@@ -449,7 +448,7 @@ pub fn uniwig_main(
449
448
clamped_start_position (
450
449
primary_end. 0 ,
451
450
smoothsize,
452
- 0
451
+ 0 ,
453
452
) ,
454
453
stepsize,
455
454
meta_data_file_names[ 1 ] . clone ( ) ,
@@ -468,7 +467,7 @@ pub fn uniwig_main(
468
467
clamped_start_position (
469
468
primary_end. 0 ,
470
469
smoothsize,
471
- 0
470
+ 0 ,
472
471
) ,
473
472
stepsize,
474
473
meta_data_file_names[ 1 ] . clone ( ) ,
@@ -520,7 +519,7 @@ pub fn uniwig_main(
520
519
& core_results. 0 ,
521
520
file_name. clone ( ) ,
522
521
chrom_name. clone ( ) ,
523
- clamped_start_position ( primary_start. 0 , 0 , 1 ) , //starts are 1 based must be shifted by 1
522
+ clamped_start_position ( primary_start. 0 , 0 , 1 ) , //starts are 1 based must be shifted by 1
524
523
stepsize,
525
524
current_chrom_size,
526
525
) ;
@@ -589,9 +588,9 @@ pub fn uniwig_main(
589
588
) ;
590
589
}
591
590
}
592
- "npy" =>{
591
+ "npy" => {
593
592
// populate hashmap for the npy meta data
594
- for chromosome in final_chromosomes. iter ( ) {
593
+ for chromosome in final_chromosomes. iter ( ) {
595
594
let chr_name = chromosome. chrom . clone ( ) ;
596
595
let current_chrom_size =
597
596
* chrom_sizes. get ( & chromosome. chrom ) . unwrap ( ) as i32 ;
@@ -605,42 +604,46 @@ pub fn uniwig_main(
605
604
}
606
605
607
606
for location in vec_count_type. iter ( ) {
608
-
609
- let temp_meta_file_name = format ! ( "{}{}.{}" , bwfileheader, * location, "meta" ) ;
607
+ let temp_meta_file_name =
608
+ format ! ( "{}{}.{}" , bwfileheader, * location, "meta" ) ;
610
609
611
610
if let Ok ( file) = File :: open ( & temp_meta_file_name) {
612
-
613
611
let reader = BufReader :: new ( file) ;
614
612
615
613
for line in reader. lines ( ) {
616
614
let line = line. unwrap ( ) ;
617
615
let parts: Vec < & str > = line. split_whitespace ( ) . collect ( ) ;
618
616
if parts. len ( ) >= 3 {
619
- let chrom = parts[ 1 ] . split ( '=' )
620
- . nth ( 1 )
621
- . expect ( "Processing npy metadata file: Missing chromosome in line" ) ;
617
+ let chrom = parts[ 1 ] . split ( '=' ) . nth ( 1 ) . expect (
618
+ "Processing npy metadata file: Missing chromosome in line" ,
619
+ ) ;
622
620
let start_str = parts[ 2 ] . split ( '=' )
623
621
. nth ( 1 )
624
622
. expect ( "Processing npy metadata file: Missing start position in line" ) ;
625
- let starting_position: i32 = start_str. parse ( ) . expect ( "Processing npy metadata file: Invalid start position" ) ;
623
+ let starting_position: i32 = start_str. parse ( ) . expect (
624
+ "Processing npy metadata file: Invalid start position" ,
625
+ ) ;
626
626
627
- if let Some ( current_chr_data) = npy_meta_data_map. get_mut ( chrom) {
628
- current_chr_data. insert ( ( * location. to_string ( ) ) . parse ( ) . unwrap ( ) , starting_position) ;
627
+ if let Some ( current_chr_data) = npy_meta_data_map. get_mut ( chrom)
628
+ {
629
+ current_chr_data. insert (
630
+ ( * location. to_string ( ) ) . parse ( ) . unwrap ( ) ,
631
+ starting_position,
632
+ ) ;
629
633
}
630
634
}
631
635
}
632
636
// Remove the file after it is used.
633
637
let path = std:: path:: Path :: new ( & temp_meta_file_name) ;
634
638
let _ = remove_file ( path) . unwrap ( ) ;
635
639
}
636
-
637
640
}
638
641
//write combined metadata as json
639
642
let json_string = serde_json:: to_string_pretty ( & npy_meta_data_map) . unwrap ( ) ;
640
- let combined_npy_meta_file_path = format ! ( "{}{}.{}" , bwfileheader, "npy_meta" , "json" ) ;
643
+ let combined_npy_meta_file_path =
644
+ format ! ( "{}{}.{}" , bwfileheader, "npy_meta" , "json" ) ;
641
645
let mut file = File :: create ( combined_npy_meta_file_path) . unwrap ( ) ;
642
646
file. write_all ( json_string. as_bytes ( ) ) . unwrap ( ) ;
643
-
644
647
}
645
648
_ => { }
646
649
}
0 commit comments