# HG changeset patch # User jampradinuk # Date 1336684757 14400 # Node ID f87183778470722efc898dfb5b015fcdd316f565 # Parent a8eccdcc080009338fce8e4c7d4ac797660ce257 Uploaded diff -r a8eccdcc0800 -r f87183778470 fastq_paired_reads_convention.pl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/fastq_paired_reads_convention.pl Thu May 10 17:19:17 2012 -0400 @@ -0,0 +1,50 @@ +#! /usr/bin/perl -w + +use strict; +use warnings; + +# fastq_paired_reads_convention2.pl [input file] [left output file] [right output file] + +die "Check arguments" unless @ARGV == 3; + +#open (LEFT, '>data/left2.fastq') or die "Cannot create $ARGV[1]: $!\n"; +#open (RIGHT, '>data/right2.fastq') or die "Cannot create $ARGV[2]: $!\n"; +#open (INPUT, '', $ARGV[1]) or die "Cannot create $ARGV[1]: $!\n"; +open (RIGHT, '>', $ARGV[2]) or die "Cannot create $ARGV[2]: $!\n"; +open (INPUT, '<', $ARGV[0]) or die "Cannot open $ARGV[0]: $!\n"; + +my $which = 0; +my $current_id; + +while() { + chomp; + if(/ 1\S*/){ + $_ =~ s/ 1\S*//; + $_.='/1'; + $current_id = substr $_, 1; + $which = 1; + } + if(/ 2\S*/){ + $_ =~ s/ 2\S*//; + $_.='/2'; + $current_id = substr $_, 1; + $which = 2; + } + + if($_ eq '+'){ + $_.=$current_id; + } + + if($which == 1){ + print LEFT "$_\n"; + } + if($which == 2){ + print RIGHT "$_\n"; + } +} + +close (LEFT); +close (RIGHT); +close (INPUT); \ No newline at end of file