← Về thư mục
📄 / / profiles / r-and-d / raw_evidence / OpenAI4S / skills / bioskills / bio-sequence-io-paired-end-fastq / references / usage-guide.md

Paired-End FASTQ - Usage Guide

Overview

This skill enables AI agents to help work with paired-end sequencing data (R1/R2 files) using Biopython, keeping mates synchronized so downstream aligners pair the right reads.

Prerequisites

pip install biopython

Quick Start

Tell your AI agent what you want to do:

Example Prompts

Synchronized Filtering

"Filter my paired FASTQ files keeping pairs where both reads have mean quality >= 30, and route reads whose mate was discarded into orphan files"

Interleaving

"Combine reads_R1.fastq and reads_R2.fastq into an interleaved file, R1 then R2 alternating"

Deinterleaving

"Split this interleaved FASTQ back into separate R1 and R2 files and confirm the alternation was intact"

Validation

"Check if my R1 and R2 files have matching read counts and whether the read names still match as pairs"

Mate Matching

"My reads use the CASAVA 1.8 header format; match R1 and R2 by the ID before the space"

Common Naming Patterns

Pattern R1 R2
Illumina sample_R1_001.fastq sample_R2_001.fastq
Simple sample_1.fastq sample_2.fastq
Underscore sample_R1.fastq sample_R2.fastq
Dotted sample.R1.fastq.gz sample.R2.fastq.gz

Read-Name Conventions

Era Mate marker Example
Pre-CASAVA 1.8 /1, /2 suffix on the name @HWUSI-EAS100R:6:73:941:1973#0/1
CASAVA 1.8+ second field after a space @EAS139:136:FC706VJ:2:2104:15343:197393 1:Y:18:ATCACG

In CASAVA 1.8+, the ID before the space is identical for both mates; tools match on that shared ID.

What the Agent Will Do

  1. Open both R1 and R2 FASTQ files (handling gzip if needed)
  2. Iterate paired records in lockstep with zip
  3. Verify pairing by matching the read ID up to the first space (and stripping /1//2)
  4. Apply any filter to BOTH mates, routing lone survivors to orphan files
  5. Interleave, deinterleave, or report paired statistics as requested

Tips