Modifying QIIME2 execution wrapper in Conda

(Please feel free to change forum section of this question if this one is not right and add appropriate tags.)

Since I got stuck on this problem, I am trying to take a look at what exactly is happening in the code level of QIIME2 - effectively meaning adding some state prints.

However, modifying /home/user/miniconda3/envs/qiime2-2018.8/bin/qiime file does not have any actual impact on the behavior of QIIME2 or its execution.

For example, this is actual execution wrapper:


# -*- coding: utf-8 -*-
import re
import sys

from q2cli.__main__ import qiime

if __name__ == '__main__':
    sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])

Adding print('Hello World!') after if statement (or even before) does not change the behavior of QIIME2 (meaning there is no print to terminal).
Thinking there is rewritten somewhere standard output to something else beside terminal, I tried to write to a file instead with similar results - there was no file created, let alone written to it.

Even commenting out lines has no impact as can be seen from this example:


# -*- coding: utf-8 -*-
import re
import sys

from q2cli.__main__ import qiime

#if __name__ == '__main__':
#    sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
#    sys.exit(qiime())

My questions are: Is this behavior caused by Conda itself and if it is not, how can I modify the code, so my changes will appear?

Steps taken:

$source activate qiime2-2018.8
$vim `which qiime` # can be replaced with actual path to execution wrapper file
# adding print('Hello World!') and saving

OS: Ubuntu 16.04.1 LTS
conda version : 4.5.11
Qiime2 version: 2018.8

You almost certainly have something out of sync here, either a PYTHONPATH env var is set, or you are operating on the wrong conda env. Check this out:


# -*- coding: utf-8 -*-
import re
import sys

from q2cli.__main__ import qiime

print('Hello World')
if __name__ == '__main__':
    sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
qiime                                                                                                                                        frag2 74f1e04
Hello World
Usage: qiime [OPTIONS] COMMAND [ARGS]...

  QIIME 2 command-line interface (q2cli)

  To get help with QIIME 2, visit

  To enable tab completion in Bash, run the following command or add it to
  your .bashrc/.bash_profile:

      source tab-qiime

  To enable tab completion in ZSH, run the following commands or add them to
  your .zshrc:

      autoload bashcompinit && bashcompinit && source tab-qiime

  --version  Show the version and exit.
  --help     Show this message and exit.

  info                Display information about current deployment.
  tools               Tools for working with QIIME 2 files.
  dev                 Utilities for developers and advanced users.
  alignment           Plugin for generating and manipulating alignments.
  composition         Plugin for compositional data analysis.
  cutadapt            Plugin for removing adapter sequences, primers, and
                      other unwanted sequence from sequence data.
  dada2               Plugin for sequence quality control with DADA2.
  deblur              Plugin for sequence quality control with Deblur.
  demux               Plugin for demultiplexing & viewing sequence quality.
  diversity           Plugin for exploring community diversity.
  emperor             Plugin for ordination plotting with Emperor.
  feature-classifier  Plugin for taxonomic classification.
  feature-table       Plugin for working with sample by feature tables.
  gneiss              Plugin for building compositional models.
  longitudinal        Plugin for paired sample and time series analyses.
  metadata            Plugin for working with Metadata.
  phylogeny           Plugin for generating and manipulating phylogenies.
  quality-control     Plugin for quality control of feature and sequence data.
  quality-filter      Plugin for PHRED-based filtering and trimming.
  sample-classifier   Plugin for machine learning prediction of sample
  taxa                Plugin for working with feature taxonomy annotations.
  vsearch             Plugin for clustering and dereplicating with vsearch.

As a general note, this is probably not the best way to go about making changes to anything in QIIME 2 — this platform is not a collection of scripts, like QIIME 1, rather it is a framework + interfaces (q2cli for example) + plugins, all of which are independent software packages.

I suspect that the problem you are seeing here is related to the import issue you reported earlier, so let’s keep the discussion there for now. Thanks!

1 Like

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.