Variant analysis

From XuShuwenn/RedAct · View interactive version

Variant analysis is an AI agent skill from the GitHub repository XuShuwenn/RedAct. Parse VCF files and count variants by FILTER status. Use when users ask about VCF file parsing, variant counting, or PASS/FAIL filter statistics.

How to use this skill

Skill file

Variant Analysis: VCF Filtering and Counting

Overview

VCF (Variant Call Format) is a standard file format for storing genetic variant data. This skill covers parsing VCF files and counting variants by their FILTER status.

VCF Format

VCF files have:

FILTER column:

Parsing VCF

# Parse VCF file line by line
with open("/root/input.vcf") as f:
    for line in f:
        if line.startswith("#"):
            continue  # Skip header
        fields = line.strip().split("\t")
        chrom = fields[0]
        pos = fields[1]
        ref = fields[2]
        alt = fields[3]
        qual = fields[4]
        filt = fields[5]  # FILTER column
        info = fields[6]  # INFO column

Counting FILTER Status

total = 0
passed = 0
failed = 0

with open("/root/input.vcf") as f:
    for line in f:
        if line.startswith("#"):
            continue
        fields = line.strip().split("\t")
        filt = fields[5]  # FILTER column
        total += 1
        if filt == "PASS" or filt == ".":
            passed += 1
        else:
            failed += 1

print(f"Total variants: {total}")
print(f"Passed variants: {passed}")
print(f"Failed variants: {failed}")

Key Rules

Using PyVCF (Optional)

import vcf

reader = vcf.VCFReader(filename="/root/input.vcf")
records = list(reader)
total = len(records)
passed = sum(1 for r in records if r.FILTER is None or r.FILTER == "PASS")
failed = total - passed

Key Reference

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.