Linux基础

生信人的linux考试20题

2018-12-10  本文已影响192人  泥人吴
一、 在任意文件夹下面创建形如 1/2/3/4/5/6/7/8/9 格式的文件夹系列
vip39@VM-0-15-ubuntu:~/test$ mkdir -p 1/2/3/4/5/6/7/8/9
vip39@VM-0-15-ubuntu:~/test$ ls
1
vip39@VM-0-15-ubuntu:~/test$ 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 里面输入内容:
vip39@VM-0-15-ubuntu:~/test$ cd ./1/2/3/4/5/6/7/8/9/
vip39@VM-0-15-ubuntu:~/test/1/2/3/4/5/6/7/8/9$ touch me.txt
vip39@VM-0-15-ubuntu:~/test/1/2/3/4/5/6/7/8/9$ ls
me.txt
vip39@VM-0-15-ubuntu:~/test/1/2/3/4/5/6/7/8/9$ vim me.txt 
vip39@VM-0-15-ubuntu:~/test/1/2/3/4/5/6/7/8/9$ cat me.txt 
Go to: http://www.biotrainee.com/
I love bioinfomatics.
And you ?
vip39@VM-0-15-ubuntu:~/test$ cat > me.txt 
Go to: http://www.biotrainee.com/
I love bioinfomatics.
And you ?
^C
vip39@VM-0-15-ubuntu:~/test$ 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
vip39@VM-0-15-ubuntu:~$ cd test/
vip39@VM-0-15-ubuntu:~/test$ ls
1
vip39@VM-0-15-ubuntu:~/test$ rm -r 1/
vip39@VM-0-15-ubuntu:~/test$ ls
vip39@VM-0-15-ubuntu:~/test$ tree
.

0 directories, 0 files
五、在任意文件夹下面创建 folder1~5这5个文件夹,然后每个文件夹下面继续创建 folder1~5这5个文件夹,效果如下:
vip39@VM-0-15-ubuntu:~/test$ mkdir -p folder{1..5}/folder{1..5}
vip39@VM-0-15-ubuntu:~/test$ ls *
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 ,内容也要一样。
vip39@VM-0-15-ubuntu:~/test$ echo folder{1..5}/folder{1..5}|xargs -n 1 cp me.txt
vip39@VM-0-15-ubuntu:~/test$ 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

30 directories, 26 files
七,再次删除掉前面几个步骤建立的文件夹及文件
vip39@VM-0-15-ubuntu:~/test$ ls
folder1  folder2  folder3  folder4  folder5  me.txt
vip39@VM-0-15-ubuntu:~/test$ rm -rf folder*
vip39@VM-0-15-ubuntu:~/test$ ls
me.txt
vip39@VM-0-15-ubuntu:~/test$ rm me.txt 
vip39@VM-0-15-ubuntu:~/test$ ls
vip39@VM-0-15-ubuntu:~/test$ 
八、下载 http://www.biotrainee.com/jmzeng/igv/test.bed 文件,后在里面选择含有 H3K4me3 的那一行是第几行,该文件总共有几行。
vip39@VM-0-15-ubuntu:~/test$ wget -c http://www.biotrainee.com/jmzeng/igv/test.bed
--2018-12-11 20:14:50--  http://www.biotrainee.com/jmzeng/igv/test.bed
Resolving www.biotrainee.com (www.biotrainee.com)... 123.206.72.184
Connecting to www.biotrainee.com (www.biotrainee.com)|123.206.72.184|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 3099 (3.0K)
Saving to: ‘test.bed’

test.bed              100%[=========================>]   3.03K  --.-KB/s    in 0s      

2018-12-11 20:14:50 (480 MB/s) - ‘test.bed’ saved [3099/3099]

vip39@VM-0-15-ubuntu:~/test$ ls
test.bed
vip39@VM-0-15-ubuntu:~/test$ cat test.bed | grep -n H3K4me3
8:chr1  9810    10438   ID=SRX387603;Name=H3K4me3%20(@%20HMLE);Title=GSM1280527:%20HMLE%20Twist3D%20H3K4me3%20rep2%3B%20Homo%20sapiens%3B%20ChIP-Seq;Cell%20group=Breast;<br>source_name=HMLE_Twist3D_H3K4me3;cell%20type=human%20mammary%20epithelial%20cells;transfected%20with=Twist1;culture%20type=sphere;chip%20antibody=H3K4me3;chip%20antibody%20vendor=Millipore;  222 .   9810    10438   0,226,255
vip39@VM-0-15-ubuntu:~/test$ cat test.bed |wc
     10      88    3099
九、下载 http://www.biotrainee.com/jmzeng/rmDuplicate.zip 文件,并且解压,查看里面的文件夹结构
# 下载
vip39@VM-0-15-ubuntu:~/test$ wget http://www.biotrainee.com/jmzeng/rmDuplicate.zip
--2018-12-11 21:02:42--  http://www.biotrainee.com/jmzeng/rmDuplicate.zip
Resolving www.biotrainee.com (www.biotrainee.com)... 123.206.72.184
Connecting to www.biotrainee.com (www.biotrainee.com)|123.206.72.184|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 104931 (102K) [application/zip]
Saving to: ‘rmDuplicate.zip’

rmDuplicate.zip       100%[=========================>] 102.47K   523KB/s    in 0.2s    

2018-12-11 21:02:43 (523 KB/s) - ‘rmDuplicate.zip’ saved [104931/104931]

vip39@VM-0-15-ubuntu:~/test$ ls
rmDuplicate.zip  test.bed

# 解压
vip39@VM-0-15-ubuntu:~/test$ unzip rmDuplicate.zip 
Archive:  rmDuplicate.zip
   creating: rmDuplicate/
   creating: rmDuplicate/picard/
   creating: rmDuplicate/picard/paired/
  inflating: rmDuplicate/picard/paired/readme.txt  
···
  inflating: rmDuplicate/samtools/single/tmp.sorted.vcf.gz  

# 查看文件结构
vip39@VM-0-15-ubuntu:~/test$ cd rmDuplicate/
vip39@VM-0-15-ubuntu:~/test/rmDuplicate$ tree
.
├── picard
│   ├── paired
│   │   ├── readme.txt
│   │   ├── tmp.header
│   │   ├── tmp.MarkDuplicates.log
│   │   ├── tmp.metrics
│   │   ├── tmp.rmdup.bai
│   │   ├── tmp.rmdup.bam
│   │   ├── tmp.sam
│   │   └── tmp.sorted.bam
│   └── single
│       ├── readme.txt
│       ├── tmp.header
│       ├── tmp.MarkDuplicates.log
│       ├── tmp.metrics
│       ├── tmp.rmdup.bai
│       ├── tmp.rmdup.bam
│       ├── tmp.sam
│       └── tmp.sorted.bam
└── samtools
    ├── paired
    │   ├── readme.txt
    │   ├── tmp.header
    │   ├── tmp.rmdup.bam
    │   ├── tmp.rmdup.vcf.gz
    │   ├── tmp.sam
    │   ├── tmp.sorted.bam
    │   └── tmp.sorted.vcf.gz
    └── single
        ├── readme.txt
        ├── tmp.header
        ├── tmp.rmdup.bam
        ├── tmp.rmdup.vcf.gz
        ├── tmp.sam
        ├── tmp.sorted.bam
        └── tmp.sorted.vcf.gz

6 directories, 30 files
十、打开第九题解压的文件,进入 rmDuplicate/samtools/single 文件夹里面,查看后缀为 .sam 的文件,搞清楚 生物信息学里面的SAM/BAM 定义是什么
十一、安装 samtools 软件
vip39@VM-0-15-ubuntu:~/src$ source ~/miniconda3/bin/activate 
(base) vip39@VM-0-15-ubuntu:~/src$ conda install samtools=1.8 y
# 检查一下能否运行
(base) vip39@VM-0-15-ubuntu:~/src$ samtools

Program: samtools (Tools for alignments in the SAM format)
Version: 1.7 (using htslib 1.7)

Usage:   samtools <command> [options]
十二、打开后缀为BAM 的文件,找到产生该文件的命令。 提示一下命令是:
十三题、根据上面的命令,找到我使用的参考基因组 /home/jianmingzeng/reference/index/bowtie/hg38 具体有多少条染色体
(base) vip39@VM-0-15-ubuntu:~$ samtools view -H ~/test/rmDuplicate/samtools/single/tmp.sorted.bam |awk '{print $2}'|cut -c4-9|sort -n|uniq -c|grep -v '_'
      1 bowtie
      1 chr1
      1 chr10
      1 chr11
      1 chr12
      1 chr13
      1 chr14
      1 chr15
      1 chr16
      1 chr17
      1 chr18
      1 chr19
      1 chr2
      1 chr20
      1 chr21
      1 chr22
      1 chr3
      1 chr4
      1 chr5
      1 chr6
      1 chr7
      1 chr8
      1 chr9
      1 chrM
      1 chrX
      1 chrY
      1 1.0
(base) vip39@VM-0-15-ubuntu:~$ samtools view -H ~/test/rmDuplicate/samtools/single/tmp.sorted.bam |awk '{print $2}'|cut -c4-9|sort -n|uniq -c|grep -v '_'|wc
     27      54     365
# 不算前两个,应该是25条
十四题、上面的后缀为BAM 的文件的第二列,只有 0 和 16 两个数字,用 cut/sort/uniq等命令统计它们的个数。
(base) vip39@VM-0-15-ubuntu:~$ samtools view  ~/test/rmDuplicate/samtools/single/tmp.sorted.bam |cut -f2|sort|uniq -c
     29 0
     24 16
十五题、重新打开 rmDuplicate/samtools/paired 文件夹下面的后缀为BAM 的文件,再次查看第二列,并且统计
(base) vip39@VM-0-15-ubuntu:~/test/rmDuplicate/samtools/paired$ samtools view tmp.sorted.bam | cut -f2|sort -n |uniq -c
      3 83
      2 97
      9 99
      8 147
      3 163
      1 323
      1 353
      1 371
      1 387
      1 433
十六题、下载 http://www.biotrainee.com/jmzeng/sickle/sickle-results.zip 文件,并且解压,查看里面的文件夹结构, 这个文件有2.3M,注意留心下载时间及下载速度。
(base) vip39@VM-0-15-ubuntu:~/test$ cd sickle-results/
(base) vip39@VM-0-15-ubuntu:~/test/sickle-results$ tree
.
├── command.txt
├── single_tmp_fastqc.html
├── single_tmp_fastqc.zip
├── test1_fastqc.html
├── test1_fastqc.zip
├── test2_fastqc.html
├── test2_fastqc.zip
├── trimmed_output_file1_fastqc.html
├── trimmed_output_file1_fastqc.zip
├── trimmed_output_file2_fastqc.html
└── trimmed_output_file2_fastqc.zip
十七题、解压 sickle-results/single_tmp_fastqc.zip 文件,并且进入解压后的文件夹,找到 fastqc_data.txt 文件,并且搜索该文本文件以 >>开头的有多少行?
(base) vip39@VM-0-15-ubuntu:~/test/sickle-results/single_tmp_fastqc$ cat fastqc_data.txt | grep '^>>'|wc -l
24
# 也可以使用:
(base) vip39@VM-0-15-ubuntu:~/test/sickle-results/single_tmp_fastqc$ cat fastqc_data.txt | awk '/^>>/{print $0}'|wc -l
24
十八题、下载 http://www.biotrainee.com/jmzeng/tmp/hg38.tss 文件,去NCBI找到TP53/BRCA1等自己感兴趣的基因对应的 refseq数据库 ID,然后找到它们的hg38.tss 文件的哪一行。
(base) vip39@VM-0-15-ubuntu:~/test$ cat hg38.tss | grep -n "NM_001126113"
29346:NM_001126113  chr17   7685550 7689550 1
十九题、解析hg38.tss 文件,统计每条染色体的基因个数。
(base) vip39@VM-0-15-ubuntu:~/test$ cat hg38.tss |cut -f2|sort|uniq -c|grep -v '_'
   6050 chr1
   2824 chr10
   3449 chr11
   2931 chr12
   1122 chr13
   1883 chr14
   2168 chr15
   2507 chr16
   3309 chr17
    873 chr18
   3817 chr19
   4042 chr2
   1676 chr20
    868 chr21
   1274 chr22
   3277 chr3
   2250 chr4
   2684 chr5
   3029 chr6
   2720 chr7
   2069 chr8
   2301 chr9
      2 chrM
   2553 chrX
    414 chrY
二十题、解析hg38.tss 文件,统计NM和NR开头的熟练,了解NM和NR开头的含义。
(base) vip39@VM-0-15-ubuntu:~/test$ cat hg38.tss |awk '{print$1}'|cut -c1-2|sort|uniq -c 
  51064 NM
  15954 NR

生信技能树公益视频合辑:学习顺序是linux,r,软件安装,geo,小技巧,ngs组学!
请猛戳下面链接
B站链接:https://m.bilibili.com/space/338686099

YouTube链接:https://m.youtube.com/channel/UC67sImqK7V8tSWHMG8azIVA/playlists

生信工程师入门最佳指南:https://mp.weixin.qq.com/s/vaX4ttaLIa19MefD86WfUA

学徒培养:https://mp.weixin.qq.com/s/3jw3_PgZXYd7FomxEMxFmw

上一篇下一篇

猜你喜欢

热点阅读