Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env perl
- use strict;
- use warnings FATAL => 'all';
- use List::Util qw(max min);
- my @COLS = qw( label _ chr strand start end );
- my @KEY_COLS = qw( label chr strand );
- my %refSeq;
- while (<>) {
- chomp;
- my %h;
- @h{@COLS} = split "\t";
- my $key = join ':', @h{@KEY_COLS};
- if ( $refSeq{$key} ) {
- $refSeq{$key}{start} = min( $refSeq{$key}{start}, $h{start} );
- $refSeq{$key}{end} = max( $refSeq{$key}{end}, $h{end} );
- }
- else {
- $refSeq{$key} = \%h;
- }
- }
- for ( sort { $a->{chr} cmp $b->{chr} || $a->{start} <=> $b->{start} || $a->{end} <=> $b->{end} } values %refSeq ) {
- print join( "\t", @{$_}{@COLS} ) . "\n";
- }
Add Comment
Please, Sign In to add comment