Mercurial > repos > iuc > data_manager_mothur_toolsuite
annotate data_manager/fetch_mothur_reference_data.py @ 0:ab7a7e798c34 draft
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
author | iuc |
---|---|
date | Mon, 06 Nov 2017 06:21:50 -0500 |
parents | |
children | aec831b54a5b |
rev | line source |
---|---|
0
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
1 #!/usr/bin/env python |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
2 # |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
3 # Data manager for reference data for the 'mothur_toolsuite' Galaxy tools |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
4 import json |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
5 import optparse |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
6 import os |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
7 import shutil |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
8 import sys |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
9 import tarfile |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
10 import tempfile |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
11 import urllib2 |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
12 import zipfile |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
13 |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
14 # When extracting files from archives, skip names that |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
15 # start with the following strings |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
16 IGNORE_PATHS = ('.', '__MACOSX/', '__') |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
17 |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
18 # Map file extensions to data table names |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
19 MOTHUR_FILE_TYPES = {".map": "map", |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
20 ".fasta": "aligndb", |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
21 ".align": "aligndb", |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
22 ".pat": "lookup", |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
23 ".tax": "taxonomy"} |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
24 |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
25 # Reference data URLs |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
26 MOTHUR_REFERENCE_DATA = { |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
27 # Look up data |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
28 # http://www.mothur.org/wiki/Lookup_files |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
29 "lookup_titanium": { |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
30 "GS FLX Titanium": ["http://www.mothur.org/w/images/9/96/LookUp_Titanium.zip", ] |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
31 }, |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
32 "lookup_gsflx": { |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
33 "GSFLX": ["http://www.mothur.org/w/images/8/84/LookUp_GSFLX.zip", ] |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
34 }, |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
35 "lookup_gs20": { |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
36 "GS20": ["http://www.mothur.org/w/images/7/7b/LookUp_GS20.zip", ] |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
37 }, |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
38 # RDP reference files |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
39 # http://www.mothur.org/wiki/RDP_reference_files |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
40 "RDP_v16": { |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
41 "16S rRNA RDP training set 16": |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
42 ["https://mothur.org/w/images/d/dc/Trainset16_022016.rdp.tgz", ], |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
43 "16S rRNA PDS training set 16": |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
44 ["https://mothur.org/w/images/c/c3/Trainset16_022016.pds.tgz", ], |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
45 }, |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
46 "RDP_v14": { |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
47 "16S rRNA RDP training set 14": |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
48 ["https://mothur.org/w/images/6/6c/Trainset14_032015.rdp.tgz", ], |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
49 "16S rRNA PDS training set 14": |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
50 ["https://mothur.org/w/images/8/88/Trainset14_032015.pds.tgz", ], |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
51 }, |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
52 "RDP_v10": { |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
53 "16S rRNA RDP training set 10": |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
54 ["http://www.mothur.org/w/images/b/b5/Trainset10_082014.rdp.tgz", ], |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
55 "16S rRNA PDS training set 10": |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
56 ["http://www.mothur.org/w/images/2/24/Trainset10_082014.pds.tgz", ], |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
57 }, |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
58 "RDP_v9": { |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
59 "16S rRNA RDP training set 9": |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
60 ["http://www.mothur.org/w/images/7/72/Trainset9_032012.rdp.zip", ], |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
61 "16S rRNA PDS training set 9": |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
62 ["http://www.mothur.org/w/images/5/59/Trainset9_032012.pds.zip", ], |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
63 }, |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
64 "RDP_v7": { |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
65 "16S rRNA RDP training set 7": |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
66 ["http://www.mothur.org/w/images/2/29/Trainset7_112011.rdp.zip", ], |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
67 "16S rRNA PDS training set 7": |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
68 ["http://www.mothur.org/w/images/4/4a/Trainset7_112011.pds.zip", ], |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
69 "8S rRNA Fungi training set 7": |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
70 ["http://www.mothur.org/w/images/3/36/FungiLSU_train_v7.zip", ], |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
71 }, |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
72 "RDP_v6": { |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
73 "RDP training set 6": |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
74 ["http://www.mothur.org/w/images/4/49/RDPTrainingSet.zip", ], |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
75 }, |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
76 # Silva reference files |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
77 # http://www.mothur.org/wiki/Silva_reference_files |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
78 "silva_release_128": { |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
79 "SILVA release 128": |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
80 ["https://mothur.org/w/images/b/b4/Silva.nr_v128.tgz", |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
81 "https://mothur.org/w/images/a/a4/Silva.seed_v128.tgz", ], |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
82 }, |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
83 "silva_release_123": { |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
84 "SILVA release 123": |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
85 ["https://mothur.org/w/images/b/be/Silva.nr_v123.tgz", |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
86 "https://mothur.org/w/images/1/15/Silva.seed_v123.tgz", ], |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
87 }, |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
88 "silva_release_119": { |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
89 "SILVA release 119": |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
90 ["http://www.mothur.org/w/images/2/27/Silva.nr_v119.tgz", |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
91 "http://www.mothur.org/w/images/5/56/Silva.seed_v119.tgz", ], |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
92 }, |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
93 "silva_release_102": { |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
94 "SILVA release 102": |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
95 ["http://www.mothur.org/w/images/9/98/Silva.bacteria.zip", |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
96 "http://www.mothur.org/w/images/3/3c/Silva.archaea.zip", |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
97 "http://www.mothur.org/w/images/1/1a/Silva.eukarya.zip", ], |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
98 }, |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
99 "silva_gold_bacteria": { |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
100 "SILVA gold": |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
101 ["http://www.mothur.org/w/images/f/f1/Silva.gold.bacteria.zip", ], |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
102 }, |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
103 # Greengenes |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
104 # http://www.mothur.org/wiki/Greengenes-formatted_databases |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
105 "greengenes_August2013": { |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
106 "Greengenes August 2013": |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
107 ["http://www.mothur.org/w/images/1/19/Gg_13_8_99.refalign.tgz", |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
108 "http://www.mothur.org/w/images/6/68/Gg_13_8_99.taxonomy.tgz", ], |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
109 }, |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
110 "greengenes_May2013": { |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
111 "Greengenes May 2013": |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
112 ["http://www.mothur.org/w/images/c/cd/Gg_13_5_99.refalign.tgz", |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
113 "http://www.mothur.org/w/images/9/9d/Gg_13_5_99.taxonomy.tgz", ], |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
114 }, |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
115 "greengenes_old": { |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
116 "Greengenes pre-May 2013": |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
117 ["http://www.mothur.org/w/images/7/72/Greengenes.alignment.zip", |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
118 "http://www.mothur.org/w/images/1/16/Greengenes.tax.tgz", ], |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
119 }, |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
120 "greengenes_gold_alignment": { |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
121 "Greengenes gold alignment": |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
122 ["http://www.mothur.org/w/images/2/21/Greengenes.gold.alignment.zip", ], |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
123 }, |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
124 # Secondary structure maps |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
125 # http://www.mothur.org/wiki/Secondary_structure_map |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
126 "secondary_structure_maps_silva": { |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
127 "SILVA": |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
128 ["http://www.mothur.org/w/images/6/6d/Silva_ss_map.zip", ], |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
129 }, |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
130 "secondary_structure_maps_greengenes": { |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
131 "Greengenes": |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
132 ["http://www.mothur.org/w/images/4/4b/Gg_ss_map.zip", ], |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
133 }, |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
134 # Lane masks: not used here? |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
135 "lane_masks": { |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
136 "Greengenes-compatible": |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
137 ["http://www.mothur.org/w/images/2/2a/Lane1241.gg.filter", |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
138 "http://www.mothur.org/w/images/a/a0/Lane1287.gg.filter", |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
139 "http://www.mothur.org/w/images/3/3d/Lane1349.gg.filter", ], |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
140 "SILVA-compatible": |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
141 ["http://www.mothur.org/w/images/6/6d/Lane1349.silva.filter", ] |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
142 }, |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
143 } |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
144 |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
145 |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
146 # Utility functions for interacting with Galaxy JSON |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
147 def read_input_json(jsonfile): |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
148 """Read the JSON supplied from the data manager tool |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
149 |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
150 Returns a tuple (param_dict,extra_files_path) |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
151 |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
152 'param_dict' is an arbitrary dictionary of parameters |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
153 input into the tool; 'extra_files_path' is the path |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
154 to a directory where output files must be put for the |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
155 receiving data manager to pick them up. |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
156 |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
157 NB the directory pointed to by 'extra_files_path' |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
158 doesn't exist initially, it is the job of the script |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
159 to create it if necessary. |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
160 |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
161 """ |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
162 params = json.loads(open(jsonfile).read()) |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
163 return (params['param_dict'], |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
164 params['output_data'][0]['extra_files_path']) |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
165 |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
166 |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
167 # Utility functions for creating data table dictionaries |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
168 # |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
169 # Example usage: |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
170 # >>> d = create_data_tables_dict() |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
171 # >>> add_data_table(d,'my_data') |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
172 # >>> add_data_table_entry(dict(dbkey='hg19',value='human')) |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
173 # >>> add_data_table_entry(dict(dbkey='mm9',value='mouse')) |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
174 # >>> print str(json.dumps(d)) |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
175 def create_data_tables_dict(): |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
176 """Return a dictionary for storing data table information |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
177 |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
178 Returns a dictionary that can be used with 'add_data_table' |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
179 and 'add_data_table_entry' to store information about a |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
180 data table. It can be converted to JSON to be sent back to |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
181 the data manager. |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
182 |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
183 """ |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
184 d = {} |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
185 d['data_tables'] = {} |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
186 return d |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
187 |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
188 |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
189 def add_data_table(d, table): |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
190 """Add a data table to the data tables dictionary |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
191 |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
192 Creates a placeholder for a data table called 'table'. |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
193 |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
194 """ |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
195 d['data_tables'][table] = [] |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
196 |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
197 |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
198 def add_data_table_entry(d, table, entry): |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
199 """Add an entry to a data table |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
200 |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
201 Appends an entry to the data table 'table'. 'entry' |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
202 should be a dictionary where the keys are the names of |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
203 columns in the data table. |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
204 |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
205 Raises an exception if the named data table doesn't |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
206 exist. |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
207 |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
208 """ |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
209 try: |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
210 d['data_tables'][table].append(entry) |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
211 except KeyError: |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
212 raise Exception("add_data_table_entry: no table '%s'" % table) |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
213 |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
214 |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
215 # Utility functions for downloading and unpacking archive files |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
216 def download_file(url, target=None, wd=None): |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
217 """Download a file from a URL |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
218 |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
219 Fetches a file from the specified URL. |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
220 |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
221 If 'target' is specified then the file is saved to this |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
222 name; otherwise it's saved as the basename of the URL. |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
223 |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
224 If 'wd' is specified then it is used as the 'working |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
225 directory' where the file will be save on the local |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
226 system. |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
227 |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
228 Returns the name that the file is saved with. |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
229 |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
230 """ |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
231 print "Downloading %s" % url |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
232 if not target: |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
233 target = os.path.basename(url) |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
234 if wd: |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
235 target = os.path.join(wd, target) |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
236 print "Saving to %s" % target |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
237 open(target, 'wb').write(urllib2.urlopen(url).read()) |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
238 return target |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
239 |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
240 |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
241 def unpack_zip_archive(filen, wd=None): |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
242 """Extract files from a ZIP archive |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
243 |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
244 Given a ZIP archive, extract the files it contains |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
245 and return a list of the resulting file names and |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
246 paths. |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
247 |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
248 'wd' specifies the working directory to extract |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
249 the files to, otherwise they are extracted to the |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
250 current working directory. |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
251 |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
252 Once all the files are extracted the ZIP archive |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
253 file is deleted from the file system. |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
254 |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
255 """ |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
256 if not zipfile.is_zipfile(filen): |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
257 print "%s: not ZIP formatted file" |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
258 return [filen] |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
259 file_list = [] |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
260 z = zipfile.ZipFile(filen) |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
261 for name in z.namelist(): |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
262 if reduce(lambda x, y: x or name.startswith(y), IGNORE_PATHS, False): |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
263 print "Ignoring %s" % name |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
264 continue |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
265 if wd: |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
266 target = os.path.join(wd, name) |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
267 else: |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
268 target = name |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
269 if name.endswith('/'): |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
270 # Make directory |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
271 print "Creating dir %s" % target |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
272 try: |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
273 os.makedirs(target) |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
274 except OSError: |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
275 pass |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
276 else: |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
277 # Extract file |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
278 print "Extracting %s" % name |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
279 try: |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
280 os.makedirs(os.path.dirname(target)) |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
281 except OSError: |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
282 pass |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
283 open(target, 'wb').write(z.read(name)) |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
284 file_list.append(target) |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
285 print "Removing %s" % filen |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
286 os.remove(filen) |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
287 return file_list |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
288 |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
289 |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
290 def unpack_tar_archive(filen, wd=None): |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
291 """Extract files from a TAR archive |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
292 |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
293 Given a TAR archive (which optionally can be |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
294 compressed with either gzip or bz2), extract the |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
295 files it contains and return a list of the |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
296 resulting file names and paths. |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
297 |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
298 'wd' specifies the working directory to extract |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
299 the files to, otherwise they are extracted to the |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
300 current working directory. |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
301 |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
302 Once all the files are extracted the TAR archive |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
303 file is deleted from the file system. |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
304 |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
305 """ |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
306 file_list = [] |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
307 if not tarfile.is_tarfile(filen): |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
308 print "%s: not TAR file" |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
309 return [filen] |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
310 t = tarfile.open(filen) |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
311 for name in t.getnames(): |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
312 # Check for unwanted files |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
313 if reduce(lambda x, y: x or name.startswith(y), IGNORE_PATHS, False): |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
314 print "Ignoring %s" % name |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
315 continue |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
316 # Extract file |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
317 print "Extracting %s" % name |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
318 t.extract(name, wd) |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
319 if wd: |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
320 target = os.path.join(wd, name) |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
321 else: |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
322 target = name |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
323 file_list.append(target) |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
324 print "Removing %s" % filen |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
325 os.remove(filen) |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
326 return file_list |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
327 |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
328 |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
329 def unpack_archive(filen, wd=None): |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
330 """Extract files from an archive |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
331 |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
332 Wrapper function that calls the appropriate |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
333 unpacking function depending on the archive |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
334 type, and returns a list of files that have |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
335 been extracted. |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
336 |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
337 'wd' specifies the working directory to extract |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
338 the files to, otherwise they are extracted to the |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
339 current working directory. |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
340 |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
341 """ |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
342 print "Unpack %s" % filen |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
343 ext = os.path.splitext(filen)[1] |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
344 print "Extension: %s" % ext |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
345 if ext == ".zip": |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
346 return unpack_zip_archive(filen, wd=wd) |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
347 elif ext == ".tgz": |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
348 return unpack_tar_archive(filen, wd=wd) |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
349 else: |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
350 return [filen] |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
351 |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
352 |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
353 def fetch_files(urls, wd=None, files=None): |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
354 """Download and unpack files from a list of URLs |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
355 |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
356 Given a list of URLs, download and unpack each |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
357 one, and return a list of the extracted files. |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
358 |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
359 'wd' specifies the working directory to extract |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
360 the files to, otherwise they are extracted to the |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
361 current working directory. |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
362 |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
363 If 'files' is given then the list of extracted |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
364 files will be appended to this list before being |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
365 returned. |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
366 |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
367 """ |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
368 if files is None: |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
369 files = [] |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
370 for url in urls: |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
371 filen = download_file(url, wd=wd) |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
372 files.extend(unpack_archive(filen, wd=wd)) |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
373 return files |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
374 |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
375 |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
376 # Utility functions specific to the Mothur reference data |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
377 def identify_type(filen): |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
378 """Return the data table name based on the file name |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
379 |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
380 """ |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
381 ext = os.path.splitext(filen)[1] |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
382 try: |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
383 return MOTHUR_FILE_TYPES[ext] |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
384 except KeyError: |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
385 print "WARNING: unknown file type for " + filen + ", skipping" |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
386 return None |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
387 |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
388 |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
389 def get_name(filen): |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
390 """Generate a descriptive name based on the file name |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
391 """ |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
392 # type_ = identify_type(filen) |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
393 name = os.path.splitext(os.path.basename(filen))[0] |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
394 for delim in ('.', '_'): |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
395 name = name.replace(delim, ' ') |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
396 return name |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
397 |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
398 |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
399 def fetch_from_mothur_website(data_tables, target_dir, datasets): |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
400 """Fetch reference data from the Mothur website |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
401 |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
402 For each dataset in the list 'datasets', download (and if |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
403 necessary unpack) the related files from the Mothur website, |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
404 copy them to the data manager's target directory, and add |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
405 references to the files to the appropriate data table. |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
406 |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
407 The 'data_tables' dictionary should have been created using |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
408 the 'create_data_tables_dict' and 'add_data_table' functions. |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
409 |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
410 Arguments: |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
411 data_tables: a dictionary containing the data table info |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
412 target_dir: directory to put the downloaded files |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
413 datasets: a list of dataset names corresponding to keys in |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
414 the MOTHUR_REFERENCE_DATA dictionary |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
415 """ |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
416 # Make working dir |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
417 wd = tempfile.mkdtemp(suffix=".mothur", dir=os.getcwd()) |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
418 print "Working dir %s" % wd |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
419 # Iterate over all requested reference data URLs |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
420 for dataset in datasets: |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
421 print "Handling dataset '%s'" % dataset |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
422 for name in MOTHUR_REFERENCE_DATA[dataset]: |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
423 for f in fetch_files(MOTHUR_REFERENCE_DATA[dataset][name], wd=wd): |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
424 type_ = identify_type(f) |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
425 entry_name = "%s (%s)" % (os.path.splitext(os.path.basename(f))[0], name) |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
426 print "%s\t\'%s'\t.../%s" % (type_, entry_name, os.path.basename(f)) |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
427 if type_ is not None: |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
428 # Move to target dir |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
429 ref_data_file = os.path.basename(f) |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
430 f1 = os.path.join(target_dir, ref_data_file) |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
431 print "Moving %s to %s" % (f, f1) |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
432 os.rename(f, f1) |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
433 # Add entry to data table |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
434 table_name = "mothur_%s" % type_ |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
435 add_data_table_entry(data_tables, table_name, dict(name=entry_name, value=ref_data_file)) |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
436 # Remove working dir |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
437 print "Removing %s" % wd |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
438 shutil.rmtree(wd) |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
439 |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
440 |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
441 def files_from_filesystem_paths(paths): |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
442 """Return list of file paths from arbitrary input paths |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
443 |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
444 Given a list of filesystem paths, return a list of |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
445 full paths corresponding to all files found recursively |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
446 from under those paths. |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
447 |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
448 """ |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
449 # Collect files to add |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
450 files = [] |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
451 for path in paths: |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
452 path = os.path.abspath(path) |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
453 print "Examining '%s'..." % path |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
454 if os.path.isfile(path): |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
455 # Store full path for file |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
456 files.append(path) |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
457 elif os.path.isdir(path): |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
458 # Descend into directory and collect the files |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
459 for f in os.listdir(path): |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
460 files.extend(files_from_filesystem_paths((os.path.join(path, f), ))) |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
461 else: |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
462 print "Not a file or directory, ignored" |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
463 return files |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
464 |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
465 |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
466 def import_from_server(data_tables, target_dir, paths, description, link_to_data=False): |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
467 """Import reference data from filesystem paths |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
468 |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
469 Creates references to the specified file(s) on the Galaxy |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
470 server in the appropriate data table (determined from the |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
471 file extension). |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
472 |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
473 The 'data_tables' dictionary should have been created using |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
474 the 'create_data_tables_dict' and 'add_data_table' functions. |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
475 |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
476 Arguments: |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
477 data_tables: a dictionary containing the data table info |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
478 target_dir: directory to put copy or link to the data file |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
479 paths: list of file and/or directory paths to import |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
480 description: text to associate with the files |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
481 link_to_data: boolean, if False then copy the data file |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
482 into Galaxy (default); if True then make a symlink to |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
483 the data file |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
484 |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
485 """ |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
486 # Collect list of files based on input paths |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
487 files = files_from_filesystem_paths(paths) |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
488 # Handle each file individually |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
489 for f in files: |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
490 type_ = identify_type(f) |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
491 if type_ is None: |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
492 print "%s: unrecognised type, skipped" % f |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
493 continue |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
494 ref_data_file = os.path.basename(f) |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
495 target_file = os.path.join(target_dir, ref_data_file) |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
496 entry_name = "%s" % os.path.splitext(ref_data_file)[0] |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
497 if description: |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
498 entry_name += " (%s)" % description |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
499 print "%s\t\'%s'\t.../%s" % (type_, entry_name, ref_data_file) |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
500 # Link to or copy the data |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
501 if link_to_data: |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
502 os.symlink(f, target_file) |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
503 else: |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
504 shutil.copyfile(f, target_file) |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
505 # Add entry to data table |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
506 table_name = "mothur_%s" % type_ |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
507 add_data_table_entry(data_tables, table_name, dict(name=entry_name, value=ref_data_file)) |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
508 |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
509 |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
510 if __name__ == "__main__": |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
511 print "Starting..." |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
512 |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
513 # Read command line |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
514 parser = optparse.OptionParser() |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
515 parser.add_option('--source', action='store', dest='data_source') |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
516 parser.add_option('--datasets', action='store', dest='datasets', default='') |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
517 parser.add_option('--paths', action='store', dest='paths', default=[]) |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
518 parser.add_option('--description', action='store', dest='description', default='') |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
519 parser.add_option('--link', action='store_true', dest='link_to_data') |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
520 options, args = parser.parse_args() |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
521 print "options: %s" % options |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
522 print "args : %s" % args |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
523 |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
524 # Check for JSON file |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
525 if len(args) != 1: |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
526 sys.stderr.write("Need to supply JSON file name") |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
527 sys.exit(1) |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
528 |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
529 jsonfile = args[0] |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
530 |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
531 # Read the input JSON |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
532 params, target_dir = read_input_json(jsonfile) |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
533 |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
534 # Make the target directory |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
535 print "Making %s" % target_dir |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
536 os.mkdir(target_dir) |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
537 |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
538 # Set up data tables dictionary |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
539 data_tables = create_data_tables_dict() |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
540 add_data_table(data_tables, 'mothur_lookup') |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
541 add_data_table(data_tables, 'mothur_aligndb') |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
542 add_data_table(data_tables, 'mothur_map') |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
543 add_data_table(data_tables, 'mothur_taxonomy') |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
544 |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
545 # Fetch data from specified data sources |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
546 if options.data_source == 'mothur_website': |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
547 datasets = options.datasets.split(',') |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
548 fetch_from_mothur_website(data_tables, target_dir, datasets) |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
549 elif options.data_source == 'filesystem_paths': |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
550 # Check description text |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
551 description = options.description.strip() |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
552 # Get list of paths (need to remove any escapes for '\n' and '\r' |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
553 # that might have been inserted by Galaxy) |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
554 paths = options.paths.replace('__cn__', '\n').replace('__cr__', '\r').split() |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
555 import_from_server(data_tables, target_dir, paths, description, link_to_data=options.link_to_data) |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
556 # Write output JSON |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
557 print "Outputting JSON" |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
558 print str(json.dumps(data_tables)) |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
559 open(jsonfile, 'wb').write(json.dumps(data_tables)) |
ab7a7e798c34
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff
changeset
|
560 print "Done." |