Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Singleton list conversion cause quirk behaviour #969

Closed
apeltzer opened this issue Dec 11, 2018 · 8 comments
Closed

Singleton list conversion cause quirk behaviour #969

apeltzer opened this issue Dec 11, 2018 · 8 comments

Comments

@apeltzer
Copy link
Contributor

apeltzer commented Dec 11, 2018

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
@apeltzer apeltzer changed the title File Channel handling File.size() call returns different objects Dec 11, 2018
@pditommaso
Copy link
Member

What is bla in your example? do you mean input_files ?

@apeltzer
Copy link
Contributor Author

Updated the post, yes that's what I meant :-)

@pditommaso
Copy link
Member

OK, this is the problem we discussed right. Therefore with input_files instanceof Path ? 1 : input_files.size() you get the list size, right?

@apeltzer
Copy link
Contributor Author

Exactly, I used this now for the RNAseq pipeline in that way :-)

@pditommaso
Copy link
Member

OK. being so I will change the title because it's misleading. The problem is not the File.size method but the fact that a list containing a single value is implicitly converted to the element value, causing that quirk behaviour.

@pditommaso pditommaso changed the title File.size() call returns different objects Singleton list conversion cause quirk behaviour Dec 12, 2018
@apeltzer
Copy link
Contributor Author

Yes of course :-)

@stale
Copy link

stale bot commented Apr 27, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale
Copy link

stale bot commented May 21, 2023

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label May 21, 2023
@stale stale bot closed this as completed Aug 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants