Example #1
0
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
Example #2
0
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
Example #3
0
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
Example #4
0
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
Example #5
0
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
Example #6
0
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