基础命令:
cd 空格 #进入家目录
cd ~ #进入家目录
cd - #与上次所在目录进行切换
pwd #查看当前所在路径
tree #以树状结构展现文件层级
history #查看所有运行命令的历史记录
cat/more/less #查看文件内容
ls #查看当前目录的文件
ls -lh #查看当前文件的详细信息
alias ll='ls -lh' #建立命令快捷方式
echo #打印字符串
rm #删除文件
mv #移动文件或改名(剪切)
cp #拷贝
1、在任意文件夹下面创建形如 1/2/3/4/5/6/7/8/9 格式的文件夹。
>mkdir -p 1/2/3/4/5/6/7/8/9 #创建多级目录要加参数-p
>tree 1
1
└── 2
└── 3
└── 4
└── 5
└── 6
└── 7
└── 8
└── 9
8 directories, 0 files
2、在创建好的文件夹下面,比如我的是 ~/1/2/3/4/5/6/7/8/9 ,里面创建文本文件 me.txt
>cd ~/1/2/3/4/5/6/7/8/9 #进入文件夹
>touch me.txt #创建文件
>ls #查看目录文件
me.txt
3、在文本文件 me.txt 里面输入内容:
I love bioinfomatics.
And you ?
>vim me.txt #esc : wq 保存
>cat me.txt #查看文件内容
I love bioinfomatics.
And you ?
4、删除上面创建的文件夹 1/2/3/4/5/6/7/8/9 及文本文件 me.txt
>cd ~
>rm -rf 1 #-rf表示逐级删除目录,删除文件不需要
5、在任意文件夹下面创建 folder1~5这5个文件夹,然后每个文件夹下面继续创建 folder1~5这5个文件夹
>for i in `seq 5`;do mkdir folder_$i;for n in `seq 5`;do mkdir folder_$i/folder_$n;done;done
>ls */
folder_1/:
folder_1 folder_2 folder_3 folder_4 folder_5
folder_2/:
folder_1 folder_2 folder_3 folder_4 folder_5
folder_3/:
folder_1 folder_2 folder_3 folder_4 folder_5
folder_4/:
folder_1 folder_2 folder_3 folder_4 folder_5
folder_5/:
folder_1 folder_2 folder_3 folder_4 folder_5
6、在第五题创建的每一个文件夹下面都创建第二题文本文件 me.txt ,内容也要一样。
>for i in `seq 5`;do for n in `seq 5`;do echo 'I love bioinfomatics.And you ?' > ~/folder_$i/folder_$n/me.txt;done;done
>tree folder_*
folder_1
├── folder_1
│ └── me.txt
├── folder_2
│ └── me.txt
├── folder_3
│ └── me.txt
├── folder_4
│ └── me.txt
└── folder_5
└── me.txt
folder_2
├── folder_1
│ └── me.txt
├── folder_2
│ └── me.txt
├── folder_3
│ └── me.txt
├── folder_4
│ └── me.txt
└── folder_5
└── me.txt
folder_3
├── folder_1
│ └── me.txt
├── folder_2
│ └── me.txt
├── folder_3
│ └── me.txt
├── folder_4
│ └── me.txt
└── folder_5
└── me.txt
folder_4
├── folder_1
│ └── me.txt
├── folder_2
│ └── me.txt
├── folder_3
│ └── me.txt
├── folder_4
│ └── me.txt
└── folder_5
└── me.txt
folder_5
├── folder_1
│ └── me.txt
├── folder_2
│ └── me.txt
├── folder_3
│ └── me.txt
├── folder_4
│ └── me.txt
└── folder_5
└── me.txt
25 directories, 25 files
7、再次删除掉前面几个步骤建立的文件夹及文件
>rm -rf folder_*
8、下载 http://www.biotrainee.com/jmzeng/igv/test.bed 文件,后在里面选择含有 H3K4me3 的那一行是第几行,该文件总共有几行。
>wget http://www.biotrainee.com/jmzeng/igv/test.bed #下载
>grep -n 'H3K4me3' test.bed #-n显示行号,如下所示有 H3K4me3 的那一行是第8行
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;
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
>wc -l test.bed #查看文件行数,该文件共10行
10 test.bed
9、下载 http://www.biotrainee.com/jmzeng/rmDuplicate.zip 文件,并且解压,查看里面的文件夹结构
>wget http://www.biotrainee.com/jmzeng/rmDuplicate.zip
>unzip rmDuplicate.zip
>tree rmDuplicate
rmDuplicate
├── 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
10、打开第九题解压的文件,进入 rmDuplicate/samtools/single 文件夹里面,查看后缀为 .sam 的文件,搞清楚生物信息学里面的SAM/BAM 定义是什么。
>cd rmDuplicate/samtools/single
>ls
readme.txt tmp.header tmp.rmdup.bam tmp.rmdup.vcf.gz tmp.sam tmp.sorted.bam tmp.sorted.vcf.gz
>less -S tmp.sam #.bam文件是二进制问件,查看要安装Samtools,使用samtools view查看
SRR1042600.42157053 0 chr1 629895 42 51M * 0 0 ATAACCAATACTACCAATCANTACTCATCATTAATAATCATAATGGCTA
SRR1042600.42212881 0 chr1 629895 42 51M * 0 0 ATAACCAATACTACCAATCANTACTCATCATTAATAATCATAATGGCTA
SRR1042600.12010763 16 chr1 629895 24 51M * 0 0 ATAACCAATACTTCTAATCAAAACTCATCATTAATAATCATAATGGCTA
>