根据网上的教程 ,加上自已的理解,做出小练习。首先打开数据
mkdir ~/biosoft
cd ~/biosoft
wget https://sourceforge.net/projects/bowtie-bio/files/bowtie2/2.3.4.3/bowtie2-2.3.4.3-linux-x86_64.zip
unzip bowtie2-2.3.4.3-linux-x86_64.zip
cd ~/biosoft/bowtie2-2.3.4.3-linux-x86_64/example/reads
1.统计reads_1.fq 文件中共有多少条序列信息
less -SN reads_1.fq| sed -n 1~4p |wc -l

2.输出所有的reads_1.fq文件中的标识符(即以@开头的那一行)
grep '^@' reads_1.fq > 2.txt
cat 2.txt

3.输出reads_1.fq文件中的 所有序列信息(即每个序列的第二行)
less -SN reads_1.fq| paste - - - - | cut -f 2

4.输出以‘+’及其后面的描述信息(即每个序列的第三行)
less -SN reads_1.fq| paste - - - - | cut -f 3
5.输出质量值信息(即每个序列的第四行)
less -SN reads_1.fq| paste - - - - | cut -f 4
6. 计算reads_1.fq 文件含有N碱基的reads个数
less -SN reads_1.fq| paste - - - - | cut -f 2|grep N|wc
7.统计文件中reads_1.fq文件里面的序列的碱基总数
less -SN reads_1.fq| paste - - - - | cut -f 2|grep -o [ATCGN]|wc
8.计算reads_1.fq 所有的reads中N碱基的总数
less -SN reads_1.fq| paste - - - - | cut -f 2|grep -o N|wc
总共有26001.
9.统计reads_1.fq 中测序碱基质量值恰好为Q20的个数
less -SN reads_1.fq| paste - - - - | cut -f 4|grep -o "5"|wc
结果为21369.
10.统计reads_1.fq 中测序碱基质量值恰好为Q30的个数
less -SN reads_1.fq| paste - - - - | cut -f 4|grep -o "?"|wc
结果为21574.
11.统计reads_1.fq 中所有序列的第一位碱基的ATCGN分布情况
less -SN reads_1.fq| paste - - - - | cut -f 2|cut -c 1|sort |uniq -c

12.将reads_1.fq 转为reads_1.fa文件(即将fastq转化为fasta)
less -SN reads_1.fq| paste - - - - | cut -f 1,2|tr '\t' '\n'|tr '@' '>' >> reads_1.fa
13.统计上述reads_1.fa文件中共有多少条序列
wc reads_1.fa
14.计算reads_1.fa文件中总的碱基序列的GC数量
less -SN reads_1.fa| paste - - | cut -f 2|grep -o [GC]|wc
在使用代码的过程中,发现GC与[GC]的答案不一样,可能是与grep的参数不一样。

15.删除 reads_1.fa文件中的每条序列的N碱基
less reads_1.fa|tr -d "N"|grep N
16.删除 reads_1.fa文件中的含有N碱基的序列
less reads_1.fa | paste - - | grep -v N
17.删除 reads_1.fa文件中的短于65bp的序列
less reads_1.fa | paste - -|awk '{if (length($2)>65) print}'|wc

18.删除 reads_1.fa文件每条序列的前后五个碱基
less reads_1.fa | paste - - | cut -f2 |cut -c 5- | cut -c -5
19.删除 reads_1.fa文件中的长于125bp的序列
less reads_1.fa | paste - -|awk '{if (length($2)>125) print}'|wc
第20道题,目前还不会做,研究中......
网友评论