bxlab / metaWRAP

MetaWRAP - a flexible pipeline for genome-resolved metagenomic data analysis
MIT License
391 stars 191 forks source link

parallelization in annotate_bins breaks conda environmental variables #10

Open karoraw1 opened 6 years ago

karoraw1 commented 6 years ago

I run this:

source activate metawrap-env
MW_O=/home-3/karoraw1@jhu.edu/scratch/metaWRAP_Out

metaWRAP annotate_bins \
-o $MW_O/Mystic_Bin_Fxns \
-t 48 \
-b $MW_O/Mystic_Bin_Reassembly/reassembled_bins

I get a copy of this for every prokka call in STDERR:

Can't locate XML/Simple.pm in @INC (you may need to install the XML::Simple module) (@INC contains: /home-3/karoraw1@jhu.edu/perl5/lib/perl5/5.22.0/x86_64-linux /home-3/karoraw1@jhu.edu/perl5/lib/perl5/5.22.0 /home-3/karoraw1@jhu.edu/perl5/lib/perl5/x86_64-linux /home-3/karoraw1@jhu.edu/perl5/lib/perl5 /cm/shared/apps/perl/5.22.0/lib/site_perl/5.22.0/x86_64-linux /cm/shared/apps/perl/5.22.0/lib/site_perl/5.22.0 /cm/shared/apps/perl/5.22.0/lib/5.22.0/x86_64-linux /cm/shared/apps/perl/5.22.0/lib/5.22.0 .) at /home-3/karoraw1@jhu.edu/scratch/miniconda2/envs/metawrap-env/bin/prokka line 25.
BEGIN failed--compilation aborted at /home-3/karoraw1@jhu.edu/scratch/miniconda2/envs/metawrap-env/bin/prokka line 25.

If I load the conda environment and run prokka manually, there is no problem. i.e.

[karoraw1@jhu.edu@compute0117 metaWRAP_bins]$ source activate metawrap-env
(metawrap-env) [karoraw1@jhu.edu@compute0117 metaWRAP_bins]$ prokka --outdir ~/scratch/test_bin_35_annot --prefix Bin35_test bin.35.fa --force
[13:22:26] This is prokka 1.12
....
[13:25:36] Thank you, come again.

The only way I can reproduce the error is by using module restore in SLURM. It seems to change where prokka searches for dependencies. blastp breaks, java breaks, and perl breaks as seen above.

It seems like calls to prokka within the parallelization scheme don't inherit the environmental variable preference that manual calls to prokka do.

Let me know if you need any other info from me.

ursky commented 6 years ago

Interesting error. MARCC is strange sometimes. I was able to replicate the issue and fixed it by manually passing Conda's perl5 libs to PROKKA with the -I flag. Hopefully that was the issue on your end too. Please re-try with metaWRAP v0.7.5, and let me know if it works.

Note: The metaWRAP conda package is not called metawrap-mg (instead of metawrap-binning).

ursky commented 6 years ago

Actually hold on, there is another issue. This one was with the parallelization of PROKKA, as you suspected. It produced many strange bugs, strangely only on MARCC... For the time being, I have to remove the parallelization of the PROKKA runs - the bins are now annotated one after another. Thankfully, PROKKA is lightning-fast to begin with! Please install and try metawrap-mg v=0.7.6.

karoraw1 commented 6 years ago

So I tried the annotate_bins in metaWRAP v=0.7.6. At first I got the same issue:

[karoraw1@jhu.edu@bigmem0011 Scripts]$ source activate metawrap2-env
(metawrap2-env) [karoraw1@jhu.edu@bigmem0011 Scripts]$ MW_O=/home-3/karoraw1@jhu.edu/scratch/THRASH_LIBS
(metawrap2-env) [karoraw1@jhu.edu@bigmem0011 Scripts]$ metaWRAP annotate_bins -t 48 -o $MW_O/BIN_ANNOTATION -b $MW_O/BIN_REASSEMBLY/reassembled_bins
/home-3/karoraw1@jhu.edu/scratch/miniconda2/envs/metawrap2-env/bin/metawrap-modules/annotate_bins.sh -t 48 -o /home-3/karoraw1@jhu.edu/scratch/THRASH_LIBS/BIN_ANNOTATION -b /home-3/karoraw1@jhu.edu/scratch/THRASH_LIBS/BIN_REASSEMBLY/reassembled_bins

########################################################################################################################
#####                                          BEGIN ANNNOTAION PIPELINE!                                          #####
########################################################################################################################

------------------------------------------------------------------------------------------------------------------------
-----                              setting up output folder and copything over bins...                             -----
------------------------------------------------------------------------------------------------------------------------

Can't locate XML/Simple.pm in @INC (you may need to install the XML::Simple module) (@INC contains: /home-3/karoraw1@jhu.edu/perl5/lib/perl5/5.22.0/x86_64-linux /home-3/karoraw1@jhu.edu/perl5/lib/perl5/5.22.0 /home-3/karoraw1@jhu.edu/perl5/lib/perl5/x86_64-linux /home-3/karoraw1@jhu.edu/perl5/lib/perl5 /cm/shared/apps/perl/5.22.0/lib/site_perl/5.22.0/x86_64-linux /cm/shared/apps/perl/5.22.0/lib/site_perl/5.22.0 /cm/shared/apps/perl/5.22.0/lib/5.22.0/x86_64-linux /cm/shared/apps/perl/5.22.0/lib/5.22.0 .) at /home-3/karoraw1@jhu.edu/scratch/miniconda2/envs/metawrap2-env/bin/prokka line 25.
BEGIN failed--compilation aborted at /home-3/karoraw1@jhu.edu/scratch/miniconda2/envs/metawrap2-env/bin/prokka line 25.

------------------------------------------------------------------------------------------------------------------------
-----           Looks like your perl is oddly configured. Will have to run perl manually using your conda          -----
-----                                                 perl lib...                                                  -----
------------------------------------------------------------------------------------------------------------------------

PROKKA path: /home-3/karoraw1@jhu.edu/scratch/miniconda2/envs/metawrap2-env/bin/prokka
conda path: /home-3/karoraw1@jhu.edu/scratch/miniconda2/bin/conda

------------------------------------------------------------------------------------------------------------------------
-----                                      Will use perl libraries located in                                      -----
-----           /home-3/karoraw1@jhu.edu/scratch/miniconda2/lib/perl5/site_perl/5.22.0 - hopefully they            -----
-----                                                 are there...                                                 -----
------------------------------------------------------------------------------------------------------------------------

/home-3/karoraw1@jhu.edu/scratch/miniconda2/envs/metawrap2-env/bin/metawrap-scripts/shorten_contig_names.py /home-3/karoraw1@jhu.edu/scratch/THRASH_LIBS/BIN_REASSEMBLY/reassembled_bins/bin.100.permissive.fa > /home-3/karoraw1@jhu.edu/scratch/THRASH_LIBS/BIN_ANNOTATION/tmp_bin.fa

------------------------------------------------------------------------------------------------------------------------
-----                                       NOW ANNOTATING bin.100.permissive                                      -----
------------------------------------------------------------------------------------------------------------------------

perl -I /home-3/karoraw1@jhu.edu/scratch/miniconda2/lib/perl5/site_perl/5.22.0 /home-3/karoraw1@jhu.edu/scratch/miniconda2/envs/metawrap2-env/bin/prokka --quiet --cpus 48 --outdir /home-3/karoraw1@jhu.edu/scratch/THRASH_LIBS/BIN_ANNOTATION/prokka_out/bin.100.permissive --prefix bin.100.permissive /home-3/karoraw1@jhu.edu/scratch/THRASH_LIBS/BIN_ANNOTATION/tmp_bin.fa
Can't locate XML/Simple.pm in @INC (you may need to install the XML::Simple module) (@INC contains: /home-3/karoraw1@jhu.edu/scratch/miniconda2/lib/perl5/site_perl/5.22.0 /home-3/karoraw1@jhu.edu/perl5/lib/perl5/5.22.0/x86_64-linux /home-3/karoraw1@jhu.edu/perl5/lib/perl5/5.22.0 /home-3/karoraw1@jhu.edu/perl5/lib/perl5/x86_64-linux /home-3/karoraw1@jhu.edu/perl5/lib/perl5 /cm/shared/apps/perl/5.22.0/lib/site_perl/5.22.0/x86_64-linux /cm/shared/apps/perl/5.22.0/lib/site_perl/5.22.0 /cm/shared/apps/perl/5.22.0/lib/5.22.0/x86_64-linux /cm/shared/apps/perl/5.22.0/lib/5.22.0 .) at /home-3/karoraw1@jhu.edu/scratch/miniconda2/envs/metawrap2-env/bin/prokka line 25.
BEGIN failed--compilation aborted at /home-3/karoraw1@jhu.edu/scratch/miniconda2/envs/metawrap2-env/bin/prokka line 25.

************************************************************************************************************************
*****                      Something went wrong with annotating bin.100.permissive. Exiting...                     *****
************************************************************************************************************************

I modified lines 98-104 to the following:

echo "PROKKA path: $prokka_path"
conda_path=${prokka_path%/*}
conda_path=${conda_path%/*}
echo "conda path: $conda_path"
##if [ ${conda_path##*/} != miniconda2 ]; then conda_path=${conda_path%/*}; echo "DOH"; fi
##if [ ${conda_path##*/} != miniconda2 ]; then error "Cannot find conda perl libraries for prokka!"; fi
perl_libs=${conda_path}/lib/perl5/site_perl/5.22.0

Now I get the following:

