simroux / VirSorter

Source code of the VirSorter tool, also available as an App on CyVerse/iVirus (https://de.iplantcollaborative.org/de/)
GNU General Public License v2.0
104 stars 30 forks source link

Addressing a common problem with BioPerl installation: "Can't locate Bio/Seq.pm in @INC" #74

Open deanna-kim opened 4 years ago

deanna-kim commented 4 years ago

Hi Simon,

I just wanted to share my quick solution to what appears to be a common issue with BioPerl installation, at least based on: #63 , #71 . This may be helpful for anyone who has found that their err output file contains the following message:

Can't locate Bio/Seq.pm in @INC (you may need to install the Bio::Seq module)
(@INC contains: /Users/kimde/opt/anaconda3/envs/virsorter/lib/site_perl/5.26.2/darwin-thread-multi-2level
/Users/kimde/opt/anaconda3/envs/virsorter/lib/site_perl/5.26.2
/Users/kimde/opt/anaconda3/envs/virsorter/lib/5.26.2/darwin-thread-multi-2level
/Users/kimde/opt/anaconda3/envs/virsorter/lib/5.26.2 .)

Some background information, which is all included in the README:

Here is the series of commands that I used to install VirSorter and MetaGeneAnnotator. ```bash # create conda environment conda create --name virsorter \ -c bioconda mcl=14.137 \ muscle \ blast \ perl-bioperl \ perl-file-which \ hmmer=3.1b2 \ perl-parallel-forkmanager \ perl-list-moreutils \ diamond=0.9.14 # clone the VirSorter repository git clone https://github.com/simroux/VirSorter.git cd VirSorter/Scripts make clean make # to run VirSorter in any directory, make symbolic links to VirSorter/wrapper_phage_contigs_sorter_iPlant.pl # and VirSorter/Scripts and place them in the bin folder for the “virsorter” conda environment. ln -s ~/VirSorter/wrapper_phage_contigs_sorter_iPlant.pl ~/opt/anaconda3/envs/virsorter/bin ln -s ~/VirSorter/Scripts ~/opt/anaconda3/envs/virsorter/bin # install MetaGeneAnnotator conda install --name virsorter -c bioconda metagene_annotator ```
Here's the series of commands I used to download the reformatted HMMs database. ```bash # download the reformatted data pack cd ~/VirSorter wget https://zenodo.org/record/1168727/files/virsorter-data-v2.tar.gz # run md5sum to make sure the output # matches to dd12af7d13da0a85df0a9106e9346b45 md5sum virsorter-data-v2.tar.gz # unpack it tar -xvzf virsorter-data-v2.tar.gz ```

Here's the series of commands I used to run wrapper_phage_contigs_sorter_iPlant.pl on my FASTA file:

source activate virsorter
wrapper_phage_contigs_sorter_iPlant.pl -f NM65_B17-contigs-prefix-formatted-only.fa \
                                       --db 1 \
                                       --wdir  \
                                       --ncpu 4 \
                                       --data-dir ~/virsorter-data

After receiving the error message that I described earlier, I decided to first check that the Bio::Seq module was actually installed. I ran conda install -n virsorter perl-bioperl as previously recommended by you in #71 . However, I received an output stating "All requested packages already installed".

When I attempted perl -e "use Bio::Seq;" I kept getting the same error message as before, stating that Seq.pm could not be found. This suggested to me that although BioPerl was installed, it wasn't in any of the directories that were listed that were listed in the @INC variable.

I visited my conda environment virsorter, and checked for Seq.pm in:

/Users/kimde/opt/anaconda3/envs/virsorter/lib/site_perl/5.26.2/darwin-thread-multi-2level
/Users/kimde/opt/anaconda3/envs/virsorter/lib/site_perl/5.26.2
/Users/kimde/opt/anaconda3/envs/virsorter/lib/5.26.2/darwin-thread-multi-2level
/Users/kimde/opt/anaconda3/envs/virsorter/lib/5.26.2 .

As suspected, Seq.pm was not in any of these directories.

I figured that BioPerl was located somewhere else within the lib of the virsorter environment. I found a folder named Bio with this full path:

/Users/kimde/opt/anaconda3/envs/virsorter/lib/perl5/site_perl/5.22.0/Bio

There was a Seq.pm file inside, along with what appeared to be a number of other BioPerl modules. Since the Bio folder was not listed in the @INC variable, Seq.pm had not been found.

I tried to modify the @INC variable, but because I have extremely cursory programming experience I found it too difficult to do. Instead, I just copied the entire Bio folder and pasted it into:

/Users/kimde/opt/anaconda3/envs/virsorter/lib/site_perl/5.26.2/darwin-thread-multi-2level

Which was one of the directories already listed in the @INC variable.

I then ran this wrapper_phage_contigs_sorter_iPlant.pl on my FASTA file again:

source activate virsorter
wrapper_phage_contigs_sorter_iPlant.pl -f NM65_B17-contigs-prefix-formatted-only.fa \
                                       --db 1 \
                                       --wdir  \
                                       --ncpu 4 \
                                       --data-dir ~/virsorter-data

And it worked!

simroux commented 4 years ago

Thanks for sharing! I'll leave the issue open so that it's easier for people to find this thread.

egoetz223 commented 3 years ago

Hi Simon,

I am having the same issue. I have Seq.pm in two places (I copied contents from the perl5 directory to the 5.26.2 directory): ./lib/site_perl/5.26.2/Seq.pm ./lib/perl5/site_perl/5.22.0/Bio/Seq.pm but don't have a directory called "darwin-thread-multi-2level".

I still can't seem to get it to run.

All the best, Elly

simroux commented 3 years ago

Hi Elly,

The easiest way to fix this error is typically to check if the original lib directory (./lib/perl5/site_perl/5.22.0/) is in the list of directories that perl looks into for its libraries. One way to do this is:

echo $PERL5LIB in a terminal after having loaded the conda environment. If the directory ./lib/perl5/site_perl/5.22.0/ does not appear in this list, we can add it with a single line in a terminal: export PERL5LIB=pwd./lib/perl5/site_perl/5.22.0/:$PERL5LIB

After that, you should be able to use the same line ("echo $PERL5LIB") to check that the variable was changed and the directory is now correctly listed. If this is the case, then you can try to check if BioPerl is now ok with:

perl -e "use Bio::Seq;" which should not throw any error anymore.

Note that you would have to do that every time you want to use VirSorter. There is a way to have conda automatically update the PERL5LIB variable at startup: see https://github.com/simroux/VirSorter#note-for-conda-installation, but in your case replace lib/site_perl/5.26.2/ by lib/perl5/site_perl/5.22.0/.

Hope this will help !

Best, Simon

egoetz223 commented 3 years ago

Hi Simon,

Thank you so much! That solved the problem.

All the best, Elly

On Mon, Jan 25, 2021 at 11:39 AM simroux notifications@github.com wrote:

Hi Elly,

The easiest way to fix this error is typically to check if the original lib directory (./lib/perl5/site_perl/5.22.0/) is in the list of directories that perl looks into for its libraries. One way to do this is:

echo $PERL5LIB in a terminal after having loaded the conda environment. If the directory ./lib/perl5/site_perl/5.22.0/ does not appear in this list, we can add it with a single line in a terminal: export PERL5LIB=pwd./lib/perl5/site_perl/5.22.0/:$PERL5LIB

After that, you should be able to use the same line ("echo $PERL5LIB") to check that the variable was changed and the directory is now correctly listed. If this is the case, then you can try to check if BioPerl is now ok with:

perl -e "use Bio::Seq;" which should not throw any error anymore.

Note that you would have to do that every time you want to use VirSorter. There is a way to have conda automatically update the PERL5LIB variable at startup: see https://github.com/simroux/VirSorter#note-for-conda-installation, but in your case replace lib/site_perl/5.26.2/ by lib/perl5/site_perl/5.22.0/.

Hope this will help !

Best, Simon

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/simroux/VirSorter/issues/74#issuecomment-766945889, or unsubscribe https://github.com/notifications/unsubscribe-auth/AQPCSBLAWQVZBLI4NL2SQJ3S3WNF7ANCNFSM4NPGQCSQ .

top334 commented 3 years ago

I meet the same problem, and saw the solution above, but I didn't have the folder"/Users/kimde/opt/anaconda3/envs/virsorter/lib/site_perl/5.26.2/darwin-thread-multi-2level". 微信图片_20210226174916

I just found the Seq.pm 微信图片_20210226173707

So I cannot cope the folder "Bio" to "/Users/kimde/opt/anaconda3/envs/virsorter/lib/site_perl/5.26.2/darwin-thread-multi-2level" So how can I solve the problem?

simroux commented 3 years ago

Right, the folder /Users/kimde/opt/anaconda3/envs/virsorter/lib/site_perl/5.26.2/darwin-thread-multi-2level only works for this specific user. As specified to Elly above, the best way to solve this is to add the folder "..XMF/USER/luoyunzhe/software/miniconda3/envs/virsorter/lib/perl5/site_perl/5.22.0" to your Perl Library path: see https://github.com/simroux/VirSorter/issues/74#issuecomment-766945889 for more specific instructions.