# HG changeset patch
# User fubar_too
# Date 1621823872 0
# Node ID 1bdd651a784faa4cc8fad904077ab7bfb8117872
# Parent 02c4c16327a0418ce04b6a4a94d1aadbcddf6f7b
Uploaded
diff -r 02c4c16327a0 -r 1bdd651a784f toolfactory/.shed.yml
--- a/toolfactory/.shed.yml Fri May 21 02:05:27 2021 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,13 +0,0 @@
-name: toolfactory
-owner: fubar
-description: ToolFactory - tool to make Galaxy tools ready for the toolshed
-homepage_url: https://github.com/fubar2/toolfactory
-long_description: |
- ToolFactory - turn executable packages and R/python/perl/bash scripts into ordinary Galaxy tools
-
- Creating re-usable tools from scripts: The Galaxy Tool Factory Ross Lazarus; Antony Kaspi; Mark Ziemann; The Galaxy Team
- Bioinformatics 2012; doi: 10.1093/bioinformatics/bts573
-remote_repository_url: https://github.com/fubar2/toolfactory
-type: tool_dependency_definition
-categories:
-- Tool Generators
diff -r 02c4c16327a0 -r 1bdd651a784f toolfactory/ToolFactory.py
--- a/toolfactory/ToolFactory.py Fri May 21 02:05:27 2021 +0000
+++ b/toolfactory/ToolFactory.py Mon May 24 02:37:52 2021 +0000
@@ -20,6 +20,7 @@
import json
import os
import re
+import rpyc
import shlex
import shutil
import subprocess
@@ -70,101 +71,6 @@
citation_tuples.append(("bibtex", citation[len("bibtex") :].strip()))
return citation_tuples
-class Locker:
- """
- multiple instances of the TF may try to update tool_conf.xml so use a simple lockfile
- to prevent overwriting mix ups.
- """
- def __enter__ (self):
- lockfile = "/tmp/.toolfactory_lockfile.lck"
- if not os.path.exists(lockfile):
- try:
- os.utime(lockfile, None)
- except OSError:
- open(lockfile, 'a').close()
- self.fp = open(lockfile)
- fcntl.flock(self.fp.fileno(), fcntl.LOCK_EX)
-
- def __exit__ (self, _type, value, tb):
- fcntl.flock(self.fp.fileno(), fcntl.LOCK_UN)
- self.fp.close()
-
-
-class Tool_Conf_Updater:
-
- """# update config/tool_conf.xml with a new tool unpacked in /tools
- # requires highly insecure docker settings - like write to tool_conf.xml and to tools !
- # if in a container possibly not so courageous.
- # Fine on your own laptop but security red flag for most production instances
- Note potential race condition for tool_conf.xml update - uses a file lock.
- """
-
- def __init__(
- self, args, tool_conf_path, new_tool_archive_path, new_tool_name, local_tool_dir
- ):
- self.args = args
- self.tool_conf_path = os.path.join(args.galaxy_root, tool_conf_path)
- self.tool_dir = os.path.join(args.galaxy_root, local_tool_dir,'TFtools')
- self.out_section = "ToolFactory Generated Tools"
- tff = tarfile.open(new_tool_archive_path, "r:*")
- flist = tff.getnames()
- ourdir = os.path.commonpath(flist) # eg pyrevpos
- self.tool_id = ourdir # they are the same for TF tools
- ourxml = [x for x in flist if x.lower().endswith(".xml")]
- tff.extractall()
- tff.close()
- try:
- self.run_rsync(ourdir, self.tool_dir)
- with Locker():
- self.update_toolconf(ourdir, ourxml)
- except Exception:
- print('Cannot install the new tool. This is only possible in the ToolFactory appliance at https://github.com/fubar2/toolfactory-galaxy-server')
-
- def run_rsync(self, srcf, dstf):
- src = os.path.abspath(srcf)
- dst = os.path.abspath(dstf)
- if os.path.isdir(src):
- cll = ["rsync", "-r", src, dst]
- else:
- cll = ["rsync", src, dst]
- subprocess.run(
- cll,
- capture_output=False,
- encoding="utf8",
- shell=False,
- )
-
-
- def update_toolconf(self, ourdir, ourxml): # path is relative to tools
-
- def sortchildrenby(parent, attr):
- parent[:] = sorted(parent, key=lambda child: child.get(attr))
-
- localconf = "./local_tool_conf.xml"
- self.run_rsync(self.tool_conf_path, localconf)
- tree = ET.parse(localconf)
- root = tree.getroot()
- hasTF = False
- TFsection = None
- for e in root.findall("section"):
- if e.attrib["name"] == self.out_section:
- hasTF = True
- TFsection = e
- if not hasTF:
- TFsection = ET.Element("section", {"id":self.out_section, "name":self.out_section})
- root.insert(0, TFsection) # at the top!
- our_tools = TFsection.findall("tool")
- conf_tools = [x.attrib["file"] for x in our_tools]
- for xml in ourxml: # may be > 1
- if xml not in conf_tools: # new
- ET.SubElement(TFsection, "tool", {"file": os.path.join('TFtools', xml)})
- sortchildrenby(TFsection,"file")
- newconf = f"{self.tool_id}_conf"
- tree.write(newconf, pretty_print=True)
- self.run_rsync(newconf, self.tool_conf_path)
-
-
-
class Tool_Factory:
"""Wrapper for an arbitrary script
@@ -978,13 +884,14 @@
r.makeTool()
r.makeToolTar()
if args.install:
- TCU = Tool_Conf_Updater(
- args=args,
- local_tool_dir=args.local_tools,
- new_tool_archive_path=r.newtarpath,
- tool_conf_path=args.tool_conf_path,
- new_tool_name=r.tool_name
- )
+ try:
+ conn = rpyc.connect("planemo-server", port=9999, config={'sync_request_timeout':1200})
+ except ConnectionRefusedError:
+ print('### no remote rpyc server found on port 9999 - this only works in the ToolFactory Appliance with that server running...')
+ sys.exit(1)
+ res = conn.root.tool_updater(galaxy_root=args.galaxy_root,
+ tool_conf_path=args.tool_conf_path, new_tool_archive_path=os.path.abspath(r.newtarpath),
+ new_tool_name=r.tool_name, local_tool_dir=args.local_tools)
if __name__ == "__main__":
main()
diff -r 02c4c16327a0 -r 1bdd651a784f toolfactory/ToolFactory.xml
--- a/toolfactory/ToolFactory.xml Fri May 21 02:05:27 2021 +0000
+++ b/toolfactory/ToolFactory.xml Mon May 24 02:37:52 2021 +0000
@@ -189,7 +189,7 @@
galaxyxml
bioblend
- rsync
+ rpyc
"sredliubloot"=di "sloot gnidliub looT"=eman noitces<
+>/"lmx.yrotcaFlooTgr/yrotcafloot"=elif loot<
+>noitces/<
+
+,ereht ydaerla ton fI
+:dda esaelp
+"yraniB:yranib.sepytatad.yxalag"=epyt "zg.dehsloot"=noisnetxe epytatad<
+>/ "eurT"=ssalcbus "pizg-x/trapitlum"=epytemim
+.lmx.fnoc_sepyt_atad lacol ruoy ot
+
+
+**noitucexe detcirtseR**
+
+- sresu nimda yb YLNO elbasu eb neht lliw flesti loot yrotcaf loot ehT
+YLNO .thgir s'taht ,seY** ini.igsw_esrevinu ni sresu_nimda ni sDI htiw elpoep
+ot dewolla fI .tnemom a rof ti tuoba knihT **loot siht nur nac sresu_nimda
+dluow taht gniht ylno eht ,revres yxalaG ruoy no tpircs yrartibra yna nur
+ylbaborp dluow atad yxalaG ruoy lla gniyortsed no tneb tnaercsim a edepmi
+.slliks lacinhcet etairporppa fo kcal eb
+
+**seod ti tahW**
+
+dna R ,nohtyp ni stpircs elpmis rof yrotcaf loot a si sihT
+.taht si looc woH .detareneg yllacitamotua era stset lanoitcnuF .yltnerruc lrep
+
+nac yllanoitpO .yrotsih eht morf tupni eno daer taht stpircs elpmis ot DETIMIL
+stuptuo fo rebmun yna tcelloc yllanoitpo dna ,tesatad yrotsih wen eno etirw
+- etagivan ot resu eht rof egap xedni LMTH detarenegotua na no sknil otni
+nwohs era stuptuo fdp - selif tuptuo dna segami setirw tpircs eht fi lufesu
+dna taht os tpircstsohg htiw knurhs era s'fdp detaolb s'R dna slianbmuht sa
+.elbaliava eb ot deen kigamegami
+
+trats os ,loot yxalaG yna ekil decnahne dna detide eb nac sloot detareneG
+a ot pu gel suoires a uoy steg tpircs detareneg a ecnis pu dliub dna llams
+.eno xelpmoc erom
+
+**od uoy tahW**
+
+dna srorre xatnys eht xif uoy ,tpircs ruoy nur dna etsap uoY
+erofeb tpircs eht tide dna nottub oder eht esu nac uoY .snur ti yllautneve
+.llew ytterp skrow ti - gubed uoy sa ti nurer ot gniyrt
+
+elbitapmoc dehsloot a etareneg nac uoy ,atad tset emos no skrow tpircs eht ecnO
+ni loot yxalaG yranidro na sa nur ot ydaer tpircs ruoy gniniatnoc elif pizg
+detamotua ylegral dna efas snaem tahT .dehsloot lacol ruoy no yrotisoper a
+.dehsloot ruoy esu ot derugifnoc yxalaG noitcudorp yna ni noitallatsni
+
+**ytiruceS loot detareneG**
+
+tsuj s'ti ,loot detareneg a llatsni uoy ecnO
+rieht dna yllamron nur tsuj yehT .efas si tpircs eht gnimussa - loot rehtona
+.dehsloot efas ecitcarp ,esaelp tub erucesni yllausunu gnihtyna od tonnac resu
+.yracs yllaer si ti - eno siht yllaicepsE .loot yna llatsni uoy erofeb edoc eht daeR
+
+**edoC dneS**
+
+?esaelp seussi tekcubtib sa emoclew snoitseggus dna sehctaP
+
+**noitubirttA**
+
+yrotcaF looT yxalaG ehT :stpircs morf sloot elbasu-er gnitaerC
+maeT yxalaG ehT ;nnameiZ kraM ;ipsaK ynotnA ;surazaL ssoR
+375stb/scitamrofnioib/3901.01 :iod ;2102 scitamrofnioiB
+
+fer=epytyek&JWYdwMrWs1hQzcl=yekji?375stb/tnirper/igc/gro.slanruojdrofxo.scitamrofnioib//:ptth
+
+**gnisneciL**
+
+0102 surazaL ssoR thgirypoC
+moc doirep liam g ta surazal ssor
+
+.devreser sthgir llA
+
+LPGL eht rednu desneciL
+
+**tohsneercs yrotagilbO**
+
+gnp.looTtpircScimanyd/segami/989ef2308adf/crs/rekamlootyxalag/rabuf/gro.tekcubtib//:ptth
diff -r 02c4c16327a0 -r 1bdd651a784f toolfactory/test-data/pyrevpos.python
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/toolfactory/test-data/pyrevpos.python Mon May 24 02:37:52 2021 +0000
@@ -0,0 +1,13 @@
+# reverse order of text by row
+import sys
+inp = sys.argv[1]
+outp = sys.argv[2]
+i = open(inp,'r').readlines()
+o = open(outp,'w')
+for row in i:
+ rs = row.rstrip()
+ rs = list(rs)
+ rs.reverse()
+ o.write(''.join(rs))
+o.close()
+
diff -r 02c4c16327a0 -r 1bdd651a784f toolfactory/test-data/pyrevpos_not_tested.toolshed_sample
Binary file toolfactory/test-data/pyrevpos_not_tested.toolshed_sample has changed
diff -r 02c4c16327a0 -r 1bdd651a784f toolfactory/test-data/test1_log.txt
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/toolfactory/test-data/test1_log.txt Mon May 24 02:37:52 2021 +0000
@@ -0,0 +1,1 @@
+## Executing Toolfactory generated command line = python /tmp/pyrevposq5dmcdy1.python /tmp/tmpqrksf8sd/files/5/b/9/dataset_5b952a86-87df-44ad-a415-ea549f3f0cee.dat output2
diff -r 02c4c16327a0 -r 1bdd651a784f toolfactory/test-data/toolfactory_pyrevpos_tgz_sample
Binary file toolfactory/test-data/toolfactory_pyrevpos_tgz_sample has changed