SionBayliss / PIRATE

A toolbox for pangenome analysis and threshold evaluation.
GNU General Public License v3.0
89 stars 29 forks source link

Use FindBin to locate true location of script #23

Closed tseemann closed 4 years ago

tseemann commented 4 years ago

FindBin is the standard way to find where you are and resolve all symlinks. It's core module. I think there can be issues with dirname($0) with symlinks.

use FindBin;
use Cwd 'abs_path';
my $script_path = abs_path($FindBin::RealBin);  # from a script in scripts/

my $script_path = abs_path("$FindBin::RealBin/../scripts");  # from PIRATE

use File::Basename;
my $exe_name = basename("$FindBin::RealScript");  # 
grep dirname -r . | grep script_path

./bin/PIRATE:my $script_path = abs_path(dirname($0));
./scripts/classify_paralogs.pl:my $script_path = abs_path(dirname($0));
./scripts/split_paralogs_runner.pl:my $script_path = abs_path(dirname($0));
./scripts/run_PIRATE.pl:my $script_path = abs_path(dirname($0));
./scripts/align_feature_sequences.pl:my $script_path = abs_path(dirname($0));
./scripts/create_pangenome_alignment.pl:my $script_path = abs_path(dirname($0));
./scripts/link_clusters_runner.pl:my $script_path = abs_path(dirname($0));
./scripts/pangenome_construction.pl:my $script_path = abs_path(dirname($0));
./tools/treeWAS/pangenome_variants_to_treeWAS.pl:my $script_path = abs_path(dirname($0));
./tools/subsetting/select_representative:#my $script_path = abs_path(dirname($0));
SionBayliss commented 4 years ago

Thanks for that. I will try to pivot to using more core modules. This has been resolved throughout with latest commit (1.0.2)