def getPathwayAs(pathway_db, species_code, mod): begin_time = time.time() try: export.deleteFolder( 'BuildDBs/WPs') ### clear any remaining pathway files except Exception: null = [] for wpid in pathway_db: file_type = 'gpml' wp_id_data = client.service.getPathwayAs(fileType=file_type, pwId=wpid, revision=0) wp_id_data = base64.b64decode(wp_id_data) gpml_path = filepath('BuildDBs/WPs/' + wpid + '.gpml') outfile = export.ExportFile(gpml_path) outfile.write(wp_id_data) outfile.close() gene_system_list = string.split(wp_id_data, '\n') parent_path = export.findParentDir(gpml_path) pathway_db = gene_associations.getGPMLGraphData( parent_path, species_code, mod) ### get GPML data back os.remove(gpml_path) ### Only store the file temporarily end_time = time.time() time_diff = float(end_time - begin_time) """ try: print "WikiPathways data imported in %d seconds" % time_diff except Exception: null=None ### Occurs when transitioning back from the Official Database download window (not sure why) -- TclError: can't invoke "update" command """ return pathway_db
def getPathwayAs(pathway_db,species_code,mod): begin_time = time.time() for wpid in pathway_db: #print [wpid],'pathway_db',len(pathway_db) file_type = 'gpml' #file_type = 'application/gpml+xml' processor_time = str(time.clock()) #try: export.deleteFolder('BuildDBs/WPs') ### clear any remaining pathway files #except Exception: pass #wp_id_data = client.service.getPathwayAs(fileType = file_type,pwId = wpid, revision = 0) kwargs = { 'identifier': 'WP2062', 'version': 0, 'file_format': 'application/gpml+xml'} #wp_id_data = wikipathways_api_client_instance.get_pathway_as(**kwargs) wp_id_data = wikipathways_api_client_instance.get_pathway_as(file_format = file_type,identifier = wpid, version = 0) #wp_id_data = base64.b64decode(wp_id_data) gpml_path = filepath('BuildDBs/WPs/'+processor_time+'/'+wpid+'.gpml') #print gpml_path outfile = export.ExportFile(gpml_path) outfile.write(wp_id_data); outfile.close() gene_system_list = string.split(wp_id_data,'\n') parent_path = export.findParentDir(gpml_path) pathway_db = gene_associations.getGPMLGraphData(parent_path,species_code,mod) ### get GPML data back #os.remove(gpml_path) ### Only store the file temporarily try: export.deleteFolder('BuildDBs/WPs/'+processor_time) ### clear any remaining pathway files except Exception: pass end_time = time.time(); time_diff = float(end_time-begin_time) """ try: print "WikiPathways data imported in %d seconds" % time_diff except Exception: null=None ### Occurs when transitioning back from the Official Database download window (not sure why) -- TclError: can't invoke "update" command """ return pathway_db
def getPathwayAs(pathway_db, species_code, mod): begin_time = time.time() for wpid in pathway_db: #print [wpid],'pathway_db',len(pathway_db) file_type = 'gpml' #file_type = 'application/gpml+xml' processor_time = str(time.clock()) #try: export.deleteFolder('BuildDBs/WPs') ### clear any remaining pathway files #except Exception: pass #wp_id_data = client.service.getPathwayAs(fileType = file_type,pwId = wpid, revision = 0) kwargs = { 'identifier': 'WP2062', 'version': 0, 'file_format': 'application/gpml+xml' } #wp_id_data = wikipathways_api_client_instance.get_pathway_as(**kwargs) wp_id_data = wikipathways_api_client_instance.get_pathway_as( file_format=file_type, identifier=wpid, version=0) #wp_id_data = base64.b64decode(wp_id_data) gpml_path = filepath('BuildDBs/WPs/' + processor_time + '/' + wpid + '.gpml') #print gpml_path outfile = export.ExportFile(gpml_path) outfile.write(wp_id_data) outfile.close() gene_system_list = string.split(wp_id_data, '\n') parent_path = export.findParentDir(gpml_path) pathway_db = gene_associations.getGPMLGraphData( parent_path, species_code, mod) ### get GPML data back #os.remove(gpml_path) ### Only store the file temporarily try: export.deleteFolder( 'BuildDBs/WPs/' + processor_time) ### clear any remaining pathway files except Exception: pass end_time = time.time() time_diff = float(end_time - begin_time) """ try: print "WikiPathways data imported in %d seconds" % time_diff except Exception: null=None ### Occurs when transitioning back from the Official Database download window (not sure why) -- TclError: can't invoke "update" command """ return pathway_db