#!/bin/bashset-e
# 设置程序参数的缺省值,少用参数即可运行# Default parameterinput=input.txt
output=output.txt
database=database.txt
execute='TRUE'# 程序功能描述,每次必改程序名、版本、时间等;版本更新要记录清楚,一般可用-h/-?来显示这部分# Function for script description and usage
usage(){
cat<<EOF >&2Usage:-------------------------------------------------------------------------------Filename: template.shRevision: 1.0Date: 2017/6/24Author: Yong-Xin LiuEmail: yxliu@genetics.ac.cnWebsite: http://bailab.genetics.ac.cn/Description: This script is solve parameter read and defaultNotes: Function of this script-------------------------------------------------------------------------------Copyright: 2017 (c) Yong-Xin LiuLicense: GPLThis program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public Licenseas published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warrantyof MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.If any changes are made to this script, please mail me a copy of the changes-------------------------------------------------------------------------------Version 1.0 2017/6/24# 输入输出文件格式和示例,非常有用,不知道格式怎么准备文件呀# Input files: input.txt, can inclue many file# 1. input.txt, design of exprimentSampleID BarcodeSequence groupWT.1 TAGCTT WTWT.2 GGCTAC WTWT.3 CGCGCG WT# 2. database.txt, annotation of geneID descriptionAT3G48300 Transcript factor# Output file1. Annotated samples & DE genesSamples ID descriptionWt AT3G48300 Transcript factor2. Volcano plot: vol_otu_SampleAvsSampleB.pdf# 参数描述,写清功能的缺省值OPTIONS: -d database file, default database.txt -i input file, recommend must give -o output file or output directory, default output.txt -h/? show help of scriptExample: template.sh -i input.txt -d database.txt -o result.txtEOF}# 解释命令行参数,是不是很面熟,其实是调用了perl语言的getopts包,# Analysis parameterwhilegetopts"d:h:i:o:"OPTION
docase$OPTIONind)database=$OPTARG;;h)usage
exit1;;i)input=$OPTARG;;o)output=$OPTARG;;?)usage
exit1;;esacdone# for 循环批量调用程序,如批量绘制热图# 有多种批量输入文件的方式,以下N种任选其一,其它用#注释掉foriina.txtb.txtn.txt;do# 文件不多,手动放在in后用空格分开foriin`seq19`;do# 文字名为数字顺序,用seq命令生成连续数据,引用命令需反引foriin`lsdata/*.txt`;do# 匹配某类文件作为输入foriin`catlist.txt`;do# 使用文本原为输入列表foriin`catlist.txt|cut-f1`;do# 指定某列作为输入文件名plot_heatmap.sh-idata/${i}-oheatmap/${i}.pdf
done