diff --git a/MetaPAL.sln b/MetaPAL.sln index ca71528..1fb6148 100644 --- a/MetaPAL.sln +++ b/MetaPAL.sln @@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 17 VisualStudioVersion = 17.6.33712.159 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MetaPAL", "MetaPAL\MetaPAL.csproj", "{FC18E2D7-18AD-4174-8C2A-6AF4B36F73ED}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MetaPAL", "MetaPAL\MetaPAL.csproj", "{FC18E2D7-18AD-4174-8C2A-6AF4B36F73ED}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution diff --git a/MetaPAL/Models/PsiMsTypes.cs b/MetaPAL/ControlledVocabulary/PsiMsTypes.cs similarity index 97% rename from MetaPAL/Models/PsiMsTypes.cs rename to MetaPAL/ControlledVocabulary/PsiMsTypes.cs index 938105d..1fd810d 100644 --- a/MetaPAL/Models/PsiMsTypes.cs +++ b/MetaPAL/ControlledVocabulary/PsiMsTypes.cs @@ -1,7 +1,7 @@ using ThermoFisher.CommonCore.Data.Business; using MassSpectrometry; -namespace MetaPAL.Models +namespace MetaPAL.ControlledVocabulary { public static class PsiMsTypes { @@ -156,14 +156,14 @@ public enum MassAnalyzerType Unknown } - /// - /// Convert mzLib's DissociationType to DissociationMethodType. Most dissociation methods map to a PSI term. - /// DissociationTypes Unknown, AnyActivationType, Custom, and Autodetect are converted to DissociationMethodType.Unknown. - /// Null value in = null value out - /// - public static DissociationMethodType? ToDissociationMethodType(this DissociationType? type) + /// + /// Convert mzLib's DissociationType to DissociationMethodType. Most dissociation methods map to a PSI term. + /// DissociationTypes Unknown, AnyActivationType, Custom, and Autodetect are converted to DissociationMethodType.Unknown. + /// Null value in = null value out + /// + public static DissociationMethodType? ToDissociationMethodType(this DissociationType? type) { - switch(type) + switch (type) { case DissociationType.CID: return DissociationMethodType.CollisionInducedDissociation; diff --git a/MetaPAL/Data/ApplicationDbContext.cs b/MetaPAL/Data/ApplicationDbContext.cs index 63c83a8..6382787 100644 --- a/MetaPAL/Data/ApplicationDbContext.cs +++ b/MetaPAL/Data/ApplicationDbContext.cs @@ -18,5 +18,7 @@ protected override void OnModelCreating(ModelBuilder builder) } public DbSet? SpectrumMatch { get; set; } + + public DbSet? MsDataScans { get; set; } } } \ No newline at end of file diff --git a/MetaPAL/Data/Migrations/20240104160959_BuildMsDataScanTable.Designer.cs b/MetaPAL/Data/Migrations/20240104160959_BuildMsDataScanTable.Designer.cs new file mode 100644 index 0000000..d0e5b86 --- /dev/null +++ b/MetaPAL/Data/Migrations/20240104160959_BuildMsDataScanTable.Designer.cs @@ -0,0 +1,496 @@ +// +using System; +using MetaPAL.Data; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace MetaPAL.Data.Migrations +{ + [DbContext(typeof(ApplicationDbContext))] + [Migration("20240104160959_BuildMsDataScanTable")] + partial class BuildMsDataScanTable + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "6.0.23") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1); + + modelBuilder.Entity("MetaPAL.Models.MsDataScanModel", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("DissociationMethod") + .HasColumnType("int"); + + b.Property("ExperimentalPrecursorMonoisotopicMz") + .HasColumnType("real"); + + b.Property("FilterString") + .HasColumnType("nvarchar(max)"); + + b.Property("IonInjectionTime") + .HasColumnType("real"); + + b.Property("IsolationWindowLowerOffset") + .HasColumnType("real"); + + b.Property("IsolationWindowTargetMz") + .HasColumnType("real"); + + b.Property("IsolationWindowUpperOffset") + .HasColumnType("real"); + + b.Property("MassAnalyzerType") + .HasColumnType("int"); + + b.Property("MassSpectrumType") + .HasColumnType("int"); + + b.Property("MsLevel") + .HasColumnType("int"); + + b.Property("NativeId") + .HasColumnType("nvarchar(max)"); + + b.Property("NormalizedCollisionEnergy") + .HasColumnType("real"); + + b.Property("PrecursorScanNumber") + .HasColumnType("int"); + + b.Property("ScanNumber") + .HasColumnType("int"); + + b.Property("ScanPolarity") + .HasColumnType("int"); + + b.Property("ScanStartTime") + .HasColumnType("real"); + + b.Property("ScanWindowLowerLimit") + .HasColumnType("real"); + + b.Property("ScanWindowUpperLimit") + .HasColumnType("real"); + + b.Property("SelectedIonChargeStateGuess") + .HasColumnType("int"); + + b.Property("SelectedIonIntensity") + .HasColumnType("real"); + + b.Property("SelectedIonMz") + .HasColumnType("real"); + + b.Property("SpectrumRepresentation") + .HasColumnType("int"); + + b.Property("TotalIonCurrent") + .HasColumnType("real"); + + b.HasKey("Id"); + + b.ToTable("MsDataScans"); + }); + + modelBuilder.Entity("MetaPAL.Models.SpectrumMatch", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Accession") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("AmbiguityLevel") + .HasColumnType("nvarchar(max)"); + + b.Property("BaseSequence") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("DecoyContamTarget") + .HasColumnType("nvarchar(max)"); + + b.Property("DeltaScore") + .HasColumnType("float"); + + b.Property("Description") + .HasColumnType("nvarchar(max)"); + + b.Property("EssentialSequence") + .HasColumnType("nvarchar(max)"); + + b.Property("FileNameWithoutExtension") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("FullSequence") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("GeneName") + .HasColumnType("nvarchar(max)"); + + b.Property("IdentifiedSequenceVariations") + .HasColumnType("nvarchar(max)"); + + b.Property("IntersectingSequenceVariations") + .HasColumnType("nvarchar(max)"); + + b.Property("MassDiffDa") + .HasColumnType("float"); + + b.Property("MassDiffPpm") + .HasColumnType("float"); + + b.Property("MatchedFragmentIons") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("MissedCleavage") + .HasColumnType("int"); + + b.Property("MonoisotopicMass") + .HasColumnType("float"); + + b.Property("Ms2ScanNumber") + .HasColumnType("int"); + + b.Property("Name") + .HasColumnType("nvarchar(max)"); + + b.Property("NextResidue") + .HasColumnType("nvarchar(max)"); + + b.Property("Notch") + .HasColumnType("nvarchar(max)"); + + b.Property("OrganismName") + .HasColumnType("nvarchar(max)"); + + b.Property("PEP") + .HasColumnType("float"); + + b.Property("PEP_QValue") + .HasColumnType("float"); + + b.Property("PrecursorCharge") + .HasColumnType("float"); + + b.Property("PrecursorMass") + .HasColumnType("float"); + + b.Property("PrecursorMz") + .HasColumnType("float"); + + b.Property("PrecursorScanNumber") + .HasColumnType("int"); + + b.Property("PreviousResidue") + .HasColumnType("nvarchar(max)"); + + b.Property("QValue") + .HasColumnType("float"); + + b.Property("QValueNotch") + .HasColumnType("float"); + + b.Property("RetentionTime") + .HasColumnType("float"); + + b.Property("Score") + .HasColumnType("float"); + + b.Property("SpectralAngle") + .HasColumnType("float"); + + b.Property("SpectrumMatchCount") + .HasColumnType("float"); + + b.Property("SpliceSites") + .HasColumnType("nvarchar(max)"); + + b.Property("StartAndEndResiduesInParentSequence") + .HasColumnType("nvarchar(max)"); + + b.Property("TotalIonCurrent") + .HasColumnType("float"); + + b.HasKey("Id"); + + b.ToTable("SpectrumMatch"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b => + { + b.Property("Id") + .HasColumnType("nvarchar(450)"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.Property("NormalizedName") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.HasKey("Id"); + + b.HasIndex("NormalizedName") + .IsUnique() + .HasDatabaseName("RoleNameIndex") + .HasFilter("[NormalizedName] IS NOT NULL"); + + b.ToTable("AspNetRoles", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("ClaimType") + .HasColumnType("nvarchar(max)"); + + b.Property("ClaimValue") + .HasColumnType("nvarchar(max)"); + + b.Property("RoleId") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.HasKey("Id"); + + b.HasIndex("RoleId"); + + b.ToTable("AspNetRoleClaims", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUser", b => + { + b.Property("Id") + .HasColumnType("nvarchar(450)"); + + b.Property("AccessFailedCount") + .HasColumnType("int"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasColumnType("nvarchar(max)"); + + b.Property("Email") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.Property("EmailConfirmed") + .HasColumnType("bit"); + + b.Property("LockoutEnabled") + .HasColumnType("bit"); + + b.Property("LockoutEnd") + .HasColumnType("datetimeoffset"); + + b.Property("NormalizedEmail") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.Property("NormalizedUserName") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.Property("PasswordHash") + .HasColumnType("nvarchar(max)"); + + b.Property("PhoneNumber") + .HasColumnType("nvarchar(max)"); + + b.Property("PhoneNumberConfirmed") + .HasColumnType("bit"); + + b.Property("SecurityStamp") + .HasColumnType("nvarchar(max)"); + + b.Property("TwoFactorEnabled") + .HasColumnType("bit"); + + b.Property("UserName") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.HasKey("Id"); + + b.HasIndex("NormalizedEmail") + .HasDatabaseName("EmailIndex"); + + b.HasIndex("NormalizedUserName") + .IsUnique() + .HasDatabaseName("UserNameIndex") + .HasFilter("[NormalizedUserName] IS NOT NULL"); + + b.ToTable("AspNetUsers", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("ClaimType") + .HasColumnType("nvarchar(max)"); + + b.Property("ClaimValue") + .HasColumnType("nvarchar(max)"); + + b.Property("UserId") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("AspNetUserClaims", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => + { + b.Property("LoginProvider") + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.Property("ProviderKey") + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.Property("ProviderDisplayName") + .HasColumnType("nvarchar(max)"); + + b.Property("UserId") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.HasKey("LoginProvider", "ProviderKey"); + + b.HasIndex("UserId"); + + b.ToTable("AspNetUserLogins", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => + { + b.Property("UserId") + .HasColumnType("nvarchar(450)"); + + b.Property("RoleId") + .HasColumnType("nvarchar(450)"); + + b.HasKey("UserId", "RoleId"); + + b.HasIndex("RoleId"); + + b.ToTable("AspNetUserRoles", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => + { + b.Property("UserId") + .HasColumnType("nvarchar(450)"); + + b.Property("LoginProvider") + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.Property("Name") + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.Property("Value") + .HasColumnType("nvarchar(max)"); + + b.HasKey("UserId", "LoginProvider", "Name"); + + b.ToTable("AspNetUserTokens", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => + { + b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null) + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => + { + b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => + { + b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => + { + b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null) + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => + { + b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/MetaPAL/Data/Migrations/20240104160959_BuildMsDataScanTable.cs b/MetaPAL/Data/Migrations/20240104160959_BuildMsDataScanTable.cs new file mode 100644 index 0000000..145a33b --- /dev/null +++ b/MetaPAL/Data/Migrations/20240104160959_BuildMsDataScanTable.cs @@ -0,0 +1,53 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace MetaPAL.Data.Migrations +{ + public partial class BuildMsDataScanTable : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "MsDataScans", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + ScanNumber = table.Column(type: "int", nullable: false), + SpectrumRepresentation = table.Column(type: "int", nullable: false), + MassSpectrumType = table.Column(type: "int", nullable: false), + MsLevel = table.Column(type: "int", nullable: false), + MassAnalyzerType = table.Column(type: "int", nullable: false), + ScanPolarity = table.Column(type: "int", nullable: false), + ScanStartTime = table.Column(type: "real", nullable: true), + ScanWindowUpperLimit = table.Column(type: "real", nullable: true), + ScanWindowLowerLimit = table.Column(type: "real", nullable: true), + FilterString = table.Column(type: "nvarchar(max)", nullable: true), + TotalIonCurrent = table.Column(type: "real", nullable: true), + IonInjectionTime = table.Column(type: "real", nullable: true), + PrecursorScanNumber = table.Column(type: "int", nullable: true), + SelectedIonMz = table.Column(type: "real", nullable: true), + ExperimentalPrecursorMonoisotopicMz = table.Column(type: "real", nullable: true), + IsolationWindowTargetMz = table.Column(type: "real", nullable: true), + IsolationWindowLowerOffset = table.Column(type: "real", nullable: true), + IsolationWindowUpperOffset = table.Column(type: "real", nullable: true), + DissociationMethod = table.Column(type: "int", nullable: true), + NormalizedCollisionEnergy = table.Column(type: "real", nullable: true), + SelectedIonChargeStateGuess = table.Column(type: "int", nullable: true), + SelectedIonIntensity = table.Column(type: "real", nullable: true), + NativeId = table.Column(type: "nvarchar(max)", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_MsDataScans", x => x.Id); + }); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "MsDataScans"); + } + } +} diff --git a/MetaPAL/Data/Migrations/ApplicationDbContextModelSnapshot.cs b/MetaPAL/Data/Migrations/ApplicationDbContextModelSnapshot.cs index c5213c3..c811b6b 100644 --- a/MetaPAL/Data/Migrations/ApplicationDbContextModelSnapshot.cs +++ b/MetaPAL/Data/Migrations/ApplicationDbContextModelSnapshot.cs @@ -22,6 +22,88 @@ protected override void BuildModel(ModelBuilder modelBuilder) SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1); + modelBuilder.Entity("MetaPAL.Models.MsDataScanModel", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("DissociationMethod") + .HasColumnType("int"); + + b.Property("ExperimentalPrecursorMonoisotopicMz") + .HasColumnType("real"); + + b.Property("FilterString") + .HasColumnType("nvarchar(max)"); + + b.Property("IonInjectionTime") + .HasColumnType("real"); + + b.Property("IsolationWindowLowerOffset") + .HasColumnType("real"); + + b.Property("IsolationWindowTargetMz") + .HasColumnType("real"); + + b.Property("IsolationWindowUpperOffset") + .HasColumnType("real"); + + b.Property("MassAnalyzerType") + .HasColumnType("int"); + + b.Property("MassSpectrumType") + .HasColumnType("int"); + + b.Property("MsLevel") + .HasColumnType("int"); + + b.Property("NativeId") + .HasColumnType("nvarchar(max)"); + + b.Property("NormalizedCollisionEnergy") + .HasColumnType("real"); + + b.Property("PrecursorScanNumber") + .HasColumnType("int"); + + b.Property("ScanNumber") + .HasColumnType("int"); + + b.Property("ScanPolarity") + .HasColumnType("int"); + + b.Property("ScanStartTime") + .HasColumnType("real"); + + b.Property("ScanWindowLowerLimit") + .HasColumnType("real"); + + b.Property("ScanWindowUpperLimit") + .HasColumnType("real"); + + b.Property("SelectedIonChargeStateGuess") + .HasColumnType("int"); + + b.Property("SelectedIonIntensity") + .HasColumnType("real"); + + b.Property("SelectedIonMz") + .HasColumnType("real"); + + b.Property("SpectrumRepresentation") + .HasColumnType("int"); + + b.Property("TotalIonCurrent") + .HasColumnType("real"); + + b.HasKey("Id"); + + b.ToTable("MsDataScans"); + }); + modelBuilder.Entity("MetaPAL.Models.SpectrumMatch", b => { b.Property("Id") diff --git a/MetaPAL/MetaPAL.csproj b/MetaPAL/MetaPAL.csproj index 1b58134..b960e05 100644 --- a/MetaPAL/MetaPAL.csproj +++ b/MetaPAL/MetaPAL.csproj @@ -1,4 +1,4 @@ - + net6.0 diff --git a/MetaPAL/Models/MsDataScanModel.cs b/MetaPAL/Models/MsDataScanModel.cs index 30e5049..cad0855 100644 --- a/MetaPAL/Models/MsDataScanModel.cs +++ b/MetaPAL/Models/MsDataScanModel.cs @@ -1,5 +1,6 @@ using MassSpectrometry; using MathNet.Numerics.RootFinding; +using MetaPAL.ControlledVocabulary; using Microsoft.CodeAnalysis; using MzLibUtil.NoiseEstimation; using System; @@ -7,11 +8,11 @@ using System.ComponentModel.DataAnnotations.Schema; using System.Reflection.Metadata; using ThermoFisher.CommonCore.Data.Business; -using static MetaPAL.Models.PsiMsTypes; +using static MetaPAL.ControlledVocabulary.PsiMsTypes; namespace MetaPAL.Models { - [Table("SpectrumMatch")] + [Table("MsDataScans")] public class MsDataScanModel { [Key] @@ -70,6 +71,8 @@ public class MsDataScanModel /// is_a: MS:1000524 ! data file content /// is_a: MS:1000559 ! spectrum type /// + // TODO: Figure out what to do here as object is not a valid type for a database column + [NotMapped] public Object? MassSpectrum { get; protected set; } /// /// id: MS:1000465 diff --git a/MetaPAL/Models/SpectrumMatch.cs b/MetaPAL/Models/SpectrumMatch.cs index 1e428f0..a0106b4 100644 --- a/MetaPAL/Models/SpectrumMatch.cs +++ b/MetaPAL/Models/SpectrumMatch.cs @@ -43,7 +43,6 @@ public class SpectrumMatch #endregion - #region Spectral Information // TODO: Turn into a foreign key to the datafile table