This file is indexed.

/usr/share/metaphlan2/_metaphlan2.py is in metaphlan2 2.7.5-1.

This file is owned by root:root, with mode 0o755.

The actual contents of the file can be viewed below.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# Run MetaPhlAn2
# Author: Francesco Asnicar
# This module defines the functions which run MetaPhlAn2 on
# single and paired fastq data.


import subprocess as sb
from q2_types.per_sample_sequences import SingleLanePerSampleSingleEndFastqDirFmt
from q2_types.per_sample_sequences import SingleLanePerSamplePairedEndFastqDirFmt
import tempfile
import biom
import os


def metaphlan2_helper(raw_data, nproc, input_type, output_file, verbose=True):
    cmd = ['metaphlan2.py', str(raw_data), '--input_type', str(input_type),
           '--biom', str(output_file), '--nproc', str(nproc)]

    if verbose:
        print("\nRunning external command line application. This may print "
              "messages to stdout and/or stderr.")
        print("Command: {}".format(' '.join(cmd)), end='\n\n')

    sb.run(cmd, check=True)


def profile_single_fastq(raw_data: SingleLanePerSampleSingleEndFastqDirFmt,
                         nproc: int=1) -> biom.Table:
    output_biom = None

    with tempfile.TemporaryDirectory() as tmp_dir:
        tmp_output_biom = os.path.join(tmp_dir, 'mp2_tmp_output.biom')
        metaphlan2_helper(raw_data, nproc, 'multifastq', tmp_output_biom)
        output_biom = biom.load_table(tmp_output_biom)

    return output_biom


def profile_paired_fastq(raw_data: SingleLanePerSamplePairedEndFastqDirFmt,
                         nproc: int=1) -> biom.Table:
    output_biom = None

    with tempfile.TemporaryDirectory() as tmp_dir:
        tmp_output_biom = os.path.join(tmp_dir, 'mp2_tmp_output.biom')
        metaphlan2_helper(raw_data, nproc, 'multifastq', tmp_output_biom)
        output_biom = biom.load_table(tmp_output_biom)

    return output_biom