Ejemplo n.º 1
0
        public async Task <IActionResult> PutGeneResult(int id, GeneResult geneResult)
        {
            if (id != geneResult.Id)
            {
                return(BadRequest());
            }

            _context.Entry(geneResult).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!GeneResultExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Ejemplo n.º 2
0
        public async Task <ActionResult <GeneResult> > PostGeneResult(GeneResult geneResult)
        {
            _context.GeneResults.Add(geneResult);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetGeneResult", new { id = geneResult.Id }, geneResult));
        }
 private void renderGeneData(ExcelPackage package)
 {
     var allData = _context.GeneResults.ToList();
     ExcelWorksheet workSheet = package.Workbook.Worksheets[1];
     if (workSheet == null) return;
     //var workSheet = package.Workbook.Worksheets.First();
     int totalRows = workSheet.Dimension.Rows;
     //var DataList = new List<Customers>();
     for (int i = 2; i <= totalRows; i++)
     {            
         {
             GeneResult geneResult = new GeneResult
             {
                 GeneName = workSheet.Cells[i, 1].Value.ToString(),
                 Result = Int32.Parse(workSheet.Cells[i, 2].Value.ToString()),
                 Text = workSheet.Cells[i, 3].Value.ToString(),
             };
             var entryToMod = allData.SingleOrDefault(i => i.GeneName == geneResult.GeneName && i.Result == geneResult.Result);
             if (entryToMod == null)
             {
                 _context.GeneResults.Add(geneResult);
             }
             else
             {
                 if (entryToMod.Text != geneResult.Text)
                 {
                     entryToMod.Text = geneResult.Text;
                     _context.Entry(entryToMod).State = EntityState.Modified;
                 }
             }
         }
     }
     _context.SaveChanges();
 }
Ejemplo n.º 4
0
        private void WriteMetadata(Excel.Worksheet worksheet, GeneResult result)
        {
            worksheet.Cells[1, 7] = "LogPValue";
            worksheet.Cells[2, 7] = -Math.Log10(result.Estimate.PValue);

            worksheet.Cells[1, 8] = "FDR";
            worksheet.Cells[2, 8] = result.FDR;

            worksheet.ListObjects.Add(Excel.XlListObjectSourceType.xlSrcRange, worksheet.Range["G1:H2"], Type.Missing, Excel.XlYesNoGuess.xlYes, Type.Missing);
        }
Ejemplo n.º 5
0
        private void WriteData(Excel.Worksheet worksheet, GeneResult result)
        {
            var groupAEvents = result.Estimate.GroupAEvents;
            var groupBEvents = result.Estimate.GroupBEvents;

            int currentTime = Math.Min(groupAEvents[0].Time, groupBEvents[0].Time);

            worksheet.Cells[2, 1] = (currentTime - 1).ToString();
            worksheet.Cells[2, 2] = "1";
            worksheet.Cells[2, 3] = "1";

            int iA = 0, iB = 0, currentRow = 3;

            while (iA < groupAEvents.Count && iB < groupBEvents.Count)
            {
                currentTime = Math.Min(groupAEvents[iA].Time, groupBEvents[iB].Time);
                int failingA = (groupAEvents[iA].Time == currentTime ? groupAEvents[iA].NumberFailing : 0);
                int failingB = (groupBEvents[iB].Time == currentTime ? groupBEvents[iB].NumberFailing : 0);

                if (failingA + failingB != 0)
                {
                    worksheet.Cells[currentRow, 1] = currentTime.ToString();
                    worksheet.Cells[currentRow, 2] = worksheet.Cells[currentRow - 1, 2];
                    worksheet.Cells[currentRow, 3] = worksheet.Cells[currentRow - 1, 3];
                    currentRow++;

                    worksheet.Cells[currentRow, 1] = currentTime.ToString();
                    worksheet.Cells[currentRow, 2] = failingA == 0 ? worksheet.Cells[currentRow - 1, 2] : groupAEvents[iA].SurvivalProbability;
                    worksheet.Cells[currentRow, 3] = failingB == 0 ? worksheet.Cells[currentRow - 1, 3] : groupBEvents[iB].SurvivalProbability;
                    currentRow++;
                }

                if (groupAEvents[iA].Time == currentTime)
                {
                    iA++;
                }

                if (groupBEvents[iB].Time == currentTime)
                {
                    iB++;
                }
            }

            while (iA < groupAEvents.Count)
            {
                currentTime = groupAEvents[iA].Time;
                int failingA = groupAEvents[iA].NumberFailing;

                if (failingA != 0)
                {
                    worksheet.Cells[currentRow, 1] = currentTime.ToString();
                    worksheet.Cells[currentRow, 2] = worksheet.Cells[currentRow - 1, 2];
                    worksheet.Cells[currentRow, 3] = worksheet.Cells[currentRow - 1, 3];
                    currentRow++;

                    worksheet.Cells[currentRow, 1] = currentTime.ToString();
                    worksheet.Cells[currentRow, 2] = groupAEvents[iA].SurvivalProbability;
                    worksheet.Cells[currentRow, 3] = worksheet.Cells[currentRow - 1, 3];
                    currentRow++;
                }

                iA++;
            }

            while (iB < groupBEvents.Count)
            {
                currentTime = groupBEvents[iB].Time;
                int failingB = groupBEvents[iB].NumberFailing;

                if (failingB != 0)
                {
                    worksheet.Cells[currentRow, 1] = currentTime.ToString();
                    worksheet.Cells[currentRow, 2] = worksheet.Cells[currentRow - 1, 2];
                    worksheet.Cells[currentRow, 3] = worksheet.Cells[currentRow - 1, 3];
                    currentRow++;

                    worksheet.Cells[currentRow, 1] = currentTime.ToString();
                    worksheet.Cells[currentRow, 2] = worksheet.Cells[currentRow - 1, 2];
                    worksheet.Cells[currentRow, 3] = groupBEvents[iB].SurvivalProbability;
                    currentRow++;
                }

                iB++;
            }

            worksheet.ListObjects.Add(Excel.XlListObjectSourceType.xlSrcRange, worksheet.UsedRange, Type.Missing, Excel.XlYesNoGuess.xlYes, Type.Missing);
        }