Hello, and welcome to GenePattern! If you have found yourself reading this document, then you must be interested in learning about how to develop GenePattern Modules.
Lucky for you, this is the right place to be! We have written some steps for you so that your first module development process goes as smooth as possible.
Note that for certain steps, we will include a
Without further ado, here are those steps:
Step 0.1 - If you have not already, install GenePattern locally 📝
- Selecting this option will take you to a new page where you will find a comprehensive module development interface.
We are going to be working with the
ABasicModule
repository from Github. If you have not already cloned this repository to your local machine or downloaded the files as a ZIP, do so right away at the following linkWe will be specifically working with the
.py
files under thesrc
folder.
- When developing a GenePattern Module, there are 4 essential components:
- Details
- Support Files
- Command Line
- Parameters
- We will start by filling out the Module Details (Name, Description, Author, Organization, etc.)
The module we are working with will simply be adding text to an existing
.txt
file that a user provides as an input to the GenePattern Module. We will want our module to be keptprivate
, and we will want our Docker Image to begenepattern/docker-python36
.Our docker container can be found at the following link for those interested.
Since this is our First Module, our Version Increment will be
New major version (v1)
to indicate that our module is going to start at Version 1.This module's category should be
Demo
, since our module's purpose is for demonstration / learning.The final important detail to fill out here is the output file format. Here, since our module will be adding text to an existing
.txt
file, we will choose.txt
as our output file format as well.The other details are not relatively important for the following basic module, so if the details were described above, make sure your module's details match the descriptions from above. In the future, your module(s) will involve details that are more applicable to the analyses done through GenePattern.
- In the
src
folder of theABasicModule
directory, there should be 3.py
files and 1.txt
file. - Add those files to the current module you are working on (you can drag and drop those files to the form).
- We are adding these files to the module so that your module can carry out the processes included in your
.py
files.
Since we are going to be running
.py
files, keep the command line type asCustom
.To ensure that the command line understands we are running
.py
files, typepython
in the included text box as you would in the terminal.Following the
python
prefix, press the [Space] bar once and type<libdir>ABasicModule.py
as shown here.What
<libdir>
does is it serves as a variable that the GenePattern server substitutes for the path to the working directory for where the uploaded files are stored. In basic terms, it finds your working directory of files for you!We then type
ABasicModule.py
to ensure that our module is processing this file each time it is called.
- We are almost done! Now, we need to specify the required parameters for our module.
- If you haven't already, take a look at the
ABasicModule.py
file found under thesrc
folder.
There are 4 required parameters in this
.py
file, and they are all prefaced byparser.add_argument()
.The 4 parameters we will want our module to include are:
- filename
- addtext
- message
- output_filename
For each of the 4 parameters, it is important to read through the
ABasicModule.py
file and pay special attention to each parameter's flags, input type, and default values (if any).
- The
filename
parameter's input field, unlike the other 3 parameters, should be aFile Field
. This option can be found under the drop down menu labeledType of field to display*:
. - The
File Format
should be.txt
since we will be altering the.txt
file that is passed in as a parameter. - The
addtext
parameter should have a default value ofFalse
. While writing this parameter, you should select the optionadd a drop-down list
and addTrue
to the list of values. filename
andaddtext
should have 1 minimum number of values and 1 maximum number of values. This is to ensure that a.txt
file is being processed and that a boolean value will determine whether text will be appended to the file.- Conversely,
message
andoutput_filename
will have 0 minimum number of values and 1 maximum number of values. This is because it is possible that the user wants to add nothing to the.txt
file and theoutput_filename
will have an arbitrary, default name of your choosing.
- Now that we have developed our module, it is time to scroll to the top of the screen and choose the
Save & Run
option. - We will now want to run our module and see if it works as expected.
- First, we want to go to the Home screen of your GenePattern local installation.
- Next, under
Search Modules & Pipelines
, type the name of your module - Once it shows up, select it
- You will now test it by doing the following:
- Upload
created_file_ground_truth.txt
from thesrc
folder ofABasicModule
- Set
addtext
to True - Type any message you'd like
- Type any output filename you'd like
- On the bottom-right side of the screen, click the
Run
button
- Upload
- From here, your program will (hopefully) run properly and produce a
.txt
file that includes your custom message. - To open the
.txt
file, simply click on the hyperlink named(your_file_name).txt
after your module has finished running. This will open your.txt
in a new tab on your browser.
Now that you know the basics of how to develop a GenePattern Module, you are ready to go ahead and create your own modules for GenePattern.
Best of luck with your future work!