public IonDefinitionItem(IsobaricType plexType, double mass) { this.PlexType = plexType; this.Mass = mass; this.Index = (int)(Math.Round(mass)); this.Name = "I" + Index.ToString(); }
public List <IsobaricIndex> GetSamples(IsobaricType sampleType) { var result = sampleType.GetFuncs(); result.RemoveAll(m => References.Any(n => n.Name.Equals(m.Name))); return(result); }
public ITraqResultMultipleFileDistiller(IITraqRawReader reader, string[] rawFiles, bool individual, int minPeakCount, IsobaricType plexType, string isotopeImpurityCorrectionTableFileName, IITraqNormalizationBuilder builder, double precursorPPMTolearnce) { this.reader = reader; this.rawFiles = rawFiles; this.individual = individual; this.minPeakCount = minPeakCount; this.plexType = plexType; this.isotopeImpurityCorrectionTableFileName = isotopeImpurityCorrectionTableFileName; this.builder = builder; this.precursorPPMTolearnce = precursorPPMTolearnce; }
private void CheckPlexType(IsobaricType plexType, string expectHeader, string expectValue) { var ann = new IdentifiedSpectrum(); var pqr = new IsobaricItem() { PlexType = plexType, Valid = true, ValidProbability = 0.0005 }; var refItems = plexType.GetDefinition().Items; foreach (var item in refItems) { pqr[item.Index] = item.Mass; } ann.SetIsobaricItem(pqr); //从实例构建converter var converter = new ITraqItemPlexConverter <IAnnotation>(); List <IPropertyConverter <IAnnotation> > converters = new List <IPropertyConverter <IAnnotation> >(); converters.Add(converter); converters.AddRange(converter.GetRelativeConverter(new IAnnotation[] { ann }.ToList())); CompositePropertyConverter <IAnnotation> finalConverter = new CompositePropertyConverter <IAnnotation>(converters, ','); if (exportToConsole) { Console.WriteLine(finalConverter.Name); } Assert.AreEqual(expectHeader, finalConverter.Name); var line1 = finalConverter.GetProperty(ann); if (exportToConsole) { Console.WriteLine(line1); } Assert.AreEqual(expectValue, line1); var protein2 = new IdentifiedSpectrum(); //从factory根据header构建converter var finalC = IdentifiedSpectrumPropertyConverterFactory.GetInstance().GetConverters(finalConverter.Name, ','); finalC.SetProperty(protein2, line1); var line2 = finalConverter.GetProperty(protein2); Assert.AreEqual(line1, line2); }
private void CheckPlexType(IsobaricType plexType, string expectHeader, string expectValue) { var ann = new IdentifiedSpectrum(); var pqr = new IsobaricItem() { PlexType = plexType, Valid = true, ValidProbability = 0.0005 }; var refItems = plexType.GetDefinition().Items; foreach (var item in refItems) { pqr[item.Index] = item.Mass; } ann.SetIsobaricItem(pqr); //从实例构建converter var converter = new ITraqItemPlexConverter<IAnnotation>(); List<IPropertyConverter<IAnnotation>> converters = new List<IPropertyConverter<IAnnotation>>(); converters.Add(converter); converters.AddRange(converter.GetRelativeConverter(new IAnnotation[] { ann }.ToList())); CompositePropertyConverter<IAnnotation> finalConverter = new CompositePropertyConverter<IAnnotation>(converters, ','); if (exportToConsole) { Console.WriteLine(finalConverter.Name); } Assert.AreEqual(expectHeader, finalConverter.Name); var line1 = finalConverter.GetProperty(ann); if (exportToConsole) { Console.WriteLine(line1); } Assert.AreEqual(expectValue, line1); var protein2 = new IdentifiedSpectrum(); //从factory根据header构建converter var finalC = IdentifiedSpectrumPropertyConverterFactory.GetInstance().GetConverters(finalConverter.Name, ','); finalC.SetProperty(protein2, line1); var line2 = finalConverter.GetProperty(protein2); Assert.AreEqual(line1, line2); }
//private static readonly IonDefinitionItem[] _TMTPlex10 = new IonDefinitionItem[]{ // new IonDefinitionItem(IsobaricType.TMT10,126.127726), // new IonDefinitionItem(IsobaricType.TMT10,127.124761), // new IonDefinitionItem(IsobaricType.TMT10,127.131081), // new IonDefinitionItem(IsobaricType.TMT10,128.128116), // new IonDefinitionItem(IsobaricType.TMT10,128.134436), // new IonDefinitionItem(IsobaricType.TMT10,129.131471), // new IonDefinitionItem(IsobaricType.TMT10,129.13779), // new IonDefinitionItem(IsobaricType.TMT10,130.134825), // new IonDefinitionItem(IsobaricType.TMT10,130.141145), // new IonDefinitionItem(IsobaricType.TMT10,131.13818) //}; //public static readonly IsobaricDefinition TMTPlex10 = new IsobaricDefinition(_TMTPlex10) //{ // TagMass = new double[] { 230.1699 } //}; public static IsobaricDefinition GetDefinition(this IsobaricType plexType) { if (plexType == IsobaricType.PLEX4) { return(ITraqPlex4); } if (plexType == IsobaricType.PLEX8) { return(ITraqPlex8); } if (plexType == IsobaricType.TMT6) { return(TMTPlex6); } //if (plexType == IsobaricType.TMT10) //{ // return TMTPlex10; //} throw new ArgumentException("Unknown isobaric type : " + plexType.ToString()); }
public ITraqItemBaseConverter(string name, Func <IsobaricItem, string> getValue, Action <IsobaricItem, string> setValue, IsobaricType plexType, bool setPlexType) : this(name, getValue, setValue) { this.plexType = plexType; this.setPlexType = setPlexType; }
public static List <IsobaricIndex> GetFuncs(this IsobaricType plexType) { return((from item in plexType.GetDefinition().Items select new IsobaricIndex(item.Index)).ToList()); }
public static IsobaricItemImpl CreateItem(this IsobaricType plexType, IsobaricItem parent) { return(new IsobaricItemImpl(parent, plexType.GetDefinition())); }
public static double[][] ParseTable(IsobaricType plexType, string isotopeImpurityFile) { var definition = plexType.GetDefinition(); var items = definition.Items; string[] lines = File.ReadAllLines(isotopeImpurityFile); if (lines.Length < items.Length + 1) { throw new ArgumentException(string.Format("Wrong format of Isotope Impurity Correction Table File of {0}\n{1}", plexType, isotopeImpurityFile)); } //Skip the header line lines = lines.Skip(1).ToArray(); char splitChar; if (lines[0].Contains(',')) { splitChar = ','; } else { splitChar = '\t'; } //Each line should contain reagent name and five values (-2,-1,0,1,2) lines = (from l in lines let s = l.Trim().Split(splitChar) where s.Length == 6 select l.Trim()).ToArray(); if (lines.Length != items.Length) { throw new ArgumentException(string.Format("Length not equals between plex type {0} and impurity file {1}", plexType, isotopeImpurityFile)); } var ignore = new List <int>(); for (int i = definition.MaxIndex - 1; i > definition.MinIndex; i--) { if (!definition.IsValid(i)) { ignore.Add(i - definition.MinIndex); } } int len = definition.MaxIndex - definition.MinIndex + 1; Dictionary <int, double[]> dic = new Dictionary <int, double[]>(); int index = definition.MinIndex - 1; for (int i = 0; i < items.Length; i++) { var lst = new List <double>(); for (int j = 0; j < len; j++) { lst.Add(0); } var p = GetIsotopes(lines[i], splitChar, ref index); var startPos = items[i].Index - definition.MinIndex - 2; var endPos = Math.Min(len, startPos + 5); var fromPos = Math.Max(0, startPos); for (int j = fromPos; j < endPos; j++) { var pIndex = j - startPos; lst[j] = p[pIndex]; } foreach (var ign in ignore) { lst.RemoveAt(ign); } dic[index] = lst.ToArray(); } return((from key in dic.Keys orderby key select dic[key]).ToArray()); }
public IsobaricImpurityCorrectionCalculator(IsobaricType plexType, string isotopeImpurityCorrectionTableFileName) { this.PlexType = plexType; this.plexTable = ParseTable(plexType, isotopeImpurityCorrectionTableFileName); }
public ITraqResultFileDistiller(IITraqRawReader itraqReader, int minPeakCount, IsobaricType plexType, string isotopeImpurityFile, double precursorPPM) { this.itraqReader = itraqReader; this.minPeakCount = minPeakCount; this.calc = new IsobaricImpurityCorrectionCalculator(plexType, isotopeImpurityFile); this.precursorPPM = precursorPPM; }