diff --git a/CREDITS b/CREDITS new file mode 100644 index 0000000..162dfad --- /dev/null +++ b/CREDITS @@ -0,0 +1,5 @@ +ViennaRNA package is obtained from http://www.tbi.univie.ac.at/RNA +The squid library is obtained from http://eddylab.org/software/squid/ +Randfold is obtained from http://bioinformatics.psb.ugent.be/software/details/Randfold +Bowtie is obtained from http://sourceforge.net/projects/bowtie-bio/files/bowtie/ + diff --git a/FAQ b/FAQ index 0969885..c63517f 100644 --- a/FAQ +++ b/FAQ @@ -16,3 +16,6 @@ A: No, but the output from the quantification module can be used directly as input for specialized differential expression tools. + + + diff --git a/README b/README index f7d9bd7..606b8de 100644 --- a/README +++ b/README @@ -5,15 +5,29 @@ This is miRDeep2 developed by Marc Friedlaender and Sebastian Mackowiak. miRDeep2 discovers active known or novel miRNAs from deep sequencing data (Solexa/Illumina, 454, ...). - - Requirements: ------------ Linux system, 2GB Ram, enough disk space dependent on your deep sequencing data - - - +# Testing version +MacOSX with Xcode and gcc compiler installed. (This can be obtained from the appstore, +if there are any issues with installing it please look for help online). + +To compile the Vienna package it maybe necessary to have GNU-grep installed since +the MacOSX grep is BSD based and sometimes not accepted by the installer. +To get a GNU grep you could for example install homebrew by typing +## +ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" +## +(the link could be out of date, in that case look up online what to do) + +After that typing +## +brew tap homebrew/dupes; brew install grep +## +will install gnu grep as 'ggrep' in /usr/local/bin/ +## + Installation: @@ -39,7 +53,7 @@ d Perl package PDF::API2 (http://search.cpan.org/search?query=PDF%3A%3AAPI2& Sample installation tutorial when packages are downloaded 2 attach the miRDeep2 executable path to your PATH - (echo 'export PATH=$PATH:your_path_to_mirdeep2' >> ~/.bashrc) + (echo 'export PATH=$PATH:your_path_to_mirdeep2/src' >> ~/.bashrc) @@ -88,7 +102,6 @@ Sample installation tutorial when packages are downloaded 2.f) start a new shell session to apply changes to environment variables - to test if everything is installed properly type in 1) bowtie 2) RNAfold -h @@ -100,21 +113,17 @@ you should not get any error messages otherwise something is not correctly insta - Install Paths: ------------- Everything that is download by the installer will be in a directory called your_path_to_mirdeep2/essentials - - Script Reference: ---------------- miRDeep2 analyses can be performed using the three scripts miRDeep2.pl, mapper.pl and quantifier.pl. - name: miRDeep2.pl diff --git a/changelog b/changelog index 82e60fc..8084f44 100644 --- a/changelog +++ b/changelog @@ -1,3 +1,14 @@ +Version 2.0.0.8 +The install.pl script has been updated to download automatically the latest PDF::API2 version and the latest bowtie1 version. +Source code has been cleaned up and pathes have been adapted. So when using this version please do a new installation of miRDeep2 +and do not just copy scripts over old version. Otherwise your installation will likely be broken. +RNAfold and randfold now compile again on MacOSX 10.10.5 due to adaptation of the fold.c source file in these packages. +minor issues removed +code is cleaned up and installation directories are also organzied more reasonable +Sean Eddys squid libray is included in the package already since the download server is sometimes not to be working + + + Version 2.0.0.6 corrected bed file coordinates, off by one error fixed the zebrafish switch works now in the species specification diff --git a/install.pl b/install.pl index baf6979..255883a 100755 --- a/install.pl +++ b/install.pl @@ -1,46 +1,89 @@ -#!/usr/bin/perl +#!/usr/bin/env perl + + use strict; use warnings; use LWP::Simple; - - - print STDERR "\n ############################################################################################### -# +# Last update: May 18, 2016 # This is the miRDeep2 installer. -# It will work under a bash,csh and ksh shell. +# It is tested under a bash and zsh shell # It will try to download all necessary files and install them. -# Please restart your shell to make changes take effect # ############################################################################################### - "; +my $dir=`pwd 2>&1`; +chomp $dir; my $time =time; -my $new = $ARGV[0]; +my $new='no'; + +$new = $ARGV[0] if($ARGV[0]); + +my $shell=$ENV{'SHELL'}; +my $shellconf='.bash_profile'; +if($shell =~ /zsh/){ + if(-f "$ENV{'HOME'}/.zshenv"){ + $shellconf='.zshenv'; + }elsif(-f "$ENV{'HOME'}/.zshrc"){ + $shellconf='.zshrc'; + }else{ + die "Could not determine file for setting environment variables\n"; + } +} + + if($new !~ /no/){ - print STDERR "making backup of .bashrc,.bash_profile and .cshrc and removing all entries of mirdeep in those files\n"; + print STDERR "making backup of .bashrc,$shellconf and .cshrc and removing all entries of mirdeep in those files\n"; rem_mirdeep(".bashrc"); - rem_mirdeep(".bash_profile"); + rem_mirdeep("$shellconf"); rem_mirdeep(".cshrc"); } +my $grep; +$grep=`which grep`; +if(not $grep){ + $grep=`which ggrep`; +} +if(not $grep){ + die "No grep found on system\n"; +} +chomp $grep; + + my $gcc=`gcc --version 2>&1`; -if($gcc !~ /(GCC)/i){ - die "\nError:\n\tno gcc compiler installed. Please install a gcc compiler\n"; +if($gcc !~ /(GCC)/i and $gcc !~ /clang/i){ + print STDERR "\nError:\n\tno gcc compiler installed. Please install a gcc compiler\n"; + my $r=`uname -s`; + chomp $r; + if($r !~ /Linux/i){ + print STDERR "==> If you are using MacOS then you probably need to install Xcode with commandline-tools from the appstore!\n\n"; + } + exit; }else{ if($gcc =~ /^gcc\s*\S*\s*(\d+\S+)\s*/){ print STDERR "gcc version: $1 already installed, nothing to do ...\n"; } + if($gcc =~ /clang/){ + print STDERR "clang installed already installed, nothing to do ...\n"; + } } -my $wget=`wget`; -my $curl=`curl 2>&1`; +my %progs; +$progs{bowtie}=0; +$progs{RNAfold}=0; +$progs{randfold}=0; +$progs{zlib}=0; +$progs{pdf}=0; +$progs{ttf}=0; + +my $wget=`which wget`; +my $curl=`which curl`; my $dtool=''; my $dopt=''; @@ -55,35 +98,123 @@ die "No commandline download tool found on your system. Please install wget or curl on your machine\n"; } -my $dir=`pwd 2>&1`; +if(not -d 'bin'){ + #creating bin directory which will also contain other executables in the end\n"; + my $ret=system("cp -r src bin"); + if(not $ret){ + print STDERR "bin directory created successful\n"; + }else{ + die "Could not create binary directory\n"; + } +} -chomp $dir; my $err; - my $dfile=''; ##only attach to config file if not yet existing -my $in=`grep "$dir/mirdeep:*" ~/.bashrc`; -if(not $in){ - `echo 'export PATH=\$PATH:$dir' >> ~/.bashrc`; +my $in=`$grep "$dir/bin" ~/.bashrc`; + + + +## set install dir +my $install_bin_dir="$dir/bin"; +foreach my $e(@ARGV){ + if($e =~ /install-dir=(.+)/){ + $install_bin_dir=$1; + } +} + +if($install_bin_dir ne "$dir/bin"){ + ## check if it is writable and existet + if(not -d $install_bin_dir){ + print STDERR "The given installation directory by argument install-dir is not existent\nexecutable files will be put into $dir/bin instead\n"; + $install_bin_dir="$dir/bin"; + }else{ + chdir $install_bin_dir; + my $ret=system("touch mirdeep_test_file"); + if(not $ret){ + system("rm mirdeep_test_file"); + }else{ + print STDERR "The given installation directory by argument install-dir is either not existent or not writeable\nexectable files will be put into $dir/bin instead\n"; + $install_bin_dir="$dir/bin"; + } + chdir "$dir"; + } } -$in=`grep "$dir/:*" ~/.bash_profile`; +## check if we have the install path in our files +$in=`$grep "$install_bin_dir" ~/$shellconf`; if(not $in){ - `echo 'export PATH=\$PATH:$dir' >> ~/.bash_profile`; + my $ret=`$grep $install_bin_dir ~/$shellconf |$grep PATH`; + if(not $ret){ + `echo 'export PATH=\$PATH:$install_bin_dir' >> ~/$shellconf`; + } +} + +## add this temporarily to make perl installation possible on some systems +print STDERR "Checking environment variables ...\n"; +my $g=`$grep PERL_MB_OPT ~/$shellconf \|$grep install_base `; +if($g){ +}else{ + print STDERR "adding variables PERL_MB_OPT,PERL_MM_OPT,PERL5LIB to $shellconf\n"; + `echo >> ~/$shellconf`; + `echo 'PERL_MB_OPT=\"--install_base $ENV{'HOME'}/perl5\";export PERL_MB_OPT' >> ~/$shellconf`; + `echo 'PERL_MM_OPT=\"INSTALL_BASE=$ENV{'HOME'}/perl5\";export PERL_MM_OPT' >> ~/$shellconf`; + $g=`grep $dir/lib/perl5 ~/$shellconf`; + if(not $g){ + $g=`grep PERL5LIB ~/$shellconf`; + if(not $g){ + `echo 'export PERL5LIB=$dir/lib/perl5' >> ~/$shellconf`; + }else{ + `echo 'export PERL5LIB=\$PERL5LIB:$dir/lib/perl5' >> ~/$shellconf`; + } + } + + `echo >> ~/$shellconf`; + print STDERR "please run the install.pl script again in a new terminal window or just type + + source ~/$shellconf + perl install.pl + + so that the new environment variables are visible to the install.pl script\n"; + + exit; +} + +$g=`$grep $dir/lib/perl5 ~/$shellconf`; +if(not $g){ + $g=`grep PERL5LIB ~/$shellconf`; + if(not $g){ + `echo 'export PERL5LIB=$dir/lib/perl5' >> ~/$shellconf`; + }else{ + `echo 'export PERL5LIB=\$PERL5LIB:$dir/lib/perl5' >> ~/$shellconf`; + } + +`echo >> ~/$shellconf`; +print STDERR "please run the install.pl script again in a new terminal window or just type + +source ~/$shellconf +perl install.pl + +so that the new environment variables are visible to the install.pl script\n"; +exit; } my $in2; if(-f "~/.cshrc"){ - $in2=`grep "$dir:*" ~/.cshrc`; + $in2=`$grep "$install_bin_dir" ~/.cshrc`; if(not $in2){ - #`echo 'setenv PATH \$PATH:$dir/mirdeep2' >> ~/.cshrc`; + `echo 'setenv PATH \$PATH:$install_bin_dir' >> ~/.cshrc`; } } +my $binnew=1; + if(not -d "essentials"){ `mkdir essentials`; +}else{ + $binnew=0; } chdir("essentials"); @@ -93,10 +224,25 @@ my $bowtie; my $bowtie_version="1.1.1"; +if($dtool =~ /curl/){ + + `$dtool https://sourceforge.net/projects/bowtie-bio/files/bowtie/ > to_del`; +}else{ + `$dtool https://sourceforge.net/projects/bowtie-bio/files/bowtie/ -O to_del`; +} +open IN,"to_del" or die "No bowtie_file_info file found\n"; +while(){ + if(/projects\/bowtie-bio\/files\/bowtie\/(\d\.\d+\.*\d*)\//){ + $bowtie_version=$1; + last; + } +} +close IN; my $ret=checkBIN("bowtie","Usage"); if($ret == 0){ print STDERR "bowtie already installed, nothing to do ...\n"; + $progs{bowtie} = 1; }else{ if(not -d "bowtie-$bowtie_version"){ @@ -110,20 +256,20 @@ } if(not -f $bowtie){ - if(check("http://netcologne.dl.sourceforge.net/project/bowtie-bio/bowtie/$bowtie_version/$bowtie")){ - $err=system("$dtool http://netcologne.dl.sourceforge.net/project/bowtie-bio/bowtie/$bowtie_version/$bowtie $dopt"); - - if($err){ - die "\nError:\n\t$bowtie could not be downloaded\n\n\n"; - } + if(check("http://netcologne.dl.sourceforge.net/project/bowtie-bio/bowtie/$bowtie_version/$bowtie")){ + $err=system("$dtool http://netcologne.dl.sourceforge.net/project/bowtie-bio/bowtie/$bowtie_version/$bowtie $dopt"); + + if($err){ + die "\nError:\n\t$bowtie could not be downloaded\n\n\n"; + } }elsif(check("http://netcologne.dl.sourceforge.net/project/bowtie-bio/bowtie/old/$bowtie_version/$bowtie")){ - $err=system("$dtool http://netcologne.dl.sourceforge.net/project/bowtie-bio/bowtie/old/$bowtie_version/$bowtie $dopt"); - if($err){ - die "\nError:\n\t$bowtie could not be downloaded\n\n\n"; - } - }else{ - die "\nError:\n\t$bowtie not found on server http://netcologne.dl.sourceforge.net/project/bowtie-bio/bowtie/ \n\n\n"; - } + $err=system("$dtool http://netcologne.dl.sourceforge.net/project/bowtie-bio/bowtie/old/$bowtie_version/$bowtie $dopt"); + if($err){ + die "\nError:\n\t$bowtie could not be downloaded\n\n\n"; + } + }else{ + die "\nError:\n\t$bowtie not found on server http://netcologne.dl.sourceforge.net/project/bowtie-bio/bowtie/ \n\n\n"; + } } if(not -f "$bowtie"){ @@ -131,38 +277,47 @@ } print STDERR "Installing bowtie binaries\n\n"; - $err=system("unzip $bowtie"); + $err=system("unzip -u $bowtie 1>> install.log 2>>install_error.log"); if($err){ die "unzip $bowtie was not successful\n"; } } + + #$in = `$grep "$dir/essentials/bowtie-$bowtie_version:*" ~/.bashrc` if(-f "~/.bashrc"); + #if(not $in){ + # `echo 'export PATH=\$PATH:$dir/essentials/bowtie-$bowtie_version' >> ~/.bashrc`; + #} - $in = `grep "$dir/essentials/bowtie-$bowtie_version:*" ~/.bashrc`; - if(not $in){ - `echo 'export PATH=\$PATH:$dir/essentials/bowtie-$bowtie_version' >> ~/.bashrc`; - } - - $in = `grep "$dir/essentials/bowtie-$bowtie_version:*" ~/.bash_profile`; - if(not $in){ - `echo 'export PATH=\$PATH:$dir/essentials/bowtie-$bowtie_version' >> ~/.bash_profile`; - } - + #$in = `$grep "$dir/essentials/bowtie-$bowtie_version:*" ~/$shellconf`; + #if(not $in){ + # `echo 'export PATH=\$PATH:$dir/essentials/bowtie-$bowtie_version' >> ~/$shellconf`; + #} - $in2 = `grep "$dir/essentials/bowtie-$bowtie_version:*" ~/.cshrc`; - if(not $in2){ - #`echo 'setenv PATH \$PATH:$dir/essentials/bowtie-$bowtie_version' >> ~/.cshrc`; - } + #$in2 = `$grep "$dir/essentials/bowtie-$bowtie_version:*" ~/.cshrc` if(-f "~/.cshrc"); + # + #if(not $in2){ + # `echo 'setenv PATH \$PATH:$dir/essentials/bowtie-$bowtie_version' >> ~/.cshrc`; + #} + chdir "$install_bin_dir"; + + buildgood("$dir/essentials/bowtie-$bowtie_version/bowtie"); + + if(not -f "bowtie"){ + system("ln -s $dir/essentials/bowtie-$bowtie_version/bowtie* ."); +} + chdir "$dir/essentials/"; } -my $ret = checkBIN("RNAfold -h 2","usage"); +$ret = checkBIN("RNAfold -h 2","usage"); #my $rna_inst=`RNAfold 2>&1`; #if($rna_inst !~ /no\s*RNAfold/i){ if($ret == 0){ - print STDERR "RNAfold already installed, nothing to do ...\n"; + print STDERR "RNAfold already installed, nothing to do ...\n"; + $progs{RNAfold}=1; }else{ if(not -d "ViennaRNA-1.8.4"){ $dfile="ViennaRNA-1.8.4.tar.gz"; @@ -178,42 +333,73 @@ Please try to download the Vienna package from here http://www.tbi.univie.ac.at/RNA/RNAfold.html \n"; } - } + } if(not -f "ViennaRNA-1.8.4.tar.gz"){ die "Vienna package download failed\n"; } - - print STDERR "Installing Vienna package now \n\n"; - `tar xvvzf ViennaRNA-1.8.4.tar.gz`; - chdir("ViennaRNA-1.8.4"); - `./configure --prefix=$dir/essentials/ViennaRNA-1.8.4/install_dir`; - `make`; - `make install`; - - - chdir(".."); } -} -$in = `grep "$dir/essentials/ViennaRNA-1.8.4/install_dir/bin:*" ~/.bashrc`; -if(not $in){ - print STDERR "Vienna package path has been added to \$PATH variable\n"; - `echo 'export PATH=\$PATH:$dir/essentials/ViennaRNA-1.8.4/install_dir/bin' >> ~/.bashrc`; -} -$in = `grep "$dir/essentials/ViennaRNA-1.8.4/install_dir/bin:*" ~/.bash_profile`; -if(not $in){ - print STDERR "Vienna package path has been added to \$PATH variable\n"; - `echo 'export PATH=\$PATH:$dir/essentials/ViennaRNA-1.8.4/install_dir/bin' >> ~/.bash_profile`; + if(not -f "ViennaRNA-1.8.4/Progs/RNAfold"){ + print STDERR "Installing Vienna package now \n\n"; + `tar xzf ViennaRNA-1.8.4.tar.gz`; + chdir("ViennaRNA-1.8.4/"); + chdir("lib"); + + open IN,"fold.c.new" or die "Cannot generate file fold.c.new\n"; + while(){ + if(/inline\s+(int\s+LoopEnergy.+$)/i){ + print OUT "$1"; + }elsif(/^inline\s+(int\s+HairpinE.+$)/i){ + print OUT "$1"; + }else{ + print OUT; + } + } + close OUT; + + `mv fold.c fold.c.orig`; + `mv fold.c.new fold.c`; + chdir(".."); + + `./configure --prefix=$dir/essentials/ViennaRNA-1.8.4/install_dir`; + `make 1>> ../install.log 2>> ../install_error.log`; + `make install 1>> ../install.log 2>> ../install_error.log`; + + buildgood("$dir/essentials/ViennaRNA-1.8.4/install_dir/bin/RNAfold"); + + chdir(".."); + chdir "$install_bin_dir"; + if(not -f "RNAfold"){ + system("ln -s $dir/essentials/ViennaRNA-1.8.4/install_dir/bin/RNAfold ."); + } + chdir "$dir/essentials/" + } } +#$in = `$grep "$dir/essentials/ViennaRNA-1.8.4/install_dir/bin:*" ~/.bashrc`; +#if(not $in){ +# print STDERR "Vienna package path has been added to \$PATH variable\n"; +# `echo 'export PATH=\$PATH:$dir/essentials/ViennaRNA-1.8.4/install_dir/bin' >> ~/.bashrc`; +#} + +#$in = `$grep "$dir/essentials/ViennaRNA-1.8.4/install_dir/bin:*" ~/$shellconf`; +#if(not $in){ +# print STDERR "Vienna package path has been added to \$PATH variable\n"; +# `echo 'export PATH=\$PATH:$dir/essentials/ViennaRNA-1.8.4/install_dir/bin' >> ~/$shellconf`; +#} + -$in2 = `grep "$dir/essentials/ViennaRNA-1.8.4/install_dir/bin:*" ~/.cshrc`; -if(not $in2){ +#$in2 = `$grep "$dir/essentials/ViennaRNA-1.8.4/install_dir/bin:*" ~/.cshrc`; +#if(not $in2){ #`echo 'setenv PATH \$PATH:$dir/essentials/ViennaRNA-1.8.4/install_dir/bin' >> ~/.cshrc`; -} +#} + + + $ret = checkBIN("randfold","let7"); @@ -221,25 +407,39 @@ #if($randf =~ /no\s*randfold/i){ ## this should work if($ret == 0){ - print STDERR "randfold\t\t\t\talready installed, nothing to do ...\n"; + print STDERR "randfold\t\t\t\t\t already installed, nothing to do ...\n"; + $progs{randfold}=1; }else{ - $dfile="squid-1.9g.tar.gz"; + $dfile="squid-1.9g.tar.gz"; if(not -f $dfile){ print STDERR "Downloading SQUID library now\n\n"; - `$dtool ftp://selab.janelia.org/pub/software/squid/squid-1.9g.tar.gz $dopt`; + `$dtool http://eddylab.org/software/squid/squid.tar.gz $dopt`; + `mv squid.tar.gz $dfile`; } - + if(not -f $dfile){ + system("cp ../squid-1.9g.tar.gz squid-1.9g.tar.gz"); + } + if(not -f "squid-1.9g.tar.gz"){ die "squid could not be downloaded\n Please try to download the library from here http://selab.janelia.org/software.html"; } - if(not -d "squid-1.9g"){ + if(not -d "squid-1.9g" and -f "squid-1.9g.tar.gz"){ print STDERR "Extracting squid and configuring it now\n\n"; - `tar xxvzf squid-1.9g.tar.gz`; - chdir("squid-1.9g"); - `./configure`; - `make`; + `mkdir squid-1.9g`; + `tar xzf squid-1.9g.tar.gz -C squid-1.9g`; + my $a=`ls squid-1.9g`; + chomp $a; + `mv squid-1.9g/$a/* squid-1.9g/`; + `rm -rf squid-1.9g/$a`; + + chdir("squid-1.9g"); + `./configure 1>>../install.log 2>>../install_error.log`; + `make 1>>../install.log 2>>install_error.log`; + + buildgood("$dir/essentials/squid-1.9g/libsquid.a"); + chdir(".."); } @@ -249,19 +449,17 @@ `$dtool http://bioinformatics.psb.ugent.be/supplementary_data/erbon/nov2003/downloads/randfold-2.0.tar.gz $dopt`; } - if(not -f "randfold-2.0.tar.gz"){ die "randfold could not be downloaded\nPlease try to download randfold from here http://bioinformatics.psb.ugent.be/software/details/Randfold\n"; } - if(not -d "randfold-2.0"){ + if(not -d "randfold-2.0" and -f "randfold-2.0.tar.gz"){ print STDERR "Installing randfold now\n\n"; - `tar xvvzf randfold-2.0.tar.gz`; + `tar xzf randfold-2.0.tar.gz`; chdir("randfold-2.0"); open IN,"Makefile_new" or die "Makefile_new could not be created\n\n"; while(){ @@ -273,33 +471,56 @@ } close IN; close OUT; - + + ## added so we can make it run on MacOSX as well. + + open IN,"fold.c.new" or die "Cannot generate file fold.c.new\n"; + while(){ + if(/^inline\s+(int\s+LoopEnergy.+$)/i){ + print OUT "$1"; + }elsif(/^inline\s+(int\s+HairpinE.+$)/i){ + print OUT "$1"; + }else{ + print OUT; + } + } + close OUT; + + + `mv fold.c fold.c.orig`; + `mv fold.c.new fold.c`; + `mv Makefile Makefile.orig`; `mv Makefile_new Makefile`; - `make`; - - chdir(".."); + `make 1>>../install.log 2>>../install_error.log`; + buildgood("$dir/essentials/randfold-2.0/randfold"); + chdir(".."); } - $in = `grep "$dir/essentials/randfold-2.0:*" ~/.bashrc`; - if(not $in){ - print STDERR "Randfold path has been added to \$PATH variable\n"; - `echo 'export PATH=\$PATH:$dir/essentials/randfold-2.0' >> ~/.bashrc`; - } +# $in = `$grep "$dir/essentials/randfold-2.0:*" ~/.bashrc`; +# if(not $in){ +# print STDERR "Randfold path has been added to \$PATH variable\n"; +# `echo 'export PATH=\$PATH:$dir/essentials/randfold-2.0' >> ~/.bashrc`; +# } - $in = `grep "$dir/essentials/randfold-2.0:*" ~/.bashrc_profile`; - if(not $in){ - print STDERR "Randfold path has been added to \$PATH variable\n"; - `echo 'export PATH=\$PATH:$dir/essentials/randfold-2.0' >> ~/.bash_profile`; -} +# $in = `$grep "$dir/essentials/randfold-2.0:*" ~/$shellconf`; +# if(not $in){ +# print STDERR "Randfold path has been added to \$PATH variable\n"; +# `echo 'export PATH=\$PATH:$dir/essentials/randfold-2.0' >> ~/$shellconf`; +#} - $in2 = `grep "$dir/essentials/randfold-2.0:*" ~/.cshrc`; - if($in2){ +# $in2 = `$grep "$dir/essentials/randfold-2.0:*" ~/.cshrc`; +# if($in2){ #`echo 'setenv PATH \$PATH:$dir/essentials/randfold-2.0' >> ~/.cshrc`; - } - + # } + chdir "$install_bin_dir"; + if(not -f "randfold"){ + system("ln -s $dir/essentials/randfold-2.0/randfold ."); + } + chdir "$dir/essentials/" } @@ -307,7 +528,8 @@ my $zlib=`perl -e 'use Compress::Zlib;' 2>&1`; if(not $zlib){ - print STDERR "Compress::Zlib\t\t\t\talready installed, nothing to do ...\n"; + print STDERR "Compress::Zlib\t\t\t\t\t already installed, nothing to do ...\n"; + $progs{zlib}=1; }else{ die "please install Compress::Zlib by using CPAN before you proceed\n"; @@ -315,18 +537,84 @@ #my $pdfapi=`perl -e 'use PDF::API2;' 2>&1`; -$ret = checkBIN("perl -e \'use PDF::API2; print \"installed\";\'","installed"); +$ret = checkBIN("perl -e \'use Font::TTF; print \"installed\";\'","installed"); -#if(not $pdfapi){ if($ret == 0){ - print STDERR "PDF::API2 already installed, nothing to do ...\n"; + print STDERR "Font::TTf already installed, nothing to do ...\n"; + $progs{ttf}=1; }else{ + my $version=''; + `$dtool http://www.cpan.org/authors/id/M/MH/MHOSKEN/CHECKSUMS $dopt`; + open IN,"CHECKSUMS" or die "File checksums not found\n"; + while(){ + if(/((Font-TTF-\d.+).tar.gz)/){ + $dfile=$1; + $version=$2; + } + } + close IN; + + if(not -f $dfile){ + print STDERR "Downloading Font::TTF now\n\n"; + `$dtool http://www.cpan.org/authors/id/M/MH/MHOSKEN/$dfile $dopt`; + } + + if(not -f $dfile){ + die "Download of Font::TTF failed\n\n"; + } + + print STDERR "Installing Font-TTF now\n\n"; + `tar xzf $dfile`; + chdir("$version"); + + `perl Makefile.PL INSTALL_BASE=$ENV{'HOME'}/perl5 LIB=$dir/lib/perl5`; + `make 1>>../install.log 2>>../install_error.log`; + `mv Makefile Makefile.orig`; + open IN,"Makefile.orig" or die "No Makefile found\n"; + open OUT,">Makefile" or die "No Makefile found\n"; + while(my $cl= ){ + if($cl =~ /^INSTALL_BASE\s=/){ + print OUT "INSTALL_BASE = $dir\n"; + }else{ + print OUT $cl; + } + } + close IN; + `make install 1>>../install.log 2>>..install_error.log`; + + $ret = checkBIN("perl -e \'use Font::TTF; print \"installed\";\'","installed"); - $dfile="PDF-API2-2.019.tar.gz"; + if($ret == 0){ + print STDERR "Font::TTF installation successful \n"; + $progs{ttf}=1; +} + + chdir(".."); +} + + + +$ret = checkBIN("perl -e \'use PDF::API2; print \"installed\";\'","installed"); + +if($ret == 0){ + print STDERR "PDF::API2 already installed, nothing to do ...\n"; + $progs{pdf}=1; +}else{ + my $version=''; + `$dtool http://www.cpan.org/authors/id/S/SS/SSIMMS/CHECKSUMS $dopt`; + open IN,"CHECKSUMS" or die "File checksums not found\n"; + while(){ + if(/((PDF-API2.+).tar.gz)/){ + $dfile=$1; + $version=$2; + } + } + close IN; + if(not -f $dfile){ print STDERR "Downloading PDF-API2 now\n\n"; `$dtool http://ftp-stud.hs-esslingen.de/pub/Mirrors/CPAN/authors/id/S/SS/SSIMMS/$dfile $dopt`; @@ -337,11 +625,11 @@ } print STDERR "Installing PDF-API2 now\n\n"; - `tar xvvzf $dfile`; - chdir("PDF-API2-2.019"); + `tar xzf $dfile`; + chdir("$version"); - `perl Makefile.PL`; - `make`; + `perl Makefile.PL INSTALL_BASE=$ENV{'HOME'}/perl5 LIB=$dir/lib/perl5`; + `make 1>>../install.log 2>>..install_error.log`; `mv Makefile Makefile.orig`; open IN,"Makefile.orig" or die "No Makefile found\n"; @@ -355,45 +643,44 @@ } close IN; - `make install`; - #} - chdir(".."); -} - -#my $perl = "$], $/"; -#chomp $perl; -#$perl =~ s/0/\./g; -#$perl =~ s/\.+/\./g; -#$perl =~ s/\,+//g; - -#$in = `grep "$dir/lib/perl5/site_perl/$perl:*" ~/.bashrc`; + `make install 1>>../install.log 2>>..install_error.log`; + + $ret = checkBIN("perl -e \'use PDF::API2; print \"installed\";\'","installed"); -#if(not $in){ - print STDERR "PDF::API2 package path has been added to \$PERL5LIB variable\n"; - `echo 'export PERL5LIB=\$PERL5LIB:$dir/lib/perl5' >> ~/.bashrc`; -#} - -#$in = `grep "$dir/lib/perl5/site_perl/$perl:*" ~/.bash_profile`; + if($ret == 0){ + print STDERR "PDF::API2 installation successful\n"; + $progs{pdf}=1; + } -#if(not $in){ - print STDERR "PDF::API2 package path has been added to \$PERL5LIB variable\n"; - `echo 'export PERL5LIB=\$PERL5LIB:$dir/lib/perl5' >> ~/.bash_profile`; -#} + chdir(".."); +} - print STDERR "\n\nif the PDF::API2 install failed it may be necessary to add the following to your .bashrc\n - PERL_MB_OPT=\"--install_base \"$ENV{'HOME'}/perl5\"; export PERL_MB_OPT; - PERL_MM_OPT=\"INSTALL_BASE=$ENV{'HOME'}/perl5\"; export PERL_MM_OPT; - then start a new shell and rerun the installer - "; +my $sum=0; +for my $k (keys %progs){ + $sum+=$progs{$k}; + print STDERR "\n\n$k was/is not installed properly\n\n" if(not $progs{$k} and $binnew==0); +} -#$in2 = `grep "$dir/lib/perl5/site_perl/$perl:*" ~/.cshrc`; +if($sum == 6){ + print STDERR "\n\nInstallation successful\n\n\n\n\n\n"; + print STDERR "To check if everything works fine you can now change to the +tutorial_dir and type 'bash run_tut.sh' to make a test run\n\n"; + + chdir $dir; + open EF,">install_successful" or die "Could not create file install_successful\n + In case that all tools are running properly then please create this empty file manually + in your mirdeep2 installation folder. Otherwise the other tools will not run. + "; + close EF; +}else{ + print STDERR "\n\nPlease run the install.pl script again to check if +everything is properly installed. -#if(not $in2){ - #`echo 'setenv PERL5LIB \$PERL5LIB:$dir/lib/' >> ~/.cshrc`; -#} +"; +} -print STDERR "\n\nInstallation successful\n\n\nPlease start a new shell\n\n\n\n"; +exit; sub rem_mirdeep{ @@ -471,3 +758,15 @@ sub check{ return 0; } } + +sub buildgood{ + if(-f $_[0]){ + print STDERR "Building of $_[0] successful\n"; + }else{ + die "Building of $_[0] not successful\nPlease have a look at the install.log and install_error.log in + the essentials directory + "; + } +} + + diff --git a/squid-1.9g.tar.gz b/squid-1.9g.tar.gz new file mode 100644 index 0000000..4b789a9 Binary files /dev/null and b/squid-1.9g.tar.gz differ diff --git a/bwa_sam_converter.pl b/src/bwa_sam_converter.pl similarity index 100% rename from bwa_sam_converter.pl rename to src/bwa_sam_converter.pl diff --git a/clip_adapters.pl b/src/clip_adapters.pl similarity index 100% rename from clip_adapters.pl rename to src/clip_adapters.pl diff --git a/collapse_reads_md.pl b/src/collapse_reads_md.pl similarity index 100% rename from collapse_reads_md.pl rename to src/collapse_reads_md.pl diff --git a/convert_bowtie_output.pl b/src/convert_bowtie_output.pl similarity index 100% rename from convert_bowtie_output.pl rename to src/convert_bowtie_output.pl diff --git a/excise_precursors.pl b/src/excise_precursors.pl similarity index 100% rename from excise_precursors.pl rename to src/excise_precursors.pl diff --git a/excise_precursors_iterative_final.pl b/src/excise_precursors_iterative_final.pl similarity index 100% rename from excise_precursors_iterative_final.pl rename to src/excise_precursors_iterative_final.pl diff --git a/extract_miRNAs.pl b/src/extract_miRNAs.pl similarity index 100% rename from extract_miRNAs.pl rename to src/extract_miRNAs.pl diff --git a/fastaparse.pl b/src/fastaparse.pl similarity index 100% rename from fastaparse.pl rename to src/fastaparse.pl diff --git a/fastaselect.pl b/src/fastaselect.pl similarity index 100% rename from fastaselect.pl rename to src/fastaselect.pl diff --git a/fastq2fasta.pl b/src/fastq2fasta.pl similarity index 100% rename from fastq2fasta.pl rename to src/fastq2fasta.pl diff --git a/find_read_count.pl b/src/find_read_count.pl similarity index 100% rename from find_read_count.pl rename to src/find_read_count.pl diff --git a/geo2fasta.pl b/src/geo2fasta.pl similarity index 100% rename from geo2fasta.pl rename to src/geo2fasta.pl diff --git a/get_mirdeep2_precursors.pl b/src/get_mirdeep2_precursors.pl similarity index 100% rename from get_mirdeep2_precursors.pl rename to src/get_mirdeep2_precursors.pl diff --git a/illumina_to_fasta.pl b/src/illumina_to_fasta.pl similarity index 100% rename from illumina_to_fasta.pl rename to src/illumina_to_fasta.pl diff --git a/make_html.pl b/src/make_html.pl similarity index 100% rename from make_html.pl rename to src/make_html.pl diff --git a/make_html2.pl b/src/make_html2.pl similarity index 100% rename from make_html2.pl rename to src/make_html2.pl diff --git a/mapper.pl b/src/mapper.pl similarity index 96% rename from mapper.pl rename to src/mapper.pl index 99724e9..87a7b15 100755 --- a/mapper.pl +++ b/src/mapper.pl @@ -1,5 +1,7 @@ #!/usr/bin/perl +## last update 21/04/2016 + use warnings; use strict; use Getopt::Std; @@ -62,6 +64,9 @@ $0 reads_seq.txt -a -h -i -j -k TCGTATGCCGTCTTCTGCTTGT -l 18 -m -p h_sapiens_37_asm -s reads.fa -t reads_vs_genome.arf -v "; +######## +check_install(); +####### ###################################### INPUT ####################################################### @@ -70,13 +75,17 @@ ## ## -if(-f "mapper.log"){ - `mv mapper.log mapper.log_bak`; -}else{ - `touch mapper.log_bak`; +my $pid=$$; + +my $tid=time; + +my $lid=$pid.'_'.$tid; + +if(not -d "mapper_logs"){ + mkdir "mapper_logs"; } -open MAP,">mapper.log_tmp" or die "could not create mapper.log_tmp\n"; +open MAP,">mapper_logs/mapper.log_$lid" or die "could not create mapper_logs/mapper.log_$lid\n"; my $cdir = `pwd`; @@ -109,13 +118,10 @@ check_options(); - - #################################### GLOBAL VARIABLES ################################################ my $threads=1; $threads=$options{'o'} if(exists $options{'o'}); - ## check number of cores on the system and threads to be used my $cores=`grep -ic ^processor /proc/cpuinfo`; if($cores !~ /^\d+$/){ @@ -155,9 +161,7 @@ close MAP; -`cat mapper.log_tmp mapper.log_bak > mapper.log`; -`rm mapper.log_tmp mapper.log_bak`; - +print STDERR "Log file for this run is in mapper_logs and called mapper.log_$pid\n"; ## get some statistics about mapped reads if options{'s'} and options{'t'} are supplied if($options{'s'} and $options{'t'}){ @@ -708,3 +712,21 @@ sub read_stats{ printf STDERR "%.3f\t%.3f\n",$k22{$_}/$k2{$_},1-($k22{$_}/$k2{$_}); } } + +sub check_install{ + my $a=`which miRDeep2.pl`; + my $bn=`dirname $a`; + chomp $bn; + if(not -f "$bn/../install_successful"){ + die "Please run the install.pl script first before using the miRDeep2 package +The install script is located in ",substr($bn,0,length($bn)-3)," so just do + +cd ",substr($bn,0,length($bn)-3), +"\nperl install.pl + +"; + } +} + + + diff --git a/miRDeep2.pl b/src/miRDeep2.pl similarity index 96% rename from miRDeep2.pl rename to src/miRDeep2.pl index 16524fd..30df571 100755 --- a/miRDeep2.pl +++ b/src/miRDeep2.pl @@ -10,10 +10,12 @@ use File::Basename; use Term::ANSIColor; - +## +check_install(); +## ## generate log file for run, all output will be printed to it -my $version="2.0.0.7"; +my $version="2.0.0.8"; print " @@ -21,7 +23,7 @@ # # # miRDeep$version # # # -# last change: 10/12/2014 # +# last change: 21/04/2016 # # # ##################################### @@ -709,14 +711,18 @@ sub fold_precursors{ print "#folding precursors\n"; print STDERR "#folding precursors\n"; - print STDERR "RNAfold < $dir_tmp/precursors.fa -noPS > $dir_tmp/precursors.str\n\n"; + start(); my $ret_fold_precursors=system("RNAfold < $dir_tmp/precursors.fa -noPS > $dir_tmp/precursors.str 2>>error_${time}.log"); if($ret_fold_precursors){ $ret_fold_precursors=system("RNAfold < $dir_tmp/precursors.fa --noPS > $dir_tmp/precursors.str"); if($ret_fold_precursors){ die "Some RNAfold error occurred. Error $ret_fold_precursors\n"; + }else{ + print STDERR "RNAfold < $dir_tmp/precursors.fa --noPS > $dir_tmp/precursors.str\n\n"; } + }else{ + print STDERR "RNAfold < $dir_tmp/precursors.fa -noPS > $dir_tmp/precursors.str\n\n"; } end(); @@ -885,15 +891,15 @@ sub output_results{ if($file_mature_ref_this_species !~ /none/i){ if($options{'q'}){ - $line="make_html.pl -f $dir/output.mrd -k $dir_tmp/$file_mature_ref_this_species -p $dir_tmp/precursors.coords -s $dir/survey.csv -c -e -q $options{'q'} -x $xopt -r ${scripts}Rfam_for_miRDeep.fa -v $sc -y $time $sort_by_sample $OE"; + $line="make_html.pl -f $dir/output.mrd -k $dir_tmp/$file_mature_ref_this_species -p $dir_tmp/precursors.coords -s $dir/survey.csv -c -e -q $options{'q'} -x $xopt -r ${scripts}/../Rfam_for_miRDeep.fa -v $sc -y $time $sort_by_sample $OE"; }else{ - $line="make_html.pl -f $dir/output.mrd -k $dir_tmp/$file_mature_ref_this_species -p $dir_tmp/precursors.coords -s $dir/survey.csv -c -e -r ${scripts}Rfam_for_miRDeep.fa -v $sc -y $time $sort_by_sample $OE"; + $line="make_html.pl -f $dir/output.mrd -k $dir_tmp/$file_mature_ref_this_species -p $dir_tmp/precursors.coords -s $dir/survey.csv -c -e -r ${scripts}/../Rfam_for_miRDeep.fa -v $sc -y $time $sort_by_sample $OE"; } }else{ if($options{'q'}){ - $line="make_html.pl -f $dir/output.mrd -p $dir_tmp/precursors.coords -s $dir/survey.csv -c -e -q $options{'q'} -x $xopt -r ${scripts}Rfam_for_miRDeep.fa -v $sc -y $time $sort_by_sample $OE"; + $line="make_html.pl -f $dir/output.mrd -p $dir_tmp/precursors.coords -s $dir/survey.csv -c -e -q $options{'q'} -x $xopt -r ${scripts}/../Rfam_for_miRDeep.fa -v $sc -y $time $sort_by_sample $OE"; }else{ - $line="make_html.pl -f $dir/output.mrd -p $dir_tmp/precursors.coords -v $sc -s $dir/survey.csv -c -e -r ${scripts}Rfam_for_miRDeep.fa -y $time $sort_by_sample $OE"; + $line="make_html.pl -f $dir/output.mrd -p $dir_tmp/precursors.coords -v $sc -s $dir/survey.csv -c -e -r ${scripts}/../Rfam_for_miRDeep.fa -y $time $sort_by_sample $OE"; } } @@ -1021,8 +1027,8 @@ sub test_installed_binaries{ $ret = checkBIN("perl -e \'use PDF::API2; print \"installed\";\'","installed"); die "Error: \tPerl PDF::API2 package not found\nCheck if the perl PDF::API2 package is correctly installed and all Pathes were set correctly.\n$stdm" if($ret); - if(not -f "$scripts/Rfam_for_miRDeep.fa"){ - die "Error:\t Rfam_for_miRDeep.fa not found in your miRDeep2 scripts directory\nPlease copy this file from the miRDeep2 archive to your miRDeep2 scripts directory\n\n"; + if(not -f "$scripts/../Rfam_for_miRDeep.fa"){ + die "Error:\t Rfam_for_miRDeep.fa not found in your miRDeep2 scripts directory\nPlease copy this file from the miRDeep2 archive to your miRDeep2 directory\n\n"; } return 0; @@ -1091,3 +1097,19 @@ sub get_longest_id{ close IN; return $l; } + + +sub check_install{ + my $a=`which miRDeep2.pl`; + my $bn=`dirname $a`; + chomp $bn; + if(not -f "$bn/../install_successful"){ + die "Please run the install.pl script first before using the miRDeep2 package + The install script is located in ",substr($bn,0,length($bn)-3)," so just do + + cd ",substr($bn,0,length($bn)-3), + "\nperl install.pl + + "; + } +} diff --git a/miRDeep2_core_algorithm.pl b/src/miRDeep2_core_algorithm.pl similarity index 100% rename from miRDeep2_core_algorithm.pl rename to src/miRDeep2_core_algorithm.pl diff --git a/mirdeep2bed.pl b/src/mirdeep2bed.pl similarity index 100% rename from mirdeep2bed.pl rename to src/mirdeep2bed.pl diff --git a/parse_mappings.pl b/src/parse_mappings.pl similarity index 100% rename from parse_mappings.pl rename to src/parse_mappings.pl diff --git a/perform_controls.pl b/src/perform_controls.pl similarity index 100% rename from perform_controls.pl rename to src/perform_controls.pl diff --git a/permute_structure.pl b/src/permute_structure.pl similarity index 100% rename from permute_structure.pl rename to src/permute_structure.pl diff --git a/prepare_signature.pl b/src/prepare_signature.pl similarity index 100% rename from prepare_signature.pl rename to src/prepare_signature.pl diff --git a/quantifier.pl b/src/quantifier.pl similarity index 98% rename from quantifier.pl rename to src/quantifier.pl index 9d5a0cb..6021964 100755 --- a/quantifier.pl +++ b/src/quantifier.pl @@ -3,10 +3,10 @@ ###################### ## Author: SM -## Date: 25/06/2012 +## Date: 21/04/2016 ## added weighed read counts ## remaining read counts is now correct -## read noramlization is now 10e6 * mature-reads/all_mature_reads +## read noramlization is now 10e6 * mature-reads/all_mature_reads (So reads per million mapped miRNA reads) ## missing/empty file with star sequences led to abortion of the script when option -s was used ###################### @@ -16,6 +16,8 @@ use File::Basename; use Getopt::Std; +check_install(); + my %hash; my %hash_star; my %hash_sample; @@ -303,9 +305,15 @@ PrintExpressionValues(); PrintExpressionValuesSamples(); +if($options{'j'}){ + print STDERR "exiting here and not creating mirdeep.mrd file\nif you want this created do not specify option -j\n"; + exit; +} print STDERR "\nCreating miRBase.mrd file\n\n"; -die "exiting here and not creating mirdeep.mrd file\nif you want this created do not specify option -j\n" if($options{'j'}); CreateOutputMRD(); + + + #CreateOutputMRD_orig(); my $opt_l ='-l'; @@ -1396,7 +1404,20 @@ sub CreateOutputMRD{ chdir("../../"); }## close sub +sub check_install{ + my $a=`which miRDeep2.pl`; + my $bn=`dirname $a`; + chomp $bn; + if(not -f "$bn/../install_successful"){ + die "Please run the install.pl script first before using the miRDeep2 package + The install script is located in ",substr($bn,0,length($bn)-3)," so just do + cd ",substr($bn,0,length($bn)-3), + "\nperl install.pl + + "; + } +} __DATA__ hsa Human diff --git a/remove_white_space_in_id.pl b/src/remove_white_space_in_id.pl similarity index 100% rename from remove_white_space_in_id.pl rename to src/remove_white_space_in_id.pl diff --git a/rna2dna.pl b/src/rna2dna.pl similarity index 100% rename from rna2dna.pl rename to src/rna2dna.pl diff --git a/samFLAGinfo.pl b/src/samFLAGinfo.pl similarity index 100% rename from samFLAGinfo.pl rename to src/samFLAGinfo.pl diff --git a/sam_reads_collapse.pl b/src/sam_reads_collapse.pl similarity index 100% rename from sam_reads_collapse.pl rename to src/sam_reads_collapse.pl diff --git a/sanity_check_genome.pl b/src/sanity_check_genome.pl similarity index 100% rename from sanity_check_genome.pl rename to src/sanity_check_genome.pl diff --git a/sanity_check_mapping_file.pl b/src/sanity_check_mapping_file.pl similarity index 100% rename from sanity_check_mapping_file.pl rename to src/sanity_check_mapping_file.pl diff --git a/sanity_check_mature_ref.pl b/src/sanity_check_mature_ref.pl similarity index 100% rename from sanity_check_mature_ref.pl rename to src/sanity_check_mature_ref.pl diff --git a/sanity_check_reads_ready_file.pl b/src/sanity_check_reads_ready_file.pl similarity index 100% rename from sanity_check_reads_ready_file.pl rename to src/sanity_check_reads_ready_file.pl diff --git a/select_for_randfold.pl b/src/select_for_randfold.pl similarity index 100% rename from select_for_randfold.pl rename to src/select_for_randfold.pl diff --git a/survey.pl b/src/survey.pl similarity index 100% rename from survey.pl rename to src/survey.pl diff --git a/tutorial_dir/run_tut.sh b/tutorial_dir/run_tut.sh index 2b3bb9a..77ef26a 100755 --- a/tutorial_dir/run_tut.sh +++ b/tutorial_dir/run_tut.sh @@ -1,8 +1,21 @@ #!/bin/bash bowtie-build cel_cluster.fa cel_cluster +ec=`echo $?` +if [ $ec != 0 ];then + echo An error occured, exit code $ec +fi mapper.pl reads.fa -c -j -k TCGTATGCCGTCTTCTGCTTGT -l 18 -m -p cel_cluster -s reads_collapsed.fa -t reads_collapsed_vs_genome.arf -v -n +ec=`echo $?` +if [ $ec != 0 ];then + echo An error occured, exit code $ec +fi miRDeep2.pl reads_collapsed.fa cel_cluster.fa reads_collapsed_vs_genome.arf mature_ref_this_species.fa mature_ref_other_species.fa precursors_ref_this_species.fa -t C.elegans +ec=`echo $?` +if [ $ec != 0 ];then + echo An error occured, exit code $ec +fi +