Skip to content
Snippets Groups Projects
samtools.wdl 1.15 KiB
Newer Older
pjvan_thof's avatar
pjvan_thof committed
task Index {
Peter van 't Hof's avatar
Peter van 't Hof committed
    String? preCommand
pjvan_thof's avatar
pjvan_thof committed
    String bamFilePath

    command {
Peter van 't Hof's avatar
Peter van 't Hof committed
        set -e -o pipefail
        ${preCommand}
pjvan_thof's avatar
pjvan_thof committed
        samtools index ${bamFilePath}
    }

    output {
        File indexFile = bamFilePath + ".bai"
    }
}

pjvan_thof's avatar
pjvan_thof committed
task Merge {
Peter van 't Hof's avatar
Peter van 't Hof committed
    String? preCommand
pjvan_thof's avatar
pjvan_thof committed
    Array[File]+ bamFiles
pjvan_thof's avatar
pjvan_thof committed
    String outputBamPath

    command {
Peter van 't Hof's avatar
Peter van 't Hof committed
        set -e -o pipefail
        ${preCommand}
        if [ ${length(bamFiles)} -gt 1 ]
          then
            samtools merge ${outputBamPath} ${sep=' ' bamFiles}
          else
            ln -sf ${bamFiles} ${outputBamPath}
        fi
pjvan_thof's avatar
pjvan_thof committed
    }

    output {
pjvan_thof's avatar
pjvan_thof committed
        File outputBam = outputBamPath
pjvan_thof's avatar
pjvan_thof committed
    }
Peter van 't Hof's avatar
Peter van 't Hof committed
}

task Markdup {
Peter van 't Hof's avatar
Peter van 't Hof committed
    String? preCommand
Peter van 't Hof's avatar
Peter van 't Hof committed
    File inputBam
    String outputBamPath

    command {
Peter van 't Hof's avatar
Peter van 't Hof committed
        set -e -o pipefail
        ${preCommand}
Peter van 't Hof's avatar
Peter van 't Hof committed
        samtools markdup ${inputBam} ${outputBamPath}
    }

    output {
        File outputBam = outputBamPath
    }
}

task Flagstat {
Peter van 't Hof's avatar
Peter van 't Hof committed
    String? preCommand
Peter van 't Hof's avatar
Peter van 't Hof committed
    File inputBam
    String outputPath

    command {
Peter van 't Hof's avatar
Peter van 't Hof committed
        set -e -o pipefail
        ${preCommand}
Peter van 't Hof's avatar
Peter van 't Hof committed
        samtools flagstat ${inputBam} > ${outputPath}
    }

    output {
        File flagstat = outputPath
    }
}