nf-core / bacass

Simple bacterial assembly and annotation pipeline

Home Page:https://nf-co.re/bacass

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Regex problem

tiendu opened this issue · comments

paths = paths.collect { it.trim().replaceAll("^[/]+|[/]+\$", "") } // Trim whitespace and trailing slashes

There seems to be an incorrect regex here. Above regex can be translated as match an h / at the beginning once or more OR match an / or more that comes with literal $.

The regex doesn't remove whitespace and trailing slash(es) I believe. Correct regex should be replaceAll("\/+$| +", "").

Hi there,
did you actually test the pipeline and had a problem related to that regex or did you "just" had a look into the code?
If its the former, please report the error and input if possible, if its the latter, than I actually assume that this is a feature not a bug (i.e. because the $ needs to be escaped to work here as intended).

Actually, I'm learning from the team's codes to make my own pipeline. I tested the code on Groovy itself, it just didn't work. Try running the code alone on Groovy with some random paths and you'll see.

Also, the correct regex is below. This will help remove all whitespace, trailing slashes and slashes appearing more than once in between.
paths = paths.collect { it.trim().replaceAll(/\/{2,}/, "/").replaceAll(/\/+$| +/,"") }

The file that you criticize is part of (admittedly not most recent) nf-core template. If this code would not work, none of the nf-core pipelines would work.
While I appreciate that you would like to learn, this is not the right place to do so.
May I refer you to

the above is sorted descending in priority based on my own judgement.

The file that you criticize is part of (admittedly not most recent) nf-core template. If this code would not work, none of the nf-core pipelines would work. While I appreciate that you would like to learn, this is not the right place to do so. May I refer you to

the above is sorted descending in priority based on my own judgement.

Thank you, Daniel, for the materials. Sorry for bringing this up in such an inappropriate place.