【问题标题】:Is it possible to run MAFFT through python sys module是否可以通过 python sys 模块运行 MAFFT
【发布时间】:2020-08-22 01:24:47
【问题描述】:

是否可以通过 Python sys.argv 模块运行诸如“mafft_exe”、“in_file”之类的 MAFFT 命令?

【问题讨论】:

    标签: python command line sys


    【解决方案1】:

    我并不完全清楚你在问什么,但根据你提供的有限上下文,我假设你正在使用 biopython 之类的东西作为 MAFFT 的包装器,并且你正在尝试改变传递给MafftCommandline 类的某些参数。

    biopython docs 中,MAFFT 可执行包装器的调用方式如下:

    mafft_cline = MafftCommandline(mafft_exe, input=in_file)
    

    Python 的参数处理模块是sys.argv。它是一个列表,您可以通过数字索引访问它的参数。

    因此,假设您想从命令行将某些值传递给 MAFFT 包装类,您可以这样做:

    import sys
    from Bio.Align.Applications import MafftCommandline
    
    # Replace with actual binary location, or implement it as an arg
    MAFFT_EXE_LOCATION = "/opt/local/mafft"
    
    def other_code(mafft):
        # Do other stuff with mafft here, now that it's configured
        pass
    
    
    def invoke_mafft(input_filename):
        mafft_cline = MafftCommandline(MAFFT_EXE, input=input_file)
        other_code(mafft_cline)
    
    if __name__ == '__main__':
        try:
            input_filename = sys.argv[1]
            invoke_mafft(input_filename)
        except IndexError:
            print("USAGE: {} <in_file>".format(sys.argv[0]))
    

    这只是一个起点。你最终在课堂上做什么取决于你。

    【讨论】:

      猜你喜欢
      • 2019-05-12
      • 1970-01-01
      • 2019-05-23
      • 2019-05-03
      • 1970-01-01
      • 2018-08-10
      • 2017-03-29
      • 1970-01-01
      • 2022-10-20
      相关资源
      最近更新 更多