NBISweden / GAAS

Genome Assembly and Annotation Service code
GNU General Public License v3.0
202 stars 46 forks source link

Increase the usage of combined assignment operators #76

Open elfring opened 3 years ago

elfring commented 3 years ago

:eyes: Some source code analysis tools can help to find opportunities for improving software components. :thought_balloon: I propose to increase the usage of combined operators accordingly.

diff --git a/annotation/tools/abinitio/augustus/gaas_junctions2hints.pl b/annotation/tools/abinitio/augustus/gaas_junctions2hints.pl
index a74a6ef..d3ee10f 100755
--- a/annotation/tools/abinitio/augustus/gaas_junctions2hints.pl
+++ b/annotation/tools/abinitio/augustus/gaas_junctions2hints.pl
@@ -47,8 +47,8 @@ while (<INFILE>) {
   unless ($_ =~ /^track/){
     my @bed_line=split(/\t/, $_);
     my ($startblock,$endblock)=split(/\,/, $bed_line[10]);
-    $bed_line[1]=$bed_line[1]+$startblock+1;
-    $bed_line[2]=$bed_line[2]-$endblock;
+    $bed_line[1] += $startblock + 1;
+    $bed_line[2] -= $endblock;
     my $key = join (':',$bed_line[0],$bed_line[1],$bed_line[2]);
     $junctions{$key} +=$bed_line[4];
   }
diff --git a/annotation/tools/comparative_genomic/gaas_orthomcl_analyzeOG.pl b/annotation/tools/comparative_genomic/gaas_orthomcl_analyzeOG.pl
index d16dacc..d01aa93 100755
--- a/annotation/tools/comparative_genomic/gaas_orthomcl_analyzeOG.pl
+++ b/annotation/tools/comparative_genomic/gaas_orthomcl_analyzeOG.pl
@@ -409,7 +409,7 @@ foreach my $keyID (keys %LossIdByAppearance){
             print $message; if ( $opt_output ){ print $outReport $message; }

             if(exists ($lossMergedByTaxid{$keyID2})){
-                $lossMergedByTaxid{$keyID2}=$lossMergedByTaxid{$keyID2}+$value;
+                $lossMergedByTaxid{$keyID2} += $value;
             }
             else{
                 $lossMergedByTaxid{$keyID2}=$value;
diff --git a/annotation/tools/comparative_genomic/gaas_prepare_matrice_by_window.pl b/annotation/tools/comparative_genomic/gaas_prepare_matrice_by_window.pl
index e4c6fa3..53c7823 100755
--- a/annotation/tools/comparative_genomic/gaas_prepare_matrice_by_window.pl
+++ b/annotation/tools/comparative_genomic/gaas_prepare_matrice_by_window.pl
@@ -263,7 +263,7 @@ foreach my $chr (keys %hash_chr2name){
     if( (1000000*$currentLimit) > $highvalue){$stop++};

     my $nbPrintedVal=0;
-    $currentLimit = $currentLimit + $opt_windowsSize;
+    $currentLimit += $opt_windowsSize;
     $currentCenter=$currentLimit-($opt_windowsSize/2);
     $currentCenter=sprintf "%.1f",$currentCenter;
     $path=$dir."/".$currentCenter."Mb.aln";
diff --git a/annotation/tools/fasta/gaas_fasta_domain_extractor.pl b/annotation/tools/fasta/gaas_fasta_domain_extractor.pl
index abb042c..200df2f 100755
--- a/annotation/tools/fasta/gaas_fasta_domain_extractor.pl
+++ b/annotation/tools/fasta/gaas_fasta_domain_extractor.pl
@@ -114,7 +114,7 @@ if(length($seq) < $end){print "End position for extraction is over the sequence
 #start is 1-based coordinate system
 # The extraction compute in 0-based coordinate system
 # Lets change the 1-based coordinate system in 0-based coordinate system for the start
-$start=$start-1;
+$start -= 1;
 my $lengtExtraction=$end-$start; #Length in 0-based coordinate (in 1-based coordinate we must add +1)
 print "Length sequence extracted: $lengtExtraction\n";
 my $extractedPart=substr($seq, $start, $lengtExtraction);
diff --git a/annotation/tools/fasta/gaas_fasta_extract_sequence_from_id.pl b/annotation/tools/fasta/gaas_fasta_extract_sequence_from_id.pl
index d962388..3408f05 100755
--- a/annotation/tools/fasta/gaas_fasta_extract_sequence_from_id.pl
+++ b/annotation/tools/fasta/gaas_fasta_extract_sequence_from_id.pl
@@ -81,7 +81,7 @@ if (-f $opt_name){
   if (! defined $col){
     $col=0;
   }
-  else{$col=$col -1 ;}
+  else{$col -= 1 ;}

   #Manage line to avoid
   if (! defined $lineToAvoid){
diff --git a/annotation/tools/fasta/gaas_fasta_splitter.pl b/annotation/tools/fasta/gaas_fasta_splitter.pl
index 44290ed..8767440 100755
--- a/annotation/tools/fasta/gaas_fasta_splitter.pl
+++ b/annotation/tools/fasta/gaas_fasta_splitter.pl
@@ -342,7 +342,7 @@ sub split_fasta{

                                if ($next_size < ceil($split_size/2) ){

-                                   $size = $size+$next_size;
+                                   $size += $next_size;
                                    $continue = undef;
                                    print "attach: attach because next_size $next_size < $split_size / 2(ceil) \n";

diff --git a/annotation/tools/fastq/gaas_fastq_check_sync_pair1_pair2.pl b/annotation/tools/fastq/gaas_fastq_check_sync_pair1_pair2.pl
index 42fbfc1..098d37e 100755
--- a/annotation/tools/fastq/gaas_fastq_check_sync_pair1_pair2.pl
+++ b/annotation/tools/fastq/gaas_fastq_check_sync_pair1_pair2.pl
@@ -114,7 +114,7 @@ while (!eof($in1) and !eof($in2)) {
 }

 my $percent = ($read_fail / $read_cpt) * 100 ;
-$percent = $percent * 100; # make it percent
+$percent *= 100; # make it percent
 $percent = sprintf("%.2f", $percent);

 my $end_run = time();
@@ -141,7 +141,7 @@ sub concat_list_from_left{

   my $result="";
   foreach my $element (@{$list}){
-    $result = $result.$element;
+    $result .= $element;
   }

   return $result;
diff --git a/annotation/tools/fastq/gaas_fastq_deinterleave_bash.pl b/annotation/tools/fastq/gaas_fastq_deinterleave_bash.pl
index 9176713..1771ae0 100755
--- a/annotation/tools/fastq/gaas_fastq_deinterleave_bash.pl
+++ b/annotation/tools/fastq/gaas_fastq_deinterleave_bash.pl
@@ -112,7 +112,7 @@ sub concat_list_from_left{

   my $result="";
   foreach my $element (@{$list}){
-    $result = $result.$element;
+    $result .= $element;
   }

   return $result;
diff --git a/annotation/tools/ncbi/gaas_ncbi_get_sequence_from_list.pl b/annotation/tools/ncbi/gaas_ncbi_get_sequence_from_list.pl
index 524846d..3c620a4 100755
--- a/annotation/tools/ncbi/gaas_ncbi_get_sequence_from_list.pl
+++ b/annotation/tools/ncbi/gaas_ncbi_get_sequence_from_list.pl
@@ -82,7 +82,7 @@ else{
 if (! defined $col){
    $col=0;
 }
-else{$col=$col -1 ;}
+else{$col -= 1 ;}

 #Manage line to avoid
 if (! defined $lineToAvoid){
diff --git a/bin/gaas_fasta_domain_extractor.pl b/bin/gaas_fasta_domain_extractor.pl
index abb042c..200df2f 100755
--- a/bin/gaas_fasta_domain_extractor.pl
+++ b/bin/gaas_fasta_domain_extractor.pl
@@ -114,7 +114,7 @@ if(length($seq) < $end){print "End position for extraction is over the sequence
 #start is 1-based coordinate system
 # The extraction compute in 0-based coordinate system
 # Lets change the 1-based coordinate system in 0-based coordinate system for the start
-$start=$start-1;
+$start -= 1;
 my $lengtExtraction=$end-$start; #Length in 0-based coordinate (in 1-based coordinate we must add +1)
 print "Length sequence extracted: $lengtExtraction\n";
 my $extractedPart=substr($seq, $start, $lengtExtraction);
diff --git a/bin/gaas_fasta_extract_sequence_from_id.pl b/bin/gaas_fasta_extract_sequence_from_id.pl
index d962388..3408f05 100755
--- a/bin/gaas_fasta_extract_sequence_from_id.pl
+++ b/bin/gaas_fasta_extract_sequence_from_id.pl
@@ -81,7 +81,7 @@ if (-f $opt_name){
   if (! defined $col){
     $col=0;
   }
-  else{$col=$col -1 ;}
+  else{$col -= 1 ;}

   #Manage line to avoid
   if (! defined $lineToAvoid){
diff --git a/bin/gaas_fasta_splitter.pl b/bin/gaas_fasta_splitter.pl
index 44290ed..8767440 100755
--- a/bin/gaas_fasta_splitter.pl
+++ b/bin/gaas_fasta_splitter.pl
@@ -342,7 +342,7 @@ sub split_fasta{

                                if ($next_size < ceil($split_size/2) ){

-                                   $size = $size+$next_size;
+                                   $size += $next_size;
                                    $continue = undef;
                                    print "attach: attach because next_size $next_size < $split_size / 2(ceil) \n";

diff --git a/bin/gaas_fastq_check_sync_pair1_pair2.pl b/bin/gaas_fastq_check_sync_pair1_pair2.pl
index 42fbfc1..098d37e 100755
--- a/bin/gaas_fastq_check_sync_pair1_pair2.pl
+++ b/bin/gaas_fastq_check_sync_pair1_pair2.pl
@@ -114,7 +114,7 @@ while (!eof($in1) and !eof($in2)) {
 }

 my $percent = ($read_fail / $read_cpt) * 100 ;
-$percent = $percent * 100; # make it percent
+$percent *= 100; # make it percent
 $percent = sprintf("%.2f", $percent);

 my $end_run = time();
@@ -141,7 +141,7 @@ sub concat_list_from_left{

   my $result="";
   foreach my $element (@{$list}){
-    $result = $result.$element;
+    $result .= $element;
   }

   return $result;
diff --git a/bin/gaas_fastq_deinterleave_bash.pl b/bin/gaas_fastq_deinterleave_bash.pl
index 9176713..1771ae0 100755
--- a/bin/gaas_fastq_deinterleave_bash.pl
+++ b/bin/gaas_fastq_deinterleave_bash.pl
@@ -112,7 +112,7 @@ sub concat_list_from_left{

   my $result="";
   foreach my $element (@{$list}){
-    $result = $result.$element;
+    $result .= $element;
   }

   return $result;
diff --git a/bin/gaas_junctions2hints.pl b/bin/gaas_junctions2hints.pl
index a74a6ef..d3ee10f 100755
--- a/bin/gaas_junctions2hints.pl
+++ b/bin/gaas_junctions2hints.pl
@@ -47,8 +47,8 @@ while (<INFILE>) {
   unless ($_ =~ /^track/){
     my @bed_line=split(/\t/, $_);
     my ($startblock,$endblock)=split(/\,/, $bed_line[10]);
-    $bed_line[1]=$bed_line[1]+$startblock+1;
-    $bed_line[2]=$bed_line[2]-$endblock;
+    $bed_line[1] += $startblock + 1;
+    $bed_line[2] -= $endblock;
     my $key = join (':',$bed_line[0],$bed_line[1],$bed_line[2]);
     $junctions{$key} +=$bed_line[4];
   }
diff --git a/bin/gaas_ncbi_get_sequence_from_list.pl b/bin/gaas_ncbi_get_sequence_from_list.pl
index 524846d..3c620a4 100755
--- a/bin/gaas_ncbi_get_sequence_from_list.pl
+++ b/bin/gaas_ncbi_get_sequence_from_list.pl
@@ -82,7 +82,7 @@ else{
 if (! defined $col){
    $col=0;
 }
-else{$col=$col -1 ;}
+else{$col -= 1 ;}

 #Manage line to avoid
 if (! defined $lineToAvoid){
diff --git a/bin/gaas_orthomcl_analyzeOG.pl b/bin/gaas_orthomcl_analyzeOG.pl
index d16dacc..d01aa93 100755
--- a/bin/gaas_orthomcl_analyzeOG.pl
+++ b/bin/gaas_orthomcl_analyzeOG.pl
@@ -409,7 +409,7 @@ foreach my $keyID (keys %LossIdByAppearance){
             print $message; if ( $opt_output ){ print $outReport $message; }

             if(exists ($lossMergedByTaxid{$keyID2})){
-                $lossMergedByTaxid{$keyID2}=$lossMergedByTaxid{$keyID2}+$value;
+                $lossMergedByTaxid{$keyID2} += $value;
             }
             else{
                 $lossMergedByTaxid{$keyID2}=$value;
diff --git a/bin/gaas_prepare_matrice_by_window.pl b/bin/gaas_prepare_matrice_by_window.pl
index e4c6fa3..53c7823 100755
--- a/bin/gaas_prepare_matrice_by_window.pl
+++ b/bin/gaas_prepare_matrice_by_window.pl
@@ -263,7 +263,7 @@ foreach my $chr (keys %hash_chr2name){
     if( (1000000*$currentLimit) > $highvalue){$stop++};

     my $nbPrintedVal=0;
-    $currentLimit = $currentLimit + $opt_windowsSize;
+    $currentLimit += $opt_windowsSize;
     $currentCenter=$currentLimit-($opt_windowsSize/2);
     $currentCenter=sprintf "%.1f",$currentCenter;
     $path=$dir."/".$currentCenter."Mb.aln";