def main(): form = cgi.FieldStorage() # CGI variables: # key = project, lab, data, freeze, status keyField = form.getvalue('key') if not keyField: keyField = 'project' switch = {'project':0, 'lab':1, 'data':2, 'freeze':5, 'status':8 } titleTag = {'project':"Project", 'lab':"Lab", 'data':"Data_Type", 'freeze':"Freeze", 'status':"Status" } if keyField not in switch: keyField = 'project' keyIndex = switch[keyField] reportFile, currentDate = encodeReportLib.getRecentReport() matrix, labels = processReportFile(reportFile, keyIndex) # Headers for the columns in the data matrix description = [("Time", "string")] for label in labels: tmpDesc = [(label, 'number')] description += tmpDesc # Create the data table data_table = gviz_api.DataTable(description) data_table.LoadData(matrix) # Convert to JavaScript code jscode = data_table.ToJSCode("jscode_data") # Set variables for HTML output template_vars = {} template_vars['jscode'] = jscode template_vars['dateStamp'] = encodeReportLib.dateIntToDateStr(currentDate) template_vars['title'] = "ENCODE Amount of Time Until Release by %s" % titleTag[keyField] template_vars['packageName'] = 'columnchart' template_vars['visClass'] = 'ColumnChart' template_vars['style'] = "" # Set the chart specific configuration options chart_config = {} chart_config['isStacked'] = 'true' chart_config['legendFontSize'] = 16 chart_config['width'] = 1200 chart_config['height'] = 480 chart_config['legend'] = 'bottom' chart_config['titleX'] = '# of Weeks' chart_config['titleY'] = '# of Submissions' chart_config['tooltipFontSize'] = 16 if (keyField == 'freeze'): chart_config['colors'] = encodeReportLib.getColorArray(len(labels)) template_vars['chart_config'] = json.dumps(chart_config) encodeReportLib.renderHtml(template_vars, 1, 0) return
def main(): reportFile, currentDate = encodeReportLib.getRecentReport() # Output the file as Google JSON Query Response description = [] dataMatrix = [] line_idx = 0 hash = {} f = open(reportFile, "r") for line in f: line = line.rstrip() splitArray = line.split('\t') project = splitArray[0] freeze = splitArray[5] assembly = splitArray[9] if line.startswith('Project') and line_idx == 0: pass else: # Parse the data if assembly != 'hg19' or freeze != 'Jun-2010': continue if not project in hash: hash[project] = 0 hash[project] += 1 data = line.split('\t') line_idx += 1 f.close() for key in hash.keys(): array = [] array.append(key) array.append(hash[key]) dataMatrix.append(array) projectHeader = ('Project', 'string') countHeader = ('Count', 'number') description.append(projectHeader) description.append(countHeader) data_table = gviz_api.DataTable(description) data_table.LoadData(dataMatrix) print "Content-type: text/plain" print print data_table.ToJSonResponse(req_id=1) return
def main(): # Headers for the columns in the data matrix description = [ ("date", "date"), ("release", "number"), ("release_cumul", "number"), ("submit", "number"), ("submit_cumul", "number"), ("events", "string") ] # Create the data table data_table = gviz_api.DataTable(description) currentFile, currentDate = encodeReportLib.getRecentReport() # Create and load the matrix matrix = processReportFile(currentFile, currentDate) data_table.LoadData(matrix) # Convert to JavaScript code jscode = data_table.ToJSCode("jscode_data") # Set variables for HTML output template_vars = {} template_vars['jscode'] = jscode template_vars['dateStamp'] = encodeReportLib.dateIntToDateStr(currentDate) template_vars['title'] = "ENCODE Cumulative Release and Submit Timeline" template_vars['packageName'] = 'annotatedtimeline' template_vars['visClass'] = 'AnnotatedTimeLine' template_vars['style'] = 'style="width:854px; height:480px"' # Set the chart specific configuration options chart_config = {} chart_config['annotationsWidth'] = 15 chart_config['displayAnnotations'] = 'true' chart_config['displayAnnotationsFilter'] = 'true' chart_config['fill'] = 25 chart_config['thickness'] = 3 chart_config['width'] = 854 chart_config['height'] = 480 template_vars['chart_config'] = json.dumps(chart_config) encodeReportLib.renderHtml(template_vars, 0, 0) return
def main(): # Headers for the columns in the data matrix description = [("date", "date"), ("release", "number"), ("release_cumul", "number"), ("submit", "number"), ("submit_cumul", "number"), ("events", "string")] # Create the data table data_table = gviz_api.DataTable(description) currentFile, currentDate = encodeReportLib.getRecentReport() # Create and load the matrix matrix = processReportFile(currentFile, currentDate) data_table.LoadData(matrix) # Convert to JavaScript code jscode = data_table.ToJSCode("jscode_data") # Set variables for HTML output template_vars = {} template_vars['jscode'] = jscode template_vars['dateStamp'] = encodeReportLib.dateIntToDateStr(currentDate) template_vars['title'] = "ENCODE Cumulative Release and Submit Timeline" template_vars['packageName'] = 'annotatedtimeline' template_vars['visClass'] = 'AnnotatedTimeLine' template_vars['style'] = 'style="width:854px; height:480px"' # Set the chart specific configuration options chart_config = {} chart_config['annotationsWidth'] = 15 chart_config['displayAnnotations'] = 'true' chart_config['displayAnnotationsFilter'] = 'true' chart_config['fill'] = 25 chart_config['thickness'] = 3 chart_config['width'] = 854 chart_config['height'] = 480 template_vars['chart_config'] = json.dumps(chart_config) encodeReportLib.renderHtml(template_vars, 0, 0) return
def main(): form = cgi.FieldStorage() # CGI variables: # key = project, lab, data, freeze, or status # value = values based on "key" # status = loaded, displayed, approved, reviewing, released or all # species = human, mouse or all # norelease = 0 or 1 keyField = form.getvalue('key') keyValue = form.getvalue('value') if not keyField or not keyValue: printErrorMsg("Error: Must specify both key and value variables") return # Convert from standard freeze value to non-standard for "post" case pattern = re.compile("post (.{3})\-(\d{4})") m = pattern.match(keyValue) if m: month = m.group(1) year = m.group(2) if month == 'Jun': # Adjust for June month = 'June' keyValue = "post ENCODE %s %s Freeze" % (month, year) status = form.getvalue('status') if not status: status = 'released' species = form.getvalue('species') if not species: species = 'all' norelease = form.getvalue('norelease') if not norelease: norelease = 0 norelease = int(norelease) freeze = form.getvalue('freeze') if not freeze: freeze = 'all' switch = {'project': 0, 'lab': 1, 'data': 2, 'freeze': 5, 'status': 8} titleTag = { 'project': "Project", 'lab': "Lab", 'data': "Data_Type", 'freeze': "Freeze", 'status': "Status" } keyIndex = switch[keyField] reportFile, date = encodeReportLib.getRecentReport() try: f = open(reportFile, "r") except: print >> sys.stderr, "Error: Can't open file '%s'" % f sys.exit(-1) print "Content-type: text/plain" print rowCount = 0 for line in f: line = line.rstrip() splitArray = line.split('\t') assembly = splitArray[9] if splitArray[8] == 'revoked' or status == 'replaced': continue if norelease == 1 and status == 'released': continue if species == 'all': pass else: if species == 'human' and assembly.startswith('hg'): pass elif species == 'mouse' and assembly.startswith('mm'): pass elif species == assembly: pass else: continue if splitArray[keyIndex] == keyValue: if status == 'all' or splitArray[8] == status: pass else: continue if freeze == 'all' or splitArray[5] == freeze: pass else: continue print line rowCount += 1 f.close() print print "%d rows" % rowCount print "key = %s, value = %s, status = %s, species = %s, norelease = %d" % ( keyField, keyValue, status, species, norelease)
def main(): form = cgi.FieldStorage() # CGI variables: # key = project, lab, data, freeze, or status # value = values based on "key" # status = loaded, displayed, approved, reviewing, released or all # species = human, mouse or all # norelease = 0 or 1 keyField = form.getvalue('key') keyValue = form.getvalue('value') if not keyField or not keyValue: printErrorMsg("Error: Must specify both key and value variables") return # Convert from standard freeze value to non-standard for "post" case pattern = re.compile("post (.{3})\-(\d{4})") m = pattern.match(keyValue) if m: month = m.group(1) year = m.group(2) if month == 'Jun': # Adjust for June month = 'June' keyValue = "post ENCODE %s %s Freeze" % (month, year) status = form.getvalue('status') if not status: status = 'released' species = form.getvalue('species') if not species: species = 'all' norelease = form.getvalue('norelease') if not norelease: norelease = 0 norelease = int(norelease) freeze = form.getvalue('freeze') if not freeze: freeze = 'all' switch = {'project':0, 'lab':1, 'data':2, 'freeze':5, 'status':8} titleTag = {'project':"Project", 'lab':"Lab", 'data':"Data_Type", 'freeze':"Freeze", 'status':"Status"} keyIndex = switch[keyField] reportFile, date = encodeReportLib.getRecentReport() try: f = open(reportFile, "r") except: print >> sys.stderr, "Error: Can't open file '%s'" % f sys.exit(-1) print "Content-type: text/plain" print rowCount = 0 for line in f: line = line.rstrip() splitArray = line.split('\t') assembly = splitArray[9] if splitArray[8] == 'revoked' or status == 'replaced': continue if norelease == 1 and status == 'released': continue if species == 'all': pass else: if species == 'human' and assembly.startswith('hg'): pass elif species == 'mouse' and assembly.startswith('mm'): pass elif species == assembly: pass else: continue if splitArray[keyIndex] == keyValue: if status == 'all' or splitArray[8] == status: pass else: continue if freeze == 'all' or splitArray[5] == freeze: pass else: continue print line rowCount += 1 f.close() print print "%d rows" % rowCount print "key = %s, value = %s, status = %s, species = %s, norelease = %d" % (keyField, keyValue, status, species, norelease)
def main(): form = cgi.FieldStorage() # CGI Variables # key = project, lab, data, freeze, or species # Display data based on the key variable # norelease = 0 or 1 # 0 = Output all data # 1 = Output only unreleased data # species = human, mouse, all # human = Output only human data # mouse = Output only mouse data # all = Output all data keyField = form.getvalue('key') if keyField == None: keyField = 'project' norelease = form.getvalue('norelease') if norelease == None: norelease = 0 norelease = int(norelease) species = form.getvalue('species') if species == None: species = 'all' switch = {'project':0, 'lab':1, 'data':2, 'freeze':5, 'status':8} titleTag = {'project':"Project", 'lab':"Lab", 'data':"Data_Type", 'freeze':"Freeze", 'status':"Status"} if keyField not in switch: keyField = 'project' keyIndex = switch[keyField] # Headers for the columns in the data matrix description = [(titleTag[keyField], "string")] fullLabel = ['released', 'reviewing', 'approved', 'displayed', 'downloads', 'loaded'] statusLabel = [] for label in fullLabel: if label == 'released' and norelease == 1: continue tmpDesc = [(label, 'number')] description += tmpDesc statusLabel.append(label) reportFile, currentDate = encodeReportLib.getRecentReport() matrix = processReportFile(reportFile, statusLabel, keyIndex, norelease, species) # Create the data table data_table = gviz_api.DataTable(description) data_table.LoadData(matrix) # Convert to JavaScript code jscode = data_table.ToJSCode("jscode_data") # Set variables for HTML output template_vars = {} template_vars['jscode'] = jscode template_vars['dateStamp'] = encodeReportLib.dateIntToDateStr(currentDate) template_vars['title'] = "ENCODE (%s) Status by %s" % (species, titleTag[keyField]) template_vars['packageName'] = 'columnchart' template_vars['visClass'] = 'ColumnChart' template_vars['style'] = "" template_vars['species'] = species template_vars['keyField'] = keyField template_vars['norelease']= norelease # Set the chart specific configuration options chart_config = {} chart_config['isStacked'] = 'true' chart_config['legendFontSize'] = 16 chart_config['width'] = 854 chart_config['height'] = 480 chart_config['titleX'] = titleTag[keyField] chart_config['titleY'] = "# of Submissions" chart_config['tooltipFontSize'] = 16 chart_config['enableTooltip'] = 'true' colors = encodeReportLib.getColorArray(len(statusLabel)) colors.reverse() chart_config['colors'] = colors template_vars['chart_config'] = json.dumps(chart_config) encodeReportLib.renderHtml(template_vars, 0, 1) return
def main(): form = cgi.FieldStorage() # CGI variables: # format = raw or pretty or google # raw = Output file as plain text # pretty = Output file as Google Visualization Table # google = Google Data Source Protocol # reportDate = 0, 1 # returns a JSON object of the latest date of the report file format = form.getvalue('format') if format == None: format = 'pretty' if format != 'pretty' and format != 'raw' and format != 'google': format = 'pretty' reportDate = form.getvalue('reportDate') if not reportDate: reportDate = 0 reportDate = int(reportDate) callback = form.getvalue('callback') reportFile, currentDate = encodeReportLib.getRecentReport() if reportDate: jsonDate = {} jsonDate['currentDate'] = encodeReportLib.dateIntToDateStr(currentDate) print "Content-Type: application/json" print if not callback: outString = json.dumps(jsonDate) else: outString = callback + "(" + json.dumps(jsonDate) + ")" print outString return try: f = open(reportFile, "r") except: print >> sys.stderr, "Error: Can't open file '%s'" % f sys.exit(-1) if format == 'raw': # Output the file as raw text print "Content-Type: text/plain" print for line in f: line = line.rstrip() print line f.close() return elif format == 'pretty' or format == 'google': # Output the file as Google Visualization Table description = [] dataMatrix = [] line_idx = 0 for line in f: line = line.rstrip() if line.startswith('Project') and line_idx == 0: # Parse the header line headers = line.split('\t') for header in headers: tmpDesc = (header, 'string') if header.endswith('Date'): tmpDesc = (header, 'date') description.append(tmpDesc) else: # Parse the data data = line.split('\t') data[6] = encodeReportLib.convertToDate(data[6]) data[7] = encodeReportLib.convertToDate(data[7]) dataMatrix.append(data) line_idx += 1 f.close() data_table = gviz_api.DataTable(description) data_table.LoadData(dataMatrix) if format == 'google': print "Content-type: text/plain" print print data_table.ToJSonResponse(req_id=1) return jscode = data_table.ToJSCode("jscode_data") # Set variables for HTML output template_vars = {} template_vars['jscode'] = jscode template_vars['dateStamp'] = encodeReportLib.dateIntToDateStr( currentDate) template_vars['title'] = "ENCODE Report" template_vars['packageName'] = 'table' template_vars['visClass'] = 'Table' template_vars['style'] = '' # Set the chart specific configuration options chart_config = {} chart_config['page'] = 'enable' chart_config['pageSize'] = 15 chart_config['pagingSymbols'] = { 'prev': 'prev', 'next': 'next' } chart_config['showRowNumber'] = 'true' template_vars['chart_config'] = json.dumps(chart_config) encodeReportLib.renderHtml(template_vars, 0, 0) return
def main(): form = cgi.FieldStorage() # CGI variables: # format = raw or pretty or google # raw = Output file as plain text # pretty = Output file as Google Visualization Table # google = Google Data Source Protocol # reportDate = 0, 1 # returns a JSON object of the latest date of the report file format = form.getvalue('format') if format == None: format = 'pretty' if format != 'pretty' and format != 'raw' and format != 'google': format = 'pretty' reportDate = form.getvalue('reportDate') if not reportDate: reportDate = 0 reportDate = int(reportDate) callback = form.getvalue('callback') reportFile, currentDate = encodeReportLib.getRecentReport() if reportDate: jsonDate = {} jsonDate['currentDate'] = encodeReportLib.dateIntToDateStr(currentDate) print "Content-Type: application/json" print if not callback: outString = json.dumps(jsonDate) else: outString = callback + "(" + json.dumps(jsonDate) + ")" print outString return try: f = open(reportFile, "r") except: print >> sys.stderr, "Error: Can't open file '%s'" % f sys.exit(-1) if format == 'raw': # Output the file as raw text print "Content-Type: text/plain" print for line in f: line = line.rstrip() print line f.close() return elif format == 'pretty' or format == 'google': # Output the file as Google Visualization Table description = [] dataMatrix = [] line_idx = 0 for line in f: line = line.rstrip() if line.startswith('Project') and line_idx == 0: # Parse the header line headers = line.split('\t') for header in headers: tmpDesc = (header, 'string') if header.endswith('Date'): tmpDesc = (header, 'date') description.append(tmpDesc) else: # Parse the data data = line.split('\t') data[6] = encodeReportLib.convertToDate(data[6]) data[7] = encodeReportLib.convertToDate(data[7]) dataMatrix.append(data) line_idx += 1 f.close() data_table = gviz_api.DataTable(description) data_table.LoadData(dataMatrix) if format == 'google': print "Content-type: text/plain" print print data_table.ToJSonResponse(req_id=1) return jscode = data_table.ToJSCode("jscode_data") # Set variables for HTML output template_vars = {} template_vars['jscode'] = jscode template_vars['dateStamp'] = encodeReportLib.dateIntToDateStr(currentDate) template_vars['title'] = "ENCODE Report" template_vars['packageName'] = 'table' template_vars['visClass'] = 'Table' template_vars['style'] = '' # Set the chart specific configuration options chart_config = {} chart_config['page'] = 'enable' chart_config['pageSize'] = 15 chart_config['pagingSymbols'] = {'prev': 'prev', 'next': 'next'}; chart_config['showRowNumber'] = 'true' template_vars['chart_config'] = json.dumps(chart_config) encodeReportLib.renderHtml(template_vars, 0, 0) return