- 论坛徽章:
- 1
|
把E1,E2...也加上了~方法有些笨~- #!/usr/bin/perl
- use strict;
- my $ref = {};
- while (<DATA>)
- {
- chomp;
- my ($name,$s,$e,$p,$inf1,$inf2) = split /\s+/,$_;
- push @{$ref->{$name}->{$p}->{$inf1}->{$inf2}},[$s,$e];
- }
- foreach my $name (sort keys %$ref) {
- foreach my $p (sort keys %{$ref->{$name}}) {
- foreach my $inf1 (sort keys %{$ref->{$name}->{$p}}) {
- foreach my $inf2 (sort keys %{$ref->{$name}->{$p}->{$inf1}}) {
- my @all = @{$ref->{$name}->{$p}->{$inf1}->{$inf2}};
- my @sort = sort {$a->[0] <=> $b->[0]}@all;
- my $start = $sort[0][0];
- my $end = $sort[0][1];
- my $n = 0;
- my $m = 1;
- for my $i (1..$#sort) {
- if ($end >= $sort[$i][0] && $end <= $sort[$i][1]){
- $end = $sort[$i][1];
- $n++;
- }
- if ($end >= $sort[$i][1])
- {$n++;}
- if ( $end <= $sort[$i][0]){
- print "$name"."\t"."$start"."\t"."$end"."\t"."$p"."\t"."$inf1"."_"."E"."$m"."\t"."$inf2"."\n" if ($n != 0);
- $m++;
- $start = $sort[$i][0];
- $end = $sort[$i][1];
- $n = 0;
- }
- }
- print "$name"."\t"."$start"."\t"."$end"."\t"."$p"."\t"."$inf1"."_"."E"."$m"."\t"."$inf2"."\n" if $n != 0;
- }
- }
- }
- }
- __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
复制代码 回复 1# 语笑嫣然qaz
|
|