Commit 51196ec9 authored by Andreas Tille's avatar Andreas Tille
Browse files

New upstream version 2.7.6

parent 4f4e0b55
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
repo: 092c2fe2278cb7f0b18d81faeb4aab98b89dc096
node: b2f9b3286d4be376805e3b5c26cf141ed375c605
node: cbd7880df400b453b8beb4e62b39e4a23b5523b6
branch: default
tag: 2.7.5
tag: 2.7.6
+3 −0
Original line number Diff line number Diff line
@@ -11,3 +11,6 @@ e424931b4d94d50cf62381c79c335935415b33b9 2.5.0
8963e486f79043c79a299f7a684e4550b0115c32 2.7.0
d8ab9ca4244c09a7a4995042a99fbba1e3598ac0 2.7.1
a1fe0d15320c04f69d56f1b7dd31cff972a7b8df 2.7.2
b2f9b3286d4be376805e3b5c26cf141ed375c605 2.7.5
847b250adbe97b9f4adc7e15f0d4bb5a66e782ec 2.7.4
178d1aaf4ac76e5d5477833e8e614104dcd32088 2.7.3
+23 −23
Original line number Diff line number Diff line
@@ -16,8 +16,8 @@ from __future__ import with_statement
__author__ = ('Nicola Segata (nicola.segata@unitn.it), '
              'Duy Tin Truong, '
              'Francesco Asnicar (f.asnicar@unitn.it)')
__version__ = '2.7.5'
__date__ = '6 February 2018'
__version__ = '2.7.6'
__date__ = '2 March 2018'


import sys
@@ -433,7 +433,7 @@ def read_params(args):
            "\n------------------------------------------------------------------- \n \n\n"


            "\n========== MetaPhlAn 2 strain tracking ============================ \n\n"
            "\n========== Marker level analysis ============================ \n\n"
            "MetaPhlAn 2 introduces the capability of charachterizing organisms at the strain level using non\n"
            "aggregated marker information. Such capability comes with several slightly different flavours and \n"
            "are a way to perform strain tracking and comparison across multiple samples.\n"
@@ -499,18 +499,16 @@ def read_params(args):
    arg('--mpa_pkl', type=str, default=None,
        help="The metadata pickled MetaPhlAn file [deprecated]")

    arg('--bowtie2db', metavar="METAPHLAN_BOWTIE2_DB", type=str, default=None,
    arg('--bowtie2db', metavar="METAPHLAN_BOWTIE2_DB", type=str, default=DEFAULT_DB_FOLDER,
        help=("The BowTie2 database file of the MetaPhlAn database. Used if "
              "--input_type is fastq, fasta, multifasta, or multifastq "
              "[deprecated]"))
              "--input_type is fastq, fasta, multifasta, or multifastq [default "+DEFAULT_DB_FOLDER+"]\n"))

    arg('-x', '--index', type=str, default='v20_m200',
        help=("Specify the id of the database version to use. If the database "
              "files are not found on the local MetaPhlAn2 installation they "
              "will be automatically downloaded"))
        help=("Specify the id of the database version to use. If the database\n"
              "files are not found on the local MetaPhlAn2 installation they\n"
              "will be automatically downloaded\n"))

    bt2ps = ['sensitive', 'very-sensitive', 'sensitive-local',
             'very-sensitive-local']
    bt2ps = ['sensitive', 'very-sensitive', 'sensitive-local', 'very-sensitive-local']
    arg('--bt2_ps', metavar="BowTie2 presets", default='very-sensitive',
        choices=bt2ps, help="Presets options for BowTie2 (applied only when a "
                            "multifasta file is provided)\n"
@@ -812,29 +810,32 @@ def download_unpack_tar(url, download_file_name, folder, bowtie2_build, nproc):
            sys.stderr.write("Fatal error running '{}'\nError message: '{}'\n\n".format(' '.join(bt2_cmd), e))
            sys.exit(1)

    sys.stderr.write('Removing uncompress database {}\n'.format(fna_file))
    os.remove(fna_file)

def check_and_install_database(index, bowtie2_build, nproc):

def check_and_install_database(index, bowtie2_db, bowtie2_build, nproc):
    """ Check if the database is installed, if not download and install """

    if len(glob(os.path.join(DEFAULT_DB_FOLDER, "mpa_{}*".format(index)))) >= 7:
    if len(glob(os.path.join(bowtie2_db, "mpa_{}*".format(index)))) >= 7:
        return

    # download the tar archive and decompress
    sys.stderr.write("\nDownloading MetaPhlAn2 database\nPlease note due to "
                     "the size this might take a few minutes\n")
    download_unpack_tar(DATABASE_DOWNLOAD, index, DEFAULT_DB_FOLDER, bowtie2_build, nproc)
    download_unpack_tar(DATABASE_DOWNLOAD, index, bowtie2_db, bowtie2_build, nproc)
    sys.stderr.write("\nDownload complete\n")


def set_mapping_arguments(index):
def set_mapping_arguments(index, bowtie2_db):
    mpa_pkl = 'mpa_pkl'
    bowtie2db = 'bowtie2db'

    if os.path.isfile(os.path.join(DEFAULT_DB_FOLDER, "mpa_{}.pkl".format(index))):
        mpa_pkl = os.path.join(DEFAULT_DB_FOLDER, "mpa_{}.pkl".format(index))
    if os.path.isfile(os.path.join(bowtie2_db, "mpa_{}.pkl".format(index))):
        mpa_pkl = os.path.join(bowtie2_db, "mpa_{}.pkl".format(index))

    if glob(os.path.join(DEFAULT_DB_FOLDER, "mpa_{}*.bt2".format(index))):
        bowtie2db = os.path.join(DEFAULT_DB_FOLDER, "mpa_{}".format(index))
    if glob(os.path.join(bowtie2_db, "mpa_{}*.bt2".format(index))):
        bowtie2db = os.path.join(bowtie2_db, "mpa_{}".format(index))

    return (mpa_pkl, bowtie2db)

@@ -1354,15 +1355,14 @@ def metaphlan2():
    pars = read_params(sys.argv)

    # check if the database is installed, if not then install
    check_and_install_database(pars['index'], pars['bowtie2_build'],
                               pars['nproc'])
    check_and_install_database(pars['index'], pars['bowtie2db'], pars['bowtie2_build'], pars['nproc'])

    if pars['install']:
        sys.stderr.write('The database is installed\n')
        return

    # set correct map_pkl and bowtie2db variables
    pars['mpa_pkl'], pars['bowtie2db'] = set_mapping_arguments(pars['index'])
    pars['mpa_pkl'], pars['bowtie2db'] = set_mapping_arguments(pars['index'], pars['bowtie2db'])

    #if pars['inp'] is None and ( pars['input_type'] is None or  pars['input_type'] == 'automatic'):
    #    sys.stderr.write( "The --input_type parameter need top be specified when the "
@@ -1440,7 +1440,7 @@ def metaphlan2():
                            for p in ["1.bt2", "2.bt2", "3.bt2", "4.bt2", "rev.1.bt2", "rev.2.bt2"]]):
            sys.stderr.write("No MetaPhlAn BowTie2 database found (--index "
                             "option)!\nExpecting location {}\nExiting..."
                             .format(DEFAULT_DB_FOLDER))
                             .format(pars['bowtie2db']))
            sys.exit(1)

        if bow:
+1 −1
Original line number Diff line number Diff line
@@ -11,7 +11,7 @@ import copy
import ConfigParser
import dendropy
import numpy
import ipdb
# import ipdb


def read_params():
+0 −0

File mode changed from 100644 to 100755.

Loading