Mercurial > repos > avowinkel > gatk
annotate tool-data/destinations.py @ 0:b80ff7f43ad1 draft default tip
planemo upload for repository https://github.com/kaktus42/galaxytools/tree/master/tools/gatk commit 8764cef47529f6285678af4ca24b66d0fe516b88-dirty
| author | avowinkel |
|---|---|
| date | Thu, 24 Sep 2015 12:10:01 -0400 |
| parents | |
| children |
| rev | line source |
|---|---|
|
0
b80ff7f43ad1
planemo upload for repository https://github.com/kaktus42/galaxytools/tree/master/tools/gatk commit 8764cef47529f6285678af4ca24b66d0fe516b88-dirty
avowinkel
parents:
diff
changeset
|
1 from galaxy.jobs import JobDestination |
|
b80ff7f43ad1
planemo upload for repository https://github.com/kaktus42/galaxytools/tree/master/tools/gatk commit 8764cef47529f6285678af4ca24b66d0fe516b88-dirty
avowinkel
parents:
diff
changeset
|
2 import os |
|
b80ff7f43ad1
planemo upload for repository https://github.com/kaktus42/galaxytools/tree/master/tools/gatk commit 8764cef47529f6285678af4ca24b66d0fe516b88-dirty
avowinkel
parents:
diff
changeset
|
3 import sys |
|
b80ff7f43ad1
planemo upload for repository https://github.com/kaktus42/galaxytools/tree/master/tools/gatk commit 8764cef47529f6285678af4ca24b66d0fe516b88-dirty
avowinkel
parents:
diff
changeset
|
4 import json |
|
b80ff7f43ad1
planemo upload for repository https://github.com/kaktus42/galaxytools/tree/master/tools/gatk commit 8764cef47529f6285678af4ca24b66d0fe516b88-dirty
avowinkel
parents:
diff
changeset
|
5 import cStringIO |
|
b80ff7f43ad1
planemo upload for repository https://github.com/kaktus42/galaxytools/tree/master/tools/gatk commit 8764cef47529f6285678af4ca24b66d0fe516b88-dirty
avowinkel
parents:
diff
changeset
|
6 import logging |
|
b80ff7f43ad1
planemo upload for repository https://github.com/kaktus42/galaxytools/tree/master/tools/gatk commit 8764cef47529f6285678af4ca24b66d0fe516b88-dirty
avowinkel
parents:
diff
changeset
|
7 |
|
b80ff7f43ad1
planemo upload for repository https://github.com/kaktus42/galaxytools/tree/master/tools/gatk commit 8764cef47529f6285678af4ca24b66d0fe516b88-dirty
avowinkel
parents:
diff
changeset
|
8 log = logging.getLogger( __name__ ) |
|
b80ff7f43ad1
planemo upload for repository https://github.com/kaktus42/galaxytools/tree/master/tools/gatk commit 8764cef47529f6285678af4ca24b66d0fe516b88-dirty
avowinkel
parents:
diff
changeset
|
9 |
|
b80ff7f43ad1
planemo upload for repository https://github.com/kaktus42/galaxytools/tree/master/tools/gatk commit 8764cef47529f6285678af4ca24b66d0fe516b88-dirty
avowinkel
parents:
diff
changeset
|
10 |
|
b80ff7f43ad1
planemo upload for repository https://github.com/kaktus42/galaxytools/tree/master/tools/gatk commit 8764cef47529f6285678af4ca24b66d0fe516b88-dirty
avowinkel
parents:
diff
changeset
|
11 def dump(obj, nested_level=0, output=sys.stdout): |
|
b80ff7f43ad1
planemo upload for repository https://github.com/kaktus42/galaxytools/tree/master/tools/gatk commit 8764cef47529f6285678af4ca24b66d0fe516b88-dirty
avowinkel
parents:
diff
changeset
|
12 spacing = ' ' |
|
b80ff7f43ad1
planemo upload for repository https://github.com/kaktus42/galaxytools/tree/master/tools/gatk commit 8764cef47529f6285678af4ca24b66d0fe516b88-dirty
avowinkel
parents:
diff
changeset
|
13 if type(obj) == dict: |
|
b80ff7f43ad1
planemo upload for repository https://github.com/kaktus42/galaxytools/tree/master/tools/gatk commit 8764cef47529f6285678af4ca24b66d0fe516b88-dirty
avowinkel
parents:
diff
changeset
|
14 print >> output, '%s{' % ((nested_level) * spacing) |
|
b80ff7f43ad1
planemo upload for repository https://github.com/kaktus42/galaxytools/tree/master/tools/gatk commit 8764cef47529f6285678af4ca24b66d0fe516b88-dirty
avowinkel
parents:
diff
changeset
|
15 for k, v in obj.items(): |
|
b80ff7f43ad1
planemo upload for repository https://github.com/kaktus42/galaxytools/tree/master/tools/gatk commit 8764cef47529f6285678af4ca24b66d0fe516b88-dirty
avowinkel
parents:
diff
changeset
|
16 if hasattr(v, '__iter__'): |
|
b80ff7f43ad1
planemo upload for repository https://github.com/kaktus42/galaxytools/tree/master/tools/gatk commit 8764cef47529f6285678af4ca24b66d0fe516b88-dirty
avowinkel
parents:
diff
changeset
|
17 print >> output, '%s%s:' % ((nested_level + 1) * spacing, k) |
|
b80ff7f43ad1
planemo upload for repository https://github.com/kaktus42/galaxytools/tree/master/tools/gatk commit 8764cef47529f6285678af4ca24b66d0fe516b88-dirty
avowinkel
parents:
diff
changeset
|
18 dump(v, nested_level + 1, output) |
|
b80ff7f43ad1
planemo upload for repository https://github.com/kaktus42/galaxytools/tree/master/tools/gatk commit 8764cef47529f6285678af4ca24b66d0fe516b88-dirty
avowinkel
parents:
diff
changeset
|
19 else: |
|
b80ff7f43ad1
planemo upload for repository https://github.com/kaktus42/galaxytools/tree/master/tools/gatk commit 8764cef47529f6285678af4ca24b66d0fe516b88-dirty
avowinkel
parents:
diff
changeset
|
20 print >> output, '%s%s: %s' % ((nested_level + 1) * spacing, k, v) |
|
b80ff7f43ad1
planemo upload for repository https://github.com/kaktus42/galaxytools/tree/master/tools/gatk commit 8764cef47529f6285678af4ca24b66d0fe516b88-dirty
avowinkel
parents:
diff
changeset
|
21 print >> output, '%s}' % (nested_level * spacing) |
|
b80ff7f43ad1
planemo upload for repository https://github.com/kaktus42/galaxytools/tree/master/tools/gatk commit 8764cef47529f6285678af4ca24b66d0fe516b88-dirty
avowinkel
parents:
diff
changeset
|
22 elif type(obj) == list: |
|
b80ff7f43ad1
planemo upload for repository https://github.com/kaktus42/galaxytools/tree/master/tools/gatk commit 8764cef47529f6285678af4ca24b66d0fe516b88-dirty
avowinkel
parents:
diff
changeset
|
23 print >> output, '%s[' % ((nested_level) * spacing) |
|
b80ff7f43ad1
planemo upload for repository https://github.com/kaktus42/galaxytools/tree/master/tools/gatk commit 8764cef47529f6285678af4ca24b66d0fe516b88-dirty
avowinkel
parents:
diff
changeset
|
24 for v in obj: |
|
b80ff7f43ad1
planemo upload for repository https://github.com/kaktus42/galaxytools/tree/master/tools/gatk commit 8764cef47529f6285678af4ca24b66d0fe516b88-dirty
avowinkel
parents:
diff
changeset
|
25 if hasattr(v, '__iter__'): |
|
b80ff7f43ad1
planemo upload for repository https://github.com/kaktus42/galaxytools/tree/master/tools/gatk commit 8764cef47529f6285678af4ca24b66d0fe516b88-dirty
avowinkel
parents:
diff
changeset
|
26 dump(v, nested_level + 1, output) |
|
b80ff7f43ad1
planemo upload for repository https://github.com/kaktus42/galaxytools/tree/master/tools/gatk commit 8764cef47529f6285678af4ca24b66d0fe516b88-dirty
avowinkel
parents:
diff
changeset
|
27 else: |
|
b80ff7f43ad1
planemo upload for repository https://github.com/kaktus42/galaxytools/tree/master/tools/gatk commit 8764cef47529f6285678af4ca24b66d0fe516b88-dirty
avowinkel
parents:
diff
changeset
|
28 print >> output, '%s%s' % ((nested_level + 1) * spacing, v) |
|
b80ff7f43ad1
planemo upload for repository https://github.com/kaktus42/galaxytools/tree/master/tools/gatk commit 8764cef47529f6285678af4ca24b66d0fe516b88-dirty
avowinkel
parents:
diff
changeset
|
29 print >> output, '%s]' % ((nested_level) * spacing) |
|
b80ff7f43ad1
planemo upload for repository https://github.com/kaktus42/galaxytools/tree/master/tools/gatk commit 8764cef47529f6285678af4ca24b66d0fe516b88-dirty
avowinkel
parents:
diff
changeset
|
30 else: |
|
b80ff7f43ad1
planemo upload for repository https://github.com/kaktus42/galaxytools/tree/master/tools/gatk commit 8764cef47529f6285678af4ca24b66d0fe516b88-dirty
avowinkel
parents:
diff
changeset
|
31 print >> output, '%s%s' % (nested_level * spacing, obj) |
|
b80ff7f43ad1
planemo upload for repository https://github.com/kaktus42/galaxytools/tree/master/tools/gatk commit 8764cef47529f6285678af4ca24b66d0fe516b88-dirty
avowinkel
parents:
diff
changeset
|
32 |
|
b80ff7f43ad1
planemo upload for repository https://github.com/kaktus42/galaxytools/tree/master/tools/gatk commit 8764cef47529f6285678af4ca24b66d0fe516b88-dirty
avowinkel
parents:
diff
changeset
|
33 |
|
b80ff7f43ad1
planemo upload for repository https://github.com/kaktus42/galaxytools/tree/master/tools/gatk commit 8764cef47529f6285678af4ca24b66d0fe516b88-dirty
avowinkel
parents:
diff
changeset
|
34 def dynamic_slurm_cluster_gatk(job, tool_id): |
|
b80ff7f43ad1
planemo upload for repository https://github.com/kaktus42/galaxytools/tree/master/tools/gatk commit 8764cef47529f6285678af4ca24b66d0fe516b88-dirty
avowinkel
parents:
diff
changeset
|
35 # Allocate extra time |
|
b80ff7f43ad1
planemo upload for repository https://github.com/kaktus42/galaxytools/tree/master/tools/gatk commit 8764cef47529f6285678af4ca24b66d0fe516b88-dirty
avowinkel
parents:
diff
changeset
|
36 inp_data = dict( [ ( da.name, da.dataset ) for da in job.input_datasets ] ) |
|
b80ff7f43ad1
planemo upload for repository https://github.com/kaktus42/galaxytools/tree/master/tools/gatk commit 8764cef47529f6285678af4ca24b66d0fe516b88-dirty
avowinkel
parents:
diff
changeset
|
37 inp_data.update( [ ( da.name, da.dataset ) for da in job.input_library_datasets ] ) |
|
b80ff7f43ad1
planemo upload for repository https://github.com/kaktus42/galaxytools/tree/master/tools/gatk commit 8764cef47529f6285678af4ca24b66d0fe516b88-dirty
avowinkel
parents:
diff
changeset
|
38 inp_data.update( [ ( da.name, json.loads(da.value) ) for da in job.parameters ] ) |
|
b80ff7f43ad1
planemo upload for repository https://github.com/kaktus42/galaxytools/tree/master/tools/gatk commit 8764cef47529f6285678af4ca24b66d0fe516b88-dirty
avowinkel
parents:
diff
changeset
|
39 out = cStringIO.StringIO() |
|
b80ff7f43ad1
planemo upload for repository https://github.com/kaktus42/galaxytools/tree/master/tools/gatk commit 8764cef47529f6285678af4ca24b66d0fe516b88-dirty
avowinkel
parents:
diff
changeset
|
40 dump(inp_data, 1, out) |
|
b80ff7f43ad1
planemo upload for repository https://github.com/kaktus42/galaxytools/tree/master/tools/gatk commit 8764cef47529f6285678af4ca24b66d0fe516b88-dirty
avowinkel
parents:
diff
changeset
|
41 log.debug(out.getvalue()) |
|
b80ff7f43ad1
planemo upload for repository https://github.com/kaktus42/galaxytools/tree/master/tools/gatk commit 8764cef47529f6285678af4ca24b66d0fe516b88-dirty
avowinkel
parents:
diff
changeset
|
42 |
|
b80ff7f43ad1
planemo upload for repository https://github.com/kaktus42/galaxytools/tree/master/tools/gatk commit 8764cef47529f6285678af4ca24b66d0fe516b88-dirty
avowinkel
parents:
diff
changeset
|
43 nativeSpecs = '--nodes=1 --ntasks=1' |
|
b80ff7f43ad1
planemo upload for repository https://github.com/kaktus42/galaxytools/tree/master/tools/gatk commit 8764cef47529f6285678af4ca24b66d0fe516b88-dirty
avowinkel
parents:
diff
changeset
|
44 |
|
b80ff7f43ad1
planemo upload for repository https://github.com/kaktus42/galaxytools/tree/master/tools/gatk commit 8764cef47529f6285678af4ca24b66d0fe516b88-dirty
avowinkel
parents:
diff
changeset
|
45 # runner doesn't allow to specify --cpus-per-task |
|
b80ff7f43ad1
planemo upload for repository https://github.com/kaktus42/galaxytools/tree/master/tools/gatk commit 8764cef47529f6285678af4ca24b66d0fe516b88-dirty
avowinkel
parents:
diff
changeset
|
46 # thus the mem calculation gets messy with more than 1 node |
|
b80ff7f43ad1
planemo upload for repository https://github.com/kaktus42/galaxytools/tree/master/tools/gatk commit 8764cef47529f6285678af4ca24b66d0fe516b88-dirty
avowinkel
parents:
diff
changeset
|
47 # --> translate nt ==> nodes, nct ==> ntasks |
|
b80ff7f43ad1
planemo upload for repository https://github.com/kaktus42/galaxytools/tree/master/tools/gatk commit 8764cef47529f6285678af4ca24b66d0fe516b88-dirty
avowinkel
parents:
diff
changeset
|
48 |
|
b80ff7f43ad1
planemo upload for repository https://github.com/kaktus42/galaxytools/tree/master/tools/gatk commit 8764cef47529f6285678af4ca24b66d0fe516b88-dirty
avowinkel
parents:
diff
changeset
|
49 if 'cond_threads' not in inp_data: |
|
b80ff7f43ad1
planemo upload for repository https://github.com/kaktus42/galaxytools/tree/master/tools/gatk commit 8764cef47529f6285678af4ca24b66d0fe516b88-dirty
avowinkel
parents:
diff
changeset
|
50 return JobDestination(runner="slurm") |
|
b80ff7f43ad1
planemo upload for repository https://github.com/kaktus42/galaxytools/tree/master/tools/gatk commit 8764cef47529f6285678af4ca24b66d0fe516b88-dirty
avowinkel
parents:
diff
changeset
|
51 |
|
b80ff7f43ad1
planemo upload for repository https://github.com/kaktus42/galaxytools/tree/master/tools/gatk commit 8764cef47529f6285678af4ca24b66d0fe516b88-dirty
avowinkel
parents:
diff
changeset
|
52 if inp_data['cond_threads']['cond_threads_enabled'] == "True": |
|
b80ff7f43ad1
planemo upload for repository https://github.com/kaktus42/galaxytools/tree/master/tools/gatk commit 8764cef47529f6285678af4ca24b66d0fe516b88-dirty
avowinkel
parents:
diff
changeset
|
53 nNodes = int(inp_data['cond_threads']['nt']) |
|
b80ff7f43ad1
planemo upload for repository https://github.com/kaktus42/galaxytools/tree/master/tools/gatk commit 8764cef47529f6285678af4ca24b66d0fe516b88-dirty
avowinkel
parents:
diff
changeset
|
54 nCPU = int(inp_data['cond_threads']['nct']) |
|
b80ff7f43ad1
planemo upload for repository https://github.com/kaktus42/galaxytools/tree/master/tools/gatk commit 8764cef47529f6285678af4ca24b66d0fe516b88-dirty
avowinkel
parents:
diff
changeset
|
55 nMEM = int(inp_data['cond_threads']['mem']) |
|
b80ff7f43ad1
planemo upload for repository https://github.com/kaktus42/galaxytools/tree/master/tools/gatk commit 8764cef47529f6285678af4ca24b66d0fe516b88-dirty
avowinkel
parents:
diff
changeset
|
56 if nMEM > 0: |
|
b80ff7f43ad1
planemo upload for repository https://github.com/kaktus42/galaxytools/tree/master/tools/gatk commit 8764cef47529f6285678af4ca24b66d0fe516b88-dirty
avowinkel
parents:
diff
changeset
|
57 nativeSpecs = '--nodes=%d --ntasks=%d --mem=%d' % (nNodes, nCPU*nNodes, nMEM) |
|
b80ff7f43ad1
planemo upload for repository https://github.com/kaktus42/galaxytools/tree/master/tools/gatk commit 8764cef47529f6285678af4ca24b66d0fe516b88-dirty
avowinkel
parents:
diff
changeset
|
58 else: |
|
b80ff7f43ad1
planemo upload for repository https://github.com/kaktus42/galaxytools/tree/master/tools/gatk commit 8764cef47529f6285678af4ca24b66d0fe516b88-dirty
avowinkel
parents:
diff
changeset
|
59 nativeSpecs = '--nodes=%d --ntasks=%d' % (nNodes, nCPU*nNodes) |
|
b80ff7f43ad1
planemo upload for repository https://github.com/kaktus42/galaxytools/tree/master/tools/gatk commit 8764cef47529f6285678af4ca24b66d0fe516b88-dirty
avowinkel
parents:
diff
changeset
|
60 |
|
b80ff7f43ad1
planemo upload for repository https://github.com/kaktus42/galaxytools/tree/master/tools/gatk commit 8764cef47529f6285678af4ca24b66d0fe516b88-dirty
avowinkel
parents:
diff
changeset
|
61 return JobDestination(runner="slurm", params={"nativeSpecification": nativeSpecs}) |
|
b80ff7f43ad1
planemo upload for repository https://github.com/kaktus42/galaxytools/tree/master/tools/gatk commit 8764cef47529f6285678af4ca24b66d0fe516b88-dirty
avowinkel
parents:
diff
changeset
|
62 |
