cwltoo学习笔记
  qmj2xyt4e0cp 2023年11月05日 41 0
执行工作流:cwltool /home/zcy/download/cwl/wf.cwl /home/zcy/download/cwl/echo-job.yml
wf.cwl
cwlVersion: v1.2
class: Workflow


inputs:
  message: string

outputs:
  out:
    type: File
    outputSource: uppercase/example_out

steps:
  echo:
    run: /home/zcy/download/cwl/zzz_print.cwl
    in:
      message: message
    out: [out]
  uppercase:
    run: /home/zcy/download/cwl/ccc.cwl
    in:
      mypath:
        source: echo/out
    out: [example_out]

echo-job.yml

message: Hello world!

zzz_print.cwl

cwlVersion: v1.0
class: CommandLineTool
stdout: tst_stdout.txt
baseCommand: [python, /home/zcy/download/cwl/input/zzz_print.py]
inputs:
  message:
    type: string
    inputBinding:
      position: 1
outputs:
  out:
    type: string
    outputBinding:
      glob: tst_stdout.txt 
      loadContents: true
      outputEval: $(self[0].contents)

zzz_print.py

import argparse
parser = argparse.ArgumentParser(description='download files by ftp')
parser.add_argument('message', type=str, help='PDB')

def tst(args):
    with open('/home/zzz_print.out', 'w') as f:
      f.write(args)
    print('/home/zzz_print.out')

if __name__ == '__main__':
    args = parser.parse_args()
    tst(args.message)

 

ccc.cwl

cwlVersion: v1.0
class: CommandLineTool
baseCommand: [python, /home/zcy/download/cwl/input/ccc.py]
inputs:
  mypath:
    type: string
    inputBinding:
      position: 1
outputs:
  example_out:
    type: stdout
stdout: output_ccc.txt
ccc.py
import argparse
parser = argparse.ArgumentParser(description='download files by ftp')
parser.add_argument('mypath', type=str, help='PDB')

def tst(args):
    fpath = args.split(None)[0]
    with open(fpath, 'r') as f:
      data = f.read()
    print('final result:')
    print(data)

if __name__ == '__main__':
    args = parser.parse_args()
    tst(args.mypath)

 

【版权声明】本文内容来自摩杜云社区用户原创、第三方投稿、转载,内容版权归原作者所有。本网站的目的在于传递更多信息,不拥有版权,亦不承担相应法律责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@moduyun.com

  1. 分享:
最后一次编辑于 2023年11月08日 0

暂无评论

推荐阅读
qmj2xyt4e0cp