annotate data_manager/fetch_mothur_reference_data.py @ 2:0e532fc0a0a6 draft

"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit b824ec6d0faa5353c5893b5a2a540b8251cae309"
author iuc
date Thu, 17 Sep 2020 09:37:41 +0000
parents aec831b54a5b
children 9d09724f2bf1
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 """
ab7a7e798c34 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff changeset
163 params = json.loads(open(jsonfile).read())
ab7a7e798c34 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff changeset
164 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
165 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
166
ab7a7e798c34 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff changeset
167
ab7a7e798c34 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 # 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
169 #
ab7a7e798c34 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 # 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
171 # >>> 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
172 # >>> 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
173 # >>> 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
174 # >>> add_data_table_entry(dict(dbkey='mm9',value='mouse'))
ab7a7e798c34 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff changeset
175 # >>> print str(json.dumps(d))
ab7a7e798c34 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff changeset
176 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
177 """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
178
ab7a7e798c34 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 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
180 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
181 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
182 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
183
ab7a7e798c34 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff changeset
184 """
ab7a7e798c34 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff changeset
185 d = {}
ab7a7e798c34 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['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
187 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
188
ab7a7e798c34 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff changeset
189
ab7a7e798c34 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 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
191 """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
192
ab7a7e798c34 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 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
194
ab7a7e798c34 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff changeset
195 """
ab7a7e798c34 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 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
197
ab7a7e798c34 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff changeset
198
ab7a7e798c34 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 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
200 """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
201
ab7a7e798c34 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 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
203 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
204 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
205
ab7a7e798c34 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 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
207 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
208
ab7a7e798c34 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff changeset
209 """
ab7a7e798c34 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 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
211 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
212 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
213 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
214
ab7a7e798c34 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff changeset
215
ab7a7e798c34 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 # 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
217 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
218 """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
219
ab7a7e798c34 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 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
221
ab7a7e798c34 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 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
223 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
224
ab7a7e798c34 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 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
226 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
227 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
228
ab7a7e798c34 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 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
230
ab7a7e798c34 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff changeset
231 """
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
232 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
233 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
234 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
235 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
236 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
237 print("Saving to %s" % target)
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
238 open(target, 'wb').write(urllib2.urlopen(url).read())
ab7a7e798c34 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff changeset
239 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
240
ab7a7e798c34 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff changeset
241
ab7a7e798c34 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 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
243 """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
244
ab7a7e798c34 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 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
246 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
247 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
248
ab7a7e798c34 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 '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
250 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
251 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
252
ab7a7e798c34 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 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
254 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
255
ab7a7e798c34 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff changeset
256 """
ab7a7e798c34 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 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
258 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
259 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
260 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
261 z = zipfile.ZipFile(filen)
ab7a7e798c34 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff changeset
262 for name in z.namelist():
ab7a7e798c34 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff changeset
263 if reduce(lambda x, y: x or name.startswith(y), IGNORE_PATHS, False):
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
264 print("Ignoring %s" % name)
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
265 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
266 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
267 target = os.path.join(wd, name)
ab7a7e798c34 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff changeset
268 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
269 target = name
ab7a7e798c34 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff changeset
270 if name.endswith('/'):
ab7a7e798c34 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff changeset
271 # Make 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
272 print("Creating dir %s" % target)
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
273 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
274 os.makedirs(target)
ab7a7e798c34 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff changeset
275 except OSError:
ab7a7e798c34 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff changeset
276 pass
ab7a7e798c34 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff changeset
277 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
278 # Extract 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
279 print("Extracting %s" % name)
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
280 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
281 os.makedirs(os.path.dirname(target))
ab7a7e798c34 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff changeset
282 except OSError:
ab7a7e798c34 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff changeset
283 pass
ab7a7e798c34 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff changeset
284 open(target, 'wb').write(z.read(name))
ab7a7e798c34 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff changeset
285 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
286 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
287 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
288 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
289
ab7a7e798c34 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff changeset
290
ab7a7e798c34 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 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
292 """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
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 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
295 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
296 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
297 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
298
ab7a7e798c34 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 '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
300 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
301 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
302
ab7a7e798c34 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 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
304 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
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 """
ab7a7e798c34 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_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
308 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
309 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
310 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
311 t = tarfile.open(filen)
ab7a7e798c34 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff changeset
312 for name in t.getnames():
ab7a7e798c34 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff changeset
313 # Check for unwanted files
ab7a7e798c34 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff changeset
314 if reduce(lambda x, y: x or name.startswith(y), IGNORE_PATHS, False):
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
315 print("Ignoring %s" % name)
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
316 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
317 # Extract 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
318 print("Extracting %s" % name)
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
319 t.extract(name, wd)
ab7a7e798c34 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff changeset
320 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
321 target = os.path.join(wd, name)
ab7a7e798c34 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff changeset
322 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
323 target = name
ab7a7e798c34 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff changeset
324 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
325 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
326 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
327 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
328
ab7a7e798c34 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff changeset
329
ab7a7e798c34 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 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
331 """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
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 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
334 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
335 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
336 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
337
ab7a7e798c34 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 '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
339 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
340 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
341
ab7a7e798c34 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff changeset
342 """
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
343 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
344 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
345 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
346 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
347 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
348 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
349 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
350 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
351 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
352
ab7a7e798c34 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff changeset
353
ab7a7e798c34 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 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
355 """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
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 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
358 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
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 '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
361 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
362 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
363
ab7a7e798c34 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 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
365 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
366 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
367
ab7a7e798c34 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff changeset
368 """
ab7a7e798c34 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 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
370 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
371 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
372 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
373 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
374 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
375
ab7a7e798c34 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff changeset
376
ab7a7e798c34 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 # 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
378 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
379 """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
380
ab7a7e798c34 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff changeset
381 """
ab7a7e798c34 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 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
383 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
384 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
385 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
386 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
387 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
388
ab7a7e798c34 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff changeset
389
ab7a7e798c34 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 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
391 """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
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 # 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
394 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
395 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
396 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
397 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
398
ab7a7e798c34 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff changeset
399
ab7a7e798c34 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 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
401 """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
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 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
404 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
405 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
406 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
407
ab7a7e798c34 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff changeset
408 The '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
409 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
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 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
412 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
413 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
414 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
415 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
416 """
ab7a7e798c34 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 # 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
418 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
419 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
420 # 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
421 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
422 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
423 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
424 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
425 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
426 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
427 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
428 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
429 # 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
430 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
431 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
432 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
433 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
434 # 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
435 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
436 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
437 # 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
438 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
439 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
440
ab7a7e798c34 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff changeset
441
ab7a7e798c34 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 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
443 """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
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 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
446 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
447 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
448
ab7a7e798c34 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff changeset
449 """
ab7a7e798c34 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 # 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
451 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
452 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
453 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
454 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
455 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
456 # 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
457 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
458 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
459 # 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
460 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
461 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
462 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
463 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
464 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
465
ab7a7e798c34 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff changeset
466
ab7a7e798c34 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 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
468 """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
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 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
471 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
472 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
473
ab7a7e798c34 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff changeset
474 The '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
475 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
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 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
478 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
479 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
480 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
481 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
482 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
483 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
484 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
485
ab7a7e798c34 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff changeset
486 """
ab7a7e798c34 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 # 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
488 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
489 # 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
490 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
491 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
492 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
493 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
494 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
495 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
496 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
497 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
498 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
499 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
500 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
501 # 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
502 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
503 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
504 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
505 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
506 # 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
507 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
508 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
509
ab7a7e798c34 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff changeset
510
ab7a7e798c34 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 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
512 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
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 # 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
515 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
516 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
517 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
518 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
519 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
520 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
521 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
522 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
523 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
524
ab7a7e798c34 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff changeset
525 # 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
526 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
527 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
528 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
529
ab7a7e798c34 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 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
531
ab7a7e798c34 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 # 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
533 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
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 # 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
536 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
537 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
538
ab7a7e798c34 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mothur_toolsuite/ commit c1b936b54b7133106b3181df1e104986613a5bea
iuc
parents:
diff changeset
539 # 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
540 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
541 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
542 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
543 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
544 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
545
ab7a7e798c34 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 # 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
547 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
548 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
549 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
550 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
551 # 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
552 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
553 # 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
554 # 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
555 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
556 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
557 # 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
558 print("Outputting JSON")
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
559 print(json.dumps(data_tables))
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
560 open(jsonfile, 'w').write(json.dumps(data_tables, sort_keys=True))
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("Done.")