diff libs/sratoolkit.2.8.0-centos_linux64/example/perl/splitfastq.pl @ 3:38ad1130d077 draft

planemo upload commit a4fb57231f274270afbfebd47f67df05babffa4a-dirty
author charles_s_test
date Mon, 27 Nov 2017 11:21:07 -0500
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libs/sratoolkit.2.8.0-centos_linux64/example/perl/splitfastq.pl	Mon Nov 27 11:21:07 2017 -0500
@@ -0,0 +1,46 @@
+#!/usr/bin/perl -w
+
+use IO::File;
+
+my $line;
+my $state = 0;
+my %filehandles;
+my $current_filehandle;
+my $base =  $ARGV[ 0 ];
+
+if ( !defined ( $base ) )
+{
+    $base = "out";
+}
+
+while ( defined ( $line = <STDIN> ) )
+{
+    #remove line-feeds, white space etc.
+    chomp( $line );
+
+    if ( $state == 0 )
+    {
+        # get the first word
+        my $word0 = ( split( /\s+/, $line ) )[ 0 ];
+
+        # start with the beginning of the word, until '/' found, continue with numbers to end of string
+        if ( $word0 =~ /^[^\/]+\/(\d+)$/ )
+        {
+            # grep what matched after the '/'
+            my $selector = $1;
+            if ( !defined ( $filehandles{$selector}) )
+            {
+                $filehandles{$selector} = new IO::File( "$base.$selector.fastq", "w" );
+            }
+            $current_filehandle = $filehandles{$selector};
+        }
+    }
+
+    if ( defined( $current_filehandle ) )
+    {
+        $current_filehandle -> print( "$line\n" );
+    }
+
+    $state ++;
+    $state &= 0x3;
+}
\ No newline at end of file