Mercurial > repos > yating-l > hac
comparison util/add_datatype.py @ 0:0bca8a6364a7 draft default tip
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
author | yating-l |
---|---|
date | Wed, 21 Dec 2016 17:21:18 -0500 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:0bca8a6364a7 |
---|---|
1 #!/usr/bin/python | |
2 | |
3 """ | |
4 This script copy the huba datatype into your galaxy: | |
5 - Add under <registration>, the datatype_conf | |
6 - Add huba.xml under display_application/ucsc/ | |
7 - Add hubAssembly.py inside lib/galaxy/datatypes | |
8 Place yourself in the folder of the python script, and launch it | |
9 - Based on the fact datatypes_conf | |
10 """ | |
11 | |
12 import argparse | |
13 import os | |
14 import shutil | |
15 import sys | |
16 import xml.etree.ElementTree as ET | |
17 | |
18 | |
19 def main(argv): | |
20 # Command Line parsing init | |
21 parser = argparse.ArgumentParser(description='Create a foo.txt inside the given folder.') | |
22 | |
23 parser.add_argument('-g', '--galaxy_root', help='Galaxy root folder', required=True) | |
24 | |
25 # Get the args passed in parameter | |
26 args = parser.parse_args() | |
27 | |
28 galaxy_root_path = args.galaxy_root | |
29 | |
30 add_datatype_conf(galaxy_root_path) | |
31 add_huba_xml(galaxy_root_path) | |
32 add_hubAssembly(galaxy_root_path) | |
33 | |
34 | |
35 def add_datatype_conf(galaxy_root_path): | |
36 print "======= Add datatype =======" | |
37 datatype_conf_path = os.path.join(galaxy_root_path, 'config/datatypes_conf.xml') | |
38 # TODO: Not relative to this python file but based on a parameter galaxy_root | |
39 # TODO: Check if datatypes_conf.xml, if not create it by copying datatypes_conf.xml.sample | |
40 # TODO: For debug only | |
41 # tree = ET.parse('../test-data/add_datatype/datatypes_conf.xml.sample') | |
42 # TODO: UnComment for prod | |
43 tree = ET.parse(datatype_conf_path) | |
44 root = tree.getroot() | |
45 print root.tag | |
46 registration = root[0] | |
47 print registration.attrib | |
48 | |
49 huba_datatype = ET.parse('../trackHub/datatypes_conf.xml').getroot() | |
50 # TODO: Verify the datatype is not already existing, else do not add / write. And in another version, check it | |
51 registration.append(huba_datatype) | |
52 tree.write(datatype_conf_path) | |
53 print "datatype added in %s" % datatype_conf_path | |
54 return | |
55 | |
56 | |
57 def add_huba_xml(galaxy_root_path): | |
58 print "======= Add hub xml =======" | |
59 displayApp_ucsc_path = os.path.join(galaxy_root_path, "display_applications/ucsc/") | |
60 shutil.copy("../trackHub/huba.xml", displayApp_ucsc_path) | |
61 print "Content of %s now: %s" % (displayApp_ucsc_path, os.listdir(displayApp_ucsc_path)) | |
62 return | |
63 | |
64 | |
65 def add_hubAssembly(galaxy_root_path): | |
66 print "======= Add hubAssembly =======" | |
67 datatype_lib_path = os.path.join(galaxy_root_path, "lib/galaxy/datatypes/") | |
68 shutil.copy("../trackHub/hubAssembly.py", datatype_lib_path) | |
69 print "Content of %s now: %s" % (datatype_lib_path, os.listdir(datatype_lib_path)) | |
70 return | |
71 | |
72 | |
73 if __name__ == "__main__": | |
74 main(sys.argv) |