Loading...
Loading...
Use when implementing production-quality bioinformatics software with proper error handling, logging, testing, and documentation, following software engineering best practices.
npx skill4agent add dangeles/claude software-developerSystems Architect provides technical spec
↓
Software Developer implements
↓ (copilot reviews continuously)
Biologist Commentator validates biological correctness
↓
Production-ready software.archive-metadata.yaml~/.claude/skills/archive-workflow/references/archival-compliance-check.md80% code coverage goal
assets/package_structure_template/project_name/
├── src/
│ ├── __init__.py
│ ├── module1.py
│ ├── module2.py
│ └── cli.py
├── tests/
│ ├── test_module1.py
│ ├── test_module2.py
│ ├── fixtures/
│ └── test_data/
├── docs/
│ ├── usage.md
│ └── api.md
├── README.md
├── setup.py
├── pyproject.toml
├── requirements.txt
├── environment.yml
└── .gitignoredef calculate_cpm(counts: pd.DataFrame) -> pd.DataFrame:
"""
Calculate counts per million (CPM) normalization.
Parameters
----------
counts : pd.DataFrame
Raw count matrix (genes × samples)
Returns
-------
pd.DataFrame
CPM-normalized counts
Raises
------
ValueError
If counts contain negative values
Examples
--------
>>> counts = pd.DataFrame({'A': [10, 20], 'B': [30, 40]})
>>> cpm = calculate_cpm(counts)
>>> cpm['A'].sum() # Should be ~1,000,000
1000000.0
"""
if (counts < 0).any().any():
raise ValueError("Counts cannot be negative")
return (counts / counts.sum(axis=0)) * 1e6# ✅ Good: Informative error messages
try:
data = pd.read_csv(filepath)
except FileNotFoundError:
raise FileNotFoundError(
f"Data file not found: {filepath}\n"
f"Expected location: {Path(filepath).absolute()}"
)
except pd.errors.EmptyDataError:
raise ValueError(
f"Data file is empty: {filepath}\n"
f"Check that file was generated correctly"
)import logging
logging.basicConfig(
level=logging.INFO,
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s'
)
logger = logging.getLogger(__name__)
def process_samples(sample_list):
logger.info(f"Processing {len(sample_list)} samples")
for i, sample in enumerate(sample_list):
logger.debug(f"Processing sample {i+1}/{len(sample_list)}: {sample}")
# ... processing code ...
logger.info("Processing complete")# tests/test_normalization.py
import pytest
import pandas as pd
import numpy as np
from src.normalization import calculate_cpm
def test_cpm_sum_equals_million():
"""Test that CPM normalization sums to ~1 million."""
counts = pd.DataFrame({'A': [10, 20, 30], 'B': [40, 50, 60]})
cpm = calculate_cpm(counts)
assert np.allclose(cpm.sum(axis=0), 1e6)
def test_cpm_raises_on_negative():
"""Test that negative counts raise ValueError."""
counts = pd.DataFrame({'A': [-10, 20], 'B': [30, 40]})
with pytest.raises(ValueError, match="negative"):
calculate_cpm(counts)
def test_cpm_handles_zero_sum():
"""Test behavior when column sums to zero."""
counts = pd.DataFrame({'A': [0, 0], 'B': [10, 20]})
# Should handle gracefully (decide behavior: NaN or raise)assets/cli_template.py#!/usr/bin/env python3
"""
QC Pipeline CLI
Usage:
qc_pipeline samples.csv --output results/
"""
import click
import logging
from pathlib import Path
@click.command()
@click.argument('sample_file', type=click.Path(exists=True))
@click.option('--output', '-o', default='results/', help='Output directory')
@click.option('--threads', '-t', default=4, help='Number of threads')
@click.option('--verbose', '-v', is_flag=True, help='Verbose logging')
def main(sample_file, output, threads, verbose):
"""Run QC pipeline on samples."""
# Setup logging
level = logging.DEBUG if verbose else logging.INFO
logging.basicConfig(level=level)
logger = logging.getLogger(__name__)
# Validate inputs
output_dir = Path(output)
output_dir.mkdir(parents=True, exist_ok=True)
logger.info(f"Processing samples from {sample_file}")
logger.info(f"Output directory: {output_dir}")
logger.info(f"Using {threads} threads")
# Main logic
try:
# ... pipeline code ...
logger.info("Pipeline complete!")
except Exception as e:
logger.error(f"Pipeline failed: {e}")
raise
if __name__ == '__main__':
main()references/coding_standards.mdreferences/testing_patterns.mdreferences/error_handling_guide.mdreferences/documentation_standards.mdscripts/project_template_generator.pytest_runner.py