Skip to content

Commit

Permalink
Add tag uniqueness checks
Browse files Browse the repository at this point in the history
  • Loading branch information
GallVp committed Feb 28, 2024
1 parent 39f6854 commit 66de124
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 4 deletions.
2 changes: 1 addition & 1 deletion assets/schema_xref_assemblies.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"$schema": "http://json-schema.org/draft-07/schema",
"$id": "https://raw.githubusercontent.com/plant-food-research-open/assemblyqc/master/assets/schema_input.json",
"$id": "https://raw.githubusercontent.com/plant-food-research-open/assemblyqc/master/assets/schema_xref_assemblies.json",
"title": "plant-food-research-open/assemblyqc pipeline - params.synteny_xref_assemblies schema",
"description": "Schema for the file provided with params.synteny_xref_assemblies",
"type": "array",
Expand Down
34 changes: 34 additions & 0 deletions lib/WorkflowAssemblyqc.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,40 @@ class WorkflowAssemblyqc {
}
}

public static ArrayList validateInput(input) {
def inputFields = 5
def assemblyTags = input[(0..input.size()-1).step(inputFields)]

def tagCounts = [:]
assemblyTags.each { tag ->
tagCounts[tag] = tagCounts.containsKey(tag) ? tagCounts[tag] + 1 : 1
}
def repeatedTags = tagCounts.findAll { key, count -> count > 1 }.collect { key, count -> key }

if (repeatedTags.size() > 0) {
Nextflow.error("Please check input assemblysheet -> Multiple assemblies have the same tags!: ${repeatedTags}")
}

return input
}

public static ArrayList validateXrefAssemblies(xref) {
def xrefFields = 3
def xrefTags = xref[(0..xref.size()-1).step(xrefFields)]

def tagCounts = [:]
xrefTags.each { tag ->
tagCounts[tag] = tagCounts.containsKey(tag) ? tagCounts[tag] + 1 : 1
}
def repeatedTags = tagCounts.findAll { key, count -> count > 1 }.collect { key, count -> key }

if (repeatedTags.size() > 0) {
Nextflow.error("Please check synteny_xref_assemblies -> Multiple xref assemblies have the same tags!: ${repeatedTags}")
}

return xref
}

public static String jsonifyParams(params) {
return JsonOutput.toJson(params).toString()
}
Expand Down
5 changes: 3 additions & 2 deletions nextflow.config
Original file line number Diff line number Diff line change
Expand Up @@ -145,10 +145,11 @@ profiles {
shifter.enabled = false
charliecloud.enabled = false
apptainer.enabled = false
docker.runOptions = '-u $(id -u):$(id -g)'
// docker.runOptions = '-u $(id -u):$(id -g)'
}
arm {
docker.runOptions = '-u $(id -u):$(id -g) --platform=linux/amd64'
// docker.runOptions = '-u $(id -u):$(id -g) --platform=linux/amd64'
docker.runOptions = '--platform=linux/amd64'
}
singularity {
singularity.enabled = true
Expand Down
2 changes: 1 addition & 1 deletion tests/stub/stub.config
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ params {

hic = 'tests/stub/hic/Dummy_hic.R{1,2}.fq.gz'

synteny_skip = false
synteny_skip = true // GitHub action runner runs out of memory
synteny_xref_assemblies = 'https://raw.githubusercontent.com/plant-food-research-open/assemblyqc/dev/assets/xrefsheet.csv'

// Limit resources so that this can run on GitHub Actions
Expand Down
8 changes: 8 additions & 0 deletions workflows/assemblyqc.nf
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,17 @@ include { CUSTOM_DUMPSOFTWAREVERSIONS } from '../modules/nf-core/custom/du

// Info required for completion email and summary
def assemblyqc_report = []
def input_assembly_sheet_fields = 5
def synteny_xref_assemblies_fields = 3

workflow ASSEMBLYQC {

// Input channels
ch_versions = Channel.empty()
ch_input = Channel.fromSamplesheet('input')
| collect
| flatMap { WorkflowAssemblyqc.validateInput(it) }
| buffer(size: input_assembly_sheet_fields)

ch_target_assemby_branch = ch_input
| map { tag, fasta, gff, mono_ids, labels ->
Expand Down Expand Up @@ -126,6 +131,9 @@ workflow ASSEMBLYQC {
ch_xref_assembly = params.synteny_skip || ! params.synteny_xref_assemblies
? Channel.empty()
: Channel.fromSamplesheet('synteny_xref_assemblies')
| collect
| flatMap { WorkflowAssemblyqc.validateXrefAssemblies(it) }
| buffer(size: synteny_xref_assemblies_fields)
| map { tag, fa, labels ->
[ tag, file(fa, checkIfExists: true), file(labels, checkIfExists: true) ]
}
Expand Down

0 comments on commit 66de124

Please sign in to comment.