给个例子:

from optparse import OptionParser

msg_usage = 'usage: %prog [-W] windows size [-H] h island size [-I] input your map file [-O] output file name'

descr = '''Correct SNPs used for constructing genetic map...

Why default h_size is 6?

Fistly, for example, aaaaaaaaaaaaaaaabbbbbbbbbbbbbb will generate 6 h.

secondly, for examplem aaaaaaaaaaaaahhhhhhhhhhhhhhhhhhhhaaaaaaaaaa will generate at least 7 when num

of h larger than 9, when num of h is 5-8, no h will be generated.

Caveat: default was setted 6 above when the window size is 15.

The question still not settled yet is what the size of h will be seted when windows size is

not 15...
'''

optparser = OptionParser(usage = msg_usage, description = descr)

optparser.add_option('-W', '--win_size', dest = 'winsize', default = 15,

help = 'The size of sliding window, default is 15.')

optparser.add_option('-H', '--h_island', dest = 'hisland', default = 6,

help = 'The length of h_island you need to split, default\
 is 6')

optparser.add_option('-I', '--input', dest = 'inputfile',
                                 help = 'Input your file need to tackle')

optparser.add_option('-O', '--output', dest = 'outputfile',
                                 help = 'Your output file name')

options, args = optparser.parse_args()

if __name__ == "__main__":
    W = int(options.winsize)
    H = int(options.hisland)
    I = options.inputfile
    O = options.outputfile
    main(I, W, H, O)

by freemao

FAFU

free_mao@qq.com

OptionParser的更多相关文章

  1. Python中optionParser模块的使用方法[转]

    本文以实例形式较为详尽的讲述了Python中optionParser模块的使用方法,对于深入学习Python有很好的借鉴价值.分享给大家供大家参考之用.具体分析如下: 一般来说,Python中有两个内 ...

  2. Python OptionParser学习

    from optparse import OptionParser import sys def main(): p = OptionParser() p.add_option('-n','--nam ...

  3. 转-Python optionParser模块的使用方法

    Python  有两个内建的模块用于处理命令行参数: 一个是  getopt,<Deep in python>一书中也有提到,只能简单处理 命令行参数: 另一个是  optparse,它功 ...

  4. Python的参数模块OptionParser说明

    可以替代getopt的一个模块 from optparse import OptionParser #  生成一个实例 parser = OptionParser(usage="%prog ...

  5. python基础之 optparse.OptionParser

    optparse是专门用来在命令行添加选项的一个模块. 首先来看一段示例代码 from optparse import OptionParser MSG_USAGE = "myprog[ - ...

  6. python OptionParser模块

    Python中强大的选项处理模块. #!/usr/bin/python from optparse import OptionParser parser = OptionParser() parser ...

  7. python中的optionParser模块

    Python 有两个内建的模块用于处理命令行参数:一个是 getopt,<Deep in python>一书中也有提到,只能简单处理 命令行参数:另一个是 optparse,它功能强大,而 ...

  8. OptionParser命令参数介绍及使用

    使用optionParse解析命令行参数分以下几个步骤: 创建parser实例 使用add_option添加我们要处理的命令行参数 得到解析sys.argv后的options对象,查看用户的输入 代码 ...

  9. Python模块: 命令行解析optionparser

    Python 有两个内建的模块用于处理命令行参数:一个是 getopt,<Deep in python>一书中也有提到,只能简单处理 命令行参数:另一个是 optparse,它功能强大,而 ...

随机推荐

  1. shell学习记录001-知识点储备

    1.BASH(bourne again shell ) cmd1 ;cmd2等同于 cmd1 cmd2 2.echo music; 中的分号不被打印出,因为分号默认为命令定界符号 3.利用pgrep找 ...

  2. Wcf Client 异常和关闭的通用处理方法

    在项目中采用wcf通讯,客户端很多地方调用服务,需要统一的处理超时和通讯异常以及关闭连接. 1.调用尝试和异常捕获 首先,项目中添加一个通用类ServiceDelegate.cs public del ...

  3. Python 2.7教程

    参考:http://www.liaoxuefeng.com/wiki/001374738125095c955c1e6d8bb493182103fac9270762a000

  4. 使用Apache HttpClient

    在一般情况下,如果只是需要Web站点的某个简单页面提交请求并获取服务器响应,完全可以使用前面所介绍的HttpConnection来完成.但在绝大部分情况下,Web站点的网页可能没这么简单,这些页面并不 ...

  5. 超简单的NDK单步调试方法

    令人兴奋的是,ADTr20已经支持JNI单步调试,再也不需要如上这么麻烦的步骤了 你现在需要做的只需以下2步: 1.使用ndk-build编译时,加上如下参数NDK_DEBUG=1,之后生成so文件之 ...

  6. [网络技术][转]PPTP连接过程

    转自:http://blog.csdn.net/zhu_hit/article/details/5698958 在未来几天会总结一下PPTP的工作过程,分为以下3篇讲述. 1. PPTP连接过程: 2 ...

  7. public protected default private

    简单来说,如果让一个变量或者方法,只想让自己类中的访问,那么就将它们设置成private 如果你想让一个变量或者方法,本包中的类可以访问,而且子类也可访问,但是包外的缺不想让他访问.就设置成prote ...

  8. javascript预解析和作用域

    JavaScript解析过程分为两个阶段: 一是:编译阶段.就是JavaScrip预解析阶段,在这个阶段JavaScript解析器将完成把JavaScript脚本代码转换到字节码; 二是:执行阶段.在 ...

  9. c++高质量编程手册

    怡化主管强烈要求我读这本书.... 笔记尚未完成,持续更新呗.. 第1章 高质量软件开发之道 1.1 软件质量基本概念 1.1.1 如何理解软件的质量:功能性和非公能性 1.1.2 提高软件质量的基本 ...

  10. DirectX 总结和DirectX 9.0 学习笔记

    转自:http://www.cnblogs.com/graphics/archive/2009/11/25/1583682.html DirectX 总结 DDS DirectXDraw Surfac ...