Catching matlab output

@mribeirodantas So I came up with a workaround. This has bash call matlab and passes $(pwd) to the program call so the script knows where to save to. The absolute path to the script is necessary – or h…/…/…/bin/matlabtest.m works too.

process simpletest {
  input:
    path fileName
  output:
    path '*.txt'
"""
#!/usr/bin/bash
matlab -batch "folder='\$(pwd)'; content='$fileName'; run('/scratch/st-akb2g-1/kd/bin/matlabtest.m'); exit;"
"""
}

with matlabtest.m:

content                                                                                                                                                                                                                            % saving ascii code numbers, okay for a test
save([folder '/testsave.txt'], 'content', "-ascii")
quit(0)

Things are working as desired now with testsave.txt being saved in the cached work/ directory.

Are there any unintended consequences lurking around with this approach? It feels weird having to use $(pwd) like this.

(edit: the matlabtest.m file has always been in the the bin/ directory. I think that since the Process script doesn’t use a matlab shebang, that that’s why it doesn’t get found.)