File tree Expand file tree Collapse file tree 1 file changed +17
-7
lines changed Expand file tree Collapse file tree 1 file changed +17
-7
lines changed Original file line number Diff line number Diff line change @@ -228,16 +228,26 @@ impl<'a> SequenceRenaming<'a> {
228
228
names. iter ( ) . for_each ( |( origin, destination) | {
229
229
let values = matrix. shift_remove ( origin) ;
230
230
if let Some ( value) = values {
231
+ // We check the sequence length if the ID is not unique
232
+ if matrix. contains_key ( destination) {
233
+ log:: warn!(
234
+ "ID {} already exists. \
235
+ Keeping the longest sequences.",
236
+ destination
237
+ ) ;
238
+ let new_value = matrix. get ( destination) . expect ( "Failed getting value" ) ;
239
+ if new_value. len ( ) > value. len ( ) {
240
+ matrix. insert ( origin. to_string ( ) , value) ;
241
+ return ;
242
+ }
243
+ }
231
244
matrix. insert ( destination. to_string ( ) , value) ;
232
245
}
233
246
} ) ;
234
-
235
- assert_eq ! (
236
- original_size,
237
- matrix. len( ) ,
238
- "Failed renaming files. New ID counts does not match original ID counts. \
239
- Original ID counts: {}. New ID counts: {}",
240
- original_size,
247
+ log:: warn!(
248
+ "Duplicate IDs found! Original ID count: {}. \
249
+ New ID count: {}",
250
+ original_size - matrix. len( ) ,
241
251
matrix. len( )
242
252
) ;
243
253
( matrix, header)
You can’t perform that action at this time.
0 commit comments