samfilter

command module
v0.0.0-...-33799e1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 3, 2026 License: 0BSD Imports: 11 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

samfilter

CI Go Reference Go Report Card

A fast, simple utility to filter SAM files by read ID.

Usage

samfilter <read_ids.txt> < input.sam > output.sam
  • read_ids.txt — a text file with one read ID per line
  • Blank lines and comment lines starting with # are ignored
  • Reads a SAM file from stdin
  • Writes filtered SAM output to stdout
  • Header lines (@ prefix) are always passed through
  • Only alignment records with a QNAME matching one of the provided IDs are included

Install

go install github.com/taigrr/samfilter@latest

Example

# Extract specific reads from a SAM file
echo -e "read_001\nread_042\nread_999" > my_ids.txt
samtools view -h input.bam | samfilter my_ids.txt > filtered.sam

Features

  • Sorted binary search for fast ID lookup
  • Automatic deduplication of input IDs
  • Handles whitespace and empty lines in ID files
  • 10 MB line buffer for long SAM records
  • Buffered I/O for efficient streaming
  • GitHub Actions CI running tests and staticcheck on pushes and pull requests

License

0BSD

Documentation

Overview

samfilter extracts entries from a SAM file based on a list of read IDs.

It reads a SAM file from stdin, filters lines whose read ID appears in the provided ID list file, and writes matching entries to stdout. Header lines (starting with @) are always passed through.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址