Mercurial > repos > jampradinuk > repo_testing
comparison fastq_paired_reads_convention.pl @ 2:50905eb47f2d draft
Uploaded
author | jampradinuk |
---|---|
date | Thu, 10 May 2012 16:36:35 -0400 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
1:028cfb1b807b | 2:50905eb47f2d |
---|---|
1 #! /usr/bin/perl -w | |
2 | |
3 use strict; | |
4 use warnings; | |
5 | |
6 # fastq_paired_reads_convention2.pl [input file] [left output file] [right output file] | |
7 | |
8 die "Check arguments" unless @ARGV == 3; | |
9 | |
10 #open (LEFT, '>data/left2.fastq') or die "Cannot create $ARGV[1]: $!\n"; | |
11 #open (RIGHT, '>data/right2.fastq') or die "Cannot create $ARGV[2]: $!\n"; | |
12 #open (INPUT, '<data/interlaced.fastq') or die "Cannot open $ARGV[0]: $!\n"; | |
13 | |
14 open (LEFT, '>', $ARGV[1]) or die "Cannot create $ARGV[1]: $!\n"; | |
15 open (RIGHT, '>', $ARGV[2]) or die "Cannot create $ARGV[2]: $!\n"; | |
16 open (INPUT, '<', $ARGV[0]) or die "Cannot open $ARGV[0]: $!\n"; | |
17 | |
18 my $which = 0; | |
19 my $current_id; | |
20 | |
21 while(<INPUT>) { | |
22 chomp; | |
23 if(/ 1\S*/){ | |
24 $_ =~ s/ 1\S*//; | |
25 $_.='/1'; | |
26 $current_id = substr $_, 1; | |
27 $which = 1; | |
28 } | |
29 if(/ 2\S*/){ | |
30 $_ =~ s/ 2\S*//; | |
31 $_.='/2'; | |
32 $current_id = substr $_, 1; | |
33 $which = 2; | |
34 } | |
35 | |
36 if($_ eq '+'){ | |
37 $_.=$current_id; | |
38 } | |
39 | |
40 if($which == 1){ | |
41 print LEFT "$_\n"; | |
42 } | |
43 if($which == 2){ | |
44 print RIGHT "$_\n"; | |
45 } | |
46 } | |
47 | |
48 close (LEFT); | |
49 close (RIGHT); | |
50 close (INPUT); |