# Development of q2-pathway plugin

**URL:** <https://forum.qiime2.org/t/development-of-q2-pathway-plugin/30429>\
**Category:** Developer Discussion\
**Tags:** plugin-development\
**Created:** [June 7, 2024, 10:12am UTC](https://forum.qiime2.org/t/development-of-q2-pathway-plugin/30429 "2024-06-07T10:12:47Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![nsato](https://forum.qiime2.org/letter_avatar_proxy/v4/letter/n/d2c977/32.png) [@nsato](https://forum.qiime2.org/u/nsato)\
**Post date:** [June 7, 2024, 10:12am UTC](https://forum.qiime2.org/t/development-of-q2-pathway-plugin/30429/1 "2024-06-07T10:12:47Z")

</div>

Hi,

I have recently made a `q2-pathway` plugin, which is capable of:

- Inference of functional profiles (gene family abundance) from 16S rRNA gene sequencing data
- Comparison and summarization of multiple functional profiles including those from `q2-sapienns` and `q2-picrust2`
- Gene set enrichment analysis based on user-specified ranking of gene family abundances
- Visualization of biological pathway information

The GitHub repository for the package is:

> **[GitHub - noriakis/q2-pathway: The unified functional prediction and comparative...](https://github.com/noriakis/q2-pathway)**
>
> The unified functional prediction and comparative analysis for 16S rRNA gene sequencing data

The package is currently being developed, and I'm seeking feedback from this active community.  
There should be much room for improvement, and I would be grateful if you could try the plugin and provide bug reports or feature suggestions.

Also, I would like to ask the following specific question regarding the development.

Currently, to use Tax4Fun2 inference, the users must provide the path to the reference database bundled with the Tax4Fun2 library. However, the plugin development guide indicated this behavior should be avoided. I am thinking of installing the database and library by making the visualizers of the name `install`, which downloads and installs the databases in the predefined location. I would be grateful if you could let me know the better way for handling this situation.

---

<div class="post-metadata">

**Author:** ![gregcaporaso](https://forum.qiime2.org/user_avatar/forum.qiime2.org/gregcaporaso/32/17769_2.png) [@gregcaporaso](https://forum.qiime2.org/u/gregcaporaso)\
**Post date:** [June 8, 2024, 12:54pm UTC](https://forum.qiime2.org/t/development-of-q2-pathway-plugin/30429/2 "2024-06-08T12:54:33Z")

</div>

Hi @nsato, Thanks for sharing q2-pathway - I look forward to trying it out once I get a grant proposal that I'm working on behind me!

Ideally you will create a new Artifact Class for the database (I'm guessing you've seen the docs on this already, but see [here](https://develop.qiime2.org/en/latest/plugins/tutorials/add-artifact-class.html) if not). Once you've done this, you can obtain the path when viewing an Artifact of that class as a [`DirectoryFormat`](https://develop.qiime2.org/en/latest/back-matter/glossary.html#term-Directory-Format) subtype.

Here's an example that works in an environment based on the [`q2-dwq2` example plugin](https://github.com/caporaso-lab/q2-dwq2) from the book.

First, let's load an Artifact of type `SingleDNASequence`. (Here's that artifact: [query.qza](https://forum.qiime2.org/uploads/short-url/gJ29Yx8wzoOipz7CRiitOFYYJKI.qza); 6.3 KB.)

```python
In [1]: import qiime2
In [2]: a = qiime2.Artifact.load('./query.qza')

```

Then, lets import the `DirectoryFormat` that we want to view it as. When defining your `Action`, this would be the view type that you associated with the input, for example in place of `DNA` [here](https://github.com/caporaso-lab/q2-dwq2/blob/1e601c41b86d98b22f4e16685e868f1c5710f3bf/q2_dwq2/_methods.py#L21).

```python
In [3]: from q2_dwq2 import SingleRecordDNAFASTADirectoryFormat

```

Internal to your Action, you would then have a `DirectoryFormat` view of the Artifact - the same as if we call `view` on it as follows:

```python
In [4]: d = a.view(SingleRecordDNAFASTADirectoryFormat)

```

You can then get the path to provide to your Tax4Fun2 call as follows:

```python
In [5]: d.path
Out[5]: InPath('/var/folders/1t/w4ys4pks4q5d5_kl7svl4t080000gn/T/qiime2/jgc/data/43edeffd-28f4-452d-a3a3-7903df851cd1/data') 

```

Does that get you what you need?

Once you get that working, you might next wonder if you can avoid the overhead of unzipping that database every time you use it. For this, the QIIME 2 artifact cache is key. We're working on some new docs that will cover this. In the meantime, @Oddant1, can you recommend the best resource for seeing how to use an Artifact Cache?

---

<div class="post-metadata">

**Author:** ![gregcaporaso](https://forum.qiime2.org/user_avatar/forum.qiime2.org/gregcaporaso/32/17769_2.png) [@gregcaporaso](https://forum.qiime2.org/u/gregcaporaso)\
**Post date:** [June 8, 2024, 1:10pm UTC](https://forum.qiime2.org/t/development-of-q2-pathway-plugin/30429/4 "2024-06-08T13:10:00Z")

</div>



---

<div class="post-metadata">

**Author:** ![Oddant1](https://forum.qiime2.org/user_avatar/forum.qiime2.org/oddant1/32/17130_2.png) [@Oddant1](https://forum.qiime2.org/u/Oddant1)\
**Post date:** [June 10, 2024, 6:03pm UTC](https://forum.qiime2.org/t/development-of-q2-pathway-plugin/30429/5 "2024-06-10T18:03:23Z")

</div>

@nsato [this](https://forum.qiime2.org/t/artifact-cache-basic-instructions/30453) tutorial provides some basic instructions on what the artifact cache is and how to use it. We should have more complete documentation soon. It can do a lot more than what is currently in that basic tutorial.

It should allow you to use your large artifacts without so much overhead from zipping and unzipping them and moving them around on your file system.

---

<div class="post-metadata">

**Author:** ![nsato](https://forum.qiime2.org/letter_avatar_proxy/v4/letter/n/d2c977/32.png) [@nsato](https://forum.qiime2.org/u/nsato)\
**Post date:** [June 11, 2024, 4:03am UTC](https://forum.qiime2.org/t/development-of-q2-pathway-plugin/30429/8 "2024-06-11T04:03:22Z")

</div>

Dear @gregcaporaso,

Thank you very much for your reply, and I am very happy that you are going to try the plugin when you have time.

For creating the new Artifact Class and viewing them in a `DirectoryFormat`, thank you for your detailed instruction about how to make and call them inside the function. I will try to implement a new class based on your guidance and documentation you referred to, and update the plugin.

Also, thank you for letting me know that Artifact Cache functionality exists. I will definitely use this feature due to the large file size as you mentioned.

---

<div class="post-metadata">

**Author:** ![nsato](https://forum.qiime2.org/letter_avatar_proxy/v4/letter/n/d2c977/32.png) [@nsato](https://forum.qiime2.org/u/nsato)\
**Post date:** [June 11, 2024, 4:03am UTC](https://forum.qiime2.org/t/development-of-q2-pathway-plugin/30429/9 "2024-06-11T04:03:31Z")

</div>

Dear @Oddant1,

Thank you very much for pointing me to the Artifact Cache tutorial post. I will definitely use this feature and report back to you if there are some questions.

---

<div class="post-metadata">

**Author:** ![lizgehret](https://forum.qiime2.org/user_avatar/forum.qiime2.org/lizgehret/32/17128_2.png) [@lizgehret](https://forum.qiime2.org/u/lizgehret)\
**Post date:** [June 11, 2024, 4:03am UTC](https://forum.qiime2.org/t/development-of-q2-pathway-plugin/30429/10 "2024-06-11T04:03:58Z")

</div>


