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

Remove for loops from the pipeline template #3183

Closed
bentsherman opened this issue Sep 27, 2024 · 3 comments
Closed

Remove for loops from the pipeline template #3183

bentsherman opened this issue Sep 27, 2024 · 3 comments
Milestone

Comments

@bentsherman
Copy link

for and while loops will not be supported in the strict parser that is on the way. Looks like #3166 addresses one of them, here are a few more.

In workflowCitation():

    // old
    for (String doi_ref: manifest_doi)
        temp_doi_ref += "  https://doi.org/${doi_ref.replace('https://doi.org/', '').replace(' ', '')}\n"

    // new
    manifest_doi.each { doi_ref ->
        temp_doi_ref += "  https://doi.org/${doi_ref.replace('https://doi.org/', '').replace(' ', '')}\n"
    }

I believe the other for loops in utils_nfcore_pipeline can be addressed in a similar way.

The one in checkCondaChannels() is a bit trickier because it's not just iterating through a list:

    def n = required_channels_in_order.size()
    for (int i = 0; i < n - 1; i++) {
        channel_priority_violation |= !(channels.indexOf(required_channels_in_order[i]) < channels.indexOf(required_channels_in_order[i+1]))
    }

I believe the intent is to make sure that the required channels are in the right order while also allowing other channels to be in the list. Here is a "groovier" 😉 way to do it:

    def channel_priority_violation = required_channels_in_order != channels.findAll { ch -> ch in required_channels_in_order }
@ewels ewels added this to the 3.0 milestone Sep 27, 2024
@mirpedrol
Copy link
Member

Hi, this was fixed by @nvnieuwk, the current code looks like this:

manifest_doi.each { doi_ref ->
        temp_doi_ref += "  https://doi.org/${doi_ref.replace('https://doi.org/', '').replace(' ', '')}\n"
    }

and

required_channels_in_order.eachWithIndex { channel, index ->
        if (index < required_channels_in_order.size() - 1) {
            channel_priority_violation |= !(channels.indexOf(channel) < channels.indexOf(required_channels_in_order[index+1]))
        }
    }

Does this look ok?

@bentsherman
Copy link
Author

Looks fine to me! Just don't forget the other for loops in utils_nfcore_pipeline, there were several more that I didn't list

@mirpedrol
Copy link
Member

Done with #3166, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants