Advertisement
HwapX

Bioperl data converter

Nov 1st, 2015
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 0.93 KB | None | 0 0
  1. ## http://www.forum-invaders.com.br/vb/showthread.php/40861-HELP-Mudando-formatos
  2.  
  3. #!/usr/bin/perl -w
  4. use warnings;
  5. use strict;
  6.  
  7. my $work = 0;
  8. my $count = 0;
  9. foreach my $line(<DATA>){
  10.     chop($line);
  11.     if($work == 1){
  12.         $line =~ /(.+),\s+(.+)$/;
  13.        
  14.         if($1 eq "Gra"){
  15.             $work = 0;
  16.         }
  17.        
  18.         my @items = split(/\s/, $2);
  19.         @_ = ([],[]);
  20.        
  21.         foreach (@items){
  22.             /(\d{2})(\d{2})/;
  23.             push(@{$_[0]}, int($1));
  24.             push(@{$_[1]}, int($2));
  25.         }
  26.        
  27.         $count++;
  28.         print "#$count\n";
  29.         print join(" ", @{$_[0]}), "\n";
  30.         print join(" ", @{$_[1]}), "\n";
  31.     }
  32.     if($line eq "Pop"){
  33.         $work = 1;
  34.     }
  35. }
  36.  
  37. __DATA__
  38. Pop
  39. 001,    0303 0303 0101 1011 0304
  40. 002,    0303 0003 0101 0410 0405
  41. 003,    0303 0305 0101 1013 0304
  42. 004,    0103 0304 0102 0207 0104
  43. Gra,    0203 0304 0202 0207 0105
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement