[ create a new paste ] login | about

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

Perl, pasted on Jan 7:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
my @oldMarkers = qw(chr1 chr2 IMP IMP IMP IMP IMP IMP IMP IMP IMP IMP IMP IMP IMP chr2);

my @newMarkers;
my $chrCount = 0;
my $impCount = 0;

foreach my $marker (@oldMarkers) {
    if ( $marker =~ /^chr\d+$/ ) {
        push @newMarkers, ++$chrCount;
        $impCount = 0;
    } elsif ( $marker eq "IMP" ) {
        $impCount++;
        $impCount = 1 if $impCount == 10;
        push @newMarkers, "$chrCount.$impCount";
    } else {
        die "Unrecognized marker $marker";
    }
}

print "@newMarkers\n";
 


Output:
1
1 2 2.1 2.2 2.3 2.4 2.5 2.6 2.7 2.8 2.9 2.1 2.2 2.3 2.4 3


Create a new paste based on this one


Comments: