annotate util/Reader.py @ 0:9945eba268e6 draft default tip

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