comparison util/Reader.py @ 0:ce4f91831680 draft default tip

planemo upload for repository https://github.com/Yating-L/suite_gonramp_apollo.git commit 5367a00befb467f162d1870edb91f9face72e894
author yating-l
date Fri, 16 Feb 2018 10:57:13 -0500
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:ce4f91831680
1 import json
2 import re
3 import logging
4 import codecs
5 import socket
6 from apollo.ApolloUser import ApolloUser
7 from util import santitizer
8
9 class Reader(object):
10
11 def __init__(self, input_json_file):
12 self.inputFile = input_json_file
13 self.args = self.loadJson()
14
15
16 def loadJson(self):
17 try:
18 data_file = codecs.open(self.inputFile, 'r', 'utf-8')
19 return json.load(data_file)
20 except IOError:
21 print "Cannot find JSON file\n"
22 exit(1)
23
24 def getJBrowseHubDir(self):
25 try:
26 return self.args["jbrowse_hub"]
27 except KeyError:
28 print ("jbrowse_hub is not defined in the input file!")
29 exit(1)
30
31 def getToolDir(self):
32 try:
33 return self.args["tool_directory"]
34 except KeyError:
35 print ("tool_directory is not defined in the input file!")
36 exit(1)
37
38 def getExtFilesPath(self):
39 try:
40 return self.args["extra_files_path"]
41 except KeyError:
42 print ("extra_files_path is not defined in the input file!")
43 exit(1)
44
45 def getUserEmail(self):
46 try:
47 return self.args["user_email"]
48 except KeyError:
49 print ("user_email is not defined in the input file!")
50 exit(1)
51
52 def getDebugMode(self):
53 try:
54 return self.args["debug_mode"]
55 except KeyError:
56 print ("debug_mode is not defined in the input file!")
57 exit(1)
58
59 def getPortNum(self):
60 try:
61 return self.args["port"]
62 except KeyError:
63 print ("port is not defined in the input file!")
64 exit(1)
65
66 def getApolloHost(self):
67 #apollo_host = self.args.get("apollo_host")
68 hostname = socket.gethostname()
69 ip = socket.gethostbyname(hostname)
70 protocol = socket.getprotobyname(hostname)
71 apollo_host = str(protocol) + str(ip)
72 return apollo_host
73
74
75 def getSpeciesName(self):
76 species_name = santitizer.sanitize_name_input(self.args["species_name"])
77 return species_name
78
79 def getAction(self):
80 action = self.args.get("action")
81 return action
82
83 def getAdminUser(self):
84 apollo_admin = self.args.get("apollo_admin")
85 return apollo_admin
86
87
88 def getOperationList(self):
89 l = self.args.get("operations")
90 return l
91
92