Mercurial > repos > geco-team > gmql_queries_monitor
annotate gmql_rest_datasets.py @ 0:4bfc6a2c4855 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:58:28 -0400 |
parents | |
children |
rev | line source |
---|---|
0
4bfc6a2c4855
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 |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
2 # (Datasets) |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
3 # ---------------------------------------------------------------------------- |
4bfc6a2c4855
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 |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
5 # ---------------------------------------------------------------------------- |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
6 |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
7 import argparse |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
8 |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
9 import tempfile |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
10 import json |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
11 from utilities import * |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
12 |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
13 module = 'repository' |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
14 |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
15 |
4bfc6a2c4855
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): |
4bfc6a2c4855
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""" |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
18 |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
19 call = 'list_datasets' |
4bfc6a2c4855
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) |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
21 |
4bfc6a2c4855
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) |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
23 list_datasets = datasets['datasets'] |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
24 |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
25 if saveResult: |
4bfc6a2c4855
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: |
4bfc6a2c4855
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: |
4bfc6a2c4855
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'])) |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
29 f.close() |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
30 else: |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
31 return list_datasets |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
32 |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
33 |
4bfc6a2c4855
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): |
4bfc6a2c4855
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""" |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
36 |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
37 call = 'list_samples' |
4bfc6a2c4855
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) |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
39 |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
40 # Specify for which dataset. |
4bfc6a2c4855
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 |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
42 |
4bfc6a2c4855
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 |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
44 owner = '' |
4bfc6a2c4855
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): |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
46 if d['name'] == ds : |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
47 owner = d['owner'] |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
48 |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
49 if (owner=='public'): |
4bfc6a2c4855
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) |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
51 else : |
4bfc6a2c4855
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) |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
53 |
4bfc6a2c4855
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) |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
55 list_s = samples['samples'] |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
56 |
4bfc6a2c4855
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: |
4bfc6a2c4855
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: |
4bfc6a2c4855
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])) |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
60 |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
61 |
4bfc6a2c4855
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): |
4bfc6a2c4855
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""" |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
64 |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
65 call = 'rename_dataset' |
4bfc6a2c4855
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) |
4bfc6a2c4855
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) |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
68 |
4bfc6a2c4855
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) |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
70 |
4bfc6a2c4855
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 |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
72 list_datasets(user, output) |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
73 |
4bfc6a2c4855
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 |
4bfc6a2c4855
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'])) |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
76 |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
77 |
4bfc6a2c4855
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): |
4bfc6a2c4855
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""" |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
80 |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
81 call = 'delete_dataset' |
4bfc6a2c4855
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) |
4bfc6a2c4855
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) |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
84 |
4bfc6a2c4855
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) |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
86 |
4bfc6a2c4855
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 |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
88 list_datasets(user, output) |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
89 |
4bfc6a2c4855
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 |
4bfc6a2c4855
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'])) |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
92 |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
93 |
4bfc6a2c4855
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): |
4bfc6a2c4855
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""" |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
96 |
4bfc6a2c4855
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 |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
98 call = 'upload_url' |
4bfc6a2c4855
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) |
4bfc6a2c4855
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) |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
101 |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
102 content = dict() |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
103 |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
104 # Put back escaped '&' |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
105 samples = samples.replace('__amp__', '&') |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
106 schema = schema.replace('__amp__', '&') |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
107 |
4bfc6a2c4855
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. |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
109 |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
110 params = dict () |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
111 |
4bfc6a2c4855
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'] : |
4bfc6a2c4855
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) |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
114 else: |
4bfc6a2c4855
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) |
4bfc6a2c4855
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") |
4bfc6a2c4855
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) |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
118 |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
119 |
4bfc6a2c4855
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__') |
4bfc6a2c4855
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__') |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
122 |
4bfc6a2c4855
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. |
4bfc6a2c4855
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]: |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
125 samples_list.remove("") |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
126 |
4bfc6a2c4855
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 |
4bfc6a2c4855
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. |
4bfc6a2c4855
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: |
4bfc6a2c4855
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) |
4bfc6a2c4855
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): |
4bfc6a2c4855
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: |
4bfc6a2c4855
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") |
4bfc6a2c4855
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)) |
4bfc6a2c4855
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.") |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
136 |
4bfc6a2c4855
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) |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
138 |
4bfc6a2c4855
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) |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
140 |
4bfc6a2c4855
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 |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
142 list_imported(result, output) |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
143 |
4bfc6a2c4855
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 |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
145 list_datasets(user, updatedDsList) |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
146 |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
147 |
4bfc6a2c4855
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): |
4bfc6a2c4855
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""" |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
150 |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
151 |
4bfc6a2c4855
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 |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
153 call = 'upload_data' |
4bfc6a2c4855
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) |
4bfc6a2c4855
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) |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
156 |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
157 #Files dict for payload |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
158 files = dict () |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
159 |
4bfc6a2c4855
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. |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
161 params = dict () |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
162 |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
163 |
4bfc6a2c4855
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'] : |
4bfc6a2c4855
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) |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
166 else : |
4bfc6a2c4855
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 |
4bfc6a2c4855
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'))}) |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
169 |
4bfc6a2c4855
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 |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
171 # The structure is |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
172 # FILENAME PATH |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
173 |
4bfc6a2c4855
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: |
4bfc6a2c4855
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) |
4bfc6a2c4855
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] |
4bfc6a2c4855
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')] |
4bfc6a2c4855
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) |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
179 |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
180 # Post call |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
181 |
4bfc6a2c4855
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') |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
183 |
4bfc6a2c4855
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 |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
185 list_imported(result, output) |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
186 |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
187 |
4bfc6a2c4855
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 |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
189 list_datasets(user, updatedDsList) |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
190 |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
191 |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
192 |
4bfc6a2c4855
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) : |
4bfc6a2c4855
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 |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
195 INPUT JSON FIELDS - |
4bfc6a2c4855
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 |
4bfc6a2c4855
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) """ |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
198 |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
199 samples = list () |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
200 |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
201 if 'imported' in result : |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
202 imported = result.get('imported') |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
203 if imported: |
4bfc6a2c4855
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')) |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
205 if 'autoMetadata' in result : |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
206 am = result.get('autoMetadata') |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
207 if am : |
4bfc6a2c4855
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')) |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
209 |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
210 |
4bfc6a2c4855
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: |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
212 for l in samples: |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
213 for s in l : |
4bfc6a2c4855
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']: |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
215 id = s['id'] |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
216 else : |
4bfc6a2c4855
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 |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
218 if 'path' in s : |
4bfc6a2c4855
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] |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
220 else : |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
221 n = s['name'].rsplit('.') |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
222 if n.__len__()>1 : |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
223 ext = n[1] |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
224 else : |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
225 ext = '' |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
226 |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
227 name = s['name'] |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
228 |
4bfc6a2c4855
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)) |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
230 |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
231 |
4bfc6a2c4855
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): |
4bfc6a2c4855
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.""" |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
234 |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
235 call = 'download_zip' |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
236 |
4bfc6a2c4855
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) |
4bfc6a2c4855
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) |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
239 |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
240 # Fetch the archive. |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
241 |
4bfc6a2c4855
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') |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
243 |
4bfc6a2c4855
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: |
4bfc6a2c4855
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): |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
246 fd.write(chunk) |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
247 |
4bfc6a2c4855
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): |
4bfc6a2c4855
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""" |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
250 |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
251 call = 'download_sample' |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
252 |
4bfc6a2c4855
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) |
4bfc6a2c4855
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) |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
255 |
4bfc6a2c4855
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') |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
257 |
4bfc6a2c4855
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: |
4bfc6a2c4855
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): |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
260 fd.write(chunk) |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
261 |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
262 |
4bfc6a2c4855
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): |
4bfc6a2c4855
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""" |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
265 |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
266 call = 'download_meta' |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
267 |
4bfc6a2c4855
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) |
4bfc6a2c4855
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) |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
270 |
4bfc6a2c4855
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') |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
272 |
4bfc6a2c4855
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: |
4bfc6a2c4855
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): |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
275 fd.write(chunk) |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
276 |
4bfc6a2c4855
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) : |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
278 |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
279 |
4bfc6a2c4855
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 |
4bfc6a2c4855
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 |
4bfc6a2c4855
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) |
4bfc6a2c4855
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) |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
284 |
4bfc6a2c4855
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 |
4bfc6a2c4855
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: |
4bfc6a2c4855
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) |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
288 t.close() |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
289 |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
290 os.makedirs('samples') |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
291 os.makedirs('metadata') |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
292 |
4bfc6a2c4855
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 |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
294 |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
295 for s in samples: |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
296 |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
297 # Get the sample |
4bfc6a2c4855
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']) |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
299 |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
300 # Get its metadata |
4bfc6a2c4855
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']) |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
302 |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
303 def helper_samples(s): |
4bfc6a2c4855
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""" |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
305 split = s.split('\t') |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
306 sample = dict() |
4bfc6a2c4855
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]) |
4bfc6a2c4855
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')) |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
309 |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
310 return sample |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
311 |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
312 |
4bfc6a2c4855
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) : |
4bfc6a2c4855
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""" |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
315 |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
316 call = "schema" |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
317 |
4bfc6a2c4855
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) |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
319 |
4bfc6a2c4855
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 |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
321 owner = '' |
4bfc6a2c4855
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): |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
323 if d['name'] == ds : |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
324 owner = d['owner'] |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
325 |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
326 if (owner=='public'): |
4bfc6a2c4855
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) |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
328 else : |
4bfc6a2c4855
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) |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
330 |
4bfc6a2c4855
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) |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
332 |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
333 |
4bfc6a2c4855
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: |
4bfc6a2c4855
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'] : |
4bfc6a2c4855
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'])) |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
337 |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
338 |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
339 |
4bfc6a2c4855
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): |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
341 |
4bfc6a2c4855
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) |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
343 |
4bfc6a2c4855
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] |
4bfc6a2c4855
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']) |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
346 |
4bfc6a2c4855
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: |
4bfc6a2c4855
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] |
4bfc6a2c4855
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] |
4bfc6a2c4855
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] |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
351 |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
352 metadata = dict() |
4bfc6a2c4855
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, |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
354 column_types=column_types) |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
355 |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
356 |
4bfc6a2c4855
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: |
4bfc6a2c4855
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: |
4bfc6a2c4855
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) |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
360 samples_list.pop() |
4bfc6a2c4855
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: |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
362 config = dict() |
4bfc6a2c4855
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', |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
364 filename=s, |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
365 metadata=metadata) |
4bfc6a2c4855
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') |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
367 |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
368 |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
369 |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
370 def stop_err(msg): |
4bfc6a2c4855
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) |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
372 sys.exit() |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
373 |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
374 |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
375 def __main__(): |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
376 |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
377 parser = argparse.ArgumentParser() |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
378 parser.add_argument("output") |
4bfc6a2c4855
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") |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
380 parser.add_argument("-user") |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
381 parser.add_argument("-cmd") |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
382 parser.add_argument("-samples") |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
383 parser.add_argument("-dataset") |
4bfc6a2c4855
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") |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
385 parser.add_argument("-schema") |
4bfc6a2c4855
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") |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
387 |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
388 args = parser.parse_args() |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
389 |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
390 if args.cmd == 'list': |
4bfc6a2c4855
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) |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
392 if args.cmd == 'samples': |
4bfc6a2c4855
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) |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
394 if args.cmd == 'rename' : |
4bfc6a2c4855
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) |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
396 if args.cmd == 'delete': |
4bfc6a2c4855
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) |
4bfc6a2c4855
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': |
4bfc6a2c4855
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) |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
400 if args.cmd == 'upload' : |
4bfc6a2c4855
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) |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
402 if args.cmd == 'import': |
4bfc6a2c4855
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) |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
404 if args.cmd == 'download' : |
4bfc6a2c4855
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) |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
406 if args.cmd == 'schema' : |
4bfc6a2c4855
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) |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
408 |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
409 |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
410 if __name__ == "__main__": |
4bfc6a2c4855
planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff
changeset
|
411 __main__() |