Re: [galaxy-dev] [galaxy-user] How to create a tool from a script that loads additional source code files?
On Mon, Feb 25, 2013 at 7:11 PM, Samuel Lampa <samuel.lampa@gmail.com> wrote:
Hi,
I have aGalaxy toolwith some R code which is split up into a few files, which are loaded by a "master R script", which orcestrates and executes the whole thing.
I realize that when the master script ("run.R" in my case) is run, it will not find the other files, since it is itself moved away to a temporary working directory (something like ".../galaxy/database/job_working_directory/000/165").
Is there any "standard way" of dealing with this, any special toolconfig syntax etc? ... or do I have to just hard code the absolute paths to the extra files in my script? :|
Presumably all the child R scripts will be in the same folder as your master R script (or you know the relative path if not). So all you need to do is workout the path of the master R script, and from that compute the path to the child R scripts. I guess you can do this in R using commandArgs(). For future reference, queries about writing tools and extending Galaxy should go to the galaxy-dev list (CC'd), not galaxy-users. Peter
Hi, thanks for the quick reply! On 02/25/2013 08:39 PM, Peter Cock wrote:
I realize that when the master script ("run.R" in my case) is run, it will
not find the other files, since it is itself moved away to a temporary working directory (something like ".../galaxy/database/job_working_directory/000/165").
Is there any "standard way" of dealing with this, any special toolconfig syntax etc? ... or do I have to just hard code the absolute paths to the extra files in my script? :| Presumably all the child R scripts will be in the same folder as your master R script (or you know the relative path if not). So all you need to do is workout the path of the master R script, and from that compute the path to the child R scripts. I guess you can do this in R using commandArgs().
True. And yes, I do keep the other scripts in the same folder. But since the main script is moved away to the job_working_directory (but not the other scripts, as far as I can tell), they will not be in the same folder anymore, so then in order to get from the job_working_directory back to the tools folder, I would need to go something like: [main R script folder]../../../../tools/[mytool]/r/[script file] I was thinking that it might be a bit fragile, but of course, if the directory depth of the job_working_directory path will keep quite constant it will surely not be a big problem.
For future reference, queries about writing tools and extending Galaxy should go to the galaxy-dev list (CC'd), not galaxy-users.
Ah, true! I always tend to forget that I'm not the true end-user of galaxy, although I'm in a way "using" it :) Best Regards // Samuel
On Mon, Feb 25, 2013 at 8:02 PM, Samuel Lampa <samuel.lampa@gmail.com> wrote:
Hi, thanks for the quick reply!
On 02/25/2013 08:39 PM, Peter Cock wrote:
I realize that when the master script ("run.R" in my case) is run, it will
not find the other files, since it is itself moved away to a temporary working directory (something like ".../galaxy/database/job_working_directory/000/165").
Is there any "standard way" of dealing with this, any special toolconfig syntax etc? ... or do I have to just hard code the absolute paths to the extra files in my script? :|
Presumably all the child R scripts will be in the same folder as your master R script (or you know the relative path if not). So all you need to do is workout the path of the master R script, and from that compute the path to the child R scripts. I guess you can do this in R using commandArgs().
True. And yes, I do keep the other scripts in the same folder. But since the main script is moved away to the job_working_directory (but not the other scripts, as far as I can tell), they will not be in the same folder anymore, ...
Are you just calling a pre-existing static R script, or doing something more complicated like generating the R script in the tool XML file? For calling pre-existing scripts or binaries, I thought it was just the current working directory which was changed to something like job_working_directory. Regards, Peter
participants (2)
-
Peter Cock
-
Samuel Lampa