def gene_network2ws(meth, feature_set_id=None, out_id=None): """ Query all available network data in KBase central store. :param feature_set_id: FeatureSet workspace object id :type feature_set_id: kbtypes.KBaseSearch.FeatureSet :param out_id: Output Networks object identifier :type out_id: kbtypes.KBaseNetworks.Network :return: New workspace object :rtype: kbtypes.Unicode :output_widget: ValueListWidget """ meth.stages = 3 meth.advance("init GWAS service") gc = GWAS(URLS.gwas, token=meth.token) meth.advance("Retrieve genes from workspace") ws = Workspace2(token=meth.token, wsid=meth.workspace_id) fs = ws.get(feature_set_id) qid2cds = ids2cds(fs['elements'].keys()) gl_str = ",".join(list(set(qid2cds.values()))); meth.advance("Running GeneList to Networks") argsx = {"ws_id" : meth.workspace_id, "inobj_id" : gl_str, "outobj_id": out_id} try: gl_oid = gc.genelist_to_networks(argsx) except Exception as err: raise GWASException("submit job failed: {}".format(err)) meth.advance("Returning object") return _workspace_output(out_id)
def gene_network2ws(meth, obj_id=None, out_id=None): """This method displays a gene list along with functional annotation in a table. :param obj_id: Gene List workspace object identifier. :type obj_id: kbtypes.KBaseGwasData.GwasGeneList :param out_id: Output Networks object identifier :type out_id: kbtypes.KBaseNetworks.Network :return: New workspace object :rtype: kbtypes.Unicode :output_widget: ValueListWidget """ # :param workspace_id: Workspace name (if empty, defaults to current workspace) # :type workspace_id: kbtypes.Unicode meth.stages = 3 meth.advance("init GWAS service") gc = GWAS(URLS.gwas, token=meth.token) meth.advance("Retrieve genes from workspace") # if not workspace_id: # meth.debug("Workspace ID is empty, setting to current ({})".format(meth.workspace_id)) # workspace_id = meth.workspace_id ws = Workspace2(token=meth.token, wsid=meth.workspace_id) raw_data = ws.get(obj_id) gl = [gr[2] for gr in raw_data['genes']] gl_str = ",".join(gl) meth.advance("Running GeneList to Networks") argsx = { "ws_id": meth.workspace_id, "inobj_id": gl_str, "outobj_id": out_id } try: gl_oid = gc.genelist_to_networks(argsx) except Exception as err: raise GWASException("submit job failed: {}".format(err)) #if not gl_oid: # it may return empty string based on current script # raise GWASException(2, "submit job failed, no job id") meth.advance("Returning object") return _workspace_output(out_id)
def gene_network2ws(meth, obj_id=None, out_id=None): """This method displays a gene list along with functional annotation in a table. :param obj_id: Gene List workspace object identifier. :type obj_id: kbtypes.KBaseGwasData.GwasGeneList :param out_id: Output Networks object identifier :type out_id: kbtypes.KBaseNetworks.Network :return: New workspace object :rtype: kbtypes.Unicode :output_widget: ValueListWidget """ # :param workspace_id: Workspace name (if empty, defaults to current workspace) # :type workspace_id: kbtypes.Unicode meth.stages = 3 meth.advance("init GWAS service") gc = GWAS(URLS.gwas, token=meth.token) meth.advance("Retrieve genes from workspace") # if not workspace_id: # meth.debug("Workspace ID is empty, setting to current ({})".format(meth.workspace_id)) # workspace_id = meth.workspace_id ws = Workspace2(token=meth.token, wsid=meth.workspace_id) raw_data = ws.get(obj_id) gl = [ gr[2] for gr in raw_data['genes']] gl_str = ",".join(gl); meth.advance("Running GeneList to Networks") argsx = {"ws_id" : meth.workspace_id, "inobj_id" : gl_str, "outobj_id": out_id} try: gl_oid = gc.genelist_to_networks(argsx) except Exception as err: raise GWASException("submit job failed: {}".format(err)) #if not gl_oid: # it may return empty string based on current script # raise GWASException(2, "submit job failed, no job id") meth.advance("Returning object") return _workspace_output(out_id)
def gene_network2ws(meth, feature_set_id=None, out_id=None): """ Query all available network data in KBase central store. :param feature_set_id: FeatureSet workspace object id :type feature_set_id: kbtypes.KBaseSearch.FeatureSet :param out_id: Output Networks object identifier :type out_id: kbtypes.KBaseNetworks.Network :return: New workspace object :rtype: kbtypes.Unicode :output_widget: ValueListWidget """ meth.stages = 3 meth.advance("init GWAS service") gc = GWAS(URLS.gwas, token=meth.token) meth.advance("Retrieve genes from workspace") ws = Workspace2(token=meth.token, wsid=meth.workspace_id) fs = ws.get(feature_set_id) qid2cds = ids2cds(fs['elements'].keys()) gl_str = ",".join(list(set(qid2cds.values()))) meth.advance("Running GeneList to Networks") argsx = { "ws_id": meth.workspace_id, "inobj_id": gl_str, "outobj_id": out_id } try: gl_oid = gc.genelist_to_networks(argsx) except Exception as err: raise GWASException("submit job failed: {}".format(err)) meth.advance("Returning object") return _workspace_output(out_id)