diff rapsodyn/PrepareFastqLight.pl @ 10:0a6c1cfe4dc8 draft

Uploaded
author mcharles
date Mon, 19 Jan 2015 04:33:21 -0500
parents d857538d9fea
children 56d328bce3a7
line wrap: on
line diff
--- a/rapsodyn/PrepareFastqLight.pl	Mon Oct 20 05:58:31 2014 -0400
+++ b/rapsodyn/PrepareFastqLight.pl	Mon Jan 19 04:33:21 2015 -0500
@@ -1,4 +1,6 @@
 #!/usr/bin/perl
+#v1.1.0 manage empty files
+#v1.0.4 bug correction, last read not considered
 #v1.0.3 support rapsodyn header (.... 1:...  / .... 2:...)
 #V1.0.2 added auto type detection
 #V1.0.1 added log, option parameters
@@ -49,6 +51,14 @@
 open(OUT2, ">$output2_file") or die ("Can't open $output2_file\n");
 open (LF,">$log_file") or die("Can't open $log_file\n");
 
+if (( -z READ1)&&( -z READ2)){
+	exit(0);
+}
+elsif (( -z READ1)||( -z READ2)){
+	print STDERR "One empty File\n";
+	exit(0);
+}
+
 
 my $error1=0;
 my $error2=0;
@@ -113,7 +123,7 @@
 
 
 
-
+my $compt=0;
 while (my $ligne1_r1 =<READ1>){
 	my $ligne2_r1 =<READ1>;
 	my $ligne3_r1 =<READ1>;
@@ -122,7 +132,13 @@
 	my $ligne2_r2 =<READ2>;
 	my $ligne3_r2 =<READ2>;
 	my $ligne4_r2 =<READ2>;
-
+	# chomp($ligne1_r1);
+	# chomp($ligne2_r1);
+	# chomp($ligne3_r1);
+	# chomp($ligne4_r1);
+	# chomp($ligne2_r1);
+	
+	$compt++;
 	$nb_read1++;
 	$nb_read2++;
 	
@@ -160,13 +176,13 @@
 #@ 1 - 2 sec
 	else {
 		
-		my $length_seq1 = length($ligne2_r1);
-		my $length_qual1 =length($ligne4_r1);
+		my $length_seq1 = length(chomp($ligne2_r1));
+		my $length_qual1 =length(chomp($ligne4_r1));
 		my $seq1;
 		my $qual1;
 	
-		my $length_seq2 = length($ligne2_r2);
-		my $length_qual2 =length($ligne4_r2);
+		my $length_seq2 = length(chomp($ligne2_r2));
+		my $length_qual2 =length(chomp($ligne4_r2));
 		my $seq2;
 		my $qual2;
 		my $header1="";
@@ -210,7 +226,7 @@
 		}
 		elsif (($TYPE eq "sanger")&&((!$header1)||(!$header2))){
 			if ($VERBOSE eq "ON"){
-				print "Error in header refgsd : empty\n";
+				print "Error in header ref : empty\n";
 				print $ligne1_r1;
 				print $ligne2_r1;
 				print $ligne3_r1;
@@ -256,10 +272,12 @@
 		elsif (($length_seq1 != $length_qual1)||($length_seq2 != $length_qual2)){
 			if ($VERBOSE eq "ON"){
 				print "Error in seq/qual length\n";
+				print "$length_seq1 / $length_qual1 \t $length_seq2 / $length_qual2\n";
 				print $ligne1_r1;
 				print $ligne2_r1;
 				print $ligne3_r1;
 				print $ligne4_r1;
+				print "\n";
 				print $ligne1_r2;
 				print $ligne2_r2;
 				print $ligne3_r2;
@@ -270,6 +288,7 @@
 		}
 #@ 1 - 2 sec	
 		else {
+			#print "TEST : $compt\n";
 			### Parsing sequence & qualité
 			if ($ligne2_r1 =~ /^([ATGCNX]+)\s*$/i){
 				$seq1 = $1;