Skip to content

Commit

Permalink
Collect query_ids into a file for FILTER_QUERY
Browse files Browse the repository at this point in the history
  • Loading branch information
kylacochrane committed Sep 12, 2024
1 parent 27a6528 commit dd42d61
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 10 deletions.
10 changes: 1 addition & 9 deletions modules/local/filter_query/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -22,27 +22,19 @@ process FILTER_QUERY {
def out_delimiter = out_format == "tsv" ? "\t" : (out_format == "csv" ? "," : out_format)
def out_extension = out_format == "tsv" ? 'tsv' : 'csv'

// Write the query IDs to a temporary file
def queryFile = file("query_ids.txt")
queryFile.text = query_ids.join("\n")

"""
# Filter the query samples only; keep only the 'id' and 'address' columns
csvtk grep \\
${addresses} \\
-f 1 \\
-P ${queryFile} \\
-P ${query_ids} \\
--delimiter "${delimiter}" \\
--out-delimiter "${out_delimiter}" | \\
csvtk cut -f id,address > ${outputFile}.${out_extension}
# Remove the query_ids file after the command runs
rm -f ${queryFile}
cat <<-END_VERSIONS > versions.yml
"${task.process}":
csvtk: \$(echo \$( csvtk version | sed -e "s/csvtk v//g" ))
END_VERSIONS
"""
}

2 changes: 1 addition & 1 deletion workflows/gas_nomenclature.nf
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ workflow GAS_NOMENCLATURE {
ch_versions = ch_versions.mix(called_data.versions)

// Filter the new queried samples and addresses into a CSV/JSON file for the IRIDANext plug in
query_ids = profiles.query.collect { it[0].id }
query_ids = profiles.query.collectFile { it[0].id + '\n' }

new_addresses = FILTER_QUERY(query_ids, called_data.distances, "tsv", "csv")
ch_versions = ch_versions.mix(new_addresses.versions)
Expand Down

0 comments on commit dd42d61

Please sign in to comment.