Guest User

Untitled

a guest
Oct 20th, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. #!/usr/bin/env perl
  2.  
  3. use strict;
  4. use warnings FATAL => 'all';
  5.  
  6. use List::Util qw(max min);
  7.  
  8. my @COLS = qw( label _ chr strand start end );
  9. my @KEY_COLS = qw( label chr strand );
  10.  
  11. my %refSeq;
  12.  
  13. while (<>) {
  14. chomp;
  15. my %h;
  16. @h{@COLS} = split "\t";
  17. my $key = join ':', @h{@KEY_COLS};
  18. if ( $refSeq{$key} ) {
  19. $refSeq{$key}{start} = min( $refSeq{$key}{start}, $h{start} );
  20. $refSeq{$key}{end} = max( $refSeq{$key}{end}, $h{end} );
  21. }
  22. else {
  23. $refSeq{$key} = \%h;
  24. }
  25. }
  26.  
  27. for ( sort { $a->{chr} cmp $b->{chr} || $a->{start} <=> $b->{start} || $a->{end} <=> $b->{end} } values %refSeq ) {
  28. print join( "\t", @{$_}{@COLS} ) . "\n";
  29. }
Add Comment
Please, Sign In to add comment