参考:Y 叔叔的推文
https://mp.weixin.qq.com/s?__biz=MzI5NjUyNzkxMg==&mid=2247485778&idx=1&sn=3593db9995356c34c68f5b1e76ae4298&chksm=ec43b815db343103e51f7e3e59759e4918b173fcd82f3aeea3438493d71ab8b8a6fae6580592&cur_album_id=1300605020534112257&scene=189#rd
使用场景
这里可以借鉴bioview 作者的原话:
比如在有些时候,我想在写代码前确定某一段实验中设计的 index 序列在 fastq records 中的大概位置,以便我对程序进行调整。但使用 less 进行查看时,面对整屏幕的黑白字符,难以从其中一眼看出 index 序列所处的位置。
又比如说,有时在对 fastq 文件进行预处理时,需要将 reads 末端低质量的序列 trim 掉,但有时候软件默认的参数并不能满足需求,需要进行参数调整,需要对处理前后的 fastq 进行比较,以确定合适的参数。通常会用 fastqc 来生成质量报告来进行检查。这时候如果能够直观地观察 reads 中碱基的质量情况就会很有帮助,而 less 看到的是黑白的 phred 质量字符,很难肉眼分辨质量的高低。
比如对于 sam 文件,标准的文件格式中每一行有 11 列,信息密度非常高,当然这样设计机器 parse 起来比较方便,但人阅读起来就不舒服了。为了能加强它的可读性,最好能对它进行简单的二次排版。
bioSyntax
地址:https://biosyntax.org/install
但是,上述软件需要sudo 权限,对于一般用户来说不太方便,可以试试bioView。
bioView
下载地址:
https://github.com/Nanguage/bioView/releases
将文件添加到工作目录后,还需要进行一些简单的配置:
$ mkdir -p ~/.config/bioview/
$ bioview example-config > ~/.config/bioview/config.json
我们可以查看一下帮助文档:
$ bioview -h
Command line tool for bioinformatics file format readability enhancement.
Usage:
bioview fq <file> [--config-file=<config_file>] [--hist=<yes/no>] [--color=<yes/no>] [--phred=<33/64>] [--delimiter=<yes/no>]
bioview fa <file> [--config-file=<config_file>] [--color=<yes/no>] [--type=<dna/rna/protein>]
bioview sam <file> [--config-file=<config_file>] [--hist=<yes/no>] [--color=<yes/no>] [--phred=<33/64>] [--multiline=<yes/no>]
bioview color-atla
bioview example-config
bioview (-h | --help)
Options:
-h --help Show this help information.
--phred=<33/64> Quality score encode for fastq file, 33 or 64. [33]
--hist=<yes/no> Show quality hist or not. [yes]
--delimiter=<yes/no> Show fastq record delimiter or not. [yes]
--multiline=<yes/no> Show multiple line format of sam file. [no]
--color=<yes/no> Show color height light of bases or not. [yes]
--type=<dna/rna/protein> The record type of fasta file. [dna]
--config-file=<config_file> The path to config file. [~/.config/bioview/config.json]
比如fq 数据:
$ zcat ERR2179218_2_val_2.fq.gz | bioview fq - | less -rS
使用的时候需要注意,其需要使用一个占位符替代文件名。
less 需要加 -r 参数用于色彩显示。
比如bam 数据:
samtools view ERR2179119.bam | bioview sam - | less -rS
还可以多行显示bam 数据,增加界面内的数据密度:
samtools view ERR2179119.bam | bioview sam --multiline=yes - | less -rS
主要的特点还是两个:
- 将枯燥的黑白世界涂上了色彩;
- 将乏味的质量字符替换成了柱形图。
定制自己的配置
我们可以通过命令bioview example-config 查看作者提供的默认配置:
比如 base_color, 代表不同碱基的颜色,内层的 base_color::fg 为前景色(foreground),而 base_color::bg 为背景色(background),其数值为终端内支持的颜色的编码。
也可以通过命令查看:
bioview color-atla
默认提供的配置是simple 主题,作者也提供了另外的一些内容:https://github.com/Nanguage/bioView/tree/master/theme
比如emoji 主题:
直接将下载的json 文件替换:~/.config/bioview/config.json
即可。