As discussed at the maintainers meeting on Friday ...
# team-maintainers
j
As discussed at the maintainers meeting on Friday - I have made a port of a subworkflow to use the samtools/multicommand module. This (BAM_MARKDUPLICATES_SAMTOOLS) was the only subworkflow I could quickly find that chains multiple samtools calls on one another, and in this case the subworkflow can be completely replaced with a single module call. One thing I did note when putting this together with a real-world example, is that the samtools modules are not particularly consistent in their interface. For example, I discovered that
samtools collate
will write to stdout when you pass the
-O
flag, rather than just passing
-
as with many of the subcommands, which required some bugfixes to the code I had already written. So I think it's possible a module like this could hold quite a few bugs if not constructed with care, and well-tested so that at the very least each subcommand is tested as the first and last command of a pipeline, which might be onerous. And if we replicated this for other tools, they might require their own carefully-constructed carve-outs. Not sure that the above is necessarily reason to not have these modules, but it means they would definitely require some care in the way they are written so that the logic is clear and are not a mess of ifs and opt-outs. github.com/nf-core/modules/pull/11550/
m
Might be worthwhile to make a variant of this? github.com/nf-core/modules/…/sormadup
j
That's functionally the module that runs in BAM_MARKDUPLICATES_SAMTOOLS - collate -> fixmate -> sort -> markdup
m
facepalm
sorry, have to read better
s
I don't think that the module needs to be 100% bug proof before we make it available. It is via use that these really surface, and this should fail completely with that sort of error. It is also likely to be used by more experienced developers in the first place
j
Agreed - I bring it up more as a general caveat to implementing this kind of module - testing should be extensive to catch as many edge-cases as possible and where possible the code should be organised to avoid spaghetti by catching exceptions in a clean way
m
ok, so
multicommand
? We agree on this for the name?
πŸ‘πŸ» 1
j
Works for me. Alternative would be
pipedcommand
if we want to be more explicit that the module creates a chain of piped commands, but I don't know if we care enough
Anyone have a good suggestion of a way to cleverly apportion threads among a set of samtools commands that is user-configuable?
What if we just checked if
args
contains a threads option and don't apply it in this case?
Or... how about
task.ext.cpus1
->
task.ext.cpusN
😌
m
All modules and subworkflows currently give all
task.ext.cpus
cpus to each sub-command, letting the OS / execution engine manage the number of CPUs being used.
j
And that's how this module works also, currently, but we discussed in the maintainer's meeting last week if we would need to think about the allocation of CPUs among these samtools commands
e.g. for
[view, sort]
you might want to apportion 16 threads as
4,12
. Though in practice I don't know if this is efficient as once view is done the sort can't take advantage if those extra 4 threads.
m
I agree with capping the number of CPUs given to some commands. For instance,
view
probably can’t print things faster with 12 CPUs than with 4 CPUs (or less) – stdout is likely the bottleneck. But not trying to keep the sum of all threads given to all commands equal to
task.ext.cpus
. This would lead to an underuse of the CPUs
j
I suppose this also depends on whether something like
view
is the final command. If I'm filtering to a 100GB+ CRAM file, I might want the spare threads at the final stage for compression.
I think that's why I'd rather leave this in the hands of the user (if at all) rather than try and hard-code anything.
πŸ‘ 1
I decided to just scan the args - if a user passes
-@
in args, the default
task.cpus
is overridden for that tool. There's no check that this adds up, but it does give some control over the threading if needed.
βœ… 2