WDL

WDL-第4学

2021-03-30  本文已影响0人  MR来了

问题:用flash批量完成数据的拼接,这里面学到的知识点

解决办法:

来源于bioWDL的一个例子

version 1.0
struct FastqPair {
    String sample
    File R1
    File R2
}
task Flash {
    input {
        FastqPair inputFastq
        String outdirPath
        Boolean compress = true
        ## 可选择
        String preCommand = ''
        Int? minOverlap
        Int? maxOverlap
        Int threads = 2
    }
    String outdir = outdirPath + "/" + inputFastq.sample + "/"
    String outPrefix = inputFastq.sample
    ## 相关命令
    command <<<
        set -e -o pipefail
        rm -rf ~{outdir}
        mkdir -p ~{outdir}
        cd ~{outdir}
        ~{preCommand}
        flash \
        ~{"--threads=" + threads} \
        ~{"--output-directory=" + outdir} \
        ~{'--output-prefix=' + inputFastq.sample} \
        ~{true="--compress " false="" compress} \
        ~{"--min-overlap=" + minOverlap} \
        ~{"--max-overlap=" + maxOverlap} \
        ~{inputFastq.R1} ~{inputFastq.R2}
    >>>
    output {
        File extendedFrags = outdir + "/" + outPrefix + ".extendedFrags.fastq.gz"
        File notCombined1  = outdir + "/" + outPrefix + ".notCombined_1.fastq.gz"
        File notCombined2  = outdir + "/" + outPrefix + ".notCombined_2.fastq.gz"
        FastqPair notCombined = object {
            R1: notCombined1,
            R2: notCombined2,
            sample: outPrefix
        }
        File hist = outdir + "/" + outPrefix + ".hist"
        File histogram = outdir + "/" + outPrefix + ".histogram"
    }
}
workflow wf_flash {
    input {
        String outdirPath
        Boolean compress = true
        String preCommand = ''
        Int? minOverlap
        Int? maxOverlap
        Int threads = 2
        Array[FastqPair] fastqs
    }
    scatter (fastq in fastqs){
        call Flash {
            input:
                outdirPath = outdirPath,
                compress = compress,
                preCommand = preCommand,
                minOverlap = minOverlap,
                maxOverlap = maxOverlap,
                threads = 2,
                inputFastq = fastq
        }
    }
}
{
  "wf_flash.preCommand": "export PATH=/your_path/FLASH-1.2.7/:$PATH",
  "wf_flash.fastqs": [
      {"sample":"sample1", "R1":"/your_path/sample1_t1.fastq", "R2":"/your_path/sample1_t2.fastq"},
      {"sample":"sample2", "R1":"/your_path/sample2_t1.fastq", "R2":"/your_path/sample2_t2.fastq"}
   ],
  "wf_flash.outdirPath": "/your_path/flash_out"
}
$ java -jar cromwell-57.jar run flash.wdl --inputs flash.json
{
  "outputs": {
    "wf_flash.Flash.notCombined2": ["/your_path/sample1.notCombined_2.fastq.gz", "/your_path/sample2.notCombined_2.fastq.gz"],
    "wf_flash.Flash.notCombined1": ["/your_path/sample1.notCombined_1.fastq.gz", "/your_path/sample2.notCombined_1.fastq.gz"],
    "wf_flash.Flash.hist": ["/your_path/sample1.hist", "/your_path/sample2.hist"],
    "wf_flash.Flash.histogram": ["/your_path/sample1.histogram", "/your_path/sample2.histogram"],
    "wf_flash.Flash.extendedFrags": ["/your_path/sample1.extendedFrags.fastq.gz", "/your_path/sample2.extendedFrags.fastq.gz"],
    "wf_flash.Flash.notCombined": [{
      "R1": "/your_path/sample1.notCombined_1.fastq.gz",
      "sample": "sample1",
      "R2": "/your_path/sample1.notCombined_2.fastq.gz"
    }, {
      "R1": "/your_path/sample2.notCombined_1.fastq.gz",
      "sample": "sample2",
      "R2": "/your_path/sample2.notCombined_2.fastq.gz"
    }]
  },
  "id": "c7b6b5ce-3fa9-418a-89fb-16afe694e932"
}
上一篇下一篇

猜你喜欢

热点阅读