Skip to main content

A Flask server for Biosynthetic Gene Cluster analysis

Project description

BGC-Viewer

!!Work-in-progress!!

A viewer for BGC data.

Project Structure

bgc-viewer/
├── bgc_viewer/
│   ├── __init__.py
│   ├── app.py              # Main Flask application
│   ├── static/
│   │   └── style.css       # Styling
│   │   └── app.js          # Frontend JavaScript
│   └── templates/
│       └── index.html      # Main HTML template
├── data/
│   └── custom_data.json    # Optional custom data file
├── tests/
│   └── test_app.py         # Test files
├── pyproject.toml          # Project configuration
├── README.md
└── .gitignore

Setup

Prerequisites

  • Python 3.8+
  • uv package manager

Installation

  1. Clone or create the project directory:

    mkdir bgc-viewer
    cd bgc-viewer
    
  2. Create the project structure and files (as shown above)

  3. Initialize the project with uv:

    uv venv
    source .venv/bin/activate  # On Windows: .venv\Scripts\activate
    uv pip install -e .
    
  4. For development dependencies:

    uv pip install -e ".[dev]"
    

Usage

Running the Server

# Using the console script
serve

# Or directly with Python
python -m bgc_viewer.app

# Or with environment variables
FLASK_DEBUG=true PORT=8000 serve

The server will start on http://localhost:5005 by default.

API Endpoints

  • GET / - Main HTML page with interactive API tester
  • GET /api/data - Get all custom data
  • GET /api/users - Get user list
  • GET /api/users/<id> - Get specific user
  • GET /api/stats - Get application statistics
  • GET /api/health - Health check endpoint

Testing the API

Visit http://localhost:5005 in your browser to access the interactive API tester, or use curl:

# Get all data
curl http://localhost:5005/api/data

# Get users
curl http://localhost:5005/api/users

# Get specific user
curl http://localhost:5005/api/users/1

# Health check
curl http://localhost:5005/api/health

Development

Code Formatting

# Format code
uv run black bgc_viewer/

# Lint code
uv run flake8 bgc_viewer/

# Type checking
uv run mypy bgc_viewer/

Testing

# Run tests
uv run pytest

# Run tests with coverage
uv run pytest --cov=bgc_viewer

Adding Custom Data

  1. Create a data/custom_data.json file with your data structure
  2. Modify the load_custom_data() function in app.py to read from your data source
  3. Update the API endpoints to serve your custom data

Customization

Adding New Endpoints

  1. Add new route functions to app.py
  2. Update the HTML template to include new endpoints
  3. Add corresponding JavaScript functions if needed

Styling

Modify static/css/style.css to customize the appearance of the web interface.

Frontend Behavior

Update static/js/app.js to add new interactive features.

Environment Variables

Environment variables can be set to change the configuration of the viewer. A convenient way to change them is to put a file called .env in the directory from which you are running the application.

  • BGCV_HOST - Server host (default: localhost)
  • BGCV_PORT - Server port (default: 5005)
  • BGCV_DEBUG_MODE - Enable dev/debug mode (default: False)

License

Apache 2.0

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

bgc_viewer-0.1.1-py3-none-any.whl (63.0 kB view details)

Uploaded Python 3

File details

Details for the file bgc_viewer-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: bgc_viewer-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 63.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.7.13

File hashes

Hashes for bgc_viewer-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 75f7c0b54129882fce4f951e9929122e4d4eb7fa50c450de7f94bafd73469c0f
MD5 9c7074a9b43cc0e2e5aba1f47f01653a
BLAKE2b-256 f2ced698d6761f4e8281949a04f9673bc0fcdbc2b0f4bfab5cf9c38430a5a7ae

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page