Initial commit: BtToxin Pipeline project structure

This commit is contained in:
2025-10-13 19:22:56 +08:00
commit c7744836e9
37 changed files with 1146 additions and 0 deletions

46
docker/digger/Dockerfile Normal file
View File

@@ -0,0 +1,46 @@
# BtToxin_Digger Docker 镜像
FROM continuumio/miniconda3:4.10.3
LABEL maintainer="your-email@example.com" \
description="BtToxin_Digger for Pipeline" \
version="1.0.10"
ENV LANG=C.UTF-8 \
PATH=/opt/conda/envs/bttoxin/bin:$PATH \
CONDA_DEFAULT_ENV=bttoxin \
PYTHONUNBUFFERED=1
# 配置 conda
RUN conda config --add channels defaults && \
conda config --add channels bioconda && \
conda config --add channels conda-forge && \
conda config --set channel_priority flexible && \
conda install -n base -c conda-forge mamba -y
# 安装 BtToxin_Digger
RUN mamba install -y \
python=3.7.10 \
perl=5.26.2 && \
mamba install -y \
bttoxin_digger=1.0.10 && \
conda clean -afy
# 安装额外工具
RUN apt-get update && apt-get install -y \
curl wget jq git && \
rm -rf /var/lib/apt/lists/*
# 创建工作目录
RUN mkdir -p /workspace/input /workspace/output /workspace/logs
WORKDIR /workspace
# 复制入口脚本
COPY entrypoint.sh /usr/local/bin/
RUN chmod +x /usr/local/bin/entrypoint.sh
HEALTHCHECK --interval=30s --timeout=10s --retries=3 \
CMD BtToxin_Digger --version || exit 1
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
CMD ["--help"]

84
docker/digger/entrypoint.sh Executable file
View File

@@ -0,0 +1,84 @@
#!/bin/bash
set -e
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
RED='\033[0;31m'
NC='\033[0m'
log_info() {
echo -e "${GREEN}[INFO]${NC} $1"
}
log_warn() {
echo -e "${YELLOW}[WARN]${NC} $1"
}
log_error() {
echo -e "${RED}[ERROR]${NC} $1"
}
init() {
log_info "Initializing BtToxin_Digger environment..."
if ! BtToxin_Digger --version &>/dev/null; then
log_error "BtToxin_Digger not found!"
exit 1
fi
log_info "BtToxin_Digger $(BtToxin_Digger --version)"
log_info "Python $(python --version)"
log_info "Perl $(perl --version | head -2 | tail -1)"
}
update_db() {
log_info "Updating BtToxin_Digger database..."
if BtToxin_Digger --update-db; then
log_info "Database updated successfully"
else
log_warn "Database update failed, using existing database"
fi
}
run_analysis() {
log_info "Starting toxin mining analysis..."
log_info "Input: $INPUT_PATH"
log_info "Type: $SEQUENCE_TYPE"
log_info "Threads: $THREADS"
BtToxin_Digger \
--SeqPath "$INPUT_PATH" \
--SequenceType "$SEQUENCE_TYPE" \
--Scaf_suffix "$SCAF_SUFFIX" \
--threads "$THREADS" \
2>&1 | tee /workspace/logs/digger.log
if [ $? -eq 0 ]; then
log_info "Analysis completed successfully"
else
log_error "Analysis failed!"
exit 1
fi
}
main() {
INPUT_PATH="${INPUT_PATH:-/workspace/input}"
SEQUENCE_TYPE="${SEQUENCE_TYPE:-nucl}"
SCAF_SUFFIX="${SCAF_SUFFIX:-.fna}"
THREADS="${THREADS:-4}"
UPDATE_DB="${UPDATE_DB:-false}"
init
if [ "$UPDATE_DB" = "true" ]; then
update_db
fi
if [ $# -gt 0 ]; then
exec BtToxin_Digger "$@"
else
run_analysis
fi
}
main "$@"

View File

@@ -0,0 +1,18 @@
FROM node:18-alpine as builder
WORKDIR /app
COPY frontend/package*.json ./
RUN npm ci
COPY frontend/ .
RUN npm run build
FROM nginx:alpine
COPY --from=builder /app/dist /usr/share/nginx/html
COPY docker/frontend/nginx.conf /etc/nginx/conf.d/default.conf
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]

View File

@@ -0,0 +1,24 @@
server {
listen 80;
server_name localhost;
root /usr/share/nginx/html;
index index.html;
location / {
try_files $uri $uri/ /index.html;
}
location /api {
proxy_pass http://backend:8000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
location /ws {
proxy_pass http://backend:8000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
}

25
docker/worker/Dockerfile Normal file
View File

@@ -0,0 +1,25 @@
FROM python:3.10-slim
WORKDIR /app
# 安装系统依赖
RUN apt-get update && apt-get install -y \
gcc \
curl \
&& rm -rf /var/lib/apt/lists/*
# 安装 Docker CLI
RUN curl -fsSL https://get.docker.com -o get-docker.sh && \
sh get-docker.sh && \
rm get-docker.sh
# 复制依赖文件
COPY backend/requirements.txt .
# 安装 Python 依赖
RUN pip install --no-cache-dir -r requirements.txt
# 复制应用代码
COPY backend/ .
CMD ["celery", "-A", "app.core.celery_app", "worker", "--loglevel=info"]