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

Check broken links #89

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions modules/local/check_broken_links.nf
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
process CHECK_BROKEN_LINKS {
label 'process_long'

conda "conda-forge::pigz=2.6"
container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ?
'https://depot.galaxyproject.org/singularity/mulled-v2-5799ab18b5fc681e75923b2450abaa969907ec98:941789bd7fe00db16531c26de8bf3c5c985242a5-0' :
'biocontainers/mulled-v2-5799ab18b5fc681e75923b2450abaa969907ec98:941789bd7fe00db16531c26de8bf3c5c985242a5-0' }"

input:
tuple val(accno), val(genome_fna), val(genome_gff)

output:
tuple val(accno), val(genome_fna), val(genome_gff), emit: valid_genomes_ch
path "versions.yml" , emit: versions

script:
"""
# Use curl to check if the URL returns 404
if curl -Is "${genome_fna}" | grep -q "404 Not Found"; then
echo "Broken link: ${genome_fna}"
exit 0 # Exit successfully but don't emit anything
Comment on lines +18 to +21
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This only works on remote files, right?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, it does.

else
# Correctly echo the variables
echo "{accno:'${accno}', genome_fna:'${genome_fna}', genome_gff:'${genome_gff}'}"
fi

cat <<-END_VERSIONS > versions.yml
"${task.process}":
pigz: \$( pigz --version 2>&1 | sed 's/^pigz //' )
END_VERSIONS
"""
}
19 changes: 18 additions & 1 deletion subworkflows/local/sourmash.nf
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ include { SOURMASH_GATHER } from '../../modules/nf-core/sourma
include { SOURMASH_SKETCH as GENOMES_SKETCH } from '../../modules/nf-core/sourmash/sketch/main'
include { SOURMASH_INDEX as GENOMES_INDEX } from '../../modules/nf-core/sourmash/index/main'
include { SOURMASH_SKETCH as SAMPLES_SKETCH } from '../../modules/nf-core/sourmash/sketch/main'
include { CHECK_BROKEN_LINKS } from '../../modules/local/check_broken_links'

workflow SOURMASH {
take:
Expand Down Expand Up @@ -140,9 +141,25 @@ workflow SOURMASH {
.mix(ch_matching_user_non_ncbi_genomes)
.set { ch_filtered_genomes }

// Check presence of broken links
CHECK_BROKEN_LINKS(ch_filtered_genomes)
ch_versions = ch_versions.mix(CHECK_BROKEN_LINKS.out.versions)

// Filter out null entries after link validation
ch_valid_genomes_filtered =
CHECK_BROKEN_LINKS.out.valid_genomes_ch
.filter { it != null }
.map{
[
accno: it[0],
genome_fna: it[1],
genome_gff: it[2]
]
}

emit:
gindex = GENOMES_SKETCH.out.signatures
sindex = SAMPLES_SKETCH.out.signatures
filtered_genomes = ch_filtered_genomes
filtered_genomes = ch_valid_genomes_filtered
versions = ch_versions
}
Loading