Exemple #1
0
 public void AddData(Peptide peptide, double[] quant, bool ismissingChannel = false)
 {
     PSMs++;
     UniquePeptides.Add(peptide);
     Peptides.Add(peptide);
     QuantData.Add(new Tuple <Peptide, double[], bool>(peptide, quant, ismissingChannel));
 }
Exemple #2
0
	private SortedList<string,Peptide> LoadPeptides() {
		SortedList<string,Peptide> SortedPeptides = new SortedList<string, Peptide>();
		int id = 1;
		foreach( PeptideType pep in m_mzid.ListPeptides ) {			
			Peptide p = new Peptide( id++, pep.PeptideSequence );
			p.Confidence = Peptide.ConfidenceType.NoThreshold;
			SortedPeptides.Add( pep.id, p );
			p.Runs.Add( m_Run );
			if( pep.Modification != null )
				foreach( ModificationType mod in pep.Modification ) {
					PTM ptm = new PTM();
					ptm.Pos = mod.locationSpecified ? mod.location : -1;
					if( mod.residues != null )
						foreach( string residue in mod.residues )
							ptm.Residues += residue;
					foreach( CVParamType param in mod.cvParam )
						if( param.cvRef.Equals("UNIMOD") )
							ptm.Name = param.name;
					p.AddPTM( ptm );
				}
			p.DBRef = pep.id;
			Peptides.Add( p );
		}
		return SortedPeptides;
	}
Exemple #3
0
 private void PeptidesToolStripMenuItemOnClick(object sender, EventArgs e)
 {
     if (RowSource is Peptides)
     {
         return;
     }
     RowSource = new Peptides(_dataSchema, new[] { IdentityPath.ROOT });
 }
Exemple #4
0
        /// <summary>
        ///     Object hash code
        /// </summary>
        /// <returns></returns>
        public override int GetHashCode()
        {
            unchecked
            {
                var hashCode = DBSequences != null?DBSequences.GetHashCode() : 0;

                hashCode = (hashCode * 397) ^ (Peptides != null ? Peptides.GetHashCode() : 0);
                hashCode = (hashCode * 397) ^ (PeptideEvidences != null ? PeptideEvidences.GetHashCode() : 0);
                return(hashCode);
            }
        }
Exemple #5
0
        private IDictionary <int, Tuple <double, bool> > CalculateProteinAbundances()
        {
            var allTransitionIdentityPaths = new HashSet <IdentityPath>();
            var quantifiers    = Peptides.Select(peptide => peptide.GetPeptideQuantifier()).ToList();
            int replicateCount = SrmDocument.Settings.HasResults
                ? SrmDocument.Settings.MeasuredResults.Chromatograms.Count : 0;
            var  abundances              = new Dictionary <int, Tuple <double, int> >();
            var  srmSettings             = SrmDocument.Settings;
            bool allowMissingTransitions =
                srmSettings.PeptideSettings.Quantification.NormalizationMethod is NormalizationMethod.RatioToLabel;

            for (int iReplicate = 0; iReplicate < replicateCount; iReplicate++)
            {
                double totalNumerator   = 0;
                double totalDenomicator = 0;
                int    transitionCount  = 0;
                foreach (var peptideQuantifier in quantifiers)
                {
                    foreach (var entry in peptideQuantifier.GetTransitionIntensities(SrmDocument.Settings, iReplicate,
                                                                                     false))
                    {
                        totalNumerator   += Math.Max(entry.Value.Intensity, 1.0);
                        totalDenomicator += Math.Max(entry.Value.Denominator, 1.0);
                        allTransitionIdentityPaths.Add(entry.Key);
                        transitionCount++;
                    }
                }

                if (transitionCount != 0)
                {
                    var abundance = totalNumerator / totalDenomicator;
                    abundances.Add(iReplicate, Tuple.Create(abundance, transitionCount));
                }
            }

            var proteinAbundanceRecords = new Dictionary <int, Tuple <double, bool> >();

            foreach (var entry in abundances)
            {
                bool incomplete;
                if (allowMissingTransitions)
                {
                    incomplete = true;
                }
                else
                {
                    incomplete = entry.Value.Item2 != allTransitionIdentityPaths.Count;
                }
                proteinAbundanceRecords.Add(entry.Key, Tuple.Create(entry.Value.Item1, incomplete));
            }

            return(proteinAbundanceRecords);
        }
