Skip to content

Commit 7362ead

Browse files
committed
fix error with warnings in mappingstat, and when cleaning more than one pair per sample
1 parent 370d662 commit 7362ead

File tree

4 files changed

+36
-22
lines changed

4 files changed

+36
-22
lines changed

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.6.4, July 2024
1+
1.6.5, August 2024

conda/master/meta.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
package:
22
name: squeezemeta
3-
version: "1.6.4"
3+
version: "1.6.5"
44

55
source:
66
git_url: https://github.com/jtamames/squeezemeta.git
7-
git_tag: 1.6.4
7+
git_tag: 1.6.5
88

99
requirements:
1010
build:

scripts/10.mapsamples.pl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@
286286

287287
}
288288
if($warnmes) {
289-
print outfile1 "\n# Notice that mapping percentage is low (<50%) for some samples. This is a potential problem, meaning that most reads are not represented in the assembly\n";
289+
print outfile1 "#\n# Notice that mapping percentage is low (<50%) for some samples. This is a potential problem, meaning that most reads are not represented in the assembly\n";
290290
if($mincontiglen>200) {
291291
print outfile1 "# Notice also that you set the minimum contig length to $mincontiglen. In this way you are removing the contigs shorter than that size. This can be, at least partially, the cause of this low mapping percentage\n";
292292
print outfile1 "# It is likely that redoing the analysis with the default minimum contig length (200) will improve the results\n";

scripts/SqueezeMeta.pl

Lines changed: 32 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@
270270
}
271271

272272
my $currtime=timediff();
273-
print BOLD "\nSqueezeMeta v$version - (c) J. Tamames, F. Puente-Sánchez CNB-CSIC, Madrid, SPAIN\n\nPlease 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 "\nSqueezeMeta v$version - (c) J. Tamames, F. Puente-Sánchez CNB-CSIC, Madrid, SPAIN\n\nPlease cite: Tamames & Puente-Sánchez, Frontiers in Microbiology 9, 3349 (2019). doi: https://doi.org/10.3389/fmicb.2018.03349\n\n"; print RESET;
274274
if($test) { print GREEN "Running in test mode! I will stop after step $test\n\n"; print RESET; }
275275
print "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

Comments
 (0)