From e3663f8bde11a20f677742b614e96cce26916696 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Carn=C3=AB=20Draug?= Date: Sun, 30 Sep 2018 17:41:46 +0100 Subject: [PATCH] Remove manipulation of @INC and use of lib - require install for use. Some scripts manipulated @INC so they could be ran without installation. Undo this, we expect users to have it installed. The authoring and installation step of BioPerl modifies the code and it may be required to work properly. Savy enough users can manually add the path when calling the script if they want. Do not catch failing to load a module to give a different error message. The standard perl message about missing module in @INC should be enough. --- bin/bp_fetch | 56 ++++++++------------------------ bin/bp_genbank2gff3 | 6 ---- bin/bp_index | 28 +++------------- examples/root/exceptions1.pl | 1 - examples/root/exceptions2.pl | 1 - examples/root/exceptions3.pl | 1 - examples/root/exceptions4.pl | 1 - examples/searchio/custom_writer.pl | 2 -- examples/searchio/hitwriter.pl | 1 - examples/searchio/hspwriter.pl | 1 - examples/searchio/htmlwriter.pl | 1 - examples/searchio/psiblast_features.pl | 1 - examples/searchio/psiblast_iterations.pl | 1 - examples/searchio/rawwriter.pl | 1 - examples/searchio/resultwriter.pl | 1 - examples/tools/seq_pattern.pl | 13 +------- lib/Bio/Search/Tiling/MapTiling.pm | 3 -- lib/BioPerl.pm | 4 +-- t/Root/Exception.t | 1 - t/SearchIO/Tiling.t | 2 -- t/SeqIO/embl.t | 1 - 21 files changed, 20 insertions(+), 107 deletions(-) diff --git a/bin/bp_fetch b/bin/bp_fetch index 86a5bbc9a..813e35d59 100644 --- a/bin/bp_fetch +++ b/bin/bp_fetch @@ -121,51 +121,21 @@ use strict; use warnings; use Getopt::Long; -# -# Dofus catcher for people who are trying this script without -# installing bioperl. In your own script, you can just go -# -# use Bio::Index::Fasta etc, rather than this -# +use Bio::Index::EMBL; +use Bio::Index::Fasta; +use Bio::Index::GenBank; +use Bio::Index::SwissPfam; +use Bio::Index::Swissprot; use Bio::SeqIO; -BEGIN { - eval { - require Bio::Index::Fasta; - require Bio::Index::EMBL; - require Bio::Index::GenBank; - require Bio::Index::Swissprot; - require Bio::Index::SwissPfam; - }; - if ( $@ ) { - # one up from here is Bio directory - we hope! - push(@INC,".."); - eval { - require Bio::Index::Fasta; - require Bio::Index::EMBL; - require Bio::Index::GenBank; - require Bio::Index::Swissprot; - require Bio::Index::SwissPfam; - }; - if ( $@ ) { - print STDERR ("\nbp_index cannot find Bio::Index::Fasta and Bio::Index::EMBL\nbp_index needs to have bioperl installed for it to run.\nBioperl is very easy to install\nSee http://bio.perl.org for more information\n\n"); - exit(1); - } else { - print STDERR ("\nYou are running bp_index.pl without installing bioperl.\nYou have done it from bioperl/scripts, and so we can find the necessary information\nbut it is much better to install bioperl\n\nPlease read the README in the bioperl distribution\n\n"); - } - } - - eval { - require Bio::DB::GenBank; - require Bio::DB::GenPept; - require Bio::DB::EMBL; - require Bio::DB::SwissProt; - }; - if ( $@ ) { - if ( !exists $ENV{'BIOPERL_SAVVY'} ) { - print STDERR ("\nbp_fetch cannot find Bio::DB::GenBank and Bio::DB::EMBL modules\nThis is most likely because LWP has not been installed\nThis does not effect local indexing\nset environment variable BIOPERL_SAVVY to suppress this message\n\n"); - } - } +eval { + require Bio::DB::GenBank; + require Bio::DB::GenPept; + require Bio::DB::EMBL; + require Bio::DB::SwissProt; +}; +if ($@ && ! exists $ENV{'BIOPERL_SAVVY'}) { + print STDERR ("\nbp_fetch cannot find Bio::DB::GenBank and Bio::DB::EMBL modules\nThis does not effect local indexing\nset environment variable BIOPERL_SAVVY to suppress this message\n\n"); } # diff --git a/bin/bp_genbank2gff3 b/bin/bp_genbank2gff3 index 4acc7a8a2..046f73fc2 100644 --- a/bin/bp_genbank2gff3 +++ b/bin/bp_genbank2gff3 @@ -199,12 +199,6 @@ Don Gilbert (gilbertd@indiana.edu) use strict; use warnings; -use lib "$ENV{HOME}/bioperl-live"; -# chad put this here to enable situations when this script is tested -# against bioperl compiled into blib along with other programs using blib -BEGIN { - unshift(@INC,'blib/lib'); -}; use Pod::Usage; use Bio::Root::RootI; use Bio::SeqIO; diff --git a/bin/bp_index b/bin/bp_index index 3af1e227d..11f78744f 100644 --- a/bin/bp_index +++ b/bin/bp_index @@ -103,29 +103,11 @@ use warnings; # installing bioperl # -BEGIN { - eval { - require Bio::Index::Fasta; - require Bio::Index::EMBL; - require Bio::Index::Swissprot; - require Bio::Index::GenBank; - require Bio::Index::SwissPfam; - }; - if ( $@ ) { - # one up from here is Bio directory - we hope! - push(@INC,".."); - eval { - require Bio::Index::Fasta; - require Bio::Index::EMBL; - }; - if ( $@ ) { - print STDERR ("\nbp_index cannot find Bio::Index::Fasta and Bio::Index::EMBL\nbp_index needs to have bioperl installed for it to run.\nBioperl is very easy to install\nSee http://bio.perl.org for more information\n\n"); - exit(1); - } else { - print STDERR ("\nYou are running bp_index.pl without installing bioperl.\nYou have done it from bioperl/scripts, and so we can find the necessary information\nbut it is much better to install bioperl\n\nPlease read the README in the bioperl distribution\n\n"); - } - } -} +use Bio::Index::Fasta; +use Bio::Index::EMBL; +use Bio::Index::Swissprot; +use Bio::Index::GenBank; +use Bio::Index::SwissPfam; my $dir = $ENV{'BIOPERL_INDEX'}; my $type = $ENV{'BIOPERL_INDEX_TYPE'}; diff --git a/examples/root/exceptions1.pl b/examples/root/exceptions1.pl index 5c6d89322..8d9be8ac2 100644 --- a/examples/root/exceptions1.pl +++ b/examples/root/exceptions1.pl @@ -16,7 +16,6 @@ # use strict; -use lib qw(lib/ ../../); use Error qw(:try); use TestObject; use Getopt::Long; diff --git a/examples/root/exceptions2.pl b/examples/root/exceptions2.pl index b6249e54f..8e8a781ca 100644 --- a/examples/root/exceptions2.pl +++ b/examples/root/exceptions2.pl @@ -15,7 +15,6 @@ use strict; -use lib qw(lib/ ../../); # Uncomment this line to force Bio::Root::Root::throw() to # not use Error.pm even if it's available. diff --git a/examples/root/exceptions3.pl b/examples/root/exceptions3.pl index a8e8b86e9..b36f8a7cb 100644 --- a/examples/root/exceptions3.pl +++ b/examples/root/exceptions3.pl @@ -16,7 +16,6 @@ # use strict; -use lib qw(lib/ ../../); use Error qw(:try); use Bio::Root::Exception; diff --git a/examples/root/exceptions4.pl b/examples/root/exceptions4.pl index cf5b9fc5f..6f769a788 100644 --- a/examples/root/exceptions4.pl +++ b/examples/root/exceptions4.pl @@ -15,7 +15,6 @@ BEGIN { $DONT_USE_ERROR = 1; } use strict; -use lib qw(lib/ ../../); use TestObject; use Getopt::Long; diff --git a/examples/searchio/custom_writer.pl b/examples/searchio/custom_writer.pl index fd75e314c..fb4aa29f2 100644 --- a/examples/searchio/custom_writer.pl +++ b/examples/searchio/custom_writer.pl @@ -34,7 +34,6 @@ package MyBlastWriter; use strict; -use lib '../../'; use Bio::Root::Root; use Bio::SearchIO::SearchWriterI; @@ -80,7 +79,6 @@ package main; use strict; -use lib '../../../'; use Bio::SearchIO; select STDOUT; $|=1; diff --git a/examples/searchio/hitwriter.pl b/examples/searchio/hitwriter.pl index 16b7536ad..089d44c83 100644 --- a/examples/searchio/hitwriter.pl +++ b/examples/searchio/hitwriter.pl @@ -40,7 +40,6 @@ # Author: Steve Chervitz use strict; -use lib '../../'; use Bio::SearchIO; use Bio::SearchIO::Writer::HitTableWriter; diff --git a/examples/searchio/hspwriter.pl b/examples/searchio/hspwriter.pl index 73cddb1f2..175991524 100644 --- a/examples/searchio/hspwriter.pl +++ b/examples/searchio/hspwriter.pl @@ -38,7 +38,6 @@ # Author: Steve Chervitz use strict; -use lib '../../'; use Bio::SearchIO; use Bio::SearchIO::Writer::HSPTableWriter; diff --git a/examples/searchio/htmlwriter.pl b/examples/searchio/htmlwriter.pl index db715ca55..e29195e28 100644 --- a/examples/searchio/htmlwriter.pl +++ b/examples/searchio/htmlwriter.pl @@ -27,7 +27,6 @@ use strict; -use lib '../../'; use Bio::SearchIO; use Bio::SearchIO::Writer::HTMLResultWriter; diff --git a/examples/searchio/psiblast_features.pl b/examples/searchio/psiblast_features.pl index e98a362b7..6c7962aa2 100644 --- a/examples/searchio/psiblast_features.pl +++ b/examples/searchio/psiblast_features.pl @@ -23,7 +23,6 @@ # Author: Steve Chervitz use strict; -use lib '../../'; use Bio::SearchIO; my $in = Bio::SearchIO->new( -format => 'psiblast', diff --git a/examples/searchio/psiblast_iterations.pl b/examples/searchio/psiblast_iterations.pl index 39734d1a3..7a7d66246 100644 --- a/examples/searchio/psiblast_iterations.pl +++ b/examples/searchio/psiblast_iterations.pl @@ -15,7 +15,6 @@ # Author: Steve Chervitz use strict; -use lib '../../'; use Bio::SearchIO; diff --git a/examples/searchio/rawwriter.pl b/examples/searchio/rawwriter.pl index 521cf7403..5d1fb9ae8 100644 --- a/examples/searchio/rawwriter.pl +++ b/examples/searchio/rawwriter.pl @@ -29,7 +29,6 @@ use strict; -use lib '../../'; use Bio::SearchIO; diff --git a/examples/searchio/resultwriter.pl b/examples/searchio/resultwriter.pl index 2033a9ffd..fd6580264 100644 --- a/examples/searchio/resultwriter.pl +++ b/examples/searchio/resultwriter.pl @@ -37,7 +37,6 @@ use strict; -use lib '../../'; use Bio::SearchIO; use Bio::SearchIO::Writer::ResultTableWriter; diff --git a/examples/tools/seq_pattern.pl b/examples/tools/seq_pattern.pl index 124100b7d..ccdb87f33 100644 --- a/examples/tools/seq_pattern.pl +++ b/examples/tools/seq_pattern.pl @@ -20,16 +20,11 @@ # # Functionality is not yet complete but it may be of use as-is. # -# INSTALLATION -# Edit the use lib "...." line to point the directory -# containing your Bioperl modules. -# # DOCUMENTATION: # http://genome-www.stanford.edu/perlOOP/bioperl/lib/Bio/Tools/SeqPattern.pm.html # #----------------------------------------------------------------------------- -use lib "/Users/steve/lib/perl"; use Bio::Tools::SeqPattern (); use Getopt::Std; @@ -127,10 +122,4 @@ sub test_pep { printf "%18s: %s\n", 'Original',$ppat->str; printf "%18s: %s\n", 'Expanded', $ppat->expand; print "\n"; -} - - - - - - +} diff --git a/lib/Bio/Search/Tiling/MapTiling.pm b/lib/Bio/Search/Tiling/MapTiling.pm index 50261fd84..a09fbaf97 100644 --- a/lib/Bio/Search/Tiling/MapTiling.pm +++ b/lib/Bio/Search/Tiling/MapTiling.pm @@ -171,9 +171,6 @@ package Bio::Search::Tiling::MapTiling; use strict; use warnings; -# Object preamble - inherits from Bio::Root::Root -#use lib '../../..'; - use Bio::Root::Root; use Bio::Search::Tiling::TilingI; use Bio::Search::Tiling::MapTileUtils; diff --git a/lib/BioPerl.pm b/lib/BioPerl.pm index 505ddda19..4b17ea462 100644 --- a/lib/BioPerl.pm +++ b/lib/BioPerl.pm @@ -93,9 +93,7 @@ check the self-described I directory as well. You are more than welcome to contribute your script! If you have installed BioPerl in the standard way, as detailed in the INSTALL in -the distribution, these scripts should work by just running them. If you have -not installed it in a standard way you will have to change the 'use lib' to -point to your installation (see INSTALL for details). +the distribution, these scripts should work by just running them. =head1 GETTING INVOLVED diff --git a/t/Root/Exception.t b/t/Root/Exception.t index 0b6fa0733..4790e8abe 100644 --- a/t/Root/Exception.t +++ b/t/Root/Exception.t @@ -5,7 +5,6 @@ use strict; BEGIN { eval {require Error;}; - use lib qw( . t/lib ); use Bio::Root::Test; test_begin(-tests => 7, diff --git a/t/SearchIO/Tiling.t b/t/SearchIO/Tiling.t index f571ffa17..d75929d7b 100644 --- a/t/SearchIO/Tiling.t +++ b/t/SearchIO/Tiling.t @@ -4,8 +4,6 @@ use strict; use warnings; use vars qw($EXHAUSTIVE $VERBOSE); BEGIN { - use lib '../..'; - use Bio::Root::Test; $EXHAUSTIVE = $ENV{BIOPERL_TILING_EXHAUSTIVE_TESTS}; $VERBOSE = $ENV{BIOPERL_TILING_VERBOSE_TESTS}; diff --git a/t/SeqIO/embl.t b/t/SeqIO/embl.t index 68886f7d4..15f821cfd 100644 --- a/t/SeqIO/embl.t +++ b/t/SeqIO/embl.t @@ -4,7 +4,6 @@ use strict; BEGIN { - use lib '../..'; use Bio::Root::Test; test_begin(-tests => 100); -- 2.11.4.GIT