http://qs1969.pair.com?node_id=11152601


in reply to How to make unique entries

#!/usr/bin/perl use strict; # https://perlmonks.org/?node_id=11152595 use warnings; my $input = <<END; >4kt0_M|P72986 MALSDTQILAALVVALLPAFLAFRLSTELYK iiiiiiiiiMMMMMMMMMMMMMMMMMIIIII >6uzv_m|P72986 MALSDTQILAALVVALLPAFLAFRLSTELYK iiiiiiiiiiiiMMMMMMMMMMMMMMMMMII >5oy0_m|P72986 MALSDTQILAALVVALLPAFLAFRLSTELYK iiiiiiiiiMMMMMMMMMMMMMMMMMIIIII >5oy0_m|P72986 MALSDTQILDIFFERENTAFLAFRLSTELYK iiiiiiiiiMMMMMMMMMMMMMMMMMIIIII >7oy0_m|P72996 MALSDTQILAALVVALLPAFLAFRLSTELYK iiiiiiiiiMMMMMMMMMMMMMMMMMIIIII >6hqb_M|P72986 MALSDTQILAALVVALLPAFLAFRLSTELYK iiiiiiiiiiiMMMMMMMMMMMMMMIIIIII END my %unique; for ( split /(?=>)/, $input ) { $unique{ join "\n", (split /[|\n]/)[1, 2]} //= $_; } use Data::Dump 'dd'; dd sort values %unique;

Outputs:

( ">4kt0_M|P72986\nMALSDTQILAALVVALLPAFLAFRLSTELYK\niiiiiiiiiMMMMMMMMM +MMMMMMMMIIIII\n", ">5oy0_m|P72986\nMALSDTQILDIFFERENTAFLAFRLSTELYK\niiiiiiiiiMMMMMMMMM +MMMMMMMMIIIII\n", ">7oy0_m|P72996\nMALSDTQILAALVVALLPAFLAFRLSTELYK\niiiiiiiiiMMMMMMMMM +MMMMMMMMIIIII\n", )