Skip to content

Commit

Permalink
Seperated reference and query for profile dist
Browse files Browse the repository at this point in the history
  • Loading branch information
sgsutcliffe committed Dec 12, 2024
1 parent 25f22dd commit f1c2fc6
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 7 deletions.
14 changes: 10 additions & 4 deletions modules/local/locidex/merge/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,22 @@ process LOCIDEX_MERGE {
'mwells14/locidex:0.2.3' }"

input:
path input_values // [file(sample1), file(sample2), file(sample3), etc...]
path input_query // [file(sample1), file(sample2), file(sample3), etc...]
path input_reference // [file(sample1), file(sample2), file(sample3), etc...]

output:
path("${combined_dir}/*.tsv"), emit: combined_profiles
path("${combined_dir1}/*.tsv"), emit: combined_profiles_query
path("${combined_dir2}/*.tsv"), emit: combined_profiles_reference
path "versions.yml", emit: versions

script:
combined_dir = "merged"
combined_dir1 = "merged_query"
combined_dir2 = "merged_reference"
"""
locidex merge -i ${input_values.join(' ')} -o ${combined_dir}
locidex merge -i ${input_query.join(' ')} -o ${combined_dir1}
mv ${combined_dir1}/profile.tsv ${combined_dir1}/profile_query.tsv
locidex merge -i ${input_reference.join(' ')} -o ${combined_dir2}
mv ${combined_dir2}/profile.tsv ${combined_dir2}/profile_reference.tsv
cat <<-END_VERSIONS > versions.yml
"${task.process}":
locidex merge: \$(echo \$(locidex search -V 2>&1) | sed 's/^.*locidex //' )
Expand Down
3 changes: 2 additions & 1 deletion modules/local/profile_dists/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ process PROFILE_DISTS{

input:
path query
path reference
val mapping_format
path mapping_file
path columns
Expand Down Expand Up @@ -40,7 +41,7 @@ process PROFILE_DISTS{
}
prefix = "distances"
"""
profile_dists --query $query --ref $query $args --outfmt $mapping_format \\
profile_dists --query $query --ref $reference $args --outfmt $mapping_format \\
--force \\
--distm $params.pd_distm \\
--file_type $params.pd_file_type \\
Expand Down
18 changes: 16 additions & 2 deletions workflows/fastmatchirida.nf
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,20 @@ workflow FASTMATCH {
meta, mlst_files -> mlst_files
}.collect()

input_assure.result
.branch { meta, mlst_file ->
reference: meta.ref_query == "reference"
query: meta.ref_query == "query"
}.set {merged_alleles}

merged_alleles_query = merged_alleles.query.map{
meta, mlst_files -> mlst_files
}.collect()

merged_alleles_reference = merged_alleles.reference.map{
meta, mlst_files -> mlst_files
}.collect()

metadata_headers = Channel.of(
tuple(
SAMPLE_HEADER,
Expand All @@ -119,7 +133,7 @@ workflow FASTMATCH {
meta.metadata_5, meta.metadata_6, meta.metadata_7, meta.metadata_8)
}.toList()

merged = LOCIDEX_MERGE(merged_alleles)
merged = LOCIDEX_MERGE(merged_alleles_query, merged_alleles_reference)
ch_versions = ch_versions.mix(merged.versions)

// optional files passed in
Expand Down Expand Up @@ -148,7 +162,7 @@ workflow FASTMATCH {
// Options related to profile dists
mapping_format = Channel.value("pairwise")

distances = PROFILE_DISTS(merged.combined_profiles, mapping_format, mapping_file, columns_file)
distances = PROFILE_DISTS(merged.combined_profiles_query, merged.combined_profiles_reference, mapping_format, mapping_file, columns_file)
ch_versions = ch_versions.mix(distances.versions)

// Append metadata to references:
Expand Down

0 comments on commit f1c2fc6

Please sign in to comment.