首先,要用到数组,请先看关于数组的基础知识
要求:把电脑中的
SRR
开头的文件名改为容易识别的Library_Name
电脑中的SRR文件如下:
Run和Library_Name的对应关系如下
也就是要以第二列代替第三列,所以简单的rename命令不行,因为这些名字之间㐊简单的替换
SAMN09837892 Lib_FUSCCTNBC158.TT_WES SRR7696207 FUSCCTNBC158_FrozenPrimaryTumorTissue
SAMN09838014 Lib_FUSCCTNBC337.TT_WES SRR8517853 FUSCCTNBC337_FrozenPrimaryTumorTissue
SAMN09837870 Lib_FUSCCTNBC123.TT_WES SRR8517854 FUSCCTNBC123_FrozenPrimaryTumorTissue
SAMN09837938 Lib_FUSCCTNBC228.TT_WES SRR8517855 FUSCCTNBC228_FrozenPrimaryTumorTissue
SAMN09837940 Lib_FUSCCTNBC230.TT_WES SRR8517856 FUSCCTNBC230_FrozenPrimaryTumorTissue
SAMN09837941 Lib_FUSCCTNBC233.TT_WES SRR8517857 FUSCCTNBC233_FrozenPrimaryTumorTissue
SAMN09837942 Lib_FUSCCTNBC234.TT_WES SRR8517858 FUSCCTNBC234_FrozenPrimaryTumorTissue
SAMN09837934 Lib_FUSCCTNBC220.TT_WES SRR8517859 FUSCCTNBC220_FrozenPrimaryTumorTissue
SAMN09837935 Lib_FUSCCTNBC223.TT_WES SRR8517860 FUSCCTNBC223_FrozenPrimaryTumorTissue
SAMN09837936 Lib_FUSCCTNBC225.TT_WES SRR8517861 FUSCCTNBC225_FrozenPrimaryTumorTissue
SAMN09837937 Lib_FUSCCTNBC227.TT_WES SRR8517862 FUSCCTNBC227_FrozenPrimaryTumorTissue
SAMN09837943 Lib_FUSCCTNBC235.TT_WES SRR8517863 FUSCCTNBC235_FrozenPrimaryTumorTissue
SAMN09837944 Lib_FUSCCTNBC236.TT_WES SRR8517864 FUSCCTNBC236_FrozenPrimaryTumorTissue
SAMN09838036 Lib_FUSCCTNBC387.TT_WES SRR8517865 FUSCCTNBC387_FrozenPrimaryTumorTissue
SAMN09838037 Lib_FUSCCTNBC389.TT_WES SRR8517866 FUSCCTNBC389_FrozenPrimaryTumorTissue
SAMN09838032 Lib_FUSCCTNBC380.TT_WES SRR8517867 FUSCCTNBC380_FrozenPrimaryTumorTissue
SAMN09838033 Lib_FUSCCTNBC383.TT_WES SRR8517868 FUSCCTNBC383_FrozenPrimaryTumorTissue
SAMN09838077 Lib_FUSCCTNBC440.TT_WES SRR8517869 FUSCCTNBC440_FrozenPrimaryTumorTissue
SAMN09838075 Lib_FUSCCTNBC438.TT_WES SRR8517870 FUSCCTNBC438_FrozenPrimaryTumorTissue
SAMN09837967 Lib_FUSCCTNBC262.TT_WES SRR8517871 FUSCCTNBC262_FrozenPrimaryTumorTissue
SAMN09837968 Lib_FUSCCTNBC263.TT_WES SRR8517872 FUSCCTNBC263_FrozenPrimaryTumorTissue
SAMN09837965 Lib_FUSCCTNBC260.TT_WES SRR8517873 FUSCCTNBC260_FrozenPrimaryTumorTissue
提示
- 1根据上面的对应关系,首先创建( touch)这些gz文件出来
- 2 然后 shell脚本改名
比如SRR7696207改为Lib_FUSCCTNBC158.TT_WES
1 创建gz文件
先写入上述第二个表的文件
cat >tmp
SAMN09837892 Lib_FUSCCTNBC158.TT_WES SRR7696207 FUSCCTNBC158_FrozenPrimaryTumorTissue
SAMN09838014 Lib_FUSCCTNBC337.TT_WES SRR8517853 FUSCCTNBC337_FrozenPrimaryTumorTissue
SAMN09837870 Lib_FUSCCTNBC123.TT_WES SRR8517854 FUSCCTNBC123_FrozenPrimaryTumorTissue
SAMN09837938 Lib_FUSCCTNBC228.TT_WES SRR8517855 FUSCCTNBC228_FrozenPrimaryTumorTissue
SAMN09837940 Lib_FUSCCTNBC230.TT_WES SRR8517856 FUSCCTNBC230_FrozenPrimaryTumorTissue
.....
创建1.fastq.gz
和2.fastq.gz
文件
cat tmp|cut -f3|while read id;do touch ${id}_{1,2}.fastq.gz;done
或者
cat config|awk '{print$3}'|while read id;do touch ${id}_{1,2}.fastq.gz;done
ls
SRR6269851_1.fastq.gz SRR6269859_1.fastq.gz SRR6269867_1.fastq.gz SRR6269875_1.fastq.gz SRR8517854_1.fastq.gz SRR8517862_1.fastq.gz SRR8517870_1.fastq.gz
SRR6269851_2.fastq.gz SRR6269859_2.fastq.gz SRR6269867_2.fastq.gz SRR6269875_2.fastq.gz SRR8517854_2.fastq.gz SRR8517862_2.fastq.gz SRR8517870_2.fastq.gz
SRR6269852_1.fastq.gz SRR6269860_1.fastq.gz SRR6269868_1.fastq.gz SRR6269876_1.fastq.gz SRR8517855_1.fastq.gz SRR8517863_1.fastq.gz SRR8517871_1.fastq.gz
SRR6269852_2.fastq.gz SRR6269860_2.fastq.gz SRR6269868_2.fastq.gz SRR6269876_2.fastq.gz
2重命名
cat tmp|while read id
do
arr=($id)
Lib_name=${arr[1]}
SRR_name=${arr[2]}
echo $Lib_name echo $SRR_name
mv ${SRR_name}_1.fastq.gz ${Lib_name}_1.fastq.gz
mv ${SRR_name}_2.fastq.gz ${Lib_name}_2.fastq.gz
done
解释如下
- 1 arr=($id)
把read到的id也就是tmp的所有数据放在了名为arr
数组里,()的作用就是建立数组- 2 arr[1]读取arr第2列,命名为Lib_name
arr[12]读取arr第3列,命名为SRR_name
课程分享
网友评论