[ create a new paste ] login | about

Link: http://codepad.org/a9QXEmdU    [ raw code | output | fork ]

Perl, pasted on Jun 20:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
use warnings;
use strict;

my @lengths = ('NM_1234' , '1452' , 'NM_345' , '5008' , 'NR_6145' , '256');
my @counts  = ('NM_1234' , '2',     'NM_345' , '5' ,    'NR_6145' , '10');

my %sequences = map { 
   $counts[2 * $_] => { count => $counts[2 * $_ + 1] } 
} 0..$#counts/2;

for (0..$#lengths/2) {
  my $the_sequence = $lengths[2 * $_];
  my $the_length   = $lengths[2 * $_ + 1];
  push @{ $sequences{$the_sequence}->{length} }, $the_length;
}

for my $name (keys %sequences) {
  my $lengths_string = join(', ', @{ $sequences{$name}->{length} });
  my $count = $sequences{$name}->{count};
  print "$name, $lengths_string, $count", "\n";
}


Output:
1
2
3
NM_345, 5008, 5
NR_6145, 256, 10
NM_1234, 1452, 2


Create a new paste based on this one


Comments: