Skip to content

A phylogenic tree pruning AppEngine app.

VertLife/tree-pruner

Repository files navigation

Tree Pruner - Go 1.25

A phylogenetic tree pruning App Engine application written in Go 1.25.

What it does

Tree Pruner is a Google App Engine web application designed for phylogenetic tree pruning. It's part of the "Map of Life" project and specifically works with bird and shark phylogenetic trees from BirdTree.org and SharkTree.org.

Key Features:

  1. Phylogenetic Tree Pruning: Takes large phylogenetic trees and creates smaller, pruned versions containing only the species you specify
  2. Multiple Tree Sets: Supports various tree sets including:
    • Ericson trees (All Species and Sequenced Species)
    • Hackett trees (All Species and Sequenced Species)
    • Stage2 trees with different configurations
  3. Random Sampling: Randomly samples from up to 10,000 trees in a given tree set
  4. Cloud Storage Integration: Uses Google Cloud Storage to store input trees and output results
  5. Web API: Provides REST endpoints for submitting jobs and checking results

Workflow:

  1. User submits a request with species names, tree set, sample size, and email
  2. System randomly selects trees from the specified tree set
  3. Each tree is pruned to contain only the requested species
  4. Results are compiled into a single output file
  5. User receives download link for results

How to run it

Prerequisites:

  • Go 1.25 or later
  • Google Cloud SDK
  • Access to Google Cloud Storage
  • A Google Cloud project with App Engine enabled

Setup:

  1. Install Go 1.25:

    # Download and install Go 1.25 from https://golang.org/dl/
    go version  # Should show go1.25.x
  2. Set up Google Cloud Storage - the app expects specific bucket structure:

    • /data.vertlife.org/processing/{tree_base}/sources/single_trees/ for input trees
    • /data.vertlife.org/pruned_treesets/ for output results
  3. Install dependencies:

    go mod tidy

Running locally:

# Set up authentication
export GOOGLE_APPLICATION_CREDENTIALS="path/to/your/service-account-key.json"

# Run the application
go run main.go

The app will be available at http://localhost:8080

API Endpoints:

  1. Submit pruning job: POST /api/prune

    • Parameters: sample_size, tree_base, tree_set, species, email
    • Example:
      http://localhost:8080/api/prune?sample_size=100&tree_set=EricsonStage1Full&species=Tinamus%20tao,Tinamus%20solitarius,Tinamus%20osgoodi,Tinamus%20major,Tinamus%20guttatus&email=user@example.com
      
  2. Check job status: GET /api/result

    • Parameters: job_id, email
    • Returns job status and download URL when complete
  3. Health check: GET /

    • Returns service health status

Deployment:

# Deploy to Google App Engine
gcloud app deploy app.yaml

Key Changes from Python Version

  1. Language: Migrated from Python 2.7 to Go 1.25
  2. Framework: Replaced webapp2 with Gorilla Mux
  3. Storage: Updated to use Google Cloud Storage Go client library
  4. Performance: Go's compiled nature provides better performance
  5. Concurrency: Native goroutines for better concurrent processing
  6. Type Safety: Strong typing helps prevent runtime errors

Architecture

  • main.go: Main application with HTTP handlers
  • app.yaml: App Engine configuration for Go 1.25
  • go.mod: Go module dependencies
  • Cloud Storage: Used for storing input trees and output results
  • Background Processing: Uses goroutines for async job processing

Notes

  • This is a simplified version that simulates tree pruning
  • In production, you'd integrate with actual phylogenetic tree libraries
  • The application maintains the same API interface as the original Python version
  • All file operations use Google Cloud Storage instead of local filesystem

About

A phylogenic tree pruning AppEngine app.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •