Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions regression/rt-cetsa-moltprot-tool/.bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
[bumpversion]
current_version = 0.1.0
commit = True
tag = False
parse = (?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)(\-(?P<release>[a-z]+)(?P<dev>\d+))?
serialize =
{major}.{minor}.{patch}-{release}{dev}
{major}.{minor}.{patch}

[bumpversion:part:release]
optional_value = _
first_value = dev
values =
dev
_

[bumpversion:part:dev]

[bumpversion:file:pyproject.toml]
search = version = "{current_version}"
replace = version = "{new_version}"

[bumpversion:file:plugin.json]

[bumpversion:file:VERSION]

[bumpversion:file:README.md]

[bumpversion:file:src/polus/tabular/regression/rt_cetsa_moltprot/__init__.py]

[bumpversion:file:ict.yml]
20 changes: 20 additions & 0 deletions regression/rt-cetsa-moltprot-tool/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
FROM polusai/bfio:2.3.6

# environment variables defined in polusai/bfio
ENV EXEC_DIR="/opt/executables"
ENV POLUS_IMG_EXT=".ome.tif"
ENV POLUS_TAB_EXT=".arrow"
ENV POLUS_LOG="INFO"

# Work directory defined in the base container
WORKDIR ${EXEC_DIR}

COPY pyproject.toml ${EXEC_DIR}
COPY VERSION ${EXEC_DIR}
COPY README.md ${EXEC_DIR}
COPY src ${EXEC_DIR}/src

RUN pip3 install ${EXEC_DIR} --no-cache-dir

ENTRYPOINT ["python3", "-m", "polus.tabular.regression.rt_cetsa_moltprot"]
CMD ["--help"]
24 changes: 24 additions & 0 deletions regression/rt-cetsa-moltprot-tool/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# RT_CETSA Moltprot Regression (v0.1.0)

This WIPP plugin runs regression analysis for the RT-CETSA pipeline.
The input csv file should be sorted by `Temperature` column.

## Building

To build the Docker image for the conversion plugin, run
`./build-docker.sh`.

## Install WIPP Plugin

If WIPP is running, navigate to the plugins page and add a new plugin. Paste the contents of `plugin.json` into the pop-up window and submit.

## Options

This plugin takes eight input argument and one output argument:

| Name | Description | I/O | Type |
|-------------|----------------------------------------------------|--------|-------------|
| `--inpDir` | Input data collection to be processed by this tool | Input | genericData |
| `--pattern` | Pattern to parse input files | Input | string |
| `--outDir` | Output file | Output | genericData |
| `--preview` | Generate JSON file with outputs | Output | JSON |
1 change: 1 addition & 0 deletions regression/rt-cetsa-moltprot-tool/VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.1.0
51 changes: 51 additions & 0 deletions regression/rt-cetsa-moltprot-tool/ict.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
author:
- Nick Schaub
- Najib Ishaq
contact: nick.schaub@nih.gov
container: polusai/rt-cetsa-moltprot-tool:0.1.0
description: Run regression analysis for the RT-CETSA pipeline.
entrypoint: python3 -m polus.tabular.regression.rt_cetsa_moltprot
inputs:
- description: Input data collection to be processed by this tool
format:
- inpDir
name: inpDir
required: true
type: path
- description: Filepattern to parse input files
format:
- pattern
name: pattern
required: false
type: string
- description: Generate an output preview.
format:
- preview
name: preview
required: false
type: boolean
name: polusai/RTCETSAMoltprot
outputs:
- description: Output collection
format:
- outDir
name: outDir
required: true
type: path
repository: https://github.com/PolusAI/tabular-tools
specVersion: 1.0.0
title: RT-CETSA Moltprot
ui:
- description: Input data collection
key: inputs.inpDir
title: Input data collection
type: path
- description: Filepattern to parse input files
key: inputs.pattern
title: pattern
type: text
- description: Generate an output preview.
key: inputs.preview
title: Preview example output of this plugin
type: checkbox
version: 0.1.0
52 changes: 52 additions & 0 deletions regression/rt-cetsa-moltprot-tool/plugin.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{
"name": "RT-CETSA Moltprot",
"version": "0.1.0",
"title": "RT-CETSA Moltprot",
"description": "Run regression analysis for the RT-CETSA pipeline.",
"author": "Nicholas Schaub (nick.schaub@nih.gov), Najib Ishaq (najib.ishaq@nih.gov)",
"institution": "National Center for Advancing Translational Sciences, National Institutes of Health",
"repository": "https://github.com/PolusAI/tabular-tools",
"website": "https://ncats.nih.gov/preclinical/core/informatics",
"citation": "",
"containerId": "polusai/rt-cetsa-moltprot-tool:0.1.0",
"baseCommand": [
"python3",
"-m",
"polus.tabular.regression.rt_cetsa_moltprot"
],
"inputs": [
{
"name": "inpDir",
"type": "genericData",
"description": "Input data collection to be processed by this tool",
"required": true
},
{
"name": "pattern",
"type": "string",
"description": "Pattern to parse input files",
"default": ".+",
"required": false
}
],
"outputs": [
{
"name": "outDir",
"type": "genericData",
"description": "Output data collection"
}
],
"ui": [
{
"key": "inputs.inpDir",
"title": "Input collection",
"description": "Input data collection to be processed by this plugin"
},
{
"key": "inputs.pattern",
"title": "pattern",
"description": "Pattern to parse input files",
"default": ".+"
}
]
}
76 changes: 76 additions & 0 deletions regression/rt-cetsa-moltprot-tool/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
[tool.poetry]
name = "polus_tabular_regression_rt_cetsa_moltprot"
version = "0.1.0"
description = "Run regression analysis for the RT-CETSA pipeline."
authors = [
"Nick Schaub <nick.schaub@nih.gov>",
"Najib Ishaq <najib.ishaq@nih.gov>",
]
readme = "README.md"
packages = [{include = "polus", from = "src"}]

