public string GetModuleTOMGenes(CoexpParams coexpdata)
        {
            //Set the URL with parameters. This URL will allow us to establish a communication with
            //CoExp R application API (published using Plumber R package)
            if (coexpURL == ProductionEnv)
            {
                coexpURL += "GetModuleTOMGenes";
                PostData  = "{\"network\":\"" + coexpdata.Network +
                            "\",\"category\":\"" + coexpdata.Category +
                            "\",\"module\":\"" + coexpdata.ModuleColor + "\"}";
            }
            else
            {
                coexpURL += "getModuleTOMGenes";
                PostData  = "{\"tissue\":\"" + coexpdata.Network +
                            "\",\"which.one\":\"" + coexpdata.Category +
                            "\",\"module\":\"" + coexpdata.ModuleColor + "\"}";
            }

            //Make the request
            var finalResponse = _adapter.POSTHttpRequestJSON(coexpURL, PostData);

            //Return the response
            return(finalResponse);
        }
示例#2
0
        public string GetModuleTOMGenes([FromQuery] CoexpParams coexpdata)
        {
            CoExpRepository repository = new CoExpRepository(_hostingEnvironment);
            string          response   = repository.GetModuleTOMGenes(coexpdata);

            return(response);
        }
示例#3
0
        public string GetAvailableNetworks([FromQuery] CoexpParams coexpdata)
        {
            CoExpRepository repository = new CoExpRepository(_hostingEnvironment);
            string          response   = repository.GetAvailableNetworks(coexpdata);

            return(response);
        }
示例#4
0
        public string GetCellTypeFromTissue([FromQuery] CoexpParams coexpdata)
        {
            CoExpRepository repository = new CoExpRepository(_hostingEnvironment);
            string          response   = repository.GetCellTypeFromTissue(coexpdata);

            response = response.Replace("_row", "Cell Type");

            return(response);
        }
示例#5
0
        public string PostGetModuleTOMGraph([FromBody] CoexpParams coexpdata)
        {
            /////////////////////////////////////////////////
            // 2. If, at least one gene has been found, we make a request to CoExp R
            /////////////////////////////////////////////////
            CoExpRepository repository = new CoExpRepository(_hostingEnvironment);
            string          response   = repository.GetModuleTOMGraph(coexpdata);

            return(response);
        }
示例#6
0
 public IActionResult Annotated(CoexpParams coexpParams)
 {
     try
     {
         return(View(coexpParams));
     }
     catch (Exception e)
     {
         ErrorViewModel errorModel = new ErrorViewModel()
         {
             Message = e.Message
         };
         return(View("Error", errorModel));
     }
 }
示例#7
0
        public string PostReportOnGenesMultipleTissue([FromBody] CoexpParams coexpdata)
        {
            //category = which.one
            //network = tissue
            CoExpRepository repository = new CoExpRepository(_hostingEnvironment);
            string          response   = repository.ReportOnGenesMultipleTissue(coexpdata);

            string parsed_response = response.Replace("go.report", "go_report");

            parsed_response = parsed_response.Replace("pd.genes", "pd_genes");
            parsed_response = parsed_response.Replace("cell.type.pred", "cell_type_pred");
            //parsed_response = parsed_response.Replace("p.val.mods", "p_val_mods");
            parsed_response = parsed_response.Replace("tissue", "network");


            return(parsed_response);
        }
        /// <summary>
        /// Method to obtain data from 'getAvailableNetworks' API method. This method makes a GET request.
        /// </summary>
        /// <param name="coexpdata">Data to be sent to 'getAvailableNetworks' CoExp API method</param>
        /// <returns>Response received from 'getAvailableNetworks' CoExp API method</returns>
        public string GetAvailableNetworks(CoexpParams coexpdata)
        {
            //Set the URL with parameters. This URL will allow us to establish a communication with
            //CoExp R application API (published using Plumber R package)
            if (coexpURL == ProductionEnv)
            {
                coexpURL += "GetAvailableNetworks";
            }
            else
            {
                coexpURL += "getAvailableNetworks";
            }

            PostData = "{\"category\":\"" + coexpdata.Category + "\"}";

            //Make the request
            var finalResponse = _adapter.POSTHttpRequestJSON(coexpURL, PostData);

            //Return the response
            return(finalResponse);
        }
        public string GetModuleTOMGraph(CoexpParams coexpdata)
        {
            if (coexpURL == ProductionEnv)
            {
                coexpURL += "GetModuleTOMGraph";
                PostData  = "{\"network\":\"" + coexpdata.Network +
                            "\",\"category\":\"" + coexpdata.Category +
                            "\",\"module\":\"" + coexpdata.ModuleColor + "\",\"topgenes\":\"" + coexpdata.TopGenes + "\"}";
            }
            else
            {
                coexpURL += "getModuleTOMGraph";
                PostData  = "{\"tissue\":\"" + coexpdata.Network +
                            "\",\"which.one\":\"" + coexpdata.Category +
                            "\",\"module\":\"" + coexpdata.ModuleColor + "\",\"topgenes\":\"" + coexpdata.TopGenes + "\"}";
            }

            //Make the request
            var finalResponse = _adapter.POSTHttpRequestJSON(coexpURL, PostData);

            return(finalResponse.ToString());
        }
