来源:生信人的linux考试 http://www.bio-info-trainee.com/2900.html
一、在任意文件夹下面创建形如 1/2/3/4/5/6/7/8/9
格式的文件夹系列。
vip21 08:29:21 ~/linux20
$ mkdir -p 1/2/3/4/5/6/7/8/9
vip21 08:33:46 ~/linux20
$ ls
1
vip21 08:34:05 ~/linux20
$ tree
.
└── 1
└── 2
└── 3
└── 4
└── 5
└── 6
└── 7
└── 8
└── 9
9 directories, 0 files
二、在创建好的文件夹下面,比如我的是 /Users/jimmy/tmp/1/2/3/4/5/6/7/8/9
,里面创建文本文件 me.txt
三、在文本文件 me.txt
里面输入内容:
Go to: http://www.biotrainee.com/
I love bioinfomatics.
And you ?
vip21 08:52:53 ~/linux20/1/2/3/4/5/6/7/8/9
$ cat > me.txt
Go to: http://www.biotrainee.com/
I love bioinfomatics.
And you ?
^C
vip21 08:53:51 ~/linux20/1/2/3/4/5/6/7/8/9
$ ls
me.txt
vip21 08:53:58 ~/linux20/1/2/3/4/5/6/7/8/9
$ cat me.txt
Go to: http://www.biotrainee.com/
I love bioinfomatics.
And you ?
四、、删除上面创建的文件夹 1/2/3/4/5/6/7/8/9
及文本文件 me.txt
vip21 08:54:37 ~/linux20/1/2/3/4/5/6/7/8/9
$ cd ~/linux20/
vip21 08:57:18 ~/linux20
$ rm -rf 1
vip21 08:57:41 ~/linux20
$ tree
.
0 directories, 0 files
五、在任意文件夹下面创建 folder1~5
这5个文件夹,然后每个文件夹下面继续创建 folder1~5
这5个文件夹
vip21 08:58:23 ~/linux20
$ mkdir -p folder{1..5}/folder{1..5}
vip21 08:59:36 ~/linux20
$ tree
.
├── folder1
│ ├── folder1
│ ├── folder2
│ ├── folder3
│ ├── folder4
│ └── folder5
├── folder2
│ ├── folder1
│ ├── folder2
│ ├── folder3
│ ├── folder4
│ └── folder5
├── folder3
│ ├── folder1
│ ├── folder2
│ ├── folder3
│ ├── folder4
│ └── folder5
├── folder4
│ ├── folder1
│ ├── folder2
│ ├── folder3
│ ├── folder4
│ └── folder5
└── folder5
├── folder1
├── folder2
├── folder3
├── folder4
└── folder5
六、在第五题创建的每一个文件夹下面都 创建第二题文本文件 me.txt
,内容也要一样
vip21 09:02:30 ~/linux20
$ ls
folder1 folder2 folder3 folder4 folder5 me.txt
vip21 09:02:38 ~/linux20
$ echo folder{1..5}/folder{1..5}|xargs -n 1 cp me.txt
vip21 09:05:34 ~/linux20
$ tree
.
├── folder1
│ ├── folder1
│ │ └── me.txt
│ ├── folder2
│ │ └── me.txt
│ ├── folder3
│ │ └── me.txt
│ ├── folder4
│ │ └── me.txt
│ └── folder5
│ └── me.txt
├── folder2
│ ├── folder1
│ │ └── me.txt
│ ├── folder2
│ │ └── me.txt
│ ├── folder3
│ │ └── me.txt
│ ├── folder4
│ │ └── me.txt
│ └── folder5
│ └── me.txt
├── folder3
│ ├── folder1
│ │ └── me.txt
│ ├── folder2
│ │ └── me.txt
│ ├── folder3
│ │ └── me.txt
│ ├── folder4
│ │ └── me.txt
│ └── folder5
│ └── me.txt
├── folder4
│ ├── folder1
│ │ └── me.txt
│ ├── folder2
│ │ └── me.txt
│ ├── folder3
│ │ └── me.txt
│ ├── folder4
│ │ └── me.txt
│ └── folder5
│ └── me.txt
├── folder5
│ ├── folder1
│ │ └── me.txt
│ ├── folder2
│ │ └── me.txt
│ ├── folder3
│ │ └── me.txt
│ ├── folder4
│ │ └── me.txt
│ └── folder5
│ └── me.txt
└── me.txt
#另外一种解决方法(from 孙小洁老师)
for dirs in folder{1..5}/folder{1..5}; do cp me.txt $dirs; done
七,再次删除掉前面几个步骤建立的文件夹及文件
vip21 09:09:19 ~/linux20
$ ls
folder1 folder2 folder3 folder4 folder5 me.txt
vip21 09:09:20 ~/linux20
$ rm -rf folder*
vip21 09:10:28 ~/linux20
$ ls
me.txt
八、下载 http://www.biotrainee.com/jmzeng/igv/test.bed
文件,后在里面选择含有 H3K4me3
的那一行是第几行,该文件总共有几行。
wget -c http://www.biotrainee.com/jmzeng/igv/test.bed
ls
cat test.bed | grep -n H3K4me3
cat test.bed | wc -l
九、下载 http://www.biotrainee.com/jmzeng/rmDuplicate.zip
文件,并且解压,查看里面的文件夹结构
wget -c http://www.biotrainee.com/jmzeng/rmDuplicate.zip
ls
unzip rmDuplicate.zip
tree rmDuplicate
十、打开第九题解压的文件,进入 rmDuplicate/samtools/single
文件夹里面,查看后缀为 .sam
的文件,搞清楚 生物信息学里面的SAM/BAM
定义是什么。
vip21 09:46:25 ~/linux20
$ cd ~/linux20/rmDuplicate/samtools/single/
vip21 09:47:56 ~/linux20/rmDuplicate/samtools/single
$ ls
readme.txt tmp.rmdup.bam tmp.sam tmp.sorted.vcf.gz
tmp.header tmp.rmdup.vcf.gz tmp.sorted.bam
vip21 09:48:04 ~/linux20/rmDuplicate/samtools/single
$ head tmp.sam
十一、安装 samtools
软件
conda软件直接搜索,安装即可。
十二、打开 后缀为BAM
的文件,找到产生该文件的命令。 提示一下命令是:
#查看BAM` 的文件
samtools view -h SRR1039508.hisat.bam
#查看命令
which samtools
十三题、根据上面的命令,找到我使用的参考基因组 /home/jianmingzeng/reference/index/bowtie/hg38
具体有多少条染色体。
less -S hg38.fa |grep '^>' |sort |uniq -c |wc -l
十四题、上面的后缀为BAM
的文件的第二列,只有 0 和 16 两个数字,用 cut/sort/uniq
等命令统计它们的个数。
samtools view -h SRR1039508.hisat.bam | cut -f2 | sort | uniq -c
十五题、重新打开 rmDuplicate/samtools/paired
文件夹下面的后缀为BAM
的文件,再次查看第二列,并且统计
samtools view tmp.sorted.bam | cut -f2|sort -n |uniq -c
十六题、下载 http://www.biotrainee.com/jmzeng/sickle/sickle-results.zip
文件,并且解压,查看里面的文件夹结构, 这个文件有2.3M,注意留心下载时间及下载速度。
wget -c http://www.biotrainee.com/jmzeng/sickle/sickle-results.zip
unzip sickle-results.zip
tree sickle-results
十七题、解压 sickle-results/single_tmp_fastqc.zip
文件,并且进入解压后的文件夹,找到 fastqc_data.txt
文件,并且搜索该文本文件以 >>
开头的有多少行?
unzip single_tmp_fastqc.zip
cd single_tmp_fastqc/
cat fastqc_data.txt | grep -n '^>>' | wc -l
十八题、下载 http://www.biotrainee.com/jmzeng/tmp/hg38.tss
文件,去NCBI找到TP53/BRCA1
等自己感兴趣的基因对应的 refseq数据库
ID,然后找到它们的hg38.tss
文件的哪一行。
https://www.ncbi.nlm.nih.gov/gene/7157
wget -c http://www.biotrainee.com/jmzeng/tmp/hg38.tss
cat hg38.tss | grep -n 'NM_007294'
十九题、解析hg38.tss
文件,统计每条染色体的基因个数。
cat hg38.tss | awk '{print$2}' | cut -c 1-5 | sort |uniq -c
cat hg38.tss |cut -f2|sort|uniq -c|grep -v '_'
二十题、解析hg38.tss
文件,统计NM
和NR
开头的熟练,了解NM
和NR
开头的含义。
cat hg38.tss | grep '^NM' | sort |wc -l
cat hg38.tss | grep '^NR' | sort |wc -l