[tool.poetry.dependencies]
python = ">=3.9,<3.12"
typer = "^0.7.0"
filepattern = "^2.0.5"
pandas = "^2.2.2"
matplotlib = "^3.8.4"
scipy = "^1.13.0"

[tool.poetry.group.dev.dependencies]
bump2version = "^1.0.1"
pre-commit = "^3.1.0"
pytest = "^7.2.1"

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"

[tool.ruff]
extend = "../../ruff.toml"
extend-ignore = [
"RET505", # Unnecessary `else` after `return` statement
"E501", # Line too long
"ANN001", # Missing type annotation
"D102", # Missing docstring in public method
"ANN201", # Missing return type annotation
"N806", # Variable in function should be lowercase
"D205", # 1 blank line required between summary line and description
"N803", # Argument name should be lowercase
"PLR0913", # Too many arguments
"D415", # First line should end with a period, question mark, or exclamation point
"PLR2004", # Magic value used in comparison
"B006", # Do not use mutable default arguments
"D107", # Missing docstring
"D101", # Missing docstring
"E731", # Do not assign a lambda expression, use a def
"E402", # Module level import not at top of file
"PTH123", # `open()` should be replaced with `Path.open()`
"PTH118", # `os.path.join()` should be replaced with `/` operator
"PTH100", # `os.path.abspath()` should be replaced with `Path.resolve()`
"PLR0915", # Too many statements
"PLR0912", # Too many branches
"C901", # Function is too complex
"T201", # `print` used
"E722", # Do not use bare 'except'
"B904", # Within an `except` clause, raise exceptions with `raise ... from err` or `raise ... from None` to distinguish them from errors in exception handling
"ANN202", # Missing return type annotation for private function
"ARG002", # Unused method argument
"N802", # Function name should be lowercase
"PTH103", # `os.makedirs()` should be replaced with `Path.mkdir(parents=True)`
"ANN003", # Missing type annotation for `**kwargs`
"B007", # Loop control variable not used within the loop body
"ANN204", # Missing return type annotation for magic method
"D417", # Missing argument descriptions in the docstring
"ANN205", # Missing return type annotation for static method
"PLR5501", # Use `elif` instead of `else` following `if` condition to avoid unnecessary indentation
"EM102", # Exception must not use an f-string literal
"D414", # Section has no content
"RUF012", # Mutable class attributes should be annotated with `typing.ClassVar`
"A001", # Variable `input` is shadowing a Python builtin
"A002", # Argument `input` is shadowing a Python builtin
"E741", # Ambiguous variable name: `l`
"PTH120", # `os.path.dirname()` should be replaced by `Path.parent`
"N816", # Variable `cfFilename` in global scope should not be mixedCase
"PTH109", # `os.getcwd()` should be replaced by `Path.cwd()`
]
20 changes: 20 additions & 0 deletions regression/rt-cetsa-moltprot-tool/run-plugin.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash
version=$(<VERSION)
datapath=$(readlink --canonicalize data)

# Inputs
inpDir=/data/input
pattern=".*"

# Output paths
outDir=/data/output

# Log level, must be one of ERROR, CRITICAL, WARNING, INFO, DEBUG
LOGLEVEL=INFO

docker run --mount type=bind,source=${datapath},target=/data/ \
--env POLUS_LOG=${LOGLEVEL} \
polusai/rt-cetsa-moltprot-tool:${version} \
--inpDir ${inpDir} \
--pattern ${pattern} \
--outDir ${outDir}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.3.1-alpha
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
"""RT_CETSA Moltprot Regression Tool."""

__version__ = "0.1.0"

import os
import pathlib

import pandas

from . import core
from . import models

POLUS_TAB_EXT = os.environ.get("POLUS_TAB_EXT", ".csv")


def fit_data(
file_path: pathlib.Path,
params: dict[str, float],
) -> pandas.DataFrame:
"""Fit data to a model using Moltprot."""
fit = core.MoltenProtFit(
filename=file_path,
input_type="csv",
)

fit.SetAnalysisOptions(
model="santoro1988",
blanks=[],
exclude=[],
invert=False,
mfilt=None,
shrink=None,
**params,
)

fit.PrepareData()
fit.ProcessData()

return fit.plate_results.sort_values("BS_factor")


def gen_out_path(file_path: pathlib.Path, out_dir: pathlib.Path) -> pathlib.Path:
"""Generate the output path."""
file_name = file_path.stem + "_moltprot" + POLUS_TAB_EXT
return out_dir / file_name
Loading