PMCC-BioinformaticsCore / janis-core

Core python modules for Janis Pipeline workflow assistant
GNU General Public License v3.0
4 stars 9 forks source link

File-of-filenames #30

Closed drtconway closed 4 years ago

drtconway commented 4 years ago

Hi Janis,

I'm writing a wrapper for whisper, for which I've already made a docker image docker pull drtomc/whisper.

The command for building the index takes a file containing filenames.

What's the right idiom for dealing with this? One possibility is to use a wrapper shell script which takes the filenames as arguments, writes them to a file, then invokes the program.

Is there a better way?

illusional commented 4 years ago

Hey @drtconway, from the docs, it looks like you can call whisper-index on a single filename:

whisper-index <index_name> <ref_seq_file_name> <dest_dir> <temp_dir>

Can you make your tool wrapper take a single fasta file, and scatter for each fasta in your workflow:


self.input("fastas", Array(Fasta))
self.step(
    "index_fasta",
    WhisperIndex(fasta=self.fastas),
    scatter="fasta"
)
drtconway commented 4 years ago

Yeah, I saw that. Maybe I misread the documentation, but I thought you got a different result - i.e. the file of filenames yielding a single index.

illusional commented 4 years ago

Hey @drtconway, one (albeit not pretty) is to reconstruct the command line with ToolArguments, (make sure to use shell_quote=False!):

def base_command(self):
    return [] # actually ["whisper-index"]
def inputs(self):
    return [
        ToolInput("fastas", Array(fasta), separator=",", position=1)
        # all other tool inputs have position 3
        ToolInput("indexName", String, position=3)
    ]
def arguments(self):
    return [
        ToolArgument("echo", position=0),
        ToolArgument("> filenames.txt && whisper-index", position=2, shell_quote=False),
        ToolArgument("@filenames.txt", position=4),
        ToolArgument(".", position=5), # dest_dir
        ToolArgument("/tmp", position=6) # temp_dir
    ]
illusional commented 4 years ago

Hey @drtconway, I'm going to close this because I think the problem is solved. But please feel free to reopen if it's still an isssue.