Author: Andreas Tille <tille@debian.org>
Last-Update: Mon, 23 May 2016 16:09:13 +0200
Description: Instead of setting mpa_dir bash variable the path to the
 database files in /usr/share/metaphlan2 is set explicitly.
 .
 The doc is also adapted to this change.

--- a/metaphlan2.py
+++ b/metaphlan2.py
@@ -385,7 +385,7 @@ def read_params(args):
             
             "*  You can also provide an externally BowTie2-mapped SAM if you specify this format with \n"
             "   --input_type. Two steps: first apply BowTie2 and then feed MetaPhlAn2 with the obtained sam:\n"
-            "$ bowtie2 --sam-no-hd --sam-no-sq --no-unal --very-sensitive -S metagenome.sam -x ${mpa_dir}/db_v20/mpa_v20_m200 -U metagenome.fastq\n"
+            "$ bowtie2 --sam-no-hd --sam-no-sq --no-unal --very-sensitive -S metagenome.sam -x /usr/share/metaphlan2/db_v20/mpa_v20_m200 -U metagenome.fastq\n"
             "$ metaphlan2.py metagenome.sam --input_type sam > profiled_metagenome.txt\n\n"
             
             "*  Multiple alternative ways to pass the input are also available:\n"
@@ -1107,7 +1107,7 @@ if __name__ == '__main__':
     # check for the mpa_pkl file
     if not os.path.isfile(pars['mpa_pkl']):
         sys.stderr.write("Error: Unable to find the mpa_pkl file at: " + pars['mpa_pkl'] +
-                         "\nExpecting location ${mpa_dir}/db_v20/map_v20_m200.pkl "
+                         "\nExpecting location /usr/share/metaphlan2/db_v20/mpa_v20_m200.pkl "
                          "\nSelect the file location with the option --mpa_pkl.\n"
                          "Exiting...\n\n")
         sys.exit(1)           
@@ -1155,7 +1155,7 @@ if __name__ == '__main__':
             sys.stderr.write( "No MetaPhlAn BowTie2 database found "
                               "[--bowtie2db option]! "
                               "(or wrong path provided)."
-                              "\nExpecting location ${mpa_dir}/db_v20/map_v20_m200 "
+                              "\nExpecting location /usr/share/metaphlan2/db_v20/mpa_v20_m200 "
                               "\nExiting... " )
             sys.exit(1)
 
