Skip to content

Commit

Permalink
Merge pull request #7 from nbollis/PsmBulkAddition
Browse files Browse the repository at this point in the history
Psm bulk addition
  • Loading branch information
nbollis authored Dec 5, 2023
2 parents da69a3c + cc5da43 commit d3ab48f
Show file tree
Hide file tree
Showing 10 changed files with 629 additions and 10 deletions.
42 changes: 39 additions & 3 deletions MetaPAL/Controllers/SpectrumMatchesController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@
using Microsoft.AspNetCore.Mvc.Rendering;
using Microsoft.EntityFrameworkCore;
using MetaPAL.Data;
using MetaPAL.DataOperations;
using MetaPAL.Models;
using Microsoft.AspNetCore.Authorization;
using Readers;

namespace MetaPAL.Controllers
{
Expand All @@ -23,11 +25,45 @@ public SpectrumMatchesController(ApplicationDbContext context)
// GET: SpectrumMatches
public async Task<IActionResult> Index()
{
return _context.SpectrumMatch != null ?
View(await _context.SpectrumMatch.ToListAsync()) :
Problem("Entity set 'ApplicationDbContext.SpectrumMatch' is null.");
// TEMPORARY: remove all spectrum matches from database
//await Task.Run(() => DataOperations.DataOperations.RemoveAll<SpectrumMatch>(_context));

if (_context.SpectrumMatch == null)
return Problem("Entity set 'ApplicationDbContext.SpectrumMatch' is null.");
return View(await _context.SpectrumMatch.ToListAsync());
}

// GET: UploadSpectralMatchesForm
public async Task<IActionResult> UploadSpectralMatchesForm()

Check warning on line 37 in MetaPAL/Controllers/SpectrumMatchesController.cs

View workflow job for this annotation

GitHub Actions / build

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.

Check warning on line 37 in MetaPAL/Controllers/SpectrumMatchesController.cs

View workflow job for this annotation

GitHub Actions / build

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.
{
return _context.SpectrumMatch != null ?
View() :
Problem("Entity set 'ApplicationDbContext.SpectrumMatch' is null.");
}

// GET: UploadSpectrumMatches
public async Task<IActionResult> UploadSpectralMatches(string PsmPath)
{
if (_context.SpectrumMatch == null)
return Problem("Entity set 'ApplicationDbContext.SpectrumMatch' is null.");
try
{
foreach (var psm in SpectrumMatchTsvReader.ReadTsv(PsmPath, out _))
{
_context.Add(SpectrumMatch.FromSpectrumMatchTsv(psm));
}

await _context.SaveChangesAsync();
}
catch (Exception e)
{
return Problem(e.Message);
}

return RedirectToAction(nameof(Index));
}


// GET: ShowSearchForm
public async Task<IActionResult> ShowSearchForm()

Check warning on line 68 in MetaPAL/Controllers/SpectrumMatchesController.cs

View workflow job for this annotation

GitHub Actions / build

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.

Check warning on line 68 in MetaPAL/Controllers/SpectrumMatchesController.cs

View workflow job for this annotation

GitHub Actions / build

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.
{
Expand Down
14 changes: 14 additions & 0 deletions MetaPAL/Data/ApplicationDbContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,20 @@ protected override void OnModelCreating(ModelBuilder builder)
.Ignore("ChildScanMatchedIons");
builder.Entity<SpectrumMatch>()
.Ignore("VariantCrossingIons");
builder.Entity<SpectrumMatch>()
.Property(p => p.IdentifiedSequenceVariations)
.IsRequired(false);
builder.Entity<SpectrumMatch>()
.Property(p => p.IntersectingSequenceVariations)
.IsRequired(false);
builder.Entity<SpectrumMatch>()
.Property(p => p.PEP)
.HasConversion(v => double.IsNaN(v) ? -1 : v,
v => v);
builder.Entity<SpectrumMatch>()
.Property(p => p.PEP_QValue)
.HasConversion(v => double.IsNaN(v) ? -1 : v,
v => v);

base.OnModelCreating(builder);
}
Expand Down
Loading

0 comments on commit d3ab48f

Please sign in to comment.