(metawrap2-env) [karoraw1@jhu.edu@bigmem0011 Scripts]$ metaWRAP annotate_bins -t 48 -o $MW_O/BIN_ANNOTATION -b $MW_O/BIN_REASSEMBLY/reassembled_bins
/home-3/karoraw1@jhu.edu/scratch/miniconda2/envs/metawrap2-env/bin/metawrap-modules/annotate_bins.sh -t 48 -o /home-3/karoraw1@jhu.edu/scratch/THRASH_LIBS/BIN_ANNOTATION -b /home-3/karoraw1@jhu.edu/scratch/THRASH_LIBS/BIN_REASSEMBLY/reassembled_bins

########################################################################################################################
#####                                          BEGIN ANNNOTAION PIPELINE!                                          #####
########################################################################################################################

------------------------------------------------------------------------------------------------------------------------
-----                              setting up output folder and copything over bins...                             -----
------------------------------------------------------------------------------------------------------------------------

Can't locate XML/Simple.pm in @INC (you may need to install the XML::Simple module) (@INC contains: /home-3/karoraw1@jhu.edu/perl5/lib/perl5/5.22.0/x86_64-linux /home-3/karoraw1@jhu.edu/perl5/lib/perl5/5.22.0 /home-3/karoraw1@jhu.edu/perl5/lib/perl5/x86_64-linux /home-3/karoraw1@jhu.edu/perl5/lib/perl5 /cm/shared/apps/perl/5.22.0/lib/site_perl/5.22.0/x86_64-linux /cm/shared/apps/perl/5.22.0/lib/site_perl/5.22.0 /cm/shared/apps/perl/5.22.0/lib/5.22.0/x86_64-linux /cm/shared/apps/perl/5.22.0/lib/5.22.0 .) at /home-3/karoraw1@jhu.edu/scratch/miniconda2/envs/metawrap2-env/bin/prokka line 25.
BEGIN failed--compilation aborted at /home-3/karoraw1@jhu.edu/scratch/miniconda2/envs/metawrap2-env/bin/prokka line 25.

------------------------------------------------------------------------------------------------------------------------
-----           Looks like your perl is oddly configured. Will have to run perl manually using your conda          -----
-----                                                 perl lib...                                                  -----
------------------------------------------------------------------------------------------------------------------------

PROKKA path: /home-3/karoraw1@jhu.edu/scratch/miniconda2/envs/metawrap2-env/bin/prokka
conda path: /home-3/karoraw1@jhu.edu/scratch/miniconda2/envs/metawrap2-env

------------------------------------------------------------------------------------------------------------------------
-----                                      Will use perl libraries located in                                      -----
-----          /home-3/karoraw1@jhu.edu/scratch/miniconda2/envs/metawrap2-env/lib/perl5/site_perl/5.22.0           -----
-----                                        - hopefully they are there...                                         -----
------------------------------------------------------------------------------------------------------------------------

/home-3/karoraw1@jhu.edu/scratch/miniconda2/envs/metawrap2-env/bin/metawrap-scripts/shorten_contig_names.py /home-3/karoraw1@jhu.edu/scratch/THRASH_LIBS/BIN_REASSEMBLY/reassembled_bins/bin.100.permissive.fa > /home-3/karoraw1@jhu.edu/scratch/THRASH_LIBS/BIN_ANNOTATION/tmp_bin.fa

------------------------------------------------------------------------------------------------------------------------
-----                                       NOW ANNOTATING bin.100.permissive                                      -----
------------------------------------------------------------------------------------------------------------------------

perl -I /home-3/karoraw1@jhu.edu/scratch/miniconda2/envs/metawrap2-env/lib/perl5/site_perl/5.22.0 /home-3/karoraw1@jhu.edu/scratch/miniconda2/envs/metawrap2-env/bin/prokka --quiet --cpus 48 --outdir /home-3/karoraw1@jhu.edu/scratch/THRASH_LIBS/BIN_ANNOTATION/prokka_out/bin.100.permissive --prefix bin.100.permissive /home-3/karoraw1@jhu.edu/scratch/THRASH_LIBS/BIN_ANNOTATION/tmp_bin.fa
Exception in thread "main" java.lang.UnsupportedClassVersionError: minced : Unsupported major.minor version 52.0
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
    at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
    at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:482)
[11:53:34] Could not determine version of minced - please install version 2.0 or higher

************************************************************************************************************************
*****                      Something went wrong with annotating bin.100.permissive. Exiting...                     *****
************************************************************************************************************************
ursky commented 6 years ago

This is a environment-specific issue, but metaWRAP needs to be able to handle this. I will contact you privately so we can come up with a long-term solution.

ursky commented 6 years ago

Hey there! I believe I was able to find a proper fix for the Perl5 library handling, and added the minced dependancy. If you don't mind, can you please try out metaWRAP v=0.8.2 and tell me if it works on your end? Thank you.

karoraw1 commented 6 years ago

I'll give it a shot over the weekend and let you know. Thanks!