当前位置: 首页 > news >正文

产品介绍网站html源码免费空间做自己的网站

产品介绍网站html源码,免费空间做自己的网站,做网站中山,网站建设php文件放哪里社会你明哥#xff0c;人狠话又多#xff01;【小明的碎碎念】与你不见不散#xff01;作为一名搞数据的生物狗#xff0c;咱们是生物狗中代码写得最六的#xff0c;程序员中生物学得最好的——大家没意见吧#xff0c;有意见请憋着跟随小明的步伐#xff0c;让我们开开… 社会你明哥人狠话又多【小明的碎碎念】与你不见不散作为一名搞数据的生物狗咱们是生物狗中代码写得最六的程序员中生物学得最好的——大家没意见吧有意见请憋着跟随小明的步伐让我们开开心心地写Bug吧我们的口号是什么日常写bug偶尔写代码下面是正文目录Perl1.1. Perl中getopt传参1.2. Perl中输出帮助文档1.3. 实现实例Shell2.1. Shell中的getopt传参2.2. Shell中输出帮助文档2.3. 实现实例Python3.1. Python中的getopt传参3.2. Python中输出帮助文档3.3. 实现实例基于本人对多种编程语言的粗浅了解不论是哪种编程语言它的参数传递方式主要分为下面两类直接传递(以Perl为例进行说明)在调用脚本时直接传递参数如./script.pl a b c然后在脚本中用ARGV变量获取这些参数getopt方法这种方法是大多数专业程序中都会用到的方法使用的时候在参数名前加连接符后面接上参数的实际赋值例如-a 1不过getopt方法的参数解析方式略显复杂下面会在具体的语言中进行逐一说明直接传递的传参方式的优点是编写和使用起来很方便但缺点很明显参数的顺序是固定的不能随意改变每回使用时都需要确定各个参数分别是什么而且一般采用这种传参方式的人是不会编写帮助文档的所以一旦忘了只能查看源代码getopt方法的优点是传参方式灵活而且采用这种传参方式的程序员一般都会在程序中添加帮助文档因此这种传参方式对用户是非常友好的但是对于程序员来说则意味着他或她不得不多写好几行代码——所以一个好的程序员头顶凉凉是可以理解的~以下我们只介绍第二种传参方法1. Perl1.1. Perl中getopt传参Perl中的这个功能需要通过调用Getopt::Long模块实现use Getopt::Long;然后使用GetOptions函数承接传递的参数my ($var1,$var2,$var3,$var4); # 若使用use strict模式则需要提前定义变量GetOptions(    i:s\$var1,    o:s\$var2,    n:i\$var3,    m:i\$var4    );这样你就可以通过以下的方式进行灵活的Perl脚本参数传递了$ perl perlscript.pl -i var1 -o var2 ...1.2. Perl中输出帮助文档可以使用POD文档实现在Perl中输出帮助文档想了解更多关于POD文档的知识请点 这里head1 part1    doc in part1head2 part2    doc in part2...cut    # pod文档结束的标志注意每个标签上下必须隔一行否则就会错误解析。用pod2doc $0可以将程序中的文档打印出来不过一般用在程序内部当程序参数设定错误时打印pod文档die pod2doc $0 if (...);1.3. 实现实例#!/usr/bin/perluse strict;use warnings;use Getopt::Long;use POSIX;# 帮助文档head1 Description    This script is used to split fasta file, which is too large with thosands of sequencehead1 Usage    $0 -i  -o  [-n ] [-m ]head1 Parameters    -i  [str]   Input raw fasta file    -o  [str]   Output file to which directory    -n  [int]   Sequence number per file, alternate chose paramerter -n or -m, if set -n and -m at the same time, only take -n parameter    -m  [int]   Output file number (default:100)cutmy ($input,$output_dir,$seq_num,$file_num);GetOptions(i:s\$input,o:s\$output_dir,n:i\$seq_num,m:i\$file_num    );die pod2text $0 if ((!$input) or (!$output_dir));...2. Shell2.1. Shell中的getopt传参Shell中的这个功能可以通过getopts函数实现getopts [option[:]] [DESCPRITION] VARIABLEoption表示为某个脚本可以使用的选项:如果某个选项(option)后面出现了冒号(:)则表示这个选项后面可以接参数(即一段描述信息DESCPRITION)VARIABLE表示将某个选项保存在变量VARIABLE中while getopts :a:b:c: optdo    case $opt in        a)        echo 参数a的值$OPTARG        ;;        b)        echo 参数b的值$OPTARG        ;;        c)        echo 参数c的值$OPTARG        ;;        ?)        echo 未知参数        exit 1;;    esacdone2.2. Shell中输出帮助文档在Shell中编辑一个helpdoc( )的函数即可实现输出帮助文档helpdoc(){    cat Description:    .    .    .Usage:    $0 -a  -b  -c  ...Option:    .    .    .EOF}将你想要打印出来的帮助信息写在cat 和EOF之间之所以使用EOF来编写是因为这是一种所见即所得的文本编辑形式(这个不好解释请自行百度)当你要打印帮助文档时直接调用执行helpdoc( )函数即可# 当没有指定参数时即参数个数为0时输出帮助文档并退出程序执行if [ $#  0 ]then    helpdoc()    exit 1fi2.3. 实现实例helpdoc(){    cat Description:    This shellscript is used to run the pipeline to call snp using GATK4    - Data merge: merge multi-BAM files coresponding to specified strain    - Data pre-processing: Mark Duplicates  Base (Quality Score) Recalibration    - Call variants per-sample    - Filter Variants: hard-filteringUsage:    $0 -S  -R  -k  -i Option:    -S    strain name, if exist character /, place / with _ (Required)    -R    the path of bwa index (Required)    -k    known-sites variants VCF file    -i    intervals list file,must be sorted (Required)EOF}workdir/work_dir# 若无指定任何参数则输出帮助文档if [ $#  0 ]then    helpdocexit 1fiwhile getopts hS:k:R:i: optdocase $opt in        h)            helpdocexit 0            ;;        S)            strain$OPTARG# 检测输入的strain名是否合格是否含有非法字符/if [[ $strain ~ / ]]thenecho Error in specifing strain name, if exist character \/\, place \/\ with \_\                helpdocexit 1fiif [ ! -d $workdir/SAM/$strain ]thenecho There is no such folder coresponding to $strain                helpdocexit 1fi            ;;        R)            index$OPTARG            ;;        k)            vcf$OPTARGif [ ! -f $vcf ]thenecho No such file: $vcf                helpdocexit 1fi            ;;            i)            intervals$OPTARGif [ ! -f $bed ]thenecho No such file: $intervals                helpdocexit 1fi            ;;        ?)echo Unknown option: $opt            helpdocexit 1            ;;esacdone...3. Python3.1. Python中的getopt传参Python中的这种功能需要通过getopt模块实现import getoptPython脚本获得成对的参数名和参数值后会分别把它们保存在一个字典变量中参数名为key参数值为valueopts,args  getopt.getopt(argv,hi:o:t:n:,[ifile,ofile,time])getopt函数的使用说明argv使用argv过滤掉第一个参数(它是执行脚本的名字不应算作参数的一部分)hi:o:t:n:使用短格式分析串当一个选项只是表示开关状态时即后面不带附加参数时在分析串中写入选项字符。当选项后面是带一个附加参数时在分析串中写入选项字符同时后面加一个: 号[ifile,ofile,time]使用长格式分析串列表长格式串也可以有开关状态即后面不跟 号。如果跟一个等号则表示后面还应有一个参数然后通过条件判断的方法对参数进行解析for opt,arg in opts:    if opt in (-h,--help):        print(helpdoc)        sys.exit()    elif opt in (-i,--ifile):        infile  arg    elif opt in (-t,--time):        sleep_time  int(arg)    .    .    .3.2. Python中输出帮助文档在Python中创建一个字符串变量helpdoc即可实现输出帮助文档helpdoc  Description    ...Usage    python pyscript.py -i/--ifile  -o/--ofile  -t/--time  ...Parameters    -h/--help        Print helpdoc    -i/--ifile        Input file, including only one column with sampleId    -o/--ofile        Output file, including two columns, the 1st column is sampleId, the 2nd column is attribute information    -t/--time        Time for interval (seconds, default 5s)    ...在需要时将这个变量打印出来即可try:    opts,args  getopt.getopt(argv,hi:o:t:n:,[ifile,ofile,time])    if len(opts)  0:        print(Options Error!\n\nhelpdoc)        sys.exit(2)except getopt.GetoptError:    print(Options Error!\n\nhelpdoc)    sys.exit(2)3.3. 实现实例import getopt...if __name__  __main__:    ...    helpdoc  Description    This script is used to grab SRA sample attributes information based on SampleIdUsage    python webspider_ncbiBiosample.py -i/--ifile  -o/--ofile  -t/--time  -n/--requests-number Parameters    -h/--help        Print helpdoc    -i/--ifile        Input file, including only one column with sampleId    -o/--ofile        Output file, including two columns, the 1st column is sampleId, the 2nd column is attribute information    -t/--time        Time for interval (seconds, default 5s)    -n/--requests-number        Setting the requests number between interval (default 10)    # 获取命令行参数    try:        opts,args  getopt.getopt(argv,hi:o:t:n:,[ifile,ofile,time])        if len(opts)  0:            print(Options Error!\n\nhelpdoc)            sys.exit(2)    except getopt.GetoptError:        print(Options Error!\n\nhelpdoc)        sys.exit(2)    # 设置参数    for opt,arg in opts:        if opt in (-h,--help):            print(helpdoc)            sys.exit()        elif opt in (-i,--ifile):            infile  arg        elif opt in (-o,--ofile):            outfile  arg            # 若指定的输出文件已经存在让用户决定覆盖该文件还是直接退出程序            if os.path.exists(outfile):                keyin  input(The output file you specified exists, rewrite it?([y]/n: )                if keyin in (y,Y,):                    os.remove(outfile)                elif keyin in (n,N):                    print(The output file existed!\n)                    sys.exit(2)                else:                    print(Input error!\n)                    sys.exit(2)        elif opt in (-t,--time):            sleep_time  int(arg)        elif opt in (-n,--requests-number):            requestNum  int(arg)    .    .    .参考资料(1) 小明github笔记Perl进阶笔记https://github.com/Ming-Lian/Bioinformatics-skills/blob/master/Perl%E8%BF%9B%E9%98%B6%E7%AC%94%E8%AE%B0.md(2) 小明github笔记实用小脚本https://github.com/Ming-Lian/Bioinformatics-skills/blob/master/%E5%AE%9E%E7%94%A8%E5%B0%8F%E8%84%9A%E6%9C%AC.md(3) 小明github笔记Linux (Raspbian) 操作进阶——Shell编程https://github.com/Ming-Lian/Hello-RaspberryPi/blob/master/Linux%E6%93%8D%E4%BD%9C%E8%BF%9B%E9%98%B6.md#shell-programing(4) Python 命令行参数和getopt模块详解https://www.cnblogs.com/kex1n/p/5975722.html【小明的碎碎念】系列往期精彩文章(1)三代测序入门技术原理与技术特点(2)三代测序入门PacBio数据分析
http://www.zqtcl.cn/news/978652/

相关文章:

  • 局域网建设网站seo优化查询
  • 网站安装模板wordpress多个函数文件
  • 网站建设飠金手指排名十二毕业设计论文网
  • 高密哪里做网站好网络营销的四大特点
  • 网站锚文本怎么做怎么在网上接网站建设
  • php做公司网站中国大工程建设需要什么样的人才
  • 优化公司怎么优化网站的技能网站建设项目需求
  • wordpress怎么修改主页网站改版seo
  • 做视频网站需要多少带宽lnmp wordpress 数据库
  • 网站速度慢wordpress徐州网络推广公司
  • 网站建设增城seo外链是什么意思
  • php做企业网站管理系统免费网站制作手机软件的app
  • 商城网站建设咨询如何通过网站后台修改网站
  • 重庆网站建设论文2 如何写一份详细的网站开发方案
  • 宁波门户网站建设做购物网站表结构分析
  • 上传网站图片处理画册设计多少钱一页
  • 网站做标签页新公司网站建设都有哪些优势
  • 上门做指甲哪个网站百度搜索榜
  • 西安网站seo优化商城域名注册管理机构
  • 凡客网站目录优化服装网站建设论文
  • 自助网站搭建哈尔滨seo优化
  • 做网站和软件的团队网页设计与网页制作的实验报告
  • 广州网站建设很棒 乐云践新wordpress搬家 登录报错
  • 顺的网站建设案例如何上传网站
  • 网站管理和建设工作职责中国建设银行卖狗年纪念币官方网站
  • 如何快速开发一个网站干洗店投资多少钱可以营业了
  • 哪些分类网站WordPress商用收费吗
  • 南开网站建设优化seo福建凭祥建设工程有限公司网站
  • 建设工程消防设计备案凭证查询网站网站建设课程设计目的和内容
  • 网站开发要花多少钱wordpress网站邀请码