Exemple #6
0
	/// <summary>
	/// Loads data from a peptide identification file
	/// </summary>
	/// <param name="merge">
	/// A <see cref="System.Boolean"/> indicating wether merge the new file with the existing data
	/// </param>
	public void Load( string path, bool merge ) {
		if( !merge || m_Run == 0 ) {
			m_InputFiles.Clear();
			Proteins.Clear();
			Peptides.Clear();
			Spectra.Clear();
			m_gid = 1;
			m_SortedProteins = new SortedList<string, Protein>();
			m_Run = 1;
		} else
			m_Run++;
		Load( path );
		m_InputFiles.Add( Path.GetFileName(path) );
	}
Exemple #7
0
 public override int GetHashCode()
 {
     unchecked
     {
         int hashCode = DbWorkspaceId.GetHashCode();
         hashCode = (hashCode * 397) ^ LastChangeLogId.GetHashCode();
         hashCode = (hashCode * 397) ^ (Peptides != null ? Peptides.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (MsDataFiles != null ? MsDataFiles.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (PeptideAnalyses != null ? PeptideAnalyses.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (TracerDefs != null ? TracerDefs.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Settings != null ? Settings.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Modifications != null ? Modifications.GetHashCode() : 0);
         return(hashCode);
     }
 }
Exemple #8
0
            public override IEnumerable <SkylineDocNode> GetSelectedNodes(BoundDataGridView dataGridView)
            {
                var rowItemValues = RowItemValues.FromDataGridView(typeof(Protein), dataGridView);

                foreach (var rowItem in rowItemValues.GetSelectedRowItems(dataGridView))
                {
                    foreach (var protein in rowItemValues.GetRowValues(rowItem).Cast <Protein>())
                    {
                        yield return(protein);
                    }
                }

                foreach (var peptide in Peptides.GetSelectedNodes(dataGridView))
                {
                    yield return(((Entities.Peptide)peptide).Protein);
                }
            }
Exemple #9
0
        public RetentionTimeProviderData(IRetentionTimeProvider retentionTimes, IEnumerable <DbIrtPeptide> standardPeptides)
        {
            RetentionTimeProvider = retentionTimes;

            Peptides = standardPeptides.Select(standardPeptide => new Peptide(standardPeptide.ModifiedTarget,
                                                                              retentionTimes.GetRetentionTime(standardPeptide.ModifiedTarget), standardPeptide.Irt)).ToList();
            Peptides.Sort((x, y) => x.Irt.CompareTo(y.Irt));

            if (!FilteredPeptides.Any())
            {
                Regression        = null;
                RegressionRefined = null;
                RegressionSuccess = false;
            }

            var filteredRt  = FilteredPeptides.Select(pep => pep.RetentionTime.Value).ToList();
            var filteredIrt = FilteredPeptides.Select(pep => pep.Irt).ToList();
            var statTimes   = new Statistics(filteredRt);
            var statIrts    = new Statistics(filteredIrt);

            Regression = new RegressionLine(statIrts.Slope(statTimes), statIrts.Intercept(statTimes));

            var removed = new List <Tuple <double, double> >();

            RegressionSuccess = RCalcIrt.TryGetRegressionLine(filteredRt, filteredIrt, MinPoints, out _regressionRefined, removed);
            foreach (var remove in removed)
            {
                for (var i = 0; i < Peptides.Count; i++)
                {
                    var peptide = Peptides[i];
                    if (peptide.RetentionTime.Equals(remove.Item1) && peptide.Irt.Equals(remove.Item2))
                    {
                        Peptides[i] = new Peptide(peptide, true);
                    }
                }
            }
        }
Exemple #10
0
	/// <summary>
	/// Checks for the presence of the given peptide in the peptide list of the protein
	/// </summary>
	public bool HasPeptide( Peptide fo ) {
		return Peptides.Contains( fo );
	}
Exemple #11
0
 private int NumberofUniquePeptides()
 {
     return(Peptides.Sum(pep => pep.PSMs.Count));
 }
Exemple #12
0
	private void LoadData( string xmlpath ) {
		SortedList<int,string> SortedAccession = new SortedList<int, string>();
	
		XmlDocument doc = new XmlDocument();
		doc.Load( xmlpath );
		
		// Load proteins
		XmlNodeList proteins = doc.GetElementsByTagName( "PROTEIN" );
		foreach( XmlElement element in proteins ) {
			int id = int.Parse(element.GetAttribute("ID"));
			if( SortedAccession.ContainsKey(id) )
				continue;
			string acc = element.GetElementsByTagName("ACCESSION")[0].InnerText;
			SortedAccession.Add( id, acc );
			if( m_SortedProteins.ContainsKey(acc) )
				continue;
			string entry = element.GetElementsByTagName("ENTRY")[0].InnerText;
			string desc = element.GetElementsByTagName("DESCRIPTION")[0].InnerText.Replace('+',' ');
			string seq = element.GetElementsByTagName("SEQUENCE")[0].InnerText.ToUpper();
			Protein p = new Protein(m_pid++, entry, acc, desc, seq);
			Proteins.Add( p );
			m_SortedProteins.Add( acc, p );
		}
		
		// Load peptides
		SortedList<int,Peptide> SortedPeptides = new SortedList<int, Peptide>();
		XmlNodeList peptides = doc.GetElementsByTagName( "PEPTIDE" );
		foreach( XmlElement element in peptides ) {
			int id = int.Parse(element.GetAttribute("ID"));
			int pid = int.Parse(element.GetAttribute("PROT_ID"));
			int mid = 0;
			if( PlgsThreshold != Peptide.ConfidenceType.NoThreshold )
				mid = int.Parse(element.GetAttribute("QUERY_MASS_ID"));
			string seq = element.GetAttribute("SEQUENCE").ToUpper();
			Peptide f = new Peptide(id, seq);
			XmlNodeList mods = element.GetElementsByTagName( "MATCH_MODIFIER" );
			f.Runs.Add( m_Run );
			foreach( XmlElement mod in mods ) {
				PTM ptm = new PTM();
				string[] strs = mod.GetAttribute("NAME").Split(new char[]{'+'});
				ptm.Name = strs[0];
				string str = mod.GetAttribute("POS");
				ptm.Pos = str.Length == 0 ? -1 : int.Parse(str);
				if( strs.Length > 1 )
					ptm.Residues = strs[1];
				f.AddPTM( ptm );
			}
			Protein p = null;
			try {
				p = m_SortedProteins[SortedAccession[pid]];
			} catch {
				Notify( "Peptide '" + id + "' references unknown protein '" + pid + "'" );
			}
			if( p != null ) {
				p.Peptides.Add( f );
				f.Proteins.Add( p );
				if( !p.Sequence.Contains(f.Sequence) )
					throw new ApplicationException( "Inconsistent sequence data" );
			}
			Peptides.Add( f );
			if( PlgsThreshold != Peptide.ConfidenceType.NoThreshold )
				SortedPeptides.Add(mid,f);
		}
		if( PlgsThreshold == Peptide.ConfidenceType.NoThreshold )
			return;
		
		// Scores
		XmlNodeList scores = doc.GetElementsByTagName( "MASS_MATCH" );
		foreach( XmlElement element in scores ) {
			int id = int.Parse(element.GetAttribute("ID"));
			double score = double.Parse(element.GetAttribute("SCORE"), m_Format);
			SortedPeptides[id].Score = score;
		}
	}
Exemple #13
0
 private DbIrtPeptide MatchingStandard(DbIrtPeptide peptide, double?irtTolerance)
 {
     return(Peptides.FirstOrDefault(p => Match(peptide, p, irtTolerance)));
 }
Exemple #14
0
        public string ToParsimonyProteins(ExperimentGroup exp, bool duplexQuant = false, bool useOnlyCompleteSets = false)
        {
            StringBuilder sb = new StringBuilder(512);

            sb.AppendFormat("{0},{1},{2},{3:G4},{4:G4},{5:G4},{6},{7},{8},{9},", Name, Description, LongestProteinLen, SequenceCoverage, RepresentativeProtein.CalculateSequenceCoverage(Peptides.Where(pep => !pep.IsShared)), SequenceRedundacy, Count, UniquePeptides, Peptides.Count, Peptides.Count(pep => pep.IsShared));
            if (exp != null)
            {
                int psms;
                HashSet <Peptide> uniquepeps;
                UniquePeptidesPerGroup.TryGetValue(exp, out uniquepeps);
                PsmsPerGroup.TryGetValue(exp, out psms);
                sb.Append(psms);
                sb.Append(',');
                if (uniquepeps != null)
                {
                    sb.Append(uniquepeps.Count);
                }
                sb.Append(',');
                sb.Append(uniquepeps.Count(pep => pep.IsShared));
                sb.Append(',');
            }
            sb.Append(PScore.ToString(CultureInfo.InvariantCulture));
            if (exp != null && exp.UseQuant)
            {
                Quantitation quant;
                if (Quantitation.TryGetValue(exp.Name, out quant))
                {
                    sb.Append(',');
                    sb.Append(quant.PSMs);
                    sb.Append(',');
                    sb.Append(quant.UniquePeptides.Count);
                    sb.Append(',');
                    sb.Append(quant.ToOutput(duplexQuant, exp.MeidanLog2Ratio, useOnlyCompleteSets));
                }
                else
                {
                    sb.Append(",0,0");
                    for (int i = 0; i < exp.QuantPlex * 4; i++)
                    {
                        sb.Append(",-");
                    }

                    if (duplexQuant)
                    {
                        sb.Append(",N/A,N/A");
                    }
                }
            }

            if (ProteinHoarder.AnnotationType != AnnotationType.None)
            {
                sb.Append(',');
                sb.Append(ProteinIdsString());
                sb.Append(',');
                sb.Append(GeneNamesString());
            }

            return(sb.ToString());
        }
        private void TestRatioFilter()
        {
            const double filterValue = 5.0;
            RunUI(() =>
            {
                SkylineWindow.OpenFile(TestFilesDir.GetTestPath("MultiLabel.sky"));
                SkylineWindow.ShowDocumentGrid(true);

            });
            DocumentGridForm documentGrid = FindOpenForm<DocumentGridForm>();
            RunUI(() => documentGrid.ChooseView(Resources.SkylineViewContext_GetDocumentGridRowSources_Precursors));
            var modifications = SkylineWindow.Document.Settings.PeptideSettings.Modifications;
            var isotopeLabel = modifications.InternalStandardTypes.First(
                    label => label.Name == "heavy 15N");
            AddFilter(documentGrid, PropertyPath.Parse("Proteins!*.Peptides!*.Precursors!*.Results!*.Value")
                        .Property(RatioPropertyDescriptor.MakePropertyName(RatioPropertyDescriptor.RATIO_PREFIX, isotopeLabel)),
                    FilterOperations.OP_IS_GREATER_THAN_OR_EQUAL,
                    filterValue.ToString(CultureInfo.CurrentCulture));
            RunUI(() =>
            {
                var colPeptide = documentGrid.FindColumn(PropertyPath.Parse("Peptide"));
                var filteredPeptides = Enumerable.Range(0, documentGrid.RowCount).Select(
                    rowIndex => (Peptide) documentGrid.DataGridView.Rows[rowIndex].Cells[colPeptide.Index].Value)
                    .ToArray();
                CollectionAssert.AreEqual(new []{"AEVAALAAENK", "AIDYVEATANSHSR"},
                    filteredPeptides.Select(peptide=>peptide.ToString()).ToArray());
                var allPeptides = new Peptides(new SkylineDataSchema(SkylineWindow, DataSchemaLocalizer.INVARIANT), new []{IdentityPath.ROOT});
                var ratioIndex = modifications.InternalStandardTypes.IndexOf(isotopeLabel);
                Assert.IsTrue(ratioIndex >= 0);
                foreach (var peptide in allPeptides)
                {
                    bool hasMatchingPrecursorResult =
                        peptide.Precursors.Any(
                            precursor =>
                                precursor.Results.Values.Any(
                                    precursorResult =>
                                        RatioValue.GetRatio(precursorResult.ChromInfo.Ratios[ratioIndex]) >= filterValue));
                    Assert.AreEqual(hasMatchingPrecursorResult, filteredPeptides.Any(filteredPeptide => filteredPeptide.IdentityPath.Equals(peptide.IdentityPath)));
                }
            }
            );
            RunUI(() => documentGrid.ChooseView(Resources.SkylineViewContext_GetDocumentGridRowSources_Precursors));
            WaitForConditionUI(() => documentGrid.IsComplete);
            Assert.AreEqual(12 + (TestSmallMolecules ? 1 : 0), documentGrid.RowCount);
            {
                var quickFilterForm = ShowDialog<QuickFilterForm>(() =>
                {
                    var precursorMzColumn = documentGrid.FindColumn(PropertyPath.Root.Property("Mz"));
                    documentGrid.QuickFilter(precursorMzColumn);
                });
                RunUI(() =>
                {
                    quickFilterForm.SetFilterOperation(0, FilterOperations.OP_IS_GREATER_THAN);
                    quickFilterForm.SetFilterOperand(0, 500.5.ToString(CultureInfo.CurrentCulture));
                    quickFilterForm.SetFilterOperation(1, FilterOperations.OP_IS_LESS_THAN);
                    quickFilterForm.SetFilterOperand(1, 600.5.ToString(CultureInfo.CurrentCulture));
                });
                OkDialog(quickFilterForm, quickFilterForm.OkDialog);
            }
            WaitForConditionUI(() => documentGrid.IsComplete);
            Assert.AreEqual(8, documentGrid.RowCount);
            {
                var quickFilterForm = ShowDialog<QuickFilterForm>(() =>
                {
                    var precursorMzColumn = documentGrid.FindColumn(PropertyPath.Root.Property("Mz"));
                    documentGrid.QuickFilter(precursorMzColumn);
                });
                RunUI(() =>
                {
                    quickFilterForm.SetFilterOperand(0, "invalidnumber");
                });
                var messageDlg = ShowDialog<AlertDlg>(quickFilterForm.OkDialog);
                OkDialog(messageDlg, messageDlg.OkDialog);
                OkDialog(quickFilterForm, quickFilterForm.CancelButton.PerformClick);
            }
        }
Exemple #16
0
	/// <summary>
	/// Loads a mzIdentML file
	/// </summary>
	override protected void Load( string mzid ) {
		m_mzid = new mzidFile1_0();
		m_mzid.Load( mzid );
		
		// Proteins
		SortedList<string,string> SortedAccession = new SortedList<string, string>();
		foreach( PSIPIanalysissearchDBSequenceType element in m_mzid.ListProteins ) {
			if( SortedAccession.ContainsKey(element.id) )
				continue;
			string acc = element.accession;
			SortedAccession.Add( element.id, acc );
			if( m_SortedProteins.ContainsKey(acc) )
				continue;
			FuGECommonOntologycvParamType cv;
			cv = FuGECommonOntologycvParamType.Find( "MS:1001352", element.cvParam );
			string entry = cv == null ? "" : cv.value;
			cv = FuGECommonOntologycvParamType.Find( "MS:1001088", element.cvParam );
			string desc = cv == null ? "" : cv.value;
			string seq = element.seq;//.ToUpper();
			Protein p = new Protein(m_pid++, entry, acc, desc, seq);
			p.DBRef = element.id;
			Proteins.Add( p );
			m_SortedProteins.Add( acc, p );
		}
		
		// Peptides
		SortedList<string,Peptide> SortedPeptides = new SortedList<string, Peptide>();
		int id = 1;
		foreach( PSIPIpolypeptidePeptideType element in m_mzid.ListPeptides ) {
			string seq = element.peptideSequence;//.ToUpper();
			Peptide f = new Peptide(id++, seq);
			f.Confidence = Peptide.ConfidenceType.PassThreshold; // It will be filtered later if neccessary
			SortedPeptides.Add( element.id, f );
			f.Runs.Add( m_Run );
			if( element.Modification != null )
				foreach( PSIPIpolypeptideModificationType mod in element.Modification ) {
					PTM ptm = new PTM();
					ptm.Pos = mod.locationSpecified ? mod.location : -1;
					if( mod.residues != null )
						foreach( string residue in mod.residues )
							ptm.Residues += residue;
					foreach( FuGECommonOntologycvParamType param in mod.cvParam )
						if( param.cvRef.Equals("UNIMOD") )
							ptm.Name = param.name;
					f.AddPTM( ptm );
				}
			Peptides.Add( f );
		}
		
		// Relations
		if( m_mzid.Data.DataCollection.AnalysisData.SpectrumIdentificationList.Length != 1 )
			throw new ApplicationException( "Multiple spectrum identification lists not supported" );
		foreach( PSIPIanalysissearchSpectrumIdentificationResultType idres in
			m_mzid.Data.DataCollection.AnalysisData.SpectrumIdentificationList[0].SpectrumIdentificationResult )
			foreach( PSIPIanalysissearchSpectrumIdentificationItemType item in idres.SpectrumIdentificationItem ) {
				if( !item.passThreshold )
					continue;
				Peptide f = SortedPeptides[item.Peptide_ref];
				if( item.PeptideEvidence == null )
					continue;
				f.Confidence = Peptide.ConfidenceType.PassThreshold;
				foreach( PSIPIanalysisprocessPeptideEvidenceType relation in item.PeptideEvidence ) {
					Protein p = m_SortedProteins[SortedAccession[relation.DBSequence_Ref]];
					if( f.Proteins.Contains(p) )
						continue;
					f.Names.Add( relation.DBSequence_Ref, relation.id );
					p.Peptides.Add( f );
					f.Proteins.Add( p );
				}
			}
	}
Exemple #17
0
 public void AddPeptide(IAminoAcidSequence peptide)
 {
     Peptides.Add(peptide);
 }
Exemple #18
0
        private void TestRatioFilter()
        {
            const double filterValue = 5.0;

            RunUI(() =>
            {
                SkylineWindow.OpenFile(TestFilesDir.GetTestPath("MultiLabel.sky"));
                SkylineWindow.ShowDocumentGrid(true);
            });
            DocumentGridForm documentGrid = FindOpenForm <DocumentGridForm>();

            RunUI(() => documentGrid.ChooseView(Resources.SkylineViewContext_GetDocumentGridRowSources_Precursors));
            var modifications = SkylineWindow.Document.Settings.PeptideSettings.Modifications;
            var isotopeLabel  = modifications.InternalStandardTypes.First(
                label => label.Name == "heavy 15N");

            AddFilter(documentGrid, PropertyPath.Parse("Proteins!*.Peptides!*.Precursors!*.Results!*.Value")
                      .Property(RatioPropertyDescriptor.MakePropertyName(RatioPropertyDescriptor.RATIO_PREFIX, isotopeLabel)),
                      FilterOperations.OP_IS_GREATER_THAN_OR_EQUAL,
                      filterValue.ToString(CultureInfo.CurrentCulture));
            RunUI(() =>
            {
                var colPeptide       = documentGrid.FindColumn(PropertyPath.Parse("Peptide"));
                var filteredPeptides = Enumerable.Range(0, documentGrid.RowCount).Select(
                    rowIndex => (Peptide)documentGrid.DataGridView.Rows[rowIndex].Cells[colPeptide.Index].Value)
                                       .ToArray();
                CollectionAssert.AreEqual(new [] { "AEVAALAAENK", "AIDYVEATANSHSR" },
                                          filteredPeptides.Select(peptide => peptide.ToString()).ToArray());
                var allPeptides = new Peptides(new SkylineDataSchema(SkylineWindow, DataSchemaLocalizer.INVARIANT), new [] { IdentityPath.ROOT });
                var ratioIndex  = modifications.InternalStandardTypes.IndexOf(isotopeLabel);
                Assert.IsTrue(ratioIndex >= 0);
                foreach (var peptide in allPeptides.GetItems().OfType <Peptide>())
                {
                    var peptidePath = peptide.IdentityPath;
                    bool hasMatchingPrecursorResult =
                        peptide.Precursors.Any(
                            precursor =>
                            precursor.Results.Values.Any(
                                precursorResult =>
                                RatioValue.GetRatio(precursorResult.ChromInfo.Ratios[ratioIndex]) >= filterValue));
                    Assert.AreEqual(hasMatchingPrecursorResult, filteredPeptides.Any(filteredPeptide => filteredPeptide.IdentityPath.Equals(peptidePath)));
                }
            }
                  );
            RunUI(() => documentGrid.ChooseView(Resources.SkylineViewContext_GetDocumentGridRowSources_Precursors));
            WaitForConditionUI(() => documentGrid.IsComplete);
            Assert.AreEqual(12, documentGrid.RowCount);
            {
                var quickFilterForm = ShowDialog <QuickFilterForm>(() =>
                {
                    var precursorMzColumn = documentGrid.FindColumn(PropertyPath.Root.Property("Mz"));
                    documentGrid.QuickFilter(precursorMzColumn);
                });
                RunUI(() =>
                {
                    quickFilterForm.SetFilterOperation(0, FilterOperations.OP_IS_GREATER_THAN);
                    quickFilterForm.SetFilterOperand(0, 500.5.ToString(CultureInfo.CurrentCulture));
                    quickFilterForm.SetFilterOperation(1, FilterOperations.OP_IS_LESS_THAN);
                    quickFilterForm.SetFilterOperand(1, 600.5.ToString(CultureInfo.CurrentCulture));
                });
                OkDialog(quickFilterForm, quickFilterForm.OkDialog);
            }
            WaitForConditionUI(() => documentGrid.IsComplete);
            Assert.AreEqual(8, documentGrid.RowCount);
            {
                var quickFilterForm = ShowDialog <QuickFilterForm>(() =>
                {
                    var precursorMzColumn = documentGrid.FindColumn(PropertyPath.Root.Property("Mz"));
                    documentGrid.QuickFilter(precursorMzColumn);
                });
                RunUI(() =>
                {
                    quickFilterForm.SetFilterOperand(0, "invalidnumber");
                });
                var messageDlg = ShowDialog <AlertDlg>(quickFilterForm.OkDialog);
                OkDialog(messageDlg, messageDlg.OkDialog);
                OkDialog(quickFilterForm, quickFilterForm.CancelButton.PerformClick);
            }
        }
Exemple #19
0
 public bool IsSubset(ICollection <DbIrtPeptide> peptides, double?irtTolerance)
 {
     return(Peptides.Count > 0 && Peptides.All(p => peptides.FirstOrDefault(peptide => Match(p, peptide, irtTolerance)) != null));
 }
Exemple #20
0
 public bool IsNonProteomic()
 {
     return(Peptides.All(p => p.IsSmallMolecule()));
 }
Exemple #21
0
        private void btnLoad_Click(object sender, EventArgs e)
        {
            openFileDialog1.Filter           = "Raw files (*.RAW,*.mzXML)|*.RAW;*.mzXML";
            openFileDialog1.RestoreDirectory = true;
            if (txtScanNo.Text == "" || txtPeptideSeq.Text == "")
            {
                MessageBox.Show("Please fill the information");
                return;
            }
            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                _torelance          = Convert.ToSingle(txtPeaKTol.Text);
                _precursorTorelance = Convert.ToSingle(txtPrecusorTol.Text);
                dtTrees.Rows.Clear();
                int ScanNo = 0;
                if (Int32.TryParse(txtScanNo.Text, out ScanNo) == false)
                {
                    MessageBox.Show("Input Scan Number Error");
                    return;
                }

                if (Path.GetExtension(openFileDialog1.FileName).ToLower() == ".raw")
                {
                    ThermoRawReader RawReader = new COL.MassLib.ThermoRawReader(openFileDialog1.FileName);

                    /*GlypID.Peaks.clsPeakProcessorParameters clsParameters = new GlypID.Peaks.clsPeakProcessorParameters();
                     * clsParameters.SignalToNoiseThreshold = 0.0f;
                     * clsParameters.PeakBackgroundRatio = 0.01f;*/
                    //RawReader.SetPeakProcessorParameter(2, 2);
                    scan = RawReader.ReadScan(ScanNo);
                }
                else
                {
                    //scan = new mzXMLReader(openFileDialog1.FileName).ReadScan(ScanNo);
                }


                int NoNeuAc = 0;
                int NoNeuGc = 0;
                if (rdoNeuAc.Checked)
                {
                    NoNeuAc = Convert.ToInt32(txtSia.Text);
                }
                else
                {
                    NoNeuGc = Convert.ToInt32(txtSia.Text);
                }


                List <int> SequenceParameters = new List <int>();
                SequenceParameters.Add(Convert.ToInt32(txtTopPeaks_i.Text));
                SequenceParameters.Add(Convert.ToInt32(txtTopDiagPeaks_j.Text));
                SequenceParameters.Add(Convert.ToInt32(txtTopCorePeaks_k.Text));
                SequenceParameters.Add(Convert.ToInt32(txtTopBrancingPeaks_l.Text));
                SequenceParameters.Add(Convert.ToInt32(txtMaxGlycansToCompleteStruct_m.Text));


                GS = new GlycanSequencing_MultipleScoring(scan, scan.ParentCharge, Convert.ToInt32(txtHex.Text), Convert.ToInt32(txtHexNAc.Text), Convert.ToInt32(txtdeHex.Text), NoNeuAc, NoNeuGc, @"D:\tmp", true, 0.8f, 10, SequenceParameters, Peptides.ReadFastaFile(txtPeptideSeq.Text));
                GS.NumbersOfPeaksForSequencing = 140;
                GS.UseAVGMass = true;
                //GS.DebugMode(@"E:\temp\SeqTmp\");
                GS.CreatePrecursotMZ          = true;
                GS.RewardForCompleteStructure = 3;
                GS.StartSequencing();
                GS.GetTopRankScoreStructre(1);



                //lstPeak.Items.Add("Top " + GS.FilteredPeaks.Count.ToString() + "  peaks");
                //lstPeak.Items.Add("m/z / normailzed intensity ");
                //foreach (MSPoint p in GS.FilteredPeaks)
                //{
                //    lstPeak.Items.Add(p.Mass.ToString("0.0000") +"/" + p.Intensity.ToString("0.0000"));
                //}

                bool isFullSeq = false;
                ReportStructure = GS.SequencedStructures;
                if (ReportStructure.Count == 0)
                {
                    MessageBox.Show("No Structure Found");
                    return;
                }
                if (GS.FullSequencedStructures.Count != 0)
                {
                    ReportStructure = GS.FullSequencedStructures;
                    isFullSeq       = true;
                }
                AminoAcidMass AA = new AminoAcidMass();
                for (int i = 0; i < ReportStructure.Count; i++)
                {
                    GlycanStructure gt  = ReportStructure[i];
                    DataRow         row = dtTrees.NewRow();
                    //row.Add(new Object[] (gt.Mass.ToString("0.0000"), gt.Score.ToString("0.0000"),gt.GetIUPACString()));
                    row["ID"]                  = i.ToString();
                    row["Glycan Mass"]         = gt.GlycanAVGMonoMass.ToString("0.0000");
                    row["Y1"]                  = gt.Y1.Mass.ToString("0.0000");;
                    row["Core Score"]          = Convert.ToSingle((gt.CoreScore).ToString("0.00"));
                    row["Branch Score"]        = Convert.ToSingle((gt.BranchScore).ToString("0.00"));
                    row["Append Glycan Score"] = Convert.ToSingle((gt.InCompleteScore).ToString("0.00"));
                    if (gt.IsCompleteByPrecursorDifference)
                    {
                        row["PPM"] =
                            Convert.ToSingle(
                                MassUtility.GetMassPPM(
                                    gt.GlycanMonoMass + AA.GetMonoMW(gt.PeptideSequence, true) +
                                    GetGlycanMassByGlycanString(gt.RestGlycanString), GS.PrecusorMonoMass)
                                .ToString("0.00"));
                    }
                    else
                    {
                        row["PPM"] =
                            Convert.ToSingle(
                                MassUtility.GetMassPPM(
                                    gt.GlycanMonoMass + AA.GetMonoMW(gt.PeptideSequence, true), GS.PrecusorMonoMass).ToString("0.00"));
                    }
                    row["Peptide"]       = gt.PeptideSequence;
                    row["Append Glycan"] = gt.RestGlycanString;
                    row["IUPAC"]         = gt.IUPACString;

                    GlycansDrawer GDRaw  = new GlycansDrawer(gt.IUPACString, false);
                    Image         tmpImg = GDRaw.GetImage();
                    row["Structure"] = tmpImg;
                    dtTrees.Rows.Add(row);
                }
                ////GS.SequencStructures[0].TheoreticalFragment
                dtTrees.DefaultView.Sort = "Glycan Mass DESC";


                for (int i = 0; i < dgView.Rows.Count; i++)
                {
                    this.dgView.AutoResizeRow(i);
                    if (Convert.ToSingle(dgView.Rows[i].Cells["PPM"].Value) <= Convert.ToSingle(txtPrecusorTol.Text))
                    {
                        dgView.Rows[i].DefaultCellStyle.BackColor = Color.Red;
                    }
                }
            }
        }