Skip to content

Commit

Permalink
good midpont
Browse files Browse the repository at this point in the history
  • Loading branch information
trishorts committed Nov 9, 2023
1 parent 8d88b32 commit df0f605
Show file tree
Hide file tree
Showing 19 changed files with 81 additions and 206 deletions.
37 changes: 34 additions & 3 deletions mzLib/Omics/Fragmentation/IProduct.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,51 @@
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Chemistry;

namespace Omics.Fragmentation
{
public interface IProduct
public interface IProduct : IHasMass, IEquatable<IProduct>
{
double NeutralMass { get; }
ProductType ProductType { get; }
double NeutralLoss { get; }
FragmentationTerminus Terminus { get; }
int FragmentNumber { get; }
int Position { get; }
int ResiduePosition { get; }
ProductType? SecondaryProductType { get; } //used for internal fragments
int SecondaryFragmentNumber { get; } //used for internal fragment ions
string Annotation { get; }
string Annotation => GetAnnotation();
string GetAnnotation()
{
StringBuilder sb = new StringBuilder();

if (SecondaryProductType == null)
{
sb.Append(ProductType);

// for "normal" fragments this is just the fragment number (e.g., the 3 in the b3 ion)
// for diagnostic ions, it's the m/z assuming z=1
// (e.g., a diagnostic ion with neutral mass 100 Da will be reported as the D101 fragment)
sb.Append(FragmentNumber);
}
else
{
//internal fragment ion, annotation used here: 10.1007/s13361-015-1078-1
//example: yIb[18-36]
sb.Append(ProductType + "I" + SecondaryProductType.Value + "[" + FragmentNumber + "-" + SecondaryFragmentNumber + "]");
}
if (NeutralLoss != 0)
{
sb.Append("-");
sb.Append(NeutralLoss.ToString("F2"));
}

return sb.ToString();

}

string ToString();
int GetHashCode();
}
}
1 change: 1 addition & 0 deletions mzLib/Omics/ISpectrumMatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using Omics.Fragmentation;

namespace Omics
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using MassSpectrometry;
using System.Collections.Generic;
using System.Linq;
using Omics.Fragmentation;

namespace Proteomics.Fragmentation
{
Expand Down
10 changes: 0 additions & 10 deletions mzLib/Proteomics/Fragmentation/FragmentationTerminus.cs

This file was deleted.

91 changes: 0 additions & 91 deletions mzLib/Proteomics/Fragmentation/MatchedFragmentIon.cs

This file was deleted.

85 changes: 31 additions & 54 deletions mzLib/Proteomics/Fragmentation/Product.cs
Original file line number Diff line number Diff line change
@@ -1,67 +1,41 @@
using System;
using System.Text;
using Omics.Fragmentation;

namespace Proteomics.Fragmentation
{
public struct Product
public class Product : IProduct
{
public readonly double NeutralMass;
public readonly ProductType ProductType;
public readonly double NeutralLoss;
public readonly FragmentationTerminus Terminus;
public readonly int FragmentNumber;
public readonly int AminoAcidPosition;
public readonly ProductType? SecondaryProductType; //used for internal fragment ions
public readonly int SecondaryFragmentNumber; //used for internal fragment ions
public double NeutralMass { get; }
public ProductType ProductType { get; }
public double NeutralLoss { get; }
public FragmentationTerminus Terminus { get; }
public int FragmentNumber { get; }
public int ResiduePosition { get; }
public int AminoAcidPosition => ResiduePosition;
public ProductType? SecondaryProductType { get; } //used for internal fragment ions
public int SecondaryFragmentNumber { get; } //used for internal fragment ions
public double MonoisotopicMass => NeutralMass;

/// <summary>
/// A product is the individual neutral fragment from an MS dissociation. A fragmentation product here contains one of the two termini (N- or C-).
/// The ProductType describes where along the backbone the fragmentaiton occurred (e.g. b-, y-, c-, zdot-). The neutral loss mass (if any) that
/// occurred from a mod on the fragment is listed as a mass. Finally the neutral mass of the whole fragment is provided.
/// </summary>
public Product(ProductType productType, FragmentationTerminus terminus, double neutralMass,
/// <summary>
/// A product is the individual neutral fragment from an MS dissociation. A fragmentation product here contains one of the two termini (N- or C-).
/// The ProductType describes where along the backbone the fragmentaiton occurred (e.g. b-, y-, c-, zdot-). The neutral loss mass (if any) that
/// occurred from a mod on the fragment is listed as a mass. Finally the neutral mass of the whole fragment is provided.
/// </summary>
public Product(ProductType productType, FragmentationTerminus terminus, double neutralMass,
int fragmentNumber, int aminoAcidPosition, double neutralLoss, ProductType? secondaryProductType = null, int secondaryFragmentNumber = 0)
{
NeutralMass = neutralMass;
ProductType = productType;
NeutralLoss = neutralLoss;
Terminus = terminus;
FragmentNumber = fragmentNumber;
AminoAcidPosition = aminoAcidPosition;
ResiduePosition = aminoAcidPosition;
SecondaryProductType = secondaryProductType;
SecondaryFragmentNumber = secondaryFragmentNumber;
}

public string Annotation
{
get
{
StringBuilder sb = new StringBuilder();

if (SecondaryProductType == null)
{
sb.Append(ProductType);

// for "normal" fragments this is just the fragment number (e.g., the 3 in the b3 ion)
// for diagnostic ions, it's the m/z assuming z=1
// (e.g., a diagnostic ion with neutral mass 100 Da will be reported as the D101 fragment)
sb.Append(FragmentNumber);
}
else
{
//internal fragment ion, annotation used here: 10.1007/s13361-015-1078-1
//example: yIb[18-36]
sb.Append(ProductType + "I" + SecondaryProductType.Value + "[" + FragmentNumber + "-" + SecondaryFragmentNumber + "]");
}
if (NeutralLoss != 0)
{
sb.Append("-");
sb.Append(NeutralLoss.ToString("F2"));
}

return sb.ToString();
}
}
public string Annotation => (this as IProduct).GetAnnotation();


/// <summary>
/// Summarizes a Product into a string for debug purposes
Expand All @@ -80,14 +54,17 @@ public override string ToString()

public override bool Equals(object obj)
{
Product other = (Product)obj;
return obj is Product other && Equals(other);
}

return this.ProductType == other.ProductType
&& this.NeutralMass == other.NeutralMass
&& this.FragmentNumber == other.FragmentNumber
&& this.NeutralLoss == other.NeutralLoss
&& this.SecondaryFragmentNumber == other.SecondaryFragmentNumber
&& this.SecondaryProductType == other.SecondaryProductType;
public bool Equals(IProduct product)
{
return this.ProductType.Equals(product.ProductType)
&& this.NeutralMass.Equals(product.NeutralMass)
&& this.FragmentNumber == product.FragmentNumber
&& this.NeutralLoss.Equals(product.NeutralLoss)
&& this.SecondaryFragmentNumber == product.SecondaryFragmentNumber
&& this.SecondaryProductType == product.SecondaryProductType;
}

public override int GetHashCode()
Expand Down
44 changes: 0 additions & 44 deletions mzLib/Proteomics/Fragmentation/ProductType.cs

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Text;
using Omics.Fragmentation;

namespace Proteomics.Fragmentation
{
Expand Down
2 changes: 1 addition & 1 deletion mzLib/Proteomics/PSM/LibrarySpectrum.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Easy.Common.Extensions;
using MassSpectrometry.MzSpectra;
using Proteomics.Fragmentation;
using Omics.Fragmentation;
using System;
using System.Collections.Generic;
using System.Linq;
Expand Down
1 change: 1 addition & 0 deletions mzLib/Proteomics/PSM/PsmFromTsv.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using Omics.Fragmentation;

namespace Proteomics.PSM
{
Expand Down
1 change: 1 addition & 0 deletions mzLib/Proteomics/Protein/Protein.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using Omics.Fragmentation;

namespace Proteomics
{
Expand Down
1 change: 1 addition & 0 deletions mzLib/Proteomics/ProteolyticDigestion/DigestionParams.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Proteomics.Fragmentation;
using System;
using Omics.Fragmentation;

namespace Proteomics.ProteolyticDigestion
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Omics.Fragmentation;

namespace Proteomics.ProteolyticDigestion
namespace Proteomics.ProteolyticDigestion
{
[Serializable]
public class PeptideWithSetModifications : ProteolyticPeptide
Expand Down
4 changes: 2 additions & 2 deletions mzLib/Proteomics/ProteolyticDigestion/ProductTypeMethods.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Proteomics.Fragmentation;
using System;
using System;
using System.Collections.Generic;
using Omics.Fragmentation;

namespace Proteomics.ProteolyticDigestion
{
Expand Down
Loading

0 comments on commit df0f605

Please sign in to comment.