- 论坛徽章:
- 8
|
- #!/usr/bin/perl
- my %R;
- while (<DATA>) {
- my @s = split;
- push @{ $R{ $s[4] }{R} }, [ $s[1], $s[2] ];
- $R{ $s[4] }{ $s[1] } = [ @s[ 0, 3, 4, 5 ] ];
- }
- while ( my ( $k, $v ) = each %R ) {
- my @tmp = sort { $a->[0] <=> $b->[0] } @{ $v->{R} };
- my ( $E, @R ) = ( 1, shift @tmp );
- for my $t (@tmp) {
- $t->[0] > $R[-1][1] && push @R, $t and next;
- $t->[1] > $R[-1][1] && ( $R[-1][1] = $t->[1] )
- }
- for my $R (@R) {
- my ( $A, $B, $C, $D ) = @{ $v->{ $R->[0] } };
- print join( "\t", $A, @$R, $B, "${C}_E" . $E++, $D ) . $/;
- }
- }
- __DATA__
- refseq1 8 13 + NM_152486 SAMD11
- refseq1 6 11 + NM_152486 SAMD11
- refseq1 14 16 + NM_152486 SAMD11
- refseq1 6 12 - NM_021170 HES4
- refseq1 8 10 - NM_021170 HES4
- refseq2 9 11 - NM_001002919 FAM150B
- refseq2 3 8 - NM_001002919 FAM150B
复制代码 这是我之前导师给我的一道考试题~ |
|