Skip to content

Singleton list conversion cause quirk behaviour #969

@apeltzer

Description

@apeltzer

Bug report

Minimal example:

    input:
    file input_files from featureCounts_to_merge.collect()

    output:
    file 'merged_gene_counts.txt'

    script:
    //if we only have 1 file, just use cat and pipe output to csvtk. Else join all files first, and then remove unwanted column names.
    def single = input_files instanceof Path ? 1 : input_files.size()
    def merge = (single == 1) ? 'cat' : 'csvtk join -t -f "Geneid,Start,Length,End,Chr,Strand,gene_name"'
    """
    $merge $input_files | csvtk cut -t -f "-Start,-Chr,-End,-Length,-Strand" | sed 's/Aligned.sortedByCoord.out.markDups.bam//g' > merged_gene_counts.txt
    """

Expected behavior and actual behavior

I expect input_files.size() to return the size of the list, e.g. having n elements.

Actually, this depends:

  • if its just one element, it returns a Path object, so path.size() returns the length of the path as a String
  • if its multiple elements, it returns the list size, as expected

Steps to reproduce the problem

See above testcase

Program output

Environment

  • Nextflow version: 18.10.1
  • Java version: 1.8
  • Operating system: no-arch

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions