peppy

0.40.8 · active · verified Thu Apr 16

peppy is the official Python package for reading Portable Encapsulated Projects (PEPs). It provides a Python interface for managing project metadata, including samples and their attributes. The library facilitates loading, validating, and interacting with PEP-formatted metadata. The current stable version is 0.40.8, with significant breaking changes anticipated in the upcoming 0.50.0aX releases. It maintains an active development and release cadence.

Common errors

Warnings

Install

Imports

Quickstart

Demonstrates how to initialize a `peppy.Project` object from a configuration file and access its samples and their attributes. Users should provide their own PEP configuration file.

import os
from peppy import Project

# For a runnable example, clone the example_peps repository:
# git clone https://github.com/pepkit/example_peps.git
# and adjust the path below to 'example_peps/example_basic/project_config.yaml'

# Placeholder for a project configuration file (YAML or CSV).
# In a real scenario, replace with the actual path to your PEP config.
project_path = os.environ.get('PEPPY_PROJECT_CONFIG', 'path/to/your/project_config.yaml')

try:
    # Instantiate an in-memory Project representation
    prj = Project(cfg=project_path)
    print(f"Successfully loaded Project: '{prj.name}'")
    print(f"Number of samples: {len(prj.samples)}")

    if prj.samples:
        first_sample = prj.samples[0]
        print(f"\nFirst sample name: {first_sample.sample_name}")
        # Access a sample attribute, e.g., 'protocol' or 'file'
        if 'protocol' in first_sample:
            print(f"First sample's protocol: {first_sample.protocol}")
    else:
        print("No samples found in the project.")

except FileNotFoundError:
    print(f"Error: Project configuration file not found at '{project_path}'.")
    print("Please ensure the path is correct or clone a PEP example.")
except Exception as e:
    print(f"An error occurred during project loading: {e}")

view raw JSON →