Skip to main content
Loading navigation
Back to prompt library

Build a Biopython FASTA Cleanser and IUPAC Code Quality Auditor — implementation

Linked challenge: Build a Biopython FASTA Cleanser and IUPAC Code Quality Auditor

Prompt source

implementation66 lines11 sectionsNo variables1 code block
## Build
Audit high-throughput FASTA sequence submissions for non-standard nucleotide characters and low-complexity regions. Generate structured FHIR DiagnosticReport payloads with quality metrics.

## User
Sequencing Core Analyst

## Workflow
1. Read uploaded multi-FASTA files using Biopython SeqIO parsing iterators.
2. Identify ambiguous IUPAC nucleotide symbols, degenerate stretches, and uncalled base runs.
3. Compute per-sequence GC percentage, sequence length, and ambiguous character frequencies.
4. Construct FHIR Molecular Observation entries detailing quality scores for bioinformatic pipelines.

## Interface
Interactive upload web portal with real-time sequence quality charts and downloadable audit reports.

## Data
Generate synthetic FASTA files with intentional IUPAC ambiguous characters (N, R, Y, S, W) locally.
Starter examples below are synthetic. They are not downloaded records.

## Source
[Biopython](https://raw.githubusercontent.com/biopython/biopython/master/README.rst)
Uses Biopython Bio.SeqIO and sequence manipulation methods described in Biopython README and documentation.

## Tools
langfuse, biopython, fastapi.
Tracks audit latency, quality parameter distributions, and sequence drift metrics across incoming batches.
Lightweight hosted language model for summarizing sequence anomaly reports into natural language.

## Deliverables
Submit runnable source, pinned dependencies, setup commands, a working interface, example outputs, and a recorded end-to-end demo. Include tests and an action log.

## Acceptance
- Flags non-IUPAC characters and calculates ambiguous base percentages accurately.
- Serializes sequence quality statistics into valid FHIR Molecular Observation resources.
- Processes multi-record FASTA files streaming line-by-line without high memory consumption.

## Starter Examples
```json
[
  {
    "input": {
      "record_id": "SEQ-001",
      "sequence": "ATGCGTACCGGTTACGTACCGTTAGGCTAGCTAGGCTACGTACGTAGCTAGCTAG"
    },
    "expected_output": {
      "record_id": "SEQ-001",
      "length_bp": 56,
      "gc_content_pct": 51.79,
      "ambiguous_count": 0,
      "pass_qc": true,
      "fhir_observation_status": "final"
    }
  },
  {
    "input": {
      "record_id": "SEQ-002",
      "sequence": "ATGCGNNNNCGGTTRYSTAGCTAGZZZCTAG"
    },
    "expected_output": {
      "record_id": "SEQ-002",
      "length_bp": 31,
      "gc_content_pct": 38.71,
      "ambiguous_count": 8,
      "invalid_chars": [
        "Z"
      ],
      "pass_qc": false,
      "fhir_observation_status": "preliminary"
    }
  }
]
```

## Safety
Quality assurance on research and de-identified sequencing data only; no medical decision support.
Use mock external writes. Require human review before any real deployment.