Writing a XML description for some custom tools, I wanted to share things using XML entities declared in an external file.
<?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE tool [ <!ENTITY % tool_entities SYSTEM "tool.ent"> %tool_entities; ]> <tool (...)> <command>&java_exe; &jvm_options; -cp /lib/my.jar my.Tool (..)</command>
The file tool.ent:
<!ENTITY java_exe "/usr/bin/java"> <!ENTITY jvm_options " -Xmx500m ">
xmllint resolve/replace my entities in the XML file without any problem:
$ xmllint --noent tools/mytools/tool.xml
but the expat engine in galaxy doesn't seem to resolve it:
ExpatError: undefined entity &java_exe;: line 8, column 30
URL: http://172.18.254.211:8080/galaxy/admin/reload_tool
File '/commun/data/users/galaxy-dev/galaxy-dist/eggs/WebError-0.8a-py2.6.egg/weberror/evalexception/middleware.py', line 364 in respond
app_iter = self.application(environ, detect_start_response)
File '/commun/data/users/galaxy-dev/galaxy-dist/eggs/Paste-1.7.5.1-py2.6.egg/paste/recursive.py', line 84 in __call__
return self.application(environ, start_response)
File '/commun/data/users/galaxy-dev/galaxy-dist/eggs/Paste-1.7.5.1-py2.6.egg/paste/httpexceptions.py', line 633 in __call__
return self.application(environ, start_response)
File '/commun/data/users/galaxy-dev/galaxy-dist/lib/galaxy/web/framework/base.py', line 125 in __call__
return self.handle_request( environ, start_response )
File '/commun/data/users/galaxy-dev/galaxy-dist/lib/galaxy/web/framework/base.py', line 182 in handle_request
body = method( trans, **kwargs )
File '/commun/data/users/galaxy-dev/galaxy-dist/lib/galaxy/web/framework/__init__.py', line 228 in decorator
return func( self, trans, *args, **kwargs )
File '/commun/data/users/galaxy-dev/galaxy-dist/lib/galaxy/web/base/controllers/admin.py', line 65 in reload_tool
message, status = toolbox.reload_tool_by_id( tool_id )
File '/commun/data/users/galaxy-dev/galaxy-dist/lib/galaxy/tools/__init__.py', line 605 in reload_tool_by_id
new_tool = self.load_tool( old_tool.config_file )
File '/commun/data/users/galaxy-dev/galaxy-dist/lib/galaxy/tools/__init__.py', line 581 in load_tool
tree = self._load_and_preprocess_tool_xml( config_file )
File '/commun/data/users/galaxy-dev/galaxy-dist/lib/galaxy/tools/__init__.py', line 767 in _load_and_preprocess_tool_xml
tree = parse_xml(config_file)
File '/commun/data/users/galaxy-dev/galaxy-dist/lib/galaxy/util/__init__.py', line 143 in parse_xml
tree = ElementTree.parse(fname)
File '/commun/data/users/galaxy-dev/galaxy-dist/eggs/elementtree-1.2.6_20050316-py2.6.egg/elementtree/ElementTree.py', line 859 in parse
tree.parse(source, parser)
File '/commun/data/users/galaxy-dev/galaxy-dist/eggs/elementtree-1.2.6_20050316-py2.6.egg/elementtree/ElementTree.py', line 583 in parse
parser.feed(data)
File '/commun/data/users/galaxy-dev/galaxy-dist/eggs/elementtree-1.2.6_20050316-py2.6.egg/elementtree/ElementTree.py', line 1242 in feed
self._parser.Parse(data, 0)
File '/commun/data/users/galaxy-dev/galaxy-dist/eggs/elementtree-1.2.6_20050316-py2.6.egg/elementtree/ElementTree.py', line 1198 in _default
self._parser.ErrorColumnNumber)
ExpatError: undefined entity &java_exe;: line 8, column 30
can I tell galaxy to resolve XML entities ?
P.
UPDATE: I tested various way of settings macros (using <tokens/>, <xml/>, <macro><action></action></macro> ... ) . For example:
<macros>
<macro name="java_exe">/usr/bin/java</macro>
<macro name="jvm_options"> -Xmx500m </macro>
</macros>
and
(...)
<macros>
<import>macros.xml</import>
</macros>
<command> <expand macro="java_exe"/> <expand macro="jvm_options"/> (...)
(...)
but the macros in <command> don't seem to be resolved (I suspect they're replaced with empty string)
Edit2: here is my files so far. In <command>,
I put the content of @JAVA_EXE@ in a file, the ouput is "@JAVA_EXE@" (no substitution)
Please note that setting -Xmx and co is not needed to be set inside the tool. Are better way would be to set it via the job_conf.xml file. Here, an administrator can specify individual settings for every tool and adjust it to the cluster settings.
Likewise the location of the Java binary might be better done via an environment variable like PATH or something specific via a dependency, rather than hard coding like this?
Yes! Imho you can omit the path and call java directly. Galaxy will lookup in $PATH and will find java.
What is in the Galaxy logging when it calls the tool? That would show you the actual command line string built from the
<command>
tag and the user's parameter selection.Cross posted to galaxy-dev http://lists.bx.psu.edu/pipermail/galaxy-dev/2014-May/019414.html / http://dev.list.galaxyproject.org/replacing-XML-fragments-in-mycustomtool-xml-tc4664538.html
Did this work once you updated Galaxy itself (as per the galaxy-dev discussion)?
sorry for the late response Peter, We are reorganizing our servers and the new server for galaxy with the latest version of galaxy isn't ready. I'll validate your answer anyway.