--- a/README.md
+++ b/README.md
@@ -60,32 +60,27 @@ Cloning the repository via the following
 
 This section presents some basic usages of MetaPhlAn2, for more advanced usages, please see at [its wiki](https://bitbucket.org/biobakery/biobakery/wiki/metaphlan2).
 
-We assume here that ``metaphlan2.py`` is in the system path and that ``mpa_dir`` bash variable contains the main MetaPhlAn folder. You can set this two variables moving to your MetaPhlAn2 local folder and type:
-```
-#!cmd
-$ export PATH=`pwd`:$PATH
-$ export mpa_dir=`pwd`
-```
+We assume here that ``metaphlan2`` is in the system path.
 
 Here is the basic example to profile a metagenome from raw reads (requires BowTie2 in the system path with execution and read permissions, Perl installed). 
 
 ```
 #!cmd
-$ metaphlan2.py metagenome.fastq --input_type fastq > profiled_metagenome.txt
+$ metaphlan2 metagenome.fastq --input_type fastq > profiled_metagenome.txt
 ```
 
 It is highly recommended to save the intermediate BowTie2 output for re-running MetaPhlAn extremely quickly (--bowtie2out), and use multiple CPUs (--nproc) if available:
 
 ```
 #!cmd
-$ metaphlan2.py metagenome.fastq --bowtie2out metagenome.bowtie2.bz2 --nproc 5 --input_type fastq > profiled_metagenome.txt
+$ metaphlan2 metagenome.fastq --bowtie2out metagenome.bowtie2.bz2 --nproc 5 --input_type fastq > profiled_metagenome.txt
 ```
 
 If you already mapped your metagenome against the marker DB (using a previous  MetaPhlAn run), you can obtain the results in few seconds by using the previously saved --bowtie2out file and specifying the input (--input_type bowtie2out):
 
 ```
 #!cmd
-$ metaphlan2.py metagenome.bowtie2.bz2 --nproc 5 --input_type bowtie2out > profiled_metagenome.txt
+$ metaphlan2 metagenome.bowtie2.bz2 --nproc 5 --input_type bowtie2out > profiled_metagenome.txt
 ```
 
 You can also provide an externally BowTie2-mapped SAM if you specify this format with --input_type. Two steps here: first map your metagenome with BowTie2 and then feed MetaPhlAn2 with the obtained sam:
@@ -93,41 +88,41 @@ You can also provide an externally BowTi
 ```
 #!cmd
 $ bowtie2 --sam-no-hd --sam-no-sq --no-unal --very-sensitive -S metagenome.sam -x ${mpa_dir}/db_v20/mpa_v20_m200 -U metagenome.fastq
-$ metaphlan2.py metagenome.sam --input_type sam > profiled_metagenome.txt
+$ metaphlan2 metagenome.sam --input_type sam > profiled_metagenome.txt
 ```
 
 In order to make MetaPhlAn 2 easily compatible with complex metagenomic pipeline, there are now multiple alternative ways to pass the input:
 
 ```
 #!cmd
-$ cat metagenome.fastq | metaphlan2.py --input_type fastq > profiled_metagenome.txt
+$ cat metagenome.fastq | metaphlan2 --input_type fastq > profiled_metagenome.txt
 ```
 
 ```
 #!cmd
-$ tar xjf metagenome.tar.bz2 --to-stdout | metaphlan2.py --input_type fastq --bowtie2db ${mpa_dir}/db_v20/mpa_v20_m200 > profiled_metagenome.txt
+$ tar xjf metagenome.tar.bz2 --to-stdout | metaphlan2 --input_type fastq --bowtie2db ${mpa_dir}/db_v20/mpa_v20_m200 > profiled_metagenome.txt
 ```
 
 ```
 #!cmd
-$ metaphlan2.py --input_type fastq < metagenome.fastq > profiled_metagenome.txt
+$ metaphlan2 --input_type fastq < metagenome.fastq > profiled_metagenome.txt
 ```
 
 ```
 #!cmd
-$ metaphlan2.py --input_type fastq <(bzcat metagenome.fastq.bz2) > profiled_metagenome.txt
+$ metaphlan2 --input_type fastq <(bzcat metagenome.fastq.bz2) > profiled_metagenome.txt
 ```
 
 ```
 #!cmd
-$ metaphlan2.py --input_type fastq <(zcat metagenome_1.fastq.gz metagenome_2.fastq.gz) > profiled_metagenome.txt
+$ metaphlan2 --input_type fastq <(zcat metagenome_1.fastq.gz metagenome_2.fastq.gz) > profiled_metagenome.txt
 ```
 
 MetaPhlAn 2 can also natively **handle paired-end metagenomes** (but does not use the paired-end information), and, more generally, metagenomes stored in multiple files (but you need to specify the --bowtie2out parameter):
 
 ```
 #!cmd
-$ metaphlan2.py metagenome_1.fastq,metagenome_2.fastq --bowtie2out metagenome.bowtie2.bz2 --nproc 5 --input_type fastq > profiled_metagenome.txt
+$ metaphlan2 metagenome_1.fastq,metagenome_2.fastq --bowtie2out metagenome.bowtie2.bz2 --nproc 5 --input_type fastq > profiled_metagenome.txt
 ```
 
 For advanced options and other analysis types (such as strain tracking) please refer to the full command-line options.
@@ -136,7 +131,7 @@ For advanced options and other analysis
 
 
 ```
-usage: metaphlan2.py --input_type
+usage: metaphlan2 --input_type
                      {fastq,fasta,multifasta,multifastq,bowtie2out,sam}
                      [--mpa_pkl MPA_PKL] [--bowtie2db METAPHLAN_BOWTIE2_DB]
                      [--bt2_ps BowTie2 presets] [--bowtie2_exe BOWTIE2_EXE]
@@ -161,7 +156,7 @@ AUTHORS: Nicola Segata (nicola.segata@un
 
 COMMON COMMANDS
 
- We assume here that metaphlan2.py is in the system path and that mpa_dir bash variable contains the
+ We assume here that metaphlan2 is in the system path and that mpa_dir bash variable contains the
  main MetaPhlAn folder. Also BowTie2 should be in the system path with execution and read
  permissions, and Perl should be installed.
 
@@ -172,32 +167,32 @@ strains in particular cases) present in
 relative abundance. This correspond to the default analysis type (--analysis_type rel_ab).
 
 *  Profiling a metagenome from raw reads:
-$ metaphlan2.py metagenome.fastq --input_type fastq
+$ metaphlan2 metagenome.fastq --input_type fastq
 
 *  You can take advantage of multiple CPUs and save the intermediate BowTie2 output for re-running
    MetaPhlAn extremely quickly:
-$ metaphlan2.py metagenome.fastq --bowtie2out metagenome.bowtie2.bz2 --nproc 5 --input_type fastq
+$ metaphlan2 metagenome.fastq --bowtie2out metagenome.bowtie2.bz2 --nproc 5 --input_type fastq
 
 *  If you already mapped your metagenome against the marker DB (using a previous MetaPhlAn run), you
    can obtain the results in few seconds by using the previously saved --bowtie2out file and 
    specifying the input (--input_type bowtie2out):
-$ metaphlan2.py metagenome.bowtie2.bz2 --nproc 5 --input_type bowtie2out
+$ metaphlan2 metagenome.bowtie2.bz2 --nproc 5 --input_type bowtie2out
 
 *  You can also provide an externally BowTie2-mapped SAM if you specify this format with 
    --input_type. Two steps: first apply BowTie2 and then feed MetaPhlAn2 with the obtained sam:
-$ bowtie2 --sam-no-hd --sam-no-sq --no-unal --very-sensitive -S metagenome.sam -x ${mpa_dir}/db_v20/mpa_v20_m200 -U metagenome.fastq
-$ metaphlan2.py metagenome.sam --input_type sam > profiled_metagenome.txt
+$ bowtie2 --sam-no-hd --sam-no-sq --no-unal --very-sensitive -S metagenome.sam -x /usr/share/metaphlan2/db_v20/mpa_v20_m200 -U metagenome.fastq
+$ metaphlan2 metagenome.sam --input_type sam > profiled_metagenome.txt
 
 *  Multiple alternative ways to pass the input are also available:
-$ cat metagenome.fastq | metaphlan2.py --input_type fastq 
-$ tar xjf metagenome.tar.bz2 --to-stdout | metaphlan2.py --input_type fastq 
-$ metaphlan2.py --input_type fastq < metagenome.fastq
-$ metaphlan2.py --input_type fastq <(bzcat metagenome.fastq.bz2)
-$ metaphlan2.py --input_type fastq <(zcat metagenome_1.fastq.gz metagenome_2.fastq.gz)
+$ cat metagenome.fastq | metaphlan2 --input_type fastq 
+$ tar xjf metagenome.tar.bz2 --to-stdout | metaphlan2 --input_type fastq 
+$ metaphlan2 --input_type fastq < metagenome.fastq
+$ metaphlan2 --input_type fastq <(bzcat metagenome.fastq.bz2)
+$ metaphlan2 --input_type fastq <(zcat metagenome_1.fastq.gz metagenome_2.fastq.gz)
 
 *  We can also natively handle paired-end metagenomes, and, more generally, metagenomes stored in 
   multiple files (but you need to specify the --bowtie2out parameter):
-$ metaphlan2.py metagenome_1.fastq,metagenome_2.fastq --bowtie2out metagenome.bowtie2.bz2 --nproc 5 --input_type fastq
+$ metaphlan2 metagenome_1.fastq,metagenome_2.fastq --bowtie2out metagenome.bowtie2.bz2 --nproc 5 --input_type fastq
 
 ------------------------------------------------------------------- 
  
@@ -215,23 +210,23 @@ file saved during the execution of the d
 *  The following command will output the abundance of each marker with a RPK (reads per kil-base) 
    higher 0.0. (we are assuming that metagenome_outfmt.bz2 has been generated before as 
    shown above).
-$ metaphlan2.py -t marker_ab_table metagenome_outfmt.bz2 --input_type bowtie2out > marker_abundance_table.txt
+$ metaphlan2 -t marker_ab_table metagenome_outfmt.bz2 --input_type bowtie2out > marker_abundance_table.txt
    The obtained RPK can be optionally normalized by the total number of reads in the metagenome 
    to guarantee fair comparisons of abundances across samples. The number of reads in the metagenome
    needs to be passed with the '--nreads' argument
 
 *  The list of markers present in the sample can be obtained with '-t marker_pres_table'
-$ metaphlan2.py -t marker_pres_table metagenome_outfmt.bz2 --input_type bowtie2out > marker_abundance_table.txt
+$ metaphlan2 -t marker_pres_table metagenome_outfmt.bz2 --input_type bowtie2out > marker_abundance_table.txt
    The --pres_th argument (default 1.0) set the minimum RPK value to consider a marker present
 
 *  The list '-t clade_profiles' analysis type reports the same information of '-t marker_ab_table'
    but the markers are reported on a clade-by-clade basis.
-$ metaphlan2.py -t clade_profiles metagenome_outfmt.bz2 --input_type bowtie2out > marker_abundance_table.txt
+$ metaphlan2 -t clade_profiles metagenome_outfmt.bz2 --input_type bowtie2out > marker_abundance_table.txt
 
 *  Finally, to obtain all markers present for a specific clade and all its subclades, the 
    '-t clade_specific_strain_tracker' should be used. For example, the following command
    is reporting the presence/absence of the markers for the B. fragulis species and its strains
-$ metaphlan2.py -t clade_specific_strain_tracker --clade s__Bacteroides_fragilis metagenome_outfmt.bz2 db_v20/mpa_v20_m200.pkl --input_type bowtie2out > marker_abundance_table.txt
+$ metaphlan2 -t clade_specific_strain_tracker --clade s__Bacteroides_fragilis metagenome_outfmt.bz2 db_v20/mpa_v20_m200.pkl --input_type bowtie2out > marker_abundance_table.txt
    the optional argument --min_ab specifies the minimum clade abundance for reporting the markers
 
 ------------------------------------------------------------------- 
@@ -536,7 +531,7 @@ pickle.dump(db, ofile, pickle.HIGHEST_PR
 ofile.close()
 ```
 
-* To use the new database, switch to metaphlan2/db_v21 instead of metaphlan2/db_v20 when running metaphlan2.py with option "--mpa_pkl".
+* To use the new database, switch to metaphlan2/db_v21 instead of metaphlan2/db_v20 when running metaphlan2 with option "--mpa_pkl".
 
 
 ##**Metagenomic strain-level population genomics**##
@@ -614,7 +609,7 @@ for f in $(ls fastqs/*.bz2)
 do
     echo "Running metaphlan2 on ${f}"
     bn=$(basename ${f} | cut -d . -f 1)
-    tar xjfO ${f} | ../metaphlan2.py --bowtie2db ../db_v20/mpa_v20_m200 --mpa_pkl ../db_v20/mpa_v20_m200.pkl --input_type multifastq --nproc 10 -s sams/${bn}.sam.bz2 --bowtie2out sams/${bn}.bowtie2_out.bz2 -o sams/${bn}.profile
+    tar xjfO ${f} | metaphlan2 --bowtie2db /usr/share/metaphlan2/db_v20/mpa_v20_m200 --mpa_pkl /usr/share/metaphlan2/db_v20/mpa_v20_m200.pkl --input_type multifastq --nproc 10 -s sams/${bn}.sam.bz2 --bowtie2out sams/${bn}.bowtie2_out.bz2 -o sams/${bn}.profile
 done
 ```
 
@@ -761,4 +756,4 @@ In the output folder, you can find the f
 1. clade_name.fasta: the alignment file of all metagenomic strains.
 3. *.marker_pos: this file shows the starting position of each marker in the strains.
 3. *.info: this file shows the general information like the total length of the concatenated markers (full sequence length), number of used markers, etc.
-4. *.polymorphic: this file shows the statistics on the polymorphic site, where "sample" is the sample name, "percentage_of_polymorphic_sites" is the percentage of sites that are suspected to be polymorphic, "avg_freq" is the average frequency of the dominant alleles on all polymorphic sites, "avg_coverage" is the average coverage at all polymorphic sites.
\ No newline at end of file
+4. *.polymorphic: this file shows the statistics on the polymorphic site, where "sample" is the sample name, "percentage_of_polymorphic_sites" is the percentage of sites that are suspected to be polymorphic, "avg_freq" is the average frequency of the dominant alleles on all polymorphic sites, "avg_coverage" is the average coverage at all polymorphic sites.
