示例#1
0
 public override bool Equals(object obj)
 {
     if (this == obj)
     {
         return(true);
     }
     if (obj is AminoAcid)
     {
         AminoAcid other = (AminoAcid)obj;
         return(other.letter == letter);
     }
     return(false);
 }
示例#2
0
 public LabelCombinations(SilacLabel[] labelsLow, SilacLabel[] labelsHigh, int maxNum, char[] allAaLetts)
 {
     AminoAcid[] aasHigh           = new AminoAcid[labelsHigh.Length];
     char[]      aaLettsHigh       = new char[labelsHigh.Length];
     Molecule[]  labelingDiff1High = new Molecule[labelsHigh.Length];
     Molecule[]  labelingDiff2High = new Molecule[labelsHigh.Length];
     for (int i = 0; i < labelsHigh.Length; i++)
     {
         aasHigh[i]           = AminoAcid.GetAminoAcidFromLabel(labelsHigh[i]);
         aaLettsHigh[i]       = aasHigh[i].Letter;
         labelingDiff1High[i] = aasHigh[i].GetLabelingDiff1(labelsHigh[i]);
         labelingDiff2High[i] = aasHigh[i].GetLabelingDiff2(labelsHigh[i]);
     }
     AminoAcid[] aasLow           = new AminoAcid[labelsLow.Length];
     char[]      aaLettsLow       = new char[labelsLow.Length];
     Molecule[]  labelingDiff1Low = new Molecule[labelsLow.Length];
     Molecule[]  labelingDiff2Low = new Molecule[labelsLow.Length];
     for (int i = 0; i < labelsLow.Length; i++)
     {
         aasLow[i]           = AminoAcid.GetAminoAcidFromLabel(labelsLow[i]);
         aaLettsLow[i]       = aasLow[i].Letter;
         labelingDiff1Low[i] = aasLow[i].GetLabelingDiff1(labelsLow[i]);
         labelingDiff2Low[i] = aasLow[i].GetLabelingDiff2(labelsLow[i]);
     }
     int[] indLow  = new int[allAaLetts.Length];
     int[] indHigh = new int[allAaLetts.Length];
     for (int i = 0; i < allAaLetts.Length; i++)
     {
         indLow[i]  = ArrayUtil.IndexOf(aaLettsLow, allAaLetts[i]);
         indHigh[i] = ArrayUtil.IndexOf(aaLettsHigh, allAaLetts[i]);
     }
     labelingDiff1 = new Molecule[allAaLetts.Length];
     labelingDiff2 = new Molecule[allAaLetts.Length];
     for (int i = 0; i < allAaLetts.Length; i++)
     {
         if (indLow[i] >= 0 && indHigh[i] >= 0)
         {
             labelingDiff1[i] = Molecule.Sum(labelingDiff2Low[indLow[i]], labelingDiff1High[indHigh[i]]);
             labelingDiff2[i] = Molecule.Sum(labelingDiff1Low[indLow[i]], labelingDiff2High[indHigh[i]]);
             Molecule[] w = Molecule.GetDifferences(labelingDiff1[i], labelingDiff2[i]);
             labelingDiff1[i] = w[0];
             labelingDiff2[i] = w[1];
         }
         else if (indLow[i] >= 0 && indHigh[i] < 0)
         {
             labelingDiff1[i] = labelingDiff2Low[indLow[i]];
             labelingDiff2[i] = labelingDiff1Low[indLow[i]];
         }
         else if (indLow[i] < 0 && indHigh[i] >= 0)
         {
             labelingDiff1[i] = labelingDiff1High[indHigh[i]];
             labelingDiff2[i] = labelingDiff2High[indHigh[i]];
         }
         else
         {
             throw new Exception("Should not happen.");
         }
     }
     partitions    = GetPartitions(maxNum, allAaLetts.Length);
     isotopeDistr1 = new double[partitions.Length][][];
     isotopeDistr2 = new double[partitions.Length][][];
     for (int i = 0; i < partitions.Length; i++)
     {
         isotopeDistr1[i] = CalcDiff1(partitions[i]).GetIsotopeDistribution(0.2);
         isotopeDistr2[i] = CalcDiff2(partitions[i]).GetIsotopeDistribution(0.2);
     }
     maxMassDiff = 0;
     for (int i = 0; i < allAaLetts.Length; i++)
     {
         double diff = Math.Abs(labelingDiff1[i].GetMostLikelyMass(0.2) -
                                labelingDiff2[i].GetMostLikelyMass(0.2));
         if (diff > maxMassDiff)
         {
             maxMassDiff = diff;
         }
     }
     maxMassDiff *= maxNum;
 }