Damon-Lee Pointon
08/25/2026, 9:48 AM// Read the .fai file to extract the number of sequences, the maximum and total sequence length
// Inspired from <https://github.com/nf-core/rnaseq/blob/3.10.1/lib/WorkflowRnaseq.groovy>
def get_sequence_map(fai_file) {
def n_sequences = 0
def max_length = 0
def total_length = 0
fai_file.eachLine { line ->
def lspl = line.split('\t')
// def chrom = lspl[0]
def length = lspl[1].toLong()
n_sequences += 1
total_length += length
if (length > max_length) {
max_length = length
}
}
def sequence_map = [:]
sequence_map.n_sequences = n_sequences
sequence_map.total_length = total_length
if (n_sequences) {
sequence_map.max_length = max_length
}
return sequence_map
}
It's a really small function which will be modified to generate a JSON file instead so we don't pollute meta. It's not doing much so is it worth a module?Matthias De Smet
08/25/2026, 10:09 AMfai file is generally very smallMatthias De Smet
08/25/2026, 10:11 AMDamon-Lee Pointon
08/26/2026, 9:34 AM