Mercurial > repos > geco-team > gmql_upload
annotate gmql_rest_datasets.py @ 0:078d77023c34 draft default tip
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
author | geco-team |
---|---|
date | Tue, 26 Jun 2018 08:59:19 -0400 |
parents | |
children |
rev | line source |
---|---|
0
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
1 # Galaxy plugin to REST access to the GMQL services |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
2 # (Datasets) |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
3 # ---------------------------------------------------------------------------- |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
4 # Luana Brancato, luana.brancato@mail.polimi.it |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
5 # ---------------------------------------------------------------------------- |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
6 |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
7 import argparse |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
8 |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
9 import tempfile |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
10 import json |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
11 from utilities import * |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
12 |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
13 module = 'repository' |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
14 |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
15 |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
16 def list_datasets(user, output, saveResult=True): |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
17 """Retrieve the list of available datasets""" |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
18 |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
19 call = 'list_datasets' |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
20 url = compose_url(module,call) |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
21 |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
22 datasets = get(url, user=user) |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
23 list_datasets = datasets['datasets'] |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
24 |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
25 if saveResult: |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
26 with open(output,'w') as f: |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
27 for ds in list_datasets: |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
28 f.write("{name}\t{owner}\n".format(name=ds['name'],owner=ds['owner'])) |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
29 f.close() |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
30 else: |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
31 return list_datasets |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
32 |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
33 |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
34 def list_samples(user, output, ds): |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
35 """List the samples of a given dataset""" |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
36 |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
37 call = 'list_samples' |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
38 url = compose_url(module,call) |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
39 |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
40 # Specify for which dataset. |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
41 # If it's a public dataset, the 'public.' prefix must be added to the dataset name |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
42 |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
43 # Check if the ds is public or not |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
44 owner = '' |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
45 for d in list_datasets(user, '', False): |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
46 if d['name'] == ds : |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
47 owner = d['owner'] |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
48 |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
49 if (owner=='public'): |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
50 url = url.format(datasetName='public.'+ ds) |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
51 else : |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
52 url = url.format(datasetName=ds) |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
53 |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
54 samples = get(url, user=user) |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
55 list_s = samples['samples'] |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
56 |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
57 with open(output, 'w') as f_out: |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
58 for s in list_s: |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
59 f_out.write("{id}\t{name}\t{ext}\n".format(id=s['id'], name=s['name'],ext=s['path'].rsplit('.',1)[1])) |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
60 |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
61 |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
62 def rename_dataset(user, output, ds, new): |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
63 """Rename a dataset from the user's private space""" |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
64 |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
65 call = 'rename_dataset' |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
66 url = compose_url(module,call) |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
67 url = url.format(datasetName=ds, newDatasetName=new) |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
68 |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
69 outcome = get(url, user=user) |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
70 |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
71 # Return the updated list of user's datasets |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
72 list_datasets(user, output) |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
73 |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
74 # Write on stdout the operation outcome |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
75 sys.stdout.write("Rename: {result}".format(result=outcome['result'])) |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
76 |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
77 |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
78 def delete_dataset(user, output, ds): |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
79 """Delete a dataset from the user's private space""" |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
80 |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
81 call = 'delete_dataset' |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
82 url = compose_url(module,call) |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
83 url = url.format(datasetName=ds) |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
84 |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
85 outcome = delete(url, user=user) |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
86 |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
87 #Return the updated list of user's datasets |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
88 list_datasets(user, output) |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
89 |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
90 #Write on stdout the operation outcome |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
91 sys.stdout.write("Delete: {result}".format(result=outcome['result'])) |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
92 |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
93 |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
94 def upload_samples_url(user, output, dataset, schema, samples, updatedDsList): |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
95 """Upload a dataset given the urls of the samples and their schema""" |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
96 |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
97 #Compose the url for the REST call |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
98 call = 'upload_url' |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
99 url = compose_url(module,call) |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
100 url = url.format(datasetName=dataset) |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
101 |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
102 content = dict() |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
103 |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
104 # Put back escaped '&' |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
105 samples = samples.replace('__amp__', '&') |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
106 schema = schema.replace('__amp__', '&') |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
107 |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
108 # If schema type is given, add the option to the url. Otherwise, it check if the provided schema is a valid url. |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
109 |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
110 params = dict () |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
111 |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
112 if schema in ['bed','bedGraph','NarrowPeak','BroadPeak','vcf'] : |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
113 params = add_url_param(params, module, call, schema) |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
114 else: |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
115 #check_schema = validators.url(schema) |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
116 #if isinstance(check_schema, validators.utils.ValidationFailure): stop_err("Schema URL not valid") |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
117 content.update(schema_file=schema) |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
118 |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
119 |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
120 # Samples are listed one per line. It lists them looking for the new line marker ('__cn__') |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
121 samples_list = samples.split('__cn__') |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
122 |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
123 # The regexp in input can allow a final empty string. The following removes it if present. |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
124 if not samples_list[-1]: |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
125 samples_list.remove("") |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
126 |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
127 # # For each sample url, check if it is valid. If at least ones is not, upload fails |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
128 # # and which one is saved in the outcome. |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
129 # for s in samples_list: |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
130 # check_url = validators.url(s) |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
131 # if isinstance(check_url, validators.utils.ValidationFailure): |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
132 # with open(output, 'w') as f_out: |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
133 # f_out.write("This resource couldn't be loaded (invalid url)\n") |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
134 # f_out.write("Line %d: %s" % (samples_list.index(s) + 1, s)) |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
135 # stop_err("Some URLs are not valid.\nCheck the output file for details.") |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
136 |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
137 content.update(data_files=samples_list) |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
138 |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
139 result = post(url, content, user=user, params=params) |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
140 |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
141 #Return the list of updated samples |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
142 list_imported(result, output) |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
143 |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
144 #Return the updated list of samples |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
145 list_datasets(user, updatedDsList) |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
146 |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
147 |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
148 def upload_samples(user, output, dataset, schema, samples, updatedDsList): |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
149 """Upload a dataset from the local instance""" |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
150 |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
151 |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
152 #Compose the url for the REST call |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
153 call = 'upload_data' |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
154 url = compose_url(module, call) |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
155 url = url.format(datasetName=dataset) |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
156 |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
157 #Files dict for payload |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
158 files = dict () |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
159 |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
160 # If the schema type is give, add the option to the url. |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
161 params = dict () |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
162 |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
163 |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
164 if schema in ['bed','bedGraph','NarrowPeak','BroadPeak','vcf'] : |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
165 params = add_url_param(params, module, call, schema) |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
166 else : |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
167 # Add the schema given to the payload dictionary |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
168 files.update({'schema' : ('{ds}.xml'.format(ds=dataset), open(schema, 'rb'))}) |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
169 |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
170 # Read samples file path and add them to the form object |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
171 # The structure is |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
172 # FILENAME PATH |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
173 |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
174 with open(samples, "r") as file: |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
175 s = map(lambda x: x.rstrip('\n').split('\t'), file) |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
176 s = [x for x in s if len(x)>1] |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
177 #s = [x for x in s if x[0].__contains__('.dat')] |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
178 map(lambda x: files.update({'file%d' % (s.index(x) + 1) : (x[0], open(x[1], 'rb'))}), s) |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
179 |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
180 # Post call |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
181 |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
182 result = post(url, files, user=user, params=params, content_type='multiform') |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
183 |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
184 #Return the list of updated samples |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
185 list_imported(result, output) |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
186 |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
187 |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
188 #Return the updated list of samples |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
189 list_datasets(user, updatedDsList) |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
190 |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
191 |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
192 |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
193 def list_imported(result, output) : |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
194 """When uploading a ds, the server returns a json object describing what has been imported |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
195 INPUT JSON FIELDS - |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
196 imported: samples imported with their metadata |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
197 autoMetadata: samples imported without metadata (those have been auto generated) """ |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
198 |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
199 samples = list () |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
200 |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
201 if 'imported' in result : |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
202 imported = result.get('imported') |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
203 if imported: |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
204 samples.append(result.get('imported')) |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
205 if 'autoMetadata' in result : |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
206 am = result.get('autoMetadata') |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
207 if am : |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
208 samples.append(result.get('autoMetadata')) |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
209 |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
210 |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
211 with open(output, 'w') as f_out: |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
212 for l in samples: |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
213 for s in l : |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
214 if 'id' in s and s['id']: |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
215 id = s['id'] |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
216 else : |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
217 id = l.index(s) + 1 |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
218 if 'path' in s : |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
219 ext = s['path'].rsplit('.')[1] |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
220 else : |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
221 n = s['name'].rsplit('.') |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
222 if n.__len__()>1 : |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
223 ext = n[1] |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
224 else : |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
225 ext = '' |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
226 |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
227 name = s['name'] |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
228 |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
229 f_out.write("{id}\t{name}\t{ext}\n".format(id=id, name=name,ext=ext)) |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
230 |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
231 |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
232 def download_samples(user, output, dataset): |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
233 """ Download the samples of the given dataset in form of a compressed zip archive.""" |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
234 |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
235 call = 'download_zip' |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
236 |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
237 url = compose_url(module, call) |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
238 url = url.format(datasetName=dataset) |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
239 |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
240 # Fetch the archive. |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
241 |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
242 data = get(url, user=user, response_type='zip') |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
243 |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
244 with open(output, 'wb') as fd: |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
245 for chunk in data.iter_content(chunk_size=128): |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
246 fd.write(chunk) |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
247 |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
248 def get_sample(user, output, dataset, name): |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
249 """Retrieve a sample given its name and the dataset it belongs to""" |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
250 |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
251 call = 'download_sample' |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
252 |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
253 url = compose_url(module,call) |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
254 url = url.format(datasetName=dataset,sample=name) |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
255 |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
256 data = get(url, user=user, response_type='file') |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
257 |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
258 with open(output, 'wb') as fd: |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
259 for chunk in data.iter_content(chunk_size=128): |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
260 fd.write(chunk) |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
261 |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
262 |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
263 def get_sample_meta(user, output, dataset, name): |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
264 """Retrieve a sample metadata given its name and the dataset it belongs to""" |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
265 |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
266 call = 'download_meta' |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
267 |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
268 url = compose_url(module, call) |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
269 url = url.format(datasetName=dataset, sample=name) |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
270 |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
271 data = get(url, user=user, response_type='file') |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
272 |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
273 with open(output, 'wb') as fd: |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
274 for chunk in data.iter_content(chunk_size=128): |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
275 fd.write(chunk) |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
276 |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
277 def import_samples(user, ds) : |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
278 |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
279 |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
280 # Retrieve the list of the samples in the resulting dataset |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
281 # The list is stored in a temporary file |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
282 temp = tempfile.NamedTemporaryFile(delete=False) |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
283 list_samples(user, temp.name, ds) |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
284 |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
285 # Retrieve names and extensions of the samples |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
286 with open(temp.name, "r") as t: |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
287 samples = map(lambda x: helper_samples(x), t) |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
288 t.close() |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
289 |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
290 os.makedirs('samples') |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
291 os.makedirs('metadata') |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
292 |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
293 # Create a new dict containing names and actual path to files |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
294 |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
295 for s in samples: |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
296 |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
297 # Get the sample |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
298 get_sample(user, "samples/{name}.{ext}".format(name=s['name'].replace('_',''), ext=s['ext']), ds, s['name']) |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
299 |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
300 # Get its metadata |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
301 get_sample_meta(user,"metadata/{name}.meta".format(name=s['name'].replace('_','')),ds,s['name']) |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
302 |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
303 def helper_samples(s): |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
304 """From a list of samples retrieve name and extension""" |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
305 split = s.split('\t') |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
306 sample = dict() |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
307 sample.update(name=split[1]) |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
308 sample.update(ext=split[2].rstrip('\n')) |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
309 |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
310 return sample |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
311 |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
312 |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
313 def get_schema(user, ds, file) : |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
314 """Get the schema field of the input dataset and save it in file""" |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
315 |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
316 call = "schema" |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
317 |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
318 url = compose_url(module, call) |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
319 |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
320 # Check if the ds is public or not |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
321 owner = '' |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
322 for d in list_datasets(user, '', False): |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
323 if d['name'] == ds : |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
324 owner = d['owner'] |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
325 |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
326 if (owner=='public'): |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
327 url = url.format(datasetName='public.'+ ds) |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
328 else : |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
329 url = url.format(datasetName=ds) |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
330 |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
331 schema = get(url, user=user) |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
332 |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
333 |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
334 with open(file,'w') as f_out: |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
335 for f in schema['fields'] : |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
336 f_out.write('{field}\t{type}\n'.format(field=f['name'],type=f['type'])) |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
337 |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
338 |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
339 |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
340 def set_columns_names(user, ds_name, samples_file, schema_file): |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
341 |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
342 get_schema(user,ds_name, schema_file) |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
343 |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
344 cwd = os.getcwd().rsplit('/',1)[0] |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
345 file = '/'.join([cwd, 'galaxy.json']) |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
346 |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
347 with open(schema_file, 'r') as f_in: |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
348 columns = [x.split('\t') for x in f_in] |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
349 column_names = [x[0] for x in columns] |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
350 column_types = [x[1].rstrip('\n') for x in columns] |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
351 |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
352 metadata = dict() |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
353 metadata.update(column_names=column_names, |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
354 column_types=column_types) |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
355 |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
356 |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
357 with open(file, 'w') as f_out: |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
358 with open(samples_file, 'r') as f_in: |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
359 samples_list = map(lambda x: x, f_in) |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
360 samples_list.pop() |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
361 for s in samples_list: |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
362 config = dict() |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
363 config.update(type='new_primary_dataset', |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
364 filename=s, |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
365 metadata=metadata) |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
366 f_out.write(json.dumps(config) + '\n') |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
367 |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
368 |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
369 |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
370 def stop_err(msg): |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
371 sys.stderr.write("%s\n" % msg) |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
372 sys.exit() |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
373 |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
374 |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
375 def __main__(): |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
376 |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
377 parser = argparse.ArgumentParser() |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
378 parser.add_argument("output") |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
379 parser.add_argument("-opt_out1") |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
380 parser.add_argument("-user") |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
381 parser.add_argument("-cmd") |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
382 parser.add_argument("-samples") |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
383 parser.add_argument("-dataset") |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
384 parser.add_argument("-new_name") |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
385 parser.add_argument("-schema") |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
386 parser.add_argument("-add_output") |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
387 |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
388 args = parser.parse_args() |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
389 |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
390 if args.cmd == 'list': |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
391 list_datasets(args.user, args.output) |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
392 if args.cmd == 'samples': |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
393 list_samples(args.user, args.output, args.dataset) |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
394 if args.cmd == 'rename' : |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
395 rename_dataset(args.user, args.output, args.dataset, args.new_name) |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
396 if args.cmd == 'delete': |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
397 delete_dataset(args.user, args.output, args.dataset) |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
398 if args.cmd == 'upload_url': |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
399 upload_samples_url(args.user, args.output, args.dataset, args.schema, args.samples, args.add_output) |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
400 if args.cmd == 'upload' : |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
401 upload_samples(args.user, args.output, args.dataset, args.schema, args.samples, args.add_output) |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
402 if args.cmd == 'import': |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
403 import_samples(args.user, args.dataset) |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
404 if args.cmd == 'download' : |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
405 download_samples(args.user,args.output,args.dataset) |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
406 if args.cmd == 'schema' : |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
407 set_columns_names(args.user, args.dataset, args.samples, args.output) |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
408 |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
409 |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
410 if __name__ == "__main__": |
078d77023c34
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
411 __main__() |