Advertisement
s4553711

extract.pl

Jul 4th, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 1.37 KB | None | 0 0
  1. #!/usr/bin/perl
  2. my $limit = $ARGV[0];
  3. my $curr_base = 0;
  4. my $end = 0;
  5. my $tot_reads = 0;
  6.  
  7. while(<STDIN>) {
  8.     chomp;
  9.     my $line = $_;
  10.     my @q = split(/\s+/, $line);
  11.     print STDERR "Log > File: $q[3]\n";
  12.  
  13.     $file = $q[3];
  14.     my $command = "aws s3 cp s3://giab/$q[3] - | pigz -dc";
  15.     open my $cmd_fh, "$command |";
  16.  
  17.     my $ind = 0;
  18.     my $chunk_reads = 0;
  19.     my $t1 = "";
  20.     my $t2 = "";
  21.     my $t3 = "";
  22.     my $t4 = "";
  23.     while (<$cmd_fh>) {
  24.     chomp;
  25.     my $line2 = $_;
  26.     $ind++;
  27.     if ($ind % 4 == 2) {
  28.         $curr_base += length($line2);
  29.         $t2 = $line2;
  30.     } elsif ($ind % 4 == 1) {
  31.         $t1 = $line2;
  32.     } elsif ($ind % 4 == 3) {
  33.         $t3 = $line2;
  34.     } else {
  35.         if ($curr_base < $limit) {
  36.             print "$t1\n$t2\n$t3\n$line2\n";
  37.             $tot_reads += 1;
  38.             $chunk_reads += 1;
  39.             print STDERR "Log > progress: $chunk_reads / $tot_reads $q[3]\n" if ($tot_reads % 100000 == 0);
  40.         } else {
  41.             $end = 1;
  42.             last;
  43.         }
  44.     }
  45.     }
  46.     close $cmd_fh;
  47.     last if ($end == 1);
  48. }
  49.  
  50. #my $t1 = "";
  51. #my $t2 = "";
  52. #my $t3 = "";
  53. #my $t4 = "";
  54. #while(<>) {
  55. #   chomp;
  56. #   my $line = $_;
  57. #   $ind++;
  58. #   if ($ind % 4 == 2) {
  59. #       $curr_base += length($line);
  60. #       $t2 = $line;
  61. #   } elsif ($ind % 4 == 1) {
  62. #       $t1 = $line;
  63. #   } elsif ($ind % 4 == 3) {
  64. #       $t3 = $line;
  65. #   } else {
  66. #       if ($curr_base < $limit) {
  67. #           print "$t1\n$t2\n$t3\n$line\n";
  68. #       } else {
  69. #           last;
  70. #       }
  71. #   }
  72. #}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement