def create_project_report_on_gdocs(fc, qc, encoded_credentials, gdocs_folder): """Upload the sample read distribution for a project to google docs. """ success = True # Create a client class which will make HTTP requests with Google Docs server. client = g_spreadsheet.get_client(encoded_credentials) doc_client = g_document.get_client(encoded_credentials) # Get a reference to the parent folder parent_folder = g_document.get_folder(doc_client, gdocs_folder) if not parent_folder: parent_folder = g_document.add_folder(doc_client, gdocs_folder) log.info("Folder {!r} created".format(gdocs_folder)) parent_folder_title = _from_unicode(parent_folder.title.text) # Loop over the projects for project_name in fc.get_project_names(): # Get a flowcell object containing just the data for the project project_fc = fc.prune_to_project(project_name) ssheet_title = project_name + "_sequencing_results" ssheet = g_spreadsheet.get_spreadsheet(client, ssheet_title) if not ssheet: ssheet = g_document.add_spreadsheet(doc_client, ssheet_title) g_document.move_to_folder(doc_client, ssheet, parent_folder) ssheet = g_spreadsheet.get_spreadsheet(client, ssheet_title) log.info("Spreadsheet {!r} created in " \ "folder {!r}".format(_from_unicode(ssheet.title.text), \ parent_folder_title)) success &= bc_metrics._write_project_report_to_gdocs( client, ssheet, project_fc) success &= bc_metrics.write_project_report_summary_to_gdocs( client, ssheet) success &= qc_metrics.write_run_report_to_gdocs(project_fc, \ qc, \ ssheet_title, \ encoded_credentials) log.info("Sequencing results report written to spreadsheet '%s'" \ % _from_unicode(ssheet.title.text)) return success
def create_project_report_on_gdocs(fc, qc, encoded_credentials, gdocs_folder): """Upload the sample read distribution for a project to google docs. """ success = True # Create a client class which will make HTTP requests with Google Docs server. client = g_spreadsheet.get_client(encoded_credentials) doc_client = g_document.get_client(encoded_credentials) # Get a reference to the parent folder parent_folder = g_document.get_folder(doc_client, gdocs_folder) if not parent_folder: parent_folder = g_document.add_folder(doc_client, gdocs_folder) log.info("Folder {!r} created".format(gdocs_folder)) parent_folder_title = _from_unicode(parent_folder.title.text) # Loop over the projects for project_name in fc.get_project_names(): # Get a flowcell object containing just the data for the project project_fc = fc.prune_to_project(project_name) ssheet_title = project_name + "_sequencing_results" ssheet = g_spreadsheet.get_spreadsheet(client, ssheet_title) if not ssheet: ssheet = g_document.add_spreadsheet(doc_client, ssheet_title) g_document.move_to_folder(doc_client, ssheet, parent_folder) ssheet = g_spreadsheet.get_spreadsheet(client, ssheet_title) log.info("Spreadsheet {!r} created in " \ "folder {!r}".format(_from_unicode(ssheet.title.text), \ parent_folder_title)) success &= bc_metrics._write_project_report_to_gdocs(client, ssheet, project_fc) success &= bc_metrics.write_project_report_summary_to_gdocs(client, ssheet) success &= qc_metrics.write_run_report_to_gdocs(project_fc, \ qc, \ ssheet_title, \ encoded_credentials) log.info("Sequencing results report written to spreadsheet '%s'" \ % _from_unicode(ssheet.title.text)) return success
def write_project_report_to_gdocs(fc_date, fc_name, project_bc_metrics, encoded_credentials, gdocs_folder=""): """Upload the sample read distribution for a project to google docs""" # Create a client class which will make HTTP requests with Google Docs server. client = bcbio.google.spreadsheet.get_client(encoded_credentials) doc_client = bcbio.google.document.get_client(encoded_credentials) # Get a reference to the parent folder parent_folder = bcbio.google.document.get_folder(doc_client, gdocs_folder) # Group the barcode data by project grouped = group_bc_stats(project_bc_metrics) # Loop over the projects and write the project summary for each for pdata in grouped: project_name = pdata.get("project_name", "") ssheet_title = project_name + "_sequencing_results" ssheet = bcbio.google.spreadsheet.get_spreadsheet(client, ssheet_title) if not ssheet: bcbio.google.document.add_spreadsheet(doc_client, ssheet_title) ssheet = bcbio.google.spreadsheet.get_spreadsheet(client, ssheet_title) _write_project_report_to_gdocs(client, ssheet, fc_date, fc_name, pdata) _write_project_report_summary_to_gdocs(client, ssheet) # Just to make it look a bit nicer, remove the default 'Sheet1' worksheet wsheet = bcbio.google.spreadsheet.get_worksheet(client, ssheet, "Sheet 1") if wsheet: client.DeleteWorksheet(wsheet) folder_name = project_name folder = bcbio.google.document.get_folder(doc_client, folder_name) if not folder: log.info("creating folder '%s'" % _from_unicode(folder_name)) folder = bcbio.google.document.add_folder(doc_client, folder_name, parent_folder) ssheet = bcbio.google.document.move_to_folder(doc_client, ssheet, folder) log.info( "'%s' spreadsheet written to folder '%s'" % (_from_unicode(ssheet.title.text), _from_unicode(folder_name)) )
def _get_query(title, exact_match): """Get a query object for the supplied parameters""" p = {} if title: # The urllib.quote method does not handle unicode, so encode the title in utf-8 p['title'] = _from_unicode(title) if exact_match: p['title-exact'] = 'true' else: p['title-exact'] = 'false' return gdata.spreadsheet.service.DocumentQuery(params=p)
def get_barcode_id(self): return _from_unicode(self.barcode_id)
def get_description(self): return _from_unicode(self.description)
def get_project(self): return _from_unicode(self.project)
def get_full_name(self): return _from_unicode(self.full_name)
def get_name(self): return _from_unicode(self.name)
def get_barcode_type(self): return _from_unicode(self.barcode_type)
def get_barcode_sequence(self): return _from_unicode(self.barcode_sequence)
def get_barcode_full_name(self): return _from_unicode(self.barcode_full_name)
def get_analysis(self): return _from_unicode(self.analysis)
def get_genome_build(self): return _from_unicode(self.genome_build)