Skip to content
Snippets Groups Projects
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
main.nf 1.97 KiB
/*
 * Copyright (c) 2016. The University of Texas Southwestern Medical Center
 *
 *   This file is part of the BioHPC Workflow Platform
 *
 * This is a minimal test workflow package that astrocyte tests can run against.
 *
 * @authors
 * David Trudgian <David.Trudgian@UTSouthwestern.edu>
 *
 */

// Path to an input file, or a pattern for multiple inputs
// Note - $baseDir is the location of this workflow file main.nf
params.story = "$baseDir/../test_data/mobydick.txt"

// Parameters for test values, only used for demonstrating parameter types
params.test_int = 999
params.test_real = 999.99
params.test_string = "Default String"
params.test_select = "Default Selection"
params.test_multiselect = "Default Selection"


stories = Channel.fromPath( params.story )

process parameters {

    cpus 1

    """
    echo "Test Parameters Provided..."
    echo "story: ${params.story}"
    echo "test_int: ${params.test_int}"
    echo "test_real: ${params.test_real}"
    echo "test_string: ${params.test_string}"
    echo "test_select: ${params.test_select}"
    echo "test_multiselect: ${params.test_multiselect}"

    """
}

process uppercase {

    cpus 1

    input:
    file story from stories

    output:
    file "${story.name}.uppercase" into uppercased

    """
    cat "$story" | tr "[a-z]" "[A-Z]" > "${story.name}.uppercase"
    """

}

process tolines {

    cpus 1

    input:
    file uppercase from uppercased

    output:
    file "${uppercase.name}.tolines" into tolines

    """
    cat "$uppercase" | tr -cs "A-Z'" "\012"  > "${uppercase.name}.tolines"
    """

}

process wordcounts {

    // Publish the outputs we create here into the workflow output directory
    publishDir "$baseDir/output", mode: 'copy'

    input:
    file wordlines from tolines

    output:
    file "${wordlines.name}.wordcount"

    """
    cat "$wordlines" | sort | uniq -c | sort -n -r > "${wordlines.name}.wordcount"
    """
}