示例#10
0
        public string GetGOFromTissue([FromQuery] CoexpParams coexpdata)
        {
            //category = which.one
            //network = tissue
            CoExpRepository repository = new CoExpRepository(_hostingEnvironment);
            string          response   = repository.GetGOFromTissue(coexpdata);

            //REPLACE CHARACTERS
            string parsed_response = response.Replace("query.number", "query_number");

            parsed_response = parsed_response.Replace("p.value", "p_value");
            parsed_response = parsed_response.Replace("term.size", "term_size");
            parsed_response = parsed_response.Replace("query.size", "query_size");
            parsed_response = parsed_response.Replace("overlap.size", "overlap_size");
            parsed_response = parsed_response.Replace("term.id", "term_id");
            parsed_response = parsed_response.Replace("subgraph.number", "subgraph_number");
            parsed_response = parsed_response.Replace("term.name", "term_name");
            parsed_response = parsed_response.Replace("relative.depth", "relative_depth");
            parsed_response = parsed_response.Replace(",", ", ");

            return(parsed_response);
        }
示例#11
0
        public string GlobalReportOnGenes(CoexpParams coexpdata)
        {
            //Declare initial variables
            string categoriesLabel = string.Empty;
            string localCategory;
            string networks = string.Empty;
            string localNetworks;
            string finalResponse;

            string[] categoryData;

            //Remove parenthesis
            coexpdata.MultipleSelectionData = coexpdata.MultipleSelectionData.Replace("{", "");
            coexpdata.MultipleSelectionData = coexpdata.MultipleSelectionData.Replace("}", "");

            var categories = (coexpdata.MultipleSelectionData).Split("**");

            foreach (var category in categories)
            {
                if (category != String.Empty)
                {
                    categoryData  = category.Split("|");
                    localCategory = categoryData[0];
                    if (categoriesLabel.Length == 0)
                    {
                        categoriesLabel = categoryData[0];
                    }
                    else
                    {
                        categoriesLabel = categoriesLabel + "," + categoryData[0];
                    }

                    if (categoryData[1].Substring(categoryData[1].Length - 1, 1) == (","))
                    {
                        localNetworks = categoryData[1].Remove(categoryData[1].Length - 2);
                        if (networks.Length > 0)
                        {
                            networks = networks + "," + categoryData[1].Remove(categoryData[1].Length - 2);
                        }
                        else
                        {
                            networks = categoryData[1].Remove(categoryData[1].Length - 2);
                        }
                    }
                    else
                    {
                        localNetworks = categoryData[1];
                        if (networks.Length > 0)
                        {
                            networks = networks + "," + categoryData[1];
                        }
                        else
                        {
                            networks = categoryData[1];
                        }
                    }
                    if (localNetworks.Split(",").Length > 1)
                    {
                        for (var i = 0; i < localNetworks.Split(",").Length - 1; i++)
                        {
                            categoriesLabel = categoriesLabel + "," + localCategory;
                        }
                    }
                }
            }


            if (coexpURL == ProductionEnv)
            {
                coexpURL += "GlobalReportOnGenes";
                PostData  = "{\"categories\":\"" + categoriesLabel + "\",\"networks\":\"" + networks + "\",\"genes\":\"" + coexpdata.Genes + "\"}";
            }
            else
            {
                coexpURL += "globalReportOnGenes";
                PostData  = "{\"categories\":\"" + categoriesLabel + "\",\"tissues\":\"" + networks + "\",\"genes\":\"" + coexpdata.Genes + "\"}";
            }

            //Make the request
            finalResponse = _adapter.POSTHttpRequestJSON(coexpURL, PostData);

            return(finalResponse);
        }
示例#12
0
        /**************************************************************/
        /********************* POST METHODS ***************************/
        /**************************************************************/

        public string ReportOnGenesMultipleTissue(CoexpParams coexpdata)
        {
            //Set the URL with parameters. This URL will allow us to establish a communication with
            //CoExp R application API (published using Plumber R package)
            var finalResponse = string.Empty;
            //"**CoExpROSMAP**probad,ad,**gtexv6**AntCingCortex"
            var           categories        = (coexpdata.MultipleSelectionData).Split("**,");
            List <JArray> responses         = new List <JArray>();
            JArray        finalJSONresponse = new JArray();
            string        localResponse;

            foreach (var category in categories)
            {
                if (category != String.Empty)
                {
                    var categoryData  = category.Split("|");
                    var categoryLabel = categoryData[0];
                    var networks      = string.Empty;
                    if (categoryData[1].Substring(categoryData[1].Length - 1, 1) == (","))
                    {
                        networks = categoryData[1].Remove(categoryData[1].Length - 2);
                    }
                    else
                    {
                        networks = categoryData[1];
                    }

                    if (networks.Contains("**"))
                    {
                        networks = networks.Remove(networks.Length - 2);
                    }


                    if (coexpURL == ProductionEnv)
                    {
                        coexpURL += "ReportOnGenesMultipleTissue";
                        PostData  = "{\"networks\":\"" + networks + "\",\"category\":\"" + categoryLabel + "\",\"genes\":\"" + coexpdata.Genes + "\"}";
                    }
                    else
                    {
                        coexpURL += "reportOnGenesMultipleTissue";
                        PostData  = "{\"tissues\":\"" + networks + "\",\"which.one\":\"" + categoryLabel + "\",\"genes\":\"" + coexpdata.Genes + "\"}";
                    }

                    //Make the request
                    localResponse = _adapter.POSTHttpRequestJSON(coexpURL, PostData);

                    if (!localResponse.Contains("error"))
                    {
                        JObject item = JObject.Parse(localResponse);
                        responses.Add((JArray)item.SelectToken("report"));
                    }
                    else
                    {
                        finalResponse = localResponse;
                        break;
                    }
                }
            }
            //finalJSONresponse = responses[0];
            if (finalResponse == string.Empty)
            {
                foreach (JArray response in responses)
                {
                    foreach (var e in response)
                    {
                        finalJSONresponse.Add(e);
                    }
                }

                return(finalJSONresponse.ToString());
            }
            else
            {
                //Return the response
                return(finalResponse);
            }
        }
示例#13
0
        public string PostGlobalReportOnGenes([FromBody] CoexpParams coexpdata)
        {
            string parsed_response;

            //////////////////////////////////////////////
            //// 1. First, we check all typed genes
            //////////////////////////////////////////////
            //var provider = new PhysicalFileProvider(_hostingEnvironment.WebRootPath);
            //var genesfileInfo = provider.GetFileInfo("data/genes.txt");

            ////Read all ensembl genes from a .csv file.
            //string csvData = System.IO.File.ReadAllText(genesfileInfo.PhysicalPath);

            ////Convert both ensembl and typed genes into two different lists
            //IEnumerable<string> genes;
            //IEnumerable<string> ensembleData = csvData.Split("\r\n");
            //ensembleData = String.Join(',',ensembleData).Split(',');
            //if (coexpdata.Genes.Contains(", ")){
            //    genes = coexpdata.Genes.Split(", ");
            //}
            //else if (coexpdata.Genes.Contains(",")){
            //    genes = coexpdata.Genes.Split(",");
            //}
            //else{
            //    genes = coexpdata.Genes.Split(" ");
            //}

            ////Using LINQ we check whether the genes typed exist
            //if(genes.Any(x => ensembleData.Contains(x))) {

            //    IEnumerable<string> genesFound = genes.Where(p => ensembleData.Any(l => p == l)).ToList();
            //    IEnumerable<string> genesNotFound = genes.Where(p => !genesFound.Any(p2 => p == p2)).ToList();

            //    if (genesNotFound.Count() > 0)
            //    {
            //        parsed_response = String.Format("The following {0} genes from your list have not been found on Ensembl: {1}.\n\nWould you like to continue the request?",
            //            genesNotFound.Count(),
            //            String.Join(",", genesNotFound));

            //        //parsed_response = "[{\"message\":\""+ parsed_response + "\",\"genes\":\""+ String.Join(',', genesFound)+ "\"}]";
            //        parsed_response = JsonConvert.SerializeObject(new
            //        {
            //            message = parsed_response,
            //            genes = String.Join(",", genesFound),
            //            multipleData = coexpdata.MultipleSelectionData
            //        });
            //    }
            //    else
            //    {
            /////////////////////////////////////////////////
            // 2. If, at least one gene has been found, we make a request to CoExp R
            /////////////////////////////////////////////////
            CoExpRepository repository = new CoExpRepository(_hostingEnvironment);
            string          response   = repository.GlobalReportOnGenes(coexpdata);

            parsed_response = response.Replace("go.report", "go_report");
            parsed_response = parsed_response.Replace("pd.genes", "pd_genes");
            parsed_response = parsed_response.Replace("cell.type.pred", "cell_type_pred");
            //parsed_response = parsed_response.Replace("p.val.mods", "p_val_mods");
            parsed_response = parsed_response.Replace("tissue", "network");
            //    }
            //}else
            //{
            //    parsed_response = "Please, check your gene list. None of your genes has been found on Ensembl.";
            //}

            return(parsed_response);
        }
示例#14
0
        public string GetTreeMenuData()
        {
            try
            {
                dynamic             jsonCategories = JsonConvert.DeserializeObject(GetNetworkCategories());
                List <TreeMenuNode> nodes          = new List <TreeMenuNode>();
                //List<Network> networks = new List<Network>();
                int categoryID = 1;
                int networkID  = 100;

                TreeMenuNode all = new TreeMenuNode()
                {
                    id   = "0",
                    name = "All",
                    pid  = string.Empty
                };
                nodes.Add(all);

                foreach (var categoryName in jsonCategories)
                {
                    TreeMenuNode category = new TreeMenuNode()
                    {
                        name  = categoryName,
                        id    = categoryID.ToString(),
                        pid   = "0",
                        label = categoryName
                    };
                    nodes.Add(category);

                    CoexpParams coexpParams = new CoexpParams()
                    {
                        Category = category.name
                    };


                    dynamic jsonNetworks = JsonConvert.DeserializeObject(GetAvailableNetworks(coexpParams));
                    foreach (var networkName in jsonNetworks)
                    {
                        TreeMenuNode network = new TreeMenuNode()
                        {
                            name  = networkName,
                            id    = networkID.ToString(),
                            pid   = categoryID.ToString(),
                            label = categoryName
                        };

                        nodes.Add(network);
                        networkID++;
                    }



                    categoryID++;
                    networkID = 100;
                }
                var jsonAllData = JsonConvert.SerializeObject(nodes);
                return(jsonAllData);
            }
            catch (Exception ex)
            {
                return("Problems with web service connection. " + ex.Message);
            }
        }