270270 }
271271
272272my $currtime =timediff();
273- print BOLD " \n SqueezeMeta v$version - (c) J. Tamames, F. Puente-Sánchez CNB-CSIC, Madrid, SPAIN\n\n Please cite: Tamames & Puente-Sanchez , Frontiers in Microbiology 9, 3349 (2019). doi: https://doi.org/10.3389/fmicb.2018.03349\n\n " ; print RESET;
273+ print BOLD " \n SqueezeMeta v$version - (c) J. Tamames, F. Puente-Sánchez CNB-CSIC, Madrid, SPAIN\n\n Please cite: Tamames & Puente-Sánchez , Frontiers in Microbiology 9, 3349 (2019). doi: https://doi.org/10.3389/fmicb.2018.03349\n\n " ; print RESET;
274274if ($test ) { print GREEN " Running in test mode! I will stop after step $test \n\n " ; print RESET; }
275275print " Run started " ,scalar localtime ," in $mode mode\n " ;
276276
@@ -627,7 +627,7 @@ sub pipeline {
627627 my $wsize = checksize($mappingstat );
628628 my $ns ;
629629 if ($mode eq " sequential" ) { $ns = 1; } else { $ns = $numsamples ; }
630- if (($wsize == $ns ) && (!$force_overwrite )) { print " Mapping file $mapcountfile already found, skipping step 10\n " ; }
630+ if (($wsize == $ns ) && (!$force_overwrite )) { print " Mapping file $mappingstat already found, skipping step 10\n " ; }
631631 else {
632632 my $scriptname =" 10.mapsamples.pl" ;
633633 print outfile3 " 10\t $scriptname \n " ;
@@ -638,7 +638,7 @@ sub pipeline {
638638 my $ecode = system (" perl $scriptdir /$scriptname $projectdir $force_overwrite " );
639639 if ($ecode !=0) { error_out(10,$scriptname ); }
640640 my $wsize = checksize($mappingstat );
641- if ($wsize !=$ns ) { error_out(10,$scriptname ,$mapcountfile ); }
641+ if ($wsize !=$ns ) { error_out(10,$scriptname ,$mappingstat ); }
642642 close (outfile4); open (outfile4," >>$syslogfile " );
643643 }
644644 }
@@ -1071,7 +1071,7 @@ sub writeconf { #-- Create directories and files, write the SqueeeMeta_conf fi
10711071 system (" mkdir $datapath " );
10721072 system (" mkdir $resultpath " );
10731073 system (" mkdir $tempdir " );
1074- system (" mkdir $datapath /raw_fastq" );
1074+ system (" mkdir $datapath /raw_fastq" );
10751075 system (" mkdir $extpath " );
10761076 system (" mkdir $interdir " );
10771077 system (" mkdir $interdir /binners" );
@@ -1156,25 +1156,39 @@ sub cleaning {
11561156 next if (!$_ || ($_ =~/ ^\# / ));
11571157 $_ =~s /\r // g ; # -- Deleting \r in samples file for windows compatibility
11581158 my ($sample ,$file ,$iden ,$mapreq )=split (/ \t / ,$_ );
1159- if ($thissample ) {
1160- if ($sample eq $thissample ) { $prepsamples {$sample }{$iden }=$file ; }
1161- }
1162- else { $prepsamples {$sample }{$iden }=$file ; }
1159+ if ($thissample and ($sample ne $thissample )) { next ; } # -- If we wanted only one sample, skip the rest
1160+ # -- Store all the input files coming from the same sample and "pair" (pair1 and pair2) into an array
1161+ # -- This will fail if the input files from the same sample have a different ordering for pair1 and pair2
1162+ # -- in the samples file, but this is very unlikely
1163+ if (!exists ($prepsamples {$sample }{$iden })) { $prepsamples {$sample }{$iden } = [$file ];}
1164+ else { push @{ $prepsamples {$sample }{$iden }} , $file ; }
11631165 }
11641166 close infile4;
11651167 foreach my $ts (sort keys %prepsamples ) {
11661168 print " Working with sample $ts \n " ;
1167- my $par1name =" $rawfastq /" .$prepsamples {$ts }{pair1 };
1168- my $par2name =" $rawfastq /" .$prepsamples {$ts }{pair2 };
1169- my $trimmedpar1name =" $newuserdir /" .$prepsamples {$ts }{pair1 };
1170- my $trimmedpar2name =" $newuserdir /" .$prepsamples {$ts }{pair2 };
1171- if (-e $par2name ) { $trimmomatic_command =" $trimmomatic_soft PE -threads $numthreads -phred33 $par1name $par2name $trimmedpar1name $trimmedpar1name .removed $trimmedpar2name $trimmedpar2name .removed $cleaningoptions > /dev/null 2>&1" ; }
1172- else { $trimmomatic_command =" $trimmomatic_soft SE -threads $numthreads -phred33 $par1name $trimmedpar1name $cleaningoptions > /dev/null 2>&1" ; }
1173- print outfile4 " Running trimmomatic: $trimmomatic_command " ;
1174- my $ecode = system $trimmomatic_command ;
1175- if ($ecode !=0) { die " Error running command: $trimmomatic_command " ; }
1176- print outmet " Quality filtering was done using Trimmomatic (Bolger et al 2014, Bioinformatics 30(15):2114-20)\n " ;
1169+ if (exists ($prepsamples {$ts }{pair2 }) and (scalar (@{ $prepsamples {$ts }{pair1 } }) != scalar (@{ $prepsamples {$ts }{pair2 } }))) {
1170+ die (" Different number of pair1 and pair2 files for sample $ts \n " );
1171+ }
1172+ my @pair1files = @{ $prepsamples {$ts }{pair1 } };
1173+ my ($par1name , $par2name , $trimmedpar1name , $trimmedpar2name );
1174+ for my $i (0 .. $#pair1files ) {
1175+ # -- Go through all the input files for this sample
1176+ $par1name = " $rawfastq /" .$prepsamples {$ts }{pair1 }[$i ];
1177+ $trimmedpar1name = " $newuserdir /" .$prepsamples {$ts }{pair1 }[$i ];
1178+ $par2name = " " ;
1179+ $trimmedpar2name = " " ;
1180+ if (exists ($prepsamples {$ts }{pair2 })) {
1181+ $par2name = " $rawfastq /" .$prepsamples {$ts }{pair2 }[$i ];
1182+ $trimmedpar2name = " $newuserdir /" .$prepsamples {$ts }{pair2 }[$i ];
1183+ }
1184+ if (-e $par2name ) { $trimmomatic_command =" $trimmomatic_soft PE -threads $numthreads -phred33 $par1name $par2name $trimmedpar1name $trimmedpar1name .removed $trimmedpar2name $trimmedpar2name .removed $cleaningoptions > /dev/null 2>&1" ; }
1185+ else { $trimmomatic_command =" $trimmomatic_soft SE -threads $numthreads -phred33 $par1name $trimmedpar1name $cleaningoptions > /dev/null 2>&1" ; }
1186+ print outfile4 " Running trimmomatic: $trimmomatic_command " ;
1187+ my $ecode = system $trimmomatic_command ;
1188+ if ($ecode !=0) { die " Error running command: $trimmomatic_command " ; }
1189+ }
11771190 }
1191+ print outmet " Quality filtering was done using Trimmomatic (Bolger et al 2014, Bioinformatics 30(15):2114-20)\n " ;
11781192 }
11791193 }
11801194
0 commit comments