fqgrep ユーティリティは、任意の入力 FASTQ ファイルを検索し、塩基が 1 つ以上のパターンに一致するレコードを検索する。
grep, but for FASTQS, but now more grep-like
— Nils Homer (@nilshomer) December 14, 2022
We've done a lot of work @fulcrumgenomics to try emulate grep, but for FASTQs. Almost all of the grep command line arguments are now implemented.
Try it out and submit your bug reports. #Bioinformaticshttps://t.co/DQDo0fxGBD https://t.co/xUC115Y0vq
インストール
condaを使ってmaosに導入した。
#conda(link)
#mamba install -c bioconda fqgrep -y
> fqgrep -h
$ fqgrep -h
fqgrep 1.0.2
The fqgrep utility searches any given input FASTQ files, selecting records whose bases match one or more patterns. By
default, a pattern matches the bases in a FASTQ record if the regular expression (RE) in the pattern matches the bases.
An empty expression matches every line. Each FASTQ record that matches at least one of the patterns is written to the
standard output.
INPUT COMPRESSION
By default, the input files are assumed to be uncompressed with the following exceptions: (1) If the input files are
real files and end with `.gz` or `.bgz`, they are assumed to be GZIP compressed, or (2) if they end with `.fastq` or
`.fq`, they are assumed to be uncompressed, or (3) if the `-Z/--decompress` option is specified then any unrecongized
inputs (including standard input) are assumed to be GZIP compressed.
THREADS
The `--threads` option controls the number of threads used to _search_ the reads. Independently, for single end reads or
interleaved paired end reads, a single thread will be used to read each input FASTQ. For paired end reads across pairs
of FASTQs, two threads will be used to read the FASTQs for each end of a pair. Finally, a single thread will be created
for the writer.
EXIT STATUS
The fqgrep utility exits with one of the following values: 0 if one or more lines were selected, 1 if no lines were
selected, and >1 if an error occurred.
USAGE:
fqgrep [FLAGS] [OPTIONS] [--] [args]...
FLAGS:
-c, --count Only a count of selected lines is written to standard output
-F, --fixed-strings Interpret pattern as a set of fixed strings
-v Selected lines are those not matching any of the specified patterns
-Z, --decompress Assume all unrecognized inputs are GZIP compressed
--paired Treat the input files as paired. The number of input files must be a multiple of two,
with the first file being R1, second R2, third R1, fourth R2, and so on. If the pattern
matches either R1 or R2, then both R1 and R2 will be output (interleaved). If the input
is standard input, then treat the input as interlaved paired end reads
--reverse-complement Search the reverse complement for matches
--progress Write progress information
-h, --help Prints help information
-V, --version Prints version information
OPTIONS:
-t, --threads <threads> The number of threads to use for matching reads against pattern. See the full usage for
threads specific to reading and writing [default: 10]
--color <color> Mark up the matching text. The possible values of when are “never”, “always” and “auto”
[default: never]
-e, --regexp <regexp>... Specify a pattern used during the search of the input: an input line is selected if it
matches any of the specified patterns. This option is most useful when multiple `-e`
options are used to specify multiple patterns
-f, --file <file> Read one or more newline separated patterns from file. Empty pattern lines match every
input line. Newlines are not considered part of a pattern. If file is empty, nothing
is matched
ARGS:
<args>... The first argument is the pattern to match, with the remaining arguments containing the files to
match. If `-e` is given, then all the arguments are files to match. Use standard input if either
no files are given or `-` is given
実行方法
探索する文字列とfastqを指定する。ヒットがある時は標準出力に書き出される。gzipped.fastqにも対応している。拡張子から推測されるがGZIP圧縮と明示するには"-Z"を付ける。
#single-end
fqgrep GACGAGATTA input.fastq.gz
#paired-end
fqgrep GACGAGATTA R1.fastq.gz R2.fastq.gz
- -t <threads> The number of threads to use for matching reads against pattern. See the full usage for threads specific to reading and writing [default: 10]
-
--color <color> Mark up the matching text. The possible values of when are “never”, “always” and “auto” [default: never]
- -Z Assume all unrecognized inputs are GZIP compressed
-
--paired Treat the input files as paired. The number of input files must be a multiple of two, with the first file being R1, second R2, third R1, fourth R2, and so on. If the pattern matches either R1 or R2, then both R1 and R2 will be output (interleaved). If the input is standard input, then treat the input as interlaved paired end reads
--color をつけるとヒットした文字列部分がハイライトされる。該当するクオリティ値部分も異なる色でハイライトされる。
> fqgrep --color auto GACGAGATTA input.fastq.gz |head
fastqとして扱われるので、ヘッダ部分やクオリティ部分にはヒットしない。また、一致する文字列の出力はリード単位になる。1つのリードからの複数のヒットにも対応している。
fqgrepはデフォルトで正規表現に対応している。
#先頭のマッチ
fqgrep ^GACGAGATTA R1.fastq
OR検索は-eを使う。
fqgrep -e AC -e AGAA --color auto in.fastq
そのほか
- "-c"をつけるとヒットしたリード数のみが報告される(1つのリード内に2個以上のマッチがあった時もリード単位なので1個)。
- "-v"をつけるとヒットしないリードだけが出力される(このあたりもgrepと同じ)。
- "--reverse-complement"で逆相補が探索される。
- "--progress"で進捗が報告される。
- "-t”でマッチングに使用するスレッド数を指定できる。
- "-f <file>"で改行で区切られたパターンを含むファイルから読み込んで検索できる。
コメント
引用
https://github.com/fulcrumgenomics/fqgrep
参考