annotate data_manager/fetch_mothur_reference_data.py @ 3:9d09724f2bf1 draft

"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit 02d2967f77e3fa5a18aea63dc84aa9ab418dc165"
author iuc
date Sun, 22 Nov 2020 12:51:44 +0000
parents 0e532fc0a0a6
children 0db22932bc39
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
2
0e532fc0a0a6 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit b824ec6d0faa5353c5893b5a2a540b8251cae309"
iuc
parents: 1
diff changeset
13 from functools import reduce
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
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
15 # 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
16 # 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
17 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
18
ab7a7e798c34 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 # 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
20 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
21 ".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
22 ".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
23 ".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
24 ".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
25
ab7a7e798c34 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 # 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
27 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
28 # 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
29 # 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
30 "lookup_titanium": {
2
0e532fc0a0a6 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit b824ec6d0faa5353c5893b5a2a540b8251cae309"
iuc
parents: 1
diff changeset
31 "GS FLX Titanium": ["https://mothur.s3.us-east-2.amazonaws.com/wiki/lookup_titanium.zip", ]
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
32 },
ab7a7e798c34 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 "lookup_gsflx": {
2
0e532fc0a0a6 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit b824ec6d0faa5353c5893b5a2a540b8251cae309"
iuc
parents: 1
diff changeset
34 "GSFLX": ["https://mothur.s3.us-east-2.amazonaws.com/wiki/lookup_gsflx.zip", ]
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
35 },
ab7a7e798c34 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 "lookup_gs20": {
2
0e532fc0a0a6 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit b824ec6d0faa5353c5893b5a2a540b8251cae309"
iuc
parents: 1
diff changeset
37 "GS20": ["https://mothur.s3.us-east-2.amazonaws.com/wiki/lookup_gs20.zip", ]
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
38 },
ab7a7e798c34 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 # 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 # 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
41 "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
42 "16S rRNA RDP training set 16":
2
0e532fc0a0a6 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit b824ec6d0faa5353c5893b5a2a540b8251cae309"
iuc
parents: 1
diff changeset
43 ["https://mothur.s3.us-east-2.amazonaws.com/wiki/trainset16_022016.rdp.tgz", ],
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
44 "16S rRNA PDS training set 16":
2
0e532fc0a0a6 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit b824ec6d0faa5353c5893b5a2a540b8251cae309"
iuc
parents: 1
diff changeset
45 ["https://mothur.s3.us-east-2.amazonaws.com/wiki/trainset16_022016.pds.tgz", ],
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
46 },
ab7a7e798c34 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 "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
48 "16S rRNA RDP training set 14":
2
0e532fc0a0a6 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit b824ec6d0faa5353c5893b5a2a540b8251cae309"
iuc
parents: 1
diff changeset
49 ["https://mothur.s3.us-east-2.amazonaws.com/wiki/trainset14_032015.rdp.tgz", ],
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
50 "16S rRNA PDS training set 14":
2
0e532fc0a0a6 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit b824ec6d0faa5353c5893b5a2a540b8251cae309"
iuc
parents: 1
diff changeset
51 ["https://mothur.s3.us-east-2.amazonaws.com/wiki/trainset14_032015.pds.tgz", ],
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
52 },
ab7a7e798c34 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 "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
54 "16S rRNA RDP training set 10":
2
0e532fc0a0a6 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit b824ec6d0faa5353c5893b5a2a540b8251cae309"
iuc
parents: 1
diff changeset
55 ["https://mothur.s3.us-east-2.amazonaws.com/wiki/trainset10_082014.rdp.tgz", ],
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
56 "16S rRNA PDS training set 10":
2
0e532fc0a0a6 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit b824ec6d0faa5353c5893b5a2a540b8251cae309"
iuc
parents: 1
diff changeset
57 ["https://mothur.s3.us-east-2.amazonaws.com/wiki/trainset10_082014.pds.tgz", ],
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
58 },
ab7a7e798c34 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 "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
60 "16S rRNA RDP training set 9":
2
0e532fc0a0a6 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit b824ec6d0faa5353c5893b5a2a540b8251cae309"
iuc
parents: 1
diff changeset
61 ["https://mothur.s3.us-east-2.amazonaws.com/wiki/trainset9_032012.rdp.zip", ],
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
62 "16S rRNA PDS training set 9":
2
0e532fc0a0a6 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit b824ec6d0faa5353c5893b5a2a540b8251cae309"
iuc
parents: 1
diff changeset
63 ["https://mothur.s3.us-east-2.amazonaws.com/wiki/trainset9_032012.pds.zip", ],
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
64 },
ab7a7e798c34 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 "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
66 "16S rRNA RDP training set 7":
2
0e532fc0a0a6 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit b824ec6d0faa5353c5893b5a2a540b8251cae309"
iuc
parents: 1
diff changeset
67 ["https://mothur.s3.us-east-2.amazonaws.com/wiki/trainset7_112011.rdp.zip", ],
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
68 "16S rRNA PDS training set 7":
2
0e532fc0a0a6 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit b824ec6d0faa5353c5893b5a2a540b8251cae309"
iuc
parents: 1
diff changeset
69 ["https://mothur.s3.us-east-2.amazonaws.com/wiki/trainset7_112011.pds.zip", ],
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
70 "8S rRNA Fungi training set 7":
2
0e532fc0a0a6 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit b824ec6d0faa5353c5893b5a2a540b8251cae309"
iuc
parents: 1
diff changeset
71 ["https://mothur.s3.us-east-2.amazonaws.com/wiki/fungilsu_train_v7.zip", ],
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
72 },
ab7a7e798c34 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_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
74 "RDP training set 6":
2
0e532fc0a0a6 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit b824ec6d0faa5353c5893b5a2a540b8251cae309"
iuc
parents: 1
diff changeset
75 ["https://mothur.s3.us-east-2.amazonaws.com/wiki/rdptrainingset.zip", ],
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
76 },
ab7a7e798c34 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 # 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 # 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
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 "SILVA release 128":
2
0e532fc0a0a6 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit b824ec6d0faa5353c5893b5a2a540b8251cae309"
iuc
parents: 1
diff changeset
81 ["https://mothur.s3.us-east-2.amazonaws.com/wiki/silva.nr_v128.tgz",
0e532fc0a0a6 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit b824ec6d0faa5353c5893b5a2a540b8251cae309"
iuc
parents: 1
diff changeset
82 "https://mothur.s3.us-east-2.amazonaws.com/wiki/silva.seed_v128.tgz", ],
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
83 },
ab7a7e798c34 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 "SILVA release 123":
2
0e532fc0a0a6 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit b824ec6d0faa5353c5893b5a2a540b8251cae309"
iuc
parents: 1
diff changeset
86 ["https://mothur.s3.us-east-2.amazonaws.com/wiki/silva.nr_v123.tgz",
0e532fc0a0a6 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit b824ec6d0faa5353c5893b5a2a540b8251cae309"
iuc
parents: 1
diff changeset
87 "https://mothur.s3.us-east-2.amazonaws.com/wiki/silva.seed_v123.tgz", ],
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
88 },
ab7a7e798c34 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 "SILVA release 119":
2
0e532fc0a0a6 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit b824ec6d0faa5353c5893b5a2a540b8251cae309"
iuc
parents: 1
diff changeset
91 ["https://mothur.s3.us-east-2.amazonaws.com/wiki/silva.nr_v119.tgz",
0e532fc0a0a6 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit b824ec6d0faa5353c5893b5a2a540b8251cae309"
iuc
parents: 1
diff changeset
92 "https://mothur.s3.us-east-2.amazonaws.com/wiki/silva.seed_v119.tgz", ],
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
93 },
ab7a7e798c34 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 "SILVA release 102":
2
0e532fc0a0a6 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit b824ec6d0faa5353c5893b5a2a540b8251cae309"
iuc
parents: 1
diff changeset
96 ["https://mothur.s3.us-east-2.amazonaws.com/wiki/silva.bacteria.zip",
0e532fc0a0a6 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit b824ec6d0faa5353c5893b5a2a540b8251cae309"
iuc
parents: 1
diff changeset
97 "https://mothur.s3.us-east-2.amazonaws.com/wiki/silva.archaea.zip",
0e532fc0a0a6 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit b824ec6d0faa5353c5893b5a2a540b8251cae309"
iuc
parents: 1
diff changeset
98 "https://mothur.s3.us-east-2.amazonaws.com/wiki/silva.eukarya.zip", ],
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
99 },
ab7a7e798c34 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_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
101 "SILVA gold":
2
0e532fc0a0a6 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit b824ec6d0faa5353c5893b5a2a540b8251cae309"
iuc
parents: 1
diff changeset
102 ["https://mothur.s3.us-east-2.amazonaws.com/wiki/silva.gold.bacteria.zip", ],
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
103 },
ab7a7e798c34 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 # 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
105 # 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
106 "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
107 "Greengenes August 2013":
2
0e532fc0a0a6 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit b824ec6d0faa5353c5893b5a2a540b8251cae309"
iuc
parents: 1
diff changeset
108 ["https://mothur.s3.us-east-2.amazonaws.com/wiki/gg_13_8_99.refalign.tgz",
0e532fc0a0a6 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit b824ec6d0faa5353c5893b5a2a540b8251cae309"
iuc
parents: 1
diff changeset
109 "https://mothur.s3.us-east-2.amazonaws.com/wiki/gg_13_8_99.taxonomy.tgz", ],
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
110 },
ab7a7e798c34 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_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
112 "Greengenes May 2013":
2
0e532fc0a0a6 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit b824ec6d0faa5353c5893b5a2a540b8251cae309"
iuc
parents: 1
diff changeset
113 ["https://mothur.s3.us-east-2.amazonaws.com/wiki/gg_13_5_99.refalign.tgz",
0e532fc0a0a6 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit b824ec6d0faa5353c5893b5a2a540b8251cae309"
iuc
parents: 1
diff changeset
114 "https://mothur.s3.us-east-2.amazonaws.com/wiki/gg_13_5_99.taxonomy.tgz", ],
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
115 },
ab7a7e798c34 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_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
117 "Greengenes pre-May 2013":
2
0e532fc0a0a6 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit b824ec6d0faa5353c5893b5a2a540b8251cae309"
iuc
parents: 1
diff changeset
118 ["https://mothur.s3.us-east-2.amazonaws.com/wiki/greengenes.alignment.zip",
0e532fc0a0a6 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit b824ec6d0faa5353c5893b5a2a540b8251cae309"
iuc
parents: 1
diff changeset
119 "https://mothur.s3.us-east-2.amazonaws.com/wiki/greengenes.tax.tgz", ],
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
120 },
ab7a7e798c34 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 "Greengenes gold alignment":
2
0e532fc0a0a6 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit b824ec6d0faa5353c5893b5a2a540b8251cae309"
iuc
parents: 1
diff changeset
123 ["https://mothur.s3.us-east-2.amazonaws.com/wiki/greengenes.gold.alignment.zip", ],
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
124 },
ab7a7e798c34 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 # 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
126 # 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
127 "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
128 "SILVA":
2
0e532fc0a0a6 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit b824ec6d0faa5353c5893b5a2a540b8251cae309"
iuc
parents: 1
diff changeset
129 ["https://mothur.s3.us-east-2.amazonaws.com/wiki/silva_ss_map.zip", ],
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
130 },
ab7a7e798c34 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 "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
132 "Greengenes":
2
0e532fc0a0a6 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit b824ec6d0faa5353c5893b5a2a540b8251cae309"
iuc
parents: 1
diff changeset
133 ["https://mothur.s3.us-east-2.amazonaws.com/wiki/gg_ss_map.zip", ],
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
134 },
ab7a7e798c34 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: 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
136 "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
137 "Greengenes-compatible":
2
0e532fc0a0a6 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit b824ec6d0faa5353c5893b5a2a540b8251cae309"
iuc
parents: 1
diff changeset
138 ["https://mothur.s3.us-east-2.amazonaws.com/wiki/Lane1241.gg.filter",
0e532fc0a0a6 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit b824ec6d0faa5353c5893b5a2a540b8251cae309"
iuc
parents: 1
diff changeset
139 "https://mothur.s3.us-east-2.amazonaws.com/wiki/lane1287.gg.filter",
0e532fc0a0a6 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit b824ec6d0faa5353c5893b5a2a540b8251cae309"
iuc
parents: 1
diff changeset
140 "https://mothur.s3.us-east-2.amazonaws.com/wiki/lane1349.gg.filter", ],
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
141 "SILVA-compatible":
2
0e532fc0a0a6 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit b824ec6d0faa5353c5893b5a2a540b8251cae309"
iuc
parents: 1
diff changeset
142 ["https://mothur.s3.us-east-2.amazonaws.com/wiki/lane1349.silva.filter", ]
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
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
ab7a7e798c34 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 # 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
148 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
149 """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
150
ab7a7e798c34 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 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
152
ab7a7e798c34 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 '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
154 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
155 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
156 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
157
ab7a7e798c34 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 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
159 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
160 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
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 """
3
9d09724f2bf1 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit 02d2967f77e3fa5a18aea63dc84aa9ab418dc165"
iuc
parents: 2
diff changeset
163 with open(jsonfile) as fh:
9d09724f2bf1 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit 02d2967f77e3fa5a18aea63dc84aa9ab418dc165"
iuc
parents: 2
diff changeset
164 params = json.load(fh)
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
165 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
166 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
167
ab7a7e798c34 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 # 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
170 #
ab7a7e798c34 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 # 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
172 # >>> 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
173 # >>> 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
174 # >>> 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
175 # >>> add_data_table_entry(dict(dbkey='mm9',value='mouse'))
3
9d09724f2bf1 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit 02d2967f77e3fa5a18aea63dc84aa9ab418dc165"
iuc
parents: 2
diff changeset
176 # >>> print(json.dumps(d))
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
177 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
178 """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
179
ab7a7e798c34 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 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
181 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
182 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
183 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
184
ab7a7e798c34 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 """
ab7a7e798c34 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 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 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
188 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
189
ab7a7e798c34 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
ab7a7e798c34 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 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
192 """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
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 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
195
ab7a7e798c34 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 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
198
ab7a7e798c34 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
ab7a7e798c34 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 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
201 """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
202
ab7a7e798c34 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 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
204 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
205 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
206
ab7a7e798c34 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 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
208 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
209
ab7a7e798c34 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 """
ab7a7e798c34 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 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
212 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
213 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
214 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
215
ab7a7e798c34 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
ab7a7e798c34 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 # 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
218 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
219 """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
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 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
222
ab7a7e798c34 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 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
224 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
225
ab7a7e798c34 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 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
227 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
228 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
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 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
231
ab7a7e798c34 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 """
1
aec831b54a5b "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit 57f71aa633a43ab02bbf05acd0c6d7f406e01f1e"
iuc
parents: 0
diff changeset
233 print("Downloading %s" % url)
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
234 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
235 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
236 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
237 target = os.path.join(wd, target)
1
aec831b54a5b "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit 57f71aa633a43ab02bbf05acd0c6d7f406e01f1e"
iuc
parents: 0
diff changeset
238 print("Saving to %s" % target)
3
9d09724f2bf1 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit 02d2967f77e3fa5a18aea63dc84aa9ab418dc165"
iuc
parents: 2
diff changeset
239 with open(target, 'wb') as fh:
9d09724f2bf1 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit 02d2967f77e3fa5a18aea63dc84aa9ab418dc165"
iuc
parents: 2
diff changeset
240 fh.write(urllib2.urlopen(url).read())
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
241 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
242
ab7a7e798c34 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 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
245 """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
246
ab7a7e798c34 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 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
248 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
249 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
250
ab7a7e798c34 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 '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
252 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
253 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
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 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
256 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
257
ab7a7e798c34 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 """
ab7a7e798c34 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 if not zipfile.is_zipfile(filen):
1
aec831b54a5b "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit 57f71aa633a43ab02bbf05acd0c6d7f406e01f1e"
iuc
parents: 0
diff changeset
260 print("%s: not ZIP formatted 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
261 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
262 file_list = []
3
9d09724f2bf1 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit 02d2967f77e3fa5a18aea63dc84aa9ab418dc165"
iuc
parents: 2
diff changeset
263 with zipfile.ZipFile(filen) as z:
9d09724f2bf1 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit 02d2967f77e3fa5a18aea63dc84aa9ab418dc165"
iuc
parents: 2
diff changeset
264 for name in z.namelist():
9d09724f2bf1 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit 02d2967f77e3fa5a18aea63dc84aa9ab418dc165"
iuc
parents: 2
diff changeset
265 if reduce(lambda x, y: x or name.startswith(y), IGNORE_PATHS, False):
9d09724f2bf1 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit 02d2967f77e3fa5a18aea63dc84aa9ab418dc165"
iuc
parents: 2
diff changeset
266 print("Ignoring %s" % name)
9d09724f2bf1 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit 02d2967f77e3fa5a18aea63dc84aa9ab418dc165"
iuc
parents: 2
diff changeset
267 continue
9d09724f2bf1 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit 02d2967f77e3fa5a18aea63dc84aa9ab418dc165"
iuc
parents: 2
diff changeset
268 if wd:
9d09724f2bf1 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit 02d2967f77e3fa5a18aea63dc84aa9ab418dc165"
iuc
parents: 2
diff changeset
269 target = os.path.join(wd, name)
9d09724f2bf1 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit 02d2967f77e3fa5a18aea63dc84aa9ab418dc165"
iuc
parents: 2
diff changeset
270 else:
9d09724f2bf1 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit 02d2967f77e3fa5a18aea63dc84aa9ab418dc165"
iuc
parents: 2
diff changeset
271 target = name
9d09724f2bf1 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit 02d2967f77e3fa5a18aea63dc84aa9ab418dc165"
iuc
parents: 2
diff changeset
272 if name.endswith('/'):
9d09724f2bf1 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit 02d2967f77e3fa5a18aea63dc84aa9ab418dc165"
iuc
parents: 2
diff changeset
273 # Make directory
9d09724f2bf1 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit 02d2967f77e3fa5a18aea63dc84aa9ab418dc165"
iuc
parents: 2
diff changeset
274 print("Creating dir %s" % target)
9d09724f2bf1 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit 02d2967f77e3fa5a18aea63dc84aa9ab418dc165"
iuc
parents: 2
diff changeset
275 try:
9d09724f2bf1 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit 02d2967f77e3fa5a18aea63dc84aa9ab418dc165"
iuc
parents: 2
diff changeset
276 os.makedirs(target)
9d09724f2bf1 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit 02d2967f77e3fa5a18aea63dc84aa9ab418dc165"
iuc
parents: 2
diff changeset
277 except OSError:
9d09724f2bf1 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit 02d2967f77e3fa5a18aea63dc84aa9ab418dc165"
iuc
parents: 2
diff changeset
278 pass
9d09724f2bf1 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit 02d2967f77e3fa5a18aea63dc84aa9ab418dc165"
iuc
parents: 2
diff changeset
279 else:
9d09724f2bf1 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit 02d2967f77e3fa5a18aea63dc84aa9ab418dc165"
iuc
parents: 2
diff changeset
280 # Extract file
9d09724f2bf1 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit 02d2967f77e3fa5a18aea63dc84aa9ab418dc165"
iuc
parents: 2
diff changeset
281 print("Extracting %s" % name)
9d09724f2bf1 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit 02d2967f77e3fa5a18aea63dc84aa9ab418dc165"
iuc
parents: 2
diff changeset
282 try:
9d09724f2bf1 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit 02d2967f77e3fa5a18aea63dc84aa9ab418dc165"
iuc
parents: 2
diff changeset
283 os.makedirs(os.path.dirname(target))
9d09724f2bf1 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit 02d2967f77e3fa5a18aea63dc84aa9ab418dc165"
iuc
parents: 2
diff changeset
284 except OSError:
9d09724f2bf1 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit 02d2967f77e3fa5a18aea63dc84aa9ab418dc165"
iuc
parents: 2
diff changeset
285 pass
9d09724f2bf1 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit 02d2967f77e3fa5a18aea63dc84aa9ab418dc165"
iuc
parents: 2
diff changeset
286 with open(target, 'wb') as fh:
9d09724f2bf1 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit 02d2967f77e3fa5a18aea63dc84aa9ab418dc165"
iuc
parents: 2
diff changeset
287 fh.write(z.read(name))
9d09724f2bf1 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit 02d2967f77e3fa5a18aea63dc84aa9ab418dc165"
iuc
parents: 2
diff changeset
288 file_list.append(target)
1
aec831b54a5b "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit 57f71aa633a43ab02bbf05acd0c6d7f406e01f1e"
iuc
parents: 0
diff changeset
289 print("Removing %s" % 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
290 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
291 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
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
ab7a7e798c34 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 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
295 """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
296
ab7a7e798c34 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 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
298 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
299 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
300 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
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 '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
303 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
304 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
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 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
307 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
308
ab7a7e798c34 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 """
ab7a7e798c34 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 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
311 if not tarfile.is_tarfile(filen):
1
aec831b54a5b "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit 57f71aa633a43ab02bbf05acd0c6d7f406e01f1e"
iuc
parents: 0
diff changeset
312 print("%s: not TAR 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
313 return [filen]
3
9d09724f2bf1 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit 02d2967f77e3fa5a18aea63dc84aa9ab418dc165"
iuc
parents: 2
diff changeset
314 with tarfile.open(filen) as t:
9d09724f2bf1 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit 02d2967f77e3fa5a18aea63dc84aa9ab418dc165"
iuc
parents: 2
diff changeset
315 for name in t.getnames():
9d09724f2bf1 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit 02d2967f77e3fa5a18aea63dc84aa9ab418dc165"
iuc
parents: 2
diff changeset
316 # Check for unwanted files
9d09724f2bf1 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit 02d2967f77e3fa5a18aea63dc84aa9ab418dc165"
iuc
parents: 2
diff changeset
317 if reduce(lambda x, y: x or name.startswith(y), IGNORE_PATHS, False):
9d09724f2bf1 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit 02d2967f77e3fa5a18aea63dc84aa9ab418dc165"
iuc
parents: 2
diff changeset
318 print("Ignoring %s" % name)
9d09724f2bf1 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit 02d2967f77e3fa5a18aea63dc84aa9ab418dc165"
iuc
parents: 2
diff changeset
319 continue
9d09724f2bf1 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit 02d2967f77e3fa5a18aea63dc84aa9ab418dc165"
iuc
parents: 2
diff changeset
320 # Extract file
9d09724f2bf1 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit 02d2967f77e3fa5a18aea63dc84aa9ab418dc165"
iuc
parents: 2
diff changeset
321 print("Extracting %s" % name)
9d09724f2bf1 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit 02d2967f77e3fa5a18aea63dc84aa9ab418dc165"
iuc
parents: 2
diff changeset
322 t.extract(name, wd)
9d09724f2bf1 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit 02d2967f77e3fa5a18aea63dc84aa9ab418dc165"
iuc
parents: 2
diff changeset
323 if wd:
9d09724f2bf1 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit 02d2967f77e3fa5a18aea63dc84aa9ab418dc165"
iuc
parents: 2
diff changeset
324 target = os.path.join(wd, name)
9d09724f2bf1 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit 02d2967f77e3fa5a18aea63dc84aa9ab418dc165"
iuc
parents: 2
diff changeset
325 else:
9d09724f2bf1 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit 02d2967f77e3fa5a18aea63dc84aa9ab418dc165"
iuc
parents: 2
diff changeset
326 target = name
9d09724f2bf1 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit 02d2967f77e3fa5a18aea63dc84aa9ab418dc165"
iuc
parents: 2
diff changeset
327 file_list.append(target)
1
aec831b54a5b "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit 57f71aa633a43ab02bbf05acd0c6d7f406e01f1e"
iuc
parents: 0
diff changeset
328 print("Removing %s" % 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
329 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
330 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
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
ab7a7e798c34 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 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
334 """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
335
ab7a7e798c34 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 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
337 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
338 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
339 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
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 '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
342 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
343 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
344
ab7a7e798c34 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 """
1
aec831b54a5b "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit 57f71aa633a43ab02bbf05acd0c6d7f406e01f1e"
iuc
parents: 0
diff changeset
346 print("Unpack %s" % 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
347 ext = os.path.splitext(filen)[1]
1
aec831b54a5b "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit 57f71aa633a43ab02bbf05acd0c6d7f406e01f1e"
iuc
parents: 0
diff changeset
348 print("Extension: %s" % ext)
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
349 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
350 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
351 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
352 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
353 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
354 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
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
ab7a7e798c34 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 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
358 """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
359
ab7a7e798c34 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 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
361 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
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 '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
364 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
365 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
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 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
368 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
369 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
370
ab7a7e798c34 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 """
ab7a7e798c34 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 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
373 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 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
375 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
376 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
377 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
378
ab7a7e798c34 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 # 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
381 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
382 """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
383
ab7a7e798c34 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 """
ab7a7e798c34 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 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
386 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
387 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
388 except KeyError:
1
aec831b54a5b "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit 57f71aa633a43ab02bbf05acd0c6d7f406e01f1e"
iuc
parents: 0
diff changeset
389 print("WARNING: unknown file type for " + filen + ", skipping")
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
390 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
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
ab7a7e798c34 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 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
394 """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
395 """
ab7a7e798c34 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 # 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
397 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
398 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
399 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
400 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
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
ab7a7e798c34 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 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
404 """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
405
ab7a7e798c34 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 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
407 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
408 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
409 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
410
ab7a7e798c34 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 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
412 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
413
ab7a7e798c34 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 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
415 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
416 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
417 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
418 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
419 """
ab7a7e798c34 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 # 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
421 wd = tempfile.mkdtemp(suffix=".mothur", dir=os.getcwd())
1
aec831b54a5b "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit 57f71aa633a43ab02bbf05acd0c6d7f406e01f1e"
iuc
parents: 0
diff changeset
422 print("Working dir %s" % wd)
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
423 # 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
424 for dataset in datasets:
1
aec831b54a5b "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit 57f71aa633a43ab02bbf05acd0c6d7f406e01f1e"
iuc
parents: 0
diff changeset
425 print("Handling dataset '%s'" % dataset)
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
426 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
427 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
428 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
429 entry_name = "%s (%s)" % (os.path.splitext(os.path.basename(f))[0], name)
1
aec831b54a5b "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit 57f71aa633a43ab02bbf05acd0c6d7f406e01f1e"
iuc
parents: 0
diff changeset
430 print("%s\t\'%s'\t.../%s" % (type_, entry_name, os.path.basename(f)))
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
431 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
432 # 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
433 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
434 f1 = os.path.join(target_dir, ref_data_file)
1
aec831b54a5b "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit 57f71aa633a43ab02bbf05acd0c6d7f406e01f1e"
iuc
parents: 0
diff changeset
435 print("Moving %s to %s" % (f, f1))
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
436 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
437 # 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
438 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
439 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
440 # Remove working dir
1
aec831b54a5b "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit 57f71aa633a43ab02bbf05acd0c6d7f406e01f1e"
iuc
parents: 0
diff changeset
441 print("Removing %s" % wd)
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
442 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
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
ab7a7e798c34 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 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
446 """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
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 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
449 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
450 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
451
ab7a7e798c34 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 """
ab7a7e798c34 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 # 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
454 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
455 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
456 path = os.path.abspath(path)
1
aec831b54a5b "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit 57f71aa633a43ab02bbf05acd0c6d7f406e01f1e"
iuc
parents: 0
diff changeset
457 print("Examining '%s'..." % path)
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
458 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
459 # 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
460 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
461 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
462 # 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
463 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
464 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
465 else:
1
aec831b54a5b "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit 57f71aa633a43ab02bbf05acd0c6d7f406e01f1e"
iuc
parents: 0
diff changeset
466 print("Not a file or directory, ignored")
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
467 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
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
ab7a7e798c34 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 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
471 """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
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 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
474 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
475 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
476
ab7a7e798c34 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 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
478 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
479
ab7a7e798c34 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 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
481 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
482 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
483 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
484 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
485 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
486 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
487 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
488
ab7a7e798c34 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 """
ab7a7e798c34 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 # 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
491 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
492 # 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
493 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
494 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
495 if type_ is None:
1
aec831b54a5b "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit 57f71aa633a43ab02bbf05acd0c6d7f406e01f1e"
iuc
parents: 0
diff changeset
496 print("%s: unrecognised type, skipped" % f)
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 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
498 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
499 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
500 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
501 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
502 entry_name += " (%s)" % description
1
aec831b54a5b "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit 57f71aa633a43ab02bbf05acd0c6d7f406e01f1e"
iuc
parents: 0
diff changeset
503 print("%s\t\'%s'\t.../%s" % (type_, entry_name, 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
504 # 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
505 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
506 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
507 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
508 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
509 # 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
510 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
511 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
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
ab7a7e798c34 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 if __name__ == "__main__":
1
aec831b54a5b "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit 57f71aa633a43ab02bbf05acd0c6d7f406e01f1e"
iuc
parents: 0
diff changeset
515 print("Starting...")
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
516
ab7a7e798c34 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 # 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
518 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
519 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
520 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
521 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
522 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
523 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
524 options, args = parser.parse_args()
1
aec831b54a5b "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit 57f71aa633a43ab02bbf05acd0c6d7f406e01f1e"
iuc
parents: 0
diff changeset
525 print("options: %s" % options)
aec831b54a5b "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit 57f71aa633a43ab02bbf05acd0c6d7f406e01f1e"
iuc
parents: 0
diff changeset
526 print("args : %s" % 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
527
ab7a7e798c34 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 # 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
529 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
530 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
531 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
532
ab7a7e798c34 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 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
534
ab7a7e798c34 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 # 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
536 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
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 # Make the target directory
1
aec831b54a5b "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit 57f71aa633a43ab02bbf05acd0c6d7f406e01f1e"
iuc
parents: 0
diff changeset
539 print("Making %s" % target_dir)
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
540 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
541
ab7a7e798c34 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 # 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
543 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
544 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
545 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
546 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
547 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
548
ab7a7e798c34 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 # 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
550 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
551 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
552 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
553 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
554 # 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
555 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
556 # 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
557 # 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
558 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
559 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
560 # Write output JSON
1
aec831b54a5b "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit 57f71aa633a43ab02bbf05acd0c6d7f406e01f1e"
iuc
parents: 0
diff changeset
561 print("Outputting JSON")
3
9d09724f2bf1 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit 02d2967f77e3fa5a18aea63dc84aa9ab418dc165"
iuc
parents: 2
diff changeset
562 with open(jsonfile, 'w') as fh:
9d09724f2bf1 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit 02d2967f77e3fa5a18aea63dc84aa9ab418dc165"
iuc
parents: 2
diff changeset
563 json.dump(data_tables, fh, sort_keys=True)
1
aec831b54a5b "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit 57f71aa633a43ab02bbf05acd0c6d7f406e01f1e"
iuc
parents: 0
diff changeset
564 print("Done.")