From: Michael R. Crusoe <crusoe@debian.org>
Subject: 'which' is deprecated, use the portable 'command -v' instead
Forwarded: https://github.com/trinityrnaseq/trinityrnaseq/pull/1089
--- trinityrnaseq.orig/Analysis/FL_reconstruction_analysis/FL_trans_analysis_pipeline.pl
+++ trinityrnaseq/Analysis/FL_reconstruction_analysis/FL_trans_analysis_pipeline.pl
@@ -92,7 +92,7 @@
 my $found_all_tools = 1;
 my @required_tools = qw (blat slclust);
 foreach my $tool (@required_tools) {
-    my $path = `which $tool`;
+    my $path = `sh -c "command -v $tool"`;
     unless ($path =~ /\w/) {
         print STDERR "Error, cannot locate required tool: $tool\n";
         $found_all_tools = 0;
--- trinityrnaseq.orig/Analysis/FL_reconstruction_analysis/util/blat_full_length_mappings.pl
+++ trinityrnaseq/Analysis/FL_reconstruction_analysis/util/blat_full_length_mappings.pl
@@ -103,7 +103,7 @@
     
 	my $blat_output = "$out_prefix.pslx";
 	
-    my  $blat_prog = `which blat`;
+    my  $blat_prog = `sh -c "command -v blat"`;
     chomp $blat_prog;
     unless ($blat_prog) {
         die "Error, cannot find a blat program in your path.\n";
--- trinityrnaseq.orig/PerlLib/CDNA/PASA_alignment_assembler.pm
+++ trinityrnaseq/PerlLib/CDNA/PASA_alignment_assembler.pm
@@ -60,7 +60,7 @@
     $self->{assemblies} = []; #contains list of all singletons and assemblies.
     $self->{fuzzlength} = $FUZZLENGTH;  #default setting.
     
-    my $pasa_bin = `which pasa`;
+    my $pasa_bin = `sh -c "command -v pasa"`;
     $pasa_bin =~ s/\s//g;
     
     unless (-x $pasa_bin) {
--- trinityrnaseq.orig/PerlLib/COMMON.pm
+++ trinityrnaseq/PerlLib/COMMON.pm
@@ -13,7 +13,7 @@
     # check it like so:
     #  perl -MCOMMON -e 'print COMMON::get_sort_exec(4);'
 
-    my $sort_exec = `which sort`;
+    my $sort_exec = `sh -c "command -v sort"`;
     unless ($sort_exec =~ /\w/) {
         confess "Error, cannot find sort utility";
     }
--- trinityrnaseq.orig/Trinity
+++ trinityrnaseq/Trinity
@@ -957,7 +957,7 @@
 ## make sure properly installed
 {
     foreach my $trinity_tool ("ParaFly", "seqtk-trinity") {
-        my $loc = `which $trinity_tool`;
+        my $loc = `sh -c "command -v $trinity_tool"`;
         unless ($loc =~ /\w/) {
             die "\n\n\tError, cannot locate Trinity-specific tool: $trinity_tool in the PATH setting: $ENV{PATH},  be sure to install Trinity by running 'make' in the base installation directory\n\n";
         }
@@ -2937,7 +2937,7 @@
         print "Running Java Tests\n";
     }
     
-    my $java_prog = `which java`;
+    my $java_prog = `sh -c "command -v java"`;
     unless ($java_prog) {
         die "Error, cannot find 'java'.  Please be sure it is available within your \${PATH} setting and then try again.";
     }
@@ -3988,7 +3988,7 @@
 
 
     # samtools
-    my $samtools_path = `which samtools`;
+    my $samtools_path = `sh -c "command -v samtools"`;
     if ($samtools_path =~ /\w/) {
         print "Found samtools at: $samtools_path\n" if $VERBOSE;
     
@@ -4005,7 +4005,7 @@
     }
 
     # jellyfish
-    my $jellyfish_path = `which jellyfish`;
+    my $jellyfish_path = `sh -c "command -v jellyfish"`;
     if ($jellyfish_path =~ /\w/) {
         print "Found jellyfish at: $jellyfish_path\n" if $VERBOSE;
 
@@ -4023,8 +4023,8 @@
     ## bowtie2
     if (!$NO_BOWTIE) {
         ## be sure we can find 'bowtie', since we use it as part of the iworm pair scaffolding step
-        $bowtie2_path = `which bowtie2`;
-        $bowtie2_build_path = `which bowtie2-build`;
+        $bowtie2_path = `sh -c "command -v bowtie2"`;
+        $bowtie2_build_path = `sh -c "command -v bowtie2-build"`;
         if ($bowtie2_path =~ /\w/ && $bowtie2_build_path =~ /\w/) {
             chomp $bowtie2_path;
             chomp $bowtie2_build_path;
@@ -4037,7 +4037,7 @@
 
     # salmon
     if (! $NO_SALMON) {
-        my $salmon_path = `which salmon`;
+        my $salmon_path = `sh -c "command -v salmon"`;
         if ($salmon_path =~ /\w/) {
             print "Found salmon installed at $salmon_path\n" if $VERBOSE;
 
--- trinityrnaseq.orig/util/align_and_estimate_abundance.pl
+++ trinityrnaseq/util/align_and_estimate_abundance.pl
@@ -401,7 +401,7 @@
     
         
     foreach my $tool (@tools) {
-        my $p = `which $tool`;
+        my $p = `sh -c "command -v $tool"`;
         unless ($p =~ /\w/) {
             warn("ERROR, cannot find $tool in PATH setting: $ENV{PATH}\n\n");
             $missing = 1;
--- trinityrnaseq.orig/util/misc/SRA_to_fastq.pl
+++ trinityrnaseq/util/misc/SRA_to_fastq.pl
@@ -24,7 +24,7 @@
     die $usage;
 }
 
-my $fastq_dump_path = `which fastq-dump`;
+my $fastq_dump_path = `sh -c "command -v fastq-dump"`;
 unless ($fastq_dump_path && $fastq_dump_path =~ /\w/) {
     die "Error, cannot find 'fastq-dump' utility in your PATH. Be sure you have SRA toolkit installed and fastq-dump in your PATH setting. ";
 }
--- trinityrnaseq.orig/util/misc/blat_util/blat_to_sam.pl
+++ trinityrnaseq/util/misc/blat_util/blat_to_sam.pl
@@ -61,7 +61,7 @@
 	my @required_progs = qw (blat psl2sam.pl);
 
 	foreach my $prog (@required_progs) {
-		my $path = `which $prog`;
+		my $path = `sh -c "command -v $prog"`;
 		unless ($path =~ /^\//) {
 			die "Error, cannot locate required program: $prog";
 		}
--- trinityrnaseq.orig/util/misc/run_HISAT.pl
+++ trinityrnaseq/util/misc/run_HISAT.pl
@@ -20,7 +20,7 @@
         $HISAT_HOME = $ENV{HISAT_HOME};
     }
     else {
-        my $hisat_prog = `which hisat`;
+        my $hisat_prog = `sh -c "command -v hisat"`;
         if ($hisat_prog) {
             chomp $hisat_prog;
             $HISAT_HOME = dirname($hisat_prog);
--- trinityrnaseq.orig/util/misc/run_STAR.pl
+++ trinityrnaseq/util/misc/run_STAR.pl
@@ -81,7 +81,7 @@
 }
 
 
-my $star_prog = `which $star_path`;
+my $star_prog = `sh -c "command -v $star_path"`;
 chomp $star_prog;
 unless ($star_prog =~ /\w/) {
     die "Error, cannot locate STAR program. Be sure it's in your PATH setting.  ";
--- trinityrnaseq.orig/util/misc/run_STAR_via_samples_file.pl
+++ trinityrnaseq/util/misc/run_STAR_via_samples_file.pl
@@ -72,7 +72,7 @@
 }
 
 
-my $star_prog = `which STAR`;
+my $star_prog = `sh -c "command -v STAR"`;
 chomp $star_prog;
 unless ($star_prog =~ /\w/) {
     die "Error, cannot locate STAR program. Be sure it's in your PATH setting.  ";
--- trinityrnaseq.orig/util/retrieve_sequences_from_fasta.pl
+++ trinityrnaseq/util/retrieve_sequences_from_fasta.pl
@@ -11,7 +11,7 @@
 
 main: {
 
-    my $samtools = `which samtools`;
+    my $samtools = `sh -c "command -v samtools"`;
     unless ($samtools =~ /\w/) {
         die "Error, need samtools in your PATH setting.";
     }
--- trinityrnaseq.orig/util/support_scripts/bowtie2_wrapper.pl
+++ trinityrnaseq/util/support_scripts/bowtie2_wrapper.pl
@@ -163,7 +163,7 @@
     my @required_progs = qw(samtools bowtie2-build bowtie2);
     
     foreach my $prog (@required_progs) {
-        my $path = `which $prog`;
+        my $path = `sh -c "command -v $prog"`;
         unless ($path =~ /^\//) {
             die "Error, path to required $prog cannot be found";
         }
