SNAP: Simulation of Nuclear and Affected Pedigrees

A powerful web-based tool for generating synthetic genetic datasets for statistical genetics research.

About SNAP

SNAP (Simulation of Nuclear and Affected Pedigrees) is a web-based software tool developed to assist researchers in statistical genetics. Hosted at https://statgen.uni-koeln.de/, SNAP enables the simulation of genetic data for case-control studies, family-based studies, and other genetic analyses. By specifying study designs, sampling strategies, and genotype-phenotype models, users can generate synthetic datasets tailored to their research needs.

SNAP is designed to be user-friendly, with a web interface for input configuration and a robust backend for processing simulations. It produces settings files, data outputs, and logs, which are downloadable for approximately 24 hours.

Key Functionalities

Input Processing

Accepts JSON configurations via a web interface, allowing users to specify simulation parameters such as study design, phenotype type, and haplotype blocks.

Settings File Generation

Creates structured settings files with sections for general settings, study design, sex and age distributions, models, separators, and haplotype blocks.

Simulation Execution

Runs SNAP binaries (v3.1 or v2.6.1) to generate synthetic genetic data based on user inputs, producing data files and logs.

Output Handling

Provides download links for settings files, data outputs, modified settings logs, and a compressed archive, accessible for 24 hours.

Error Handling

Validates inputs, logs errors, and displays user-friendly messages for issues like invalid JSON or simulation failures.

File Cleanup

Automatically deletes temporary files older than 24 hours to manage server disk space.

Requirements

Functional Requirements

  • Handle JSON input (SNAP_JSON) for simulation parameters.
  • Support study designs: individuals (case-control or joint) and nuclear-families (fixed or random).
  • Allow phenotype types: qualitative or quantitative.
  • Generate settings (.set), data (.dat), log (.log), and error (.txt) files.
  • Provide download links for outputs, valid for ~24 hours.
  • Validate inputs and handle errors gracefully.

Technical Requirements

  • PHP 7.x+ with error reporting (E_ALL).
  • Apache server with write access to /var/www/html/statgen.uni-koeln.de/software/snap/.
  • SNAP binaries (snap3.1, snap2.6.1) in snap/run/.
  • Temporary directory: snap/temp/.
  • Error log: snap/run_error.log.
  • Client-side: HTML/JavaScript with Bootstrap and Bootstrap Icons.

Non-Functional Requirements

  • Performance: Fast processing of inputs and simulations.
  • Security: Sanitize filenames, set strict file permissions.
  • Reliability: Robust error handling for malformed inputs.
  • Maintainability: Modular PHP code with logging.

Technical Structure

The core of SNAP is a PHP backend script (run.php) that processes user inputs and executes simulations. Below is an overview of its structure:

Backend (run.php)

  • Configuration: Defines paths, SNAP version, and cleanup timeout.
  • Helper Functions:
    • logError: Logs errors to run_error.log.
    • sanitizeFilename: Secures filenames.
    • writeSection: Writes settings file sections.
    • getArrayValue: Safely accesses array values.
    • search_temp: Finds unique temp directories.
  • Core Functions:
    • generateSettingsFile: Creates settings file with sections: [General], [Design], [SexAge], [Model], [Separators], [Blocks].
    • buildHTML: Processes JSON, runs SNAP, and generates output HTML.

Input (SNAP_JSON)

JSON structure stored in localStorage, sent via AJAX:

  • SnapSettings: Filenames, output types, separators.
  • DesignData: Study design, phenotype, sampling, counts.
  • SexAgeData: Sex ratio, age distributions.
  • ModelData: Genotype-phenotype models, penetrances.
  • HaplotypeBloks: Haplotype block configurations.

Outputs

  • settings.set: Simulation parameters.
  • data.dat: Simulated genetic data.
  • settings_log.log: Modified settings.
  • stderr.txt: SNAP errors/warnings.
  • snap.tgz: Archive of all files.

Recent Updates

SNAP has been enhanced to improve reliability and alignment with user needs, based on feedback and example settings: