-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
1,034 additions
and
936 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using Chemistry; | ||
|
||
namespace Omics.Fragmentation | ||
{ | ||
public class Product : IHasMass | ||
{ | ||
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, | ||
int fragmentNumber, int residuePosition, double neutralLoss, ProductType? secondaryProductType = null, | ||
int secondaryFragmentNumber = 0) | ||
{ | ||
NeutralMass = neutralMass; | ||
ProductType = productType; | ||
NeutralLoss = neutralLoss; | ||
Terminus = terminus; | ||
FragmentNumber = fragmentNumber; | ||
ResiduePosition = residuePosition; | ||
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(); | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// Summarizes a Product into a string for debug purposes | ||
/// </summary> | ||
public override string ToString() | ||
{ | ||
if (SecondaryProductType == null) | ||
{ | ||
return ProductType + "" + FragmentNumber + ";" + NeutralMass.ToString("F5") + "-" + | ||
string.Format("{0:0.##}", NeutralLoss); | ||
} | ||
else | ||
{ | ||
return ProductType + "I" + SecondaryProductType.Value + "[" + FragmentNumber + "-" + | ||
SecondaryFragmentNumber + "]" + ";" + NeutralMass.ToString("F5") + "-" + | ||
string.Format("{0:0.##}", NeutralLoss); | ||
} | ||
} | ||
|
||
public override bool Equals(object obj) | ||
{ | ||
return obj is Product other && Equals(other); | ||
} | ||
|
||
public bool Equals(Product 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() | ||
{ | ||
return NeutralMass.GetHashCode(); | ||
} | ||
} | ||
} |
7 changes: 1 addition & 6 deletions
7
...mentation/TerminusSpecificProductTypes.cs → ...mentation/TerminusSpecificProductTypes.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.