public unsafe Dataset(float[][] data, int numCol, CommonParameters cp, DatasetParameters dp, float[] labels = null, float[] weights = null, int[] groups = null, Dataset reference = null) { CommonParameters = cp; DatasetParameters = dp; var pmString = ParamsToString(cp, dp); _handle = IntPtr.Zero; var gcHandles = new List <GCHandle>(data.Length); try { float *[] dataPtrs = new float *[data.Length]; int[] nRows = new int[data.Length]; for (int i = 0; i < data.Length; i++) { var hdl = GCHandle.Alloc(data[i], GCHandleType.Pinned); gcHandles.Add(hdl); dataPtrs[i] = (float *)hdl.AddrOfPinnedObject().ToPointer(); nRows[i] = 1; } ; fixed(float **dataPtr = dataPtrs) fixed(int *nRowsPtr = nRows) { PInvokeException.Check(PInvoke.DatasetCreateFromMats( data.Length, dataPtr, nRowsPtr, numCol, /*isRowMajor*/ true, pmString, reference?._handle ?? IntPtr.Zero, ref _handle ), nameof(PInvoke.DatasetCreateFromMats)); } } finally { foreach (var hdl in gcHandles) { if (hdl.IsAllocated) { hdl.Free(); } } ; } if (labels != null) { SetLabels(labels); } if (weights != null) { SetWeights(weights); } if (groups != null) { SetGroups(groups); } if (NumFeatures != numCol) { throw new Exception("Expected GetNumCols to be equal to numCol"); } if (NumRows != data.Length) { throw new Exception("Expected GetNumRows to be equal to numTotalRow"); } }
/// <summary> /// Specifies if the x5c claim (public key of the certificate) should be sent to the STS. /// Sending the x5c enables application developers to achieve easy certificate roll-over in Azure AD: /// this method will send the public certificate to Azure AD along with the token request, /// so that Azure AD can use it to validate the subject name based on a trusted issuer policy. /// This saves the application admin from the need to explicitly manage the certificate rollover /// (either via portal or powershell/CLI operation) /// </summary> /// <param name="withSendX5C"><c>true</c> if the x5c should be sent. Otherwise <c>false</c>. /// The default is <c>false</c></param> /// <returns>The builder to chain the .With methods</returns> public AcquireTokenSilentParameterBuilder WithSendX5C(bool withSendX5C) { CommonParameters.AddApiTelemetryFeature(ApiTelemetryFeature.WithSendX5C); Parameters.SendX5C = withSendX5C; return(this); }
private AcquireTokenSilentParameterBuilder WithLoginHint(string loginHint) { CommonParameters.AddApiTelemetryFeature(ApiTelemetryFeature.WithLoginHint); Parameters.LoginHint = loginHint; return(this); }
public static void TestCoIsolation() { List <DigestionMotif> motifs = new List <DigestionMotif> { new DigestionMotif("K", null, 1, null) }; Protease protease = new Protease("CustProtease", CleavageSpecificity.Full, null, null, motifs); ProteaseDictionary.Dictionary.Add(protease.Name, protease); CommonParameters CommonParameters = new CommonParameters(scoreCutoff: 1, deconvolutionIntensityRatio: 50, digestionParams: new DigestionParams(protease.Name, minPeptideLength: 1)); var fsp = new List <(string fileName, CommonParameters fileSpecificParameters)>(); fsp.Add(("", CommonParameters)); var variableModifications = new List <Modification>(); var fixedModifications = new List <Modification>(); var proteinList = new List <Protein> { new Protein("MNNNKNDNK", null) }; var searchModes = new SinglePpmAroundZeroSearchMode(5); Proteomics.AminoAcidPolymer.Peptide pep1 = new Proteomics.AminoAcidPolymer.Peptide("NNNK"); Proteomics.AminoAcidPolymer.Peptide pep2 = new Proteomics.AminoAcidPolymer.Peptide("NDNK"); var dist1 = IsotopicDistribution.GetDistribution(pep1.GetChemicalFormula(), 0.1, 0.01); var dist2 = IsotopicDistribution.GetDistribution(pep2.GetChemicalFormula(), 0.1, 0.01); MsDataScan[] Scans = new MsDataScan[2]; double[] ms1intensities = new double[] { 0.8, 0.8, 0.2, 0.02, 0.2, 0.02 }; double[] ms1mzs = dist1.Masses.Concat(dist2.Masses).OrderBy(b => b).Select(b => b.ToMz(1)).ToArray(); double selectedIonMz = ms1mzs[1]; MzSpectrum MS1 = new MzSpectrum(ms1mzs, ms1intensities, false); Scans[0] = new MsDataScan(MS1, 1, 1, false, Polarity.Positive, 1.0, new MzRange(300, 2000), "first spectrum", MZAnalyzerType.Unknown, MS1.SumOfAllY, null, null, "scan=1"); double[] ms2intensities = new double[] { 1, 1, 1, 1, 1 }; double[] ms2mzs = new double[] { 146.106.ToMz(1), 228.086.ToMz(1), 229.07.ToMz(1), 260.148.ToMz(1), 342.129.ToMz(1) }; MzSpectrum MS2 = new MzSpectrum(ms2mzs, ms2intensities, false); double isolationMZ = selectedIonMz; Scans[1] = new MsDataScan(MS2, 2, 2, false, Polarity.Positive, 2.0, new MzRange(100, 1500), "second spectrum", MZAnalyzerType.Unknown, MS2.SumOfAllY, null, null, "scan=2", selectedIonMz, null, null, isolationMZ, 2.5, DissociationType.HCD, 1, null); var myMsDataFile = new MsDataFile(Scans, null); var listOfSortedms2Scans = MetaMorpheusTask.GetMs2Scans(myMsDataFile, null, new CommonParameters(deconvolutionIntensityRatio: 50)).OrderBy(b => b.PrecursorMass).ToArray(); PeptideSpectralMatch[] allPsmsArray = new PeptideSpectralMatch[listOfSortedms2Scans.Length];; new ClassicSearchEngine(allPsmsArray, listOfSortedms2Scans, variableModifications, fixedModifications, null, null, null, proteinList, searchModes, CommonParameters, fsp, null, new List <string>()).Run(); // Two matches for this single scan! Corresponding to two co-isolated masses Assert.AreEqual(2, allPsmsArray.Length); Assert.IsTrue(allPsmsArray[0].Score > 1); Assert.AreEqual(2, allPsmsArray[0].ScanNumber); Assert.AreEqual("NNNK", allPsmsArray[0].BaseSequence); Assert.AreEqual("NDNK", allPsmsArray[1].BaseSequence); }
public static void TestIndexEngineLowRes() { var proteinList = ProteinDbLoader.LoadProteinFasta(Path.Combine(TestContext.CurrentContext.TestDirectory, @"indexEngineTestFasta.fasta"), true, DecoyType.Reverse, false, ProteinDbLoader.UniprotAccessionRegex, ProteinDbLoader.UniprotFullNameRegex, ProteinDbLoader.UniprotFullNameRegex, ProteinDbLoader.UniprotGeneNameRegex, ProteinDbLoader.UniprotOrganismRegex, out var dbErrors, -1); var variableModifications = new List <Modification>(); var fixedModifications = new List <Modification>(); var localizeableModifications = new List <Modification>(); Dictionary <Modification, ushort> modsDictionary = new Dictionary <Modification, ushort>(); foreach (var mod in fixedModifications) { modsDictionary.Add(mod, 0); } int i = 1; foreach (var mod in variableModifications) { modsDictionary.Add(mod, (ushort)i); i++; } foreach (var mod in localizeableModifications) { modsDictionary.Add(mod, (ushort)i); i++; } CommonParameters CommonParameters = new CommonParameters(dissociationType: DissociationType.LowCID, maxThreadsToUsePerFile: 1, scoreCutoff: 1, digestionParams: new DigestionParams(protease: "trypsin", minPeptideLength: 1)); var fsp = new List <(string fileName, CommonParameters fileSpecificParameters)>(); fsp.Add(("", CommonParameters)); var engine = new IndexingEngine(proteinList, variableModifications, fixedModifications, null, null, null, 1, DecoyType.Reverse, CommonParameters, fsp, 30000, false, new List <FileInfo>(), TargetContaminantAmbiguity.RemoveContaminant, new List <string>()); var results = (IndexingResults)engine.Run(); Assert.AreEqual(10, results.PeptideIndex.Count); var bubba = results.FragmentIndex; var tooBubba = results.PrecursorIndex; var digestedList = proteinList[0].Digest(CommonParameters.DigestionParams, new List <Modification>(), variableModifications).ToList(); digestedList.AddRange(proteinList[1].Digest(CommonParameters.DigestionParams, new List <Modification>(), variableModifications)); Assert.AreEqual(10, digestedList.Count); foreach (PeptideWithSetModifications peptide in digestedList) { Assert.Contains(peptide, results.PeptideIndex); var fragments = new List <Product>(); peptide.Fragment(CommonParameters.DissociationType, FragmentationTerminus.Both, fragments); int positionInPeptideIndex = results.PeptideIndex.IndexOf(peptide); foreach (Product fragment in fragments.Where(f => f.ProductType == ProductType.b || f.ProductType == ProductType.y)) { // mass of the fragment double fragmentMass = Math.Round(fragment.NeutralMass / 1.0005079, 0) * 1.0005079; int integerMassRepresentation = (int)Math.Round(fragmentMass * 1000); // look up the peptides that have fragments with this mass // the result of the lookup is a list of peptide IDs that have this fragment mass List <int> fragmentBin = results.FragmentIndex[integerMassRepresentation]; // this list should contain this peptide! Assert.Contains(positionInPeptideIndex, fragmentBin); } } foreach (var fdfd in digestedList) { Assert.Contains(fdfd, results.PeptideIndex); } }
public ShaderCompilerResult Compile(ShaderCode shaderCode, ShaderCompilerArguments arguments) { var entryPoint = arguments.GetString("EntryPoint"); var targetProfile = arguments.GetString("TargetProfile"); var disableOptimizations = arguments.GetBoolean("DisableOptimizations"); var optimizationLevel = Convert.ToInt32(arguments.GetString("OptimizationLevel")); using (var tempFile = TempFile.FromShaderCode(shaderCode)) { var fcPath = $"{tempFile.FilePath}.fc"; var fePath = $"{tempFile.FilePath}.fe"; var foPath = $"{tempFile.FilePath}.fo"; var args = $"--target-profile {targetProfile} --entry-point {entryPoint} --optimization-level {optimizationLevel}"; args += $" --assembly-file \"{fcPath}\" --errors-file \"{fePath}\" --object-file \"{foPath}\""; args += $" --file \"{tempFile.FilePath}\""; if (disableOptimizations) { args += " --disable-optimizations"; } var fxcShimPath = CommonParameters.GetBinaryPath("fxc", arguments, "ShaderPlayground.Shims.Fxc.dll"); ProcessHelper.Run( "dotnet.exe", $"\"{fxcShimPath}\" {args}", out var _, out var stderr); int?selectedOutputIndex = null; bool success = true; var disassembly = FileHelper.ReadAllTextIfExists(fcPath); if (string.IsNullOrWhiteSpace(disassembly)) { disassembly = "<Compilation error occurred>"; selectedOutputIndex = 1; success = false; } var binaryOutput = FileHelper.ReadAllBytesIfExists(foPath); var buildOutput = FileHelper.ReadAllTextIfExists(fePath); if (string.IsNullOrWhiteSpace(buildOutput)) { buildOutput = stderr; } FileHelper.DeleteIfExists(fcPath); FileHelper.DeleteIfExists(fePath); FileHelper.DeleteIfExists(foPath); return(new ShaderCompilerResult( success, new ShaderCode(LanguageNames.Dxbc, binaryOutput), selectedOutputIndex, new ShaderCompilerOutput("Disassembly", LanguageNames.Dxbc, disassembly), new ShaderCompilerOutput("Build output", null, buildOutput))); } }
private void SaveButton_Click(object sender, RoutedEventArgs e) { string fieldNotUsed = "1"; if (!GlobalGuiSettings.CheckTaskSettingsValidity(PrecursorMassToleranceTextBox.Text, ProductMassToleranceTextBox.Text, MissedCleavagesTextBox.Text, MaxModificationIsoformsTextBox.Text, MinPeptideLengthTextBox.Text, MaxPeptideLengthTextBox.Text, MaxThreadsTextBox.Text, MinScoreAllowed.Text, fieldNotUsed, fieldNotUsed, fieldNotUsed, fieldNotUsed, fieldNotUsed, null, null, fieldNotUsed, MaxModsPerPeptideTextBox.Text, fieldNotUsed, fieldNotUsed)) { return; } Protease protease = (Protease)ProteaseComboBox.SelectedItem; int maxMissedCleavages = string.IsNullOrEmpty(MissedCleavagesTextBox.Text) ? int.MaxValue : (int.Parse(MissedCleavagesTextBox.Text, CultureInfo.InvariantCulture)); int minPeptideLength = int.Parse(MinPeptideLengthTextBox.Text, NumberStyles.Any, CultureInfo.InvariantCulture); int maxPeptideLength = string.IsNullOrEmpty(MaxPeptideLengthTextBox.Text) ? int.MaxValue : (int.Parse(MaxPeptideLengthTextBox.Text, NumberStyles.Any, CultureInfo.InvariantCulture)); int minVariantDepth = int.Parse(MinVariantDepthTextBox.Text, NumberStyles.Any, CultureInfo.InvariantCulture); int maxHeterozygousVariants = int.Parse(MaxHeterozygousVariantsTextBox.Text, NumberStyles.Any, CultureInfo.InvariantCulture); int maxModificationIsoforms = int.Parse(MaxModificationIsoformsTextBox.Text, CultureInfo.InvariantCulture); int maxModsPerPeptide = int.Parse(MaxModsPerPeptideTextBox.Text, CultureInfo.InvariantCulture); DissociationType dissociationType = GlobalVariables.AllSupportedDissociationTypes[DissociationTypeComboBox.SelectedItem.ToString()]; CustomFragmentationWindow.Close(); DigestionParams digestionParamsToSave = new DigestionParams( protease: protease.Name, maxMissedCleavages: maxMissedCleavages, minPeptideLength: minPeptideLength, maxPeptideLength: maxPeptideLength, maxModificationIsoforms: maxModificationIsoforms, maxModsForPeptides: maxModsPerPeptide); var listOfModsVariable = new List <(string, string)>(); foreach (var heh in VariableModTypeForTreeViewObservableCollection) { listOfModsVariable.AddRange(heh.Children.Where(b => b.Use).Select(b => (b.Parent.DisplayName, b.ModName))); } if (!GlobalGuiSettings.VariableModCheck(listOfModsVariable)) { return; } var listOfModsFixed = new List <(string, string)>(); foreach (var heh in FixedModTypeForTreeViewObservableCollection) { listOfModsFixed.AddRange(heh.Children.Where(b => b.Use).Select(b => (b.Parent.DisplayName, b.ModName))); } Tolerance productMassTolerance; if (ProductMassToleranceComboBox.SelectedIndex == 0) { productMassTolerance = new AbsoluteTolerance(double.Parse(ProductMassToleranceTextBox.Text, CultureInfo.InvariantCulture)); } else { productMassTolerance = new PpmTolerance(double.Parse(ProductMassToleranceTextBox.Text, CultureInfo.InvariantCulture)); } Tolerance precursorMassTolerance; if (PrecursorMassToleranceComboBox.SelectedIndex == 0) { precursorMassTolerance = new AbsoluteTolerance(double.Parse(PrecursorMassToleranceTextBox.Text, CultureInfo.InvariantCulture)); } else { precursorMassTolerance = new PpmTolerance(double.Parse(PrecursorMassToleranceTextBox.Text, CultureInfo.InvariantCulture)); } bool parseMaxThreadsPerFile = int.Parse(MaxThreadsTextBox.Text, CultureInfo.InvariantCulture) <= Environment.ProcessorCount && int.Parse(MaxThreadsTextBox.Text, CultureInfo.InvariantCulture) > 0; //the below parameters are optimized for top-down but do not exist in the GUI as of Nov. 13, 2019 if (((Protease)ProteaseComboBox.SelectedItem).Name.Contains("top-down")) { CommonParameters commonParamsToSave = new CommonParameters( taskDescriptor: OutputFileNameTextBox.Text != "" ? OutputFileNameTextBox.Text : "CalibrateTask", maxThreadsToUsePerFile: parseMaxThreadsPerFile ? int.Parse(MaxThreadsTextBox.Text, CultureInfo.InvariantCulture) : new CommonParameters().MaxThreadsToUsePerFile, digestionParams: digestionParamsToSave, dissociationType: dissociationType, scoreCutoff: double.Parse(MinScoreAllowed.Text, CultureInfo.InvariantCulture), listOfModsFixed: listOfModsFixed, listOfModsVariable: listOfModsVariable, productMassTolerance: productMassTolerance, precursorMassTolerance: precursorMassTolerance, assumeOrphanPeaksAreZ1Fragments: protease.Name != "top-down", minVariantDepth: minVariantDepth, maxHeterozygousVariants: maxHeterozygousVariants, useProvidedPrecursorInfo: false, //Updated deconvolutionMaxAssumedChargeState: 60, //Updated trimMsMsPeaks: false); //Updated TheTask.CommonParameters = commonParamsToSave; } else //bottom-up { CommonParameters commonParamsToSave = new CommonParameters( taskDescriptor: OutputFileNameTextBox.Text != "" ? OutputFileNameTextBox.Text : "CalibrateTask", maxThreadsToUsePerFile: parseMaxThreadsPerFile ? int.Parse(MaxThreadsTextBox.Text, CultureInfo.InvariantCulture) : new CommonParameters().MaxThreadsToUsePerFile, digestionParams: digestionParamsToSave, dissociationType: dissociationType, scoreCutoff: double.Parse(MinScoreAllowed.Text, CultureInfo.InvariantCulture), listOfModsFixed: listOfModsFixed, listOfModsVariable: listOfModsVariable, productMassTolerance: productMassTolerance, precursorMassTolerance: precursorMassTolerance, assumeOrphanPeaksAreZ1Fragments: protease.Name != "top-down", minVariantDepth: minVariantDepth, maxHeterozygousVariants: maxHeterozygousVariants); TheTask.CommonParameters = commonParamsToSave; } TheTask.CalibrationParameters.WriteIndexedMzml = writeIndexMzmlCheckbox.IsChecked.Value; DialogResult = true; }
public CalibrationEngine(MsDataFile myMSDataFile, DataPointAquisitionResults datapoints, CommonParameters commonParameters, List <string> nestedIds) : base(commonParameters, nestedIds) { MyMsDataFile = myMSDataFile; Datapoints = datapoints; }
private void SaveButton_Click(object sender, RoutedEventArgs e) { string fieldNotUsed = "1"; if (!GlobalGuiSettings.CheckTaskSettingsValidity(XLPrecusorMsTlTextBox.Text, productMassToleranceTextBox.Text, missedCleavagesTextBox.Text, maxModificationIsoformsTextBox.Text, MinPeptideLengthTextBox.Text, MaxPeptideLengthTextBox.Text, maxThreadsTextBox.Text, minScoreAllowed.Text, fieldNotUsed, fieldNotUsed, fieldNotUsed, TopNPeaksTextBox.Text, MinRatioTextBox.Text, null, null, numberOfDatabaseSearchesTextBox.Text, fieldNotUsed, fieldNotUsed, fieldNotUsed)) { return; } DissociationType dissociationType = GlobalVariables.AllSupportedDissociationTypes[DissociationTypeComboBox.SelectedItem.ToString()]; DissociationType childDissociationType = DissociationType.Unknown; if (ChildScanDissociationTypeComboBox.SelectedItem != null) { childDissociationType = GlobalVariables.AllSupportedDissociationTypes[ChildScanDissociationTypeComboBox.SelectedItem.ToString()]; } CustomFragmentationWindow.Close(); //TheTask.XlSearchParameters.SearchGlyco = RbSearchGlyco.IsChecked.Value; //TheTask.XlSearchParameters.SearchGlycoWithBgYgIndex = CkbSearchGlycoWithBgYgIndex.IsChecked.Value; TheTask.XlSearchParameters.RestrictToTopNHits = ckbXLTopNum.IsChecked.Value; TheTask.XlSearchParameters.CrosslinkSearchTopNum = int.Parse(txtXLTopNum.Text, CultureInfo.InvariantCulture); TheTask.XlSearchParameters.CrosslinkAtCleavageSite = ckbCrosslinkAtCleavageSite.IsChecked.Value; TheTask.XlSearchParameters.Crosslinker = (Crosslinker)cbCrosslinkers.SelectedItem; TheTask.XlSearchParameters.XlQuench_H2O = ckbQuenchH2O.IsChecked.Value; TheTask.XlSearchParameters.XlQuench_NH2 = ckbQuenchNH2.IsChecked.Value; TheTask.XlSearchParameters.XlQuench_Tris = ckbQuenchTris.IsChecked.Value; TheTask.XlSearchParameters.DecoyType = checkBoxDecoy.IsChecked.Value ? DecoyType.Reverse : DecoyType.None; Protease protease = (Protease)proteaseComboBox.SelectedItem; int MaxMissedCleavages = string.IsNullOrEmpty(missedCleavagesTextBox.Text) ? int.MaxValue : (int.Parse(missedCleavagesTextBox.Text, NumberStyles.Any, CultureInfo.InvariantCulture)); int MinPeptideLength = (int.Parse(MinPeptideLengthTextBox.Text, NumberStyles.Any, CultureInfo.InvariantCulture)); int MaxPeptideLength = string.IsNullOrEmpty(MaxPeptideLengthTextBox.Text) ? int.MaxValue : (int.Parse(MaxPeptideLengthTextBox.Text, NumberStyles.Any, CultureInfo.InvariantCulture)); int MaxModificationIsoforms = (int.Parse(maxModificationIsoformsTextBox.Text, CultureInfo.InvariantCulture)); InitiatorMethionineBehavior InitiatorMethionineBehavior = ((InitiatorMethionineBehavior)initiatorMethionineBehaviorComboBox.SelectedIndex); DigestionParams digestionParamsToSave = new DigestionParams( protease: protease.Name, maxMissedCleavages: MaxMissedCleavages, minPeptideLength: MinPeptideLength, maxPeptideLength: MaxPeptideLength, maxModificationIsoforms: MaxModificationIsoforms, initiatorMethionineBehavior: InitiatorMethionineBehavior); Tolerance ProductMassTolerance; if (productMassToleranceComboBox.SelectedIndex == 0) { ProductMassTolerance = new AbsoluteTolerance(double.Parse(productMassToleranceTextBox.Text, CultureInfo.InvariantCulture)); } else { ProductMassTolerance = new PpmTolerance(double.Parse(productMassToleranceTextBox.Text, CultureInfo.InvariantCulture)); } Tolerance PrecursorMassTolerance; if (cbbXLprecusorMsTl.SelectedIndex == 0) { PrecursorMassTolerance = new AbsoluteTolerance(double.Parse(XLPrecusorMsTlTextBox.Text, CultureInfo.InvariantCulture)); } else { PrecursorMassTolerance = new PpmTolerance(double.Parse(XLPrecusorMsTlTextBox.Text, CultureInfo.InvariantCulture)); } TheTask.XlSearchParameters.WriteOutputForPercolator = ckbPercolator.IsChecked.Value; TheTask.XlSearchParameters.WritePepXml = ckbPepXML.IsChecked.Value; var listOfModsVariable = new List <(string, string)>(); foreach (var heh in VariableModTypeForTreeViewObservableCollection) { listOfModsVariable.AddRange(heh.Children.Where(b => b.Use).Select(b => (b.Parent.DisplayName, b.ModName))); } var listOfModsFixed = new List <(string, string)>(); foreach (var heh in FixedModTypeForTreeViewObservableCollection) { listOfModsFixed.AddRange(heh.Children.Where(b => b.Use).Select(b => (b.Parent.DisplayName, b.ModName))); } CommonParameters commonParamsToSave = new CommonParameters( precursorMassTolerance: PrecursorMassTolerance, taskDescriptor: OutputFileNameTextBox.Text != "" ? OutputFileNameTextBox.Text : "XLSearchTask", productMassTolerance: ProductMassTolerance, doPrecursorDeconvolution: deconvolutePrecursors.IsChecked.Value, useProvidedPrecursorInfo: useProvidedPrecursor.IsChecked.Value, digestionParams: digestionParamsToSave, trimMs1Peaks: trimMs1.IsChecked.Value, trimMsMsPeaks: trimMsMs.IsChecked.Value, numberOfPeaksToKeepPerWindow: int.Parse(TopNPeaksTextBox.Text), minimumAllowedIntensityRatioToBasePeak: double.Parse(MinRatioTextBox.Text, CultureInfo.InvariantCulture), dissociationType: dissociationType, childScanDissociationType: childDissociationType, scoreCutoff: double.Parse(minScoreAllowed.Text, CultureInfo.InvariantCulture), totalPartitions: int.Parse(numberOfDatabaseSearchesTextBox.Text, CultureInfo.InvariantCulture), listOfModsVariable: listOfModsVariable, listOfModsFixed: listOfModsFixed, assumeOrphanPeaksAreZ1Fragments: protease.Name != "top-down"); TheTask.CommonParameters = commonParamsToSave; DialogResult = true; }
private static Tuple <List <PeptideSpectralMatch>, Dictionary <CompactPeptideBase, HashSet <PeptideWithSetModifications> >, MassDiffAcceptor, bool, CompactPeptideBase, CompactPeptideBase> GetInfo(bool localizeable) { CommonParameters CommonParameters = new CommonParameters { DigestionParams = new DigestionParams { MinPeptideLength = null, MaxMissedCleavages = 0, InitiatorMethionineBehavior = InitiatorMethionineBehavior.Retain, MaxModsForPeptide = 1, MaxModificationIsoforms = 2, }, ScoreCutoff = 1 }; // Alanine = Glycine + CH2 Protein protein1 = new Protein("MA", "protein1"); Protein protein2 = new Protein("MG", "protein2"); Protein protein3; double monoisotopicMass = Chemistry.ChemicalFormula.ParseFormula("CH2").MonoisotopicMass; ModificationMotif.TryGetMotif("G", out ModificationMotif motif1); ModificationMotif.TryGetMotif("A", out ModificationMotif motif2); TerminusLocalization modificationSites = TerminusLocalization.Any; List <ModificationWithMass> allKnownFixedModifications = new List <ModificationWithMass> { new ModificationWithMass("CH2 on Glycine", null, motif1, modificationSites, monoisotopicMass) }; List <ModificationWithMass> variableModifications; ModificationWithMass alanineMod = new ModificationWithMass("CH2 on Alanine", null, motif2, modificationSites, monoisotopicMass); if (localizeable) { variableModifications = new List <ModificationWithMass>(); IDictionary <int, List <Modification> > oneBasedModifications = new Dictionary <int, List <Modification> > { { 2, new List <Modification> { alanineMod } } }; protein3 = new Protein("MA", "protein3", oneBasedModifications: oneBasedModifications); } else { variableModifications = new List <ModificationWithMass>(); variableModifications = new List <ModificationWithMass> { alanineMod }; protein3 = new Protein("MA", "protein3"); } var pepWithSetModifications1 = protein1.Digest(CommonParameters.DigestionParams, allKnownFixedModifications, variableModifications).First(); var pepWithSetModifications2 = protein2.Digest(CommonParameters.DigestionParams, allKnownFixedModifications, variableModifications).First(); var pepWithSetModifications3 = protein3.Digest(CommonParameters.DigestionParams, allKnownFixedModifications, variableModifications).Last(); CompactPeptide compactPeptide1 = new CompactPeptide(pepWithSetModifications1, TerminusType.None); CompactPeptide compactPeptideDuplicate = new CompactPeptide(pepWithSetModifications2, TerminusType.None); Assert.AreEqual(compactPeptide1, compactPeptideDuplicate); CompactPeptide compactPeptide2 = new CompactPeptide(pepWithSetModifications3, TerminusType.None); string fullFilePath = null; int precursorCharge = 0; TestDataFile testDataFile = new TestDataFile(); IMsDataScanWithPrecursor <IMzSpectrum <IMzPeak> > mzLibScan = testDataFile.GetOneBasedScan(2) as IMsDataScanWithPrecursor <IMzSpectrum <IMzPeak> >; Ms2ScanWithSpecificMass scan = new Ms2ScanWithSpecificMass(mzLibScan, 0, precursorCharge, fullFilePath); int scanIndex = 0; double score = 0; int notch = 0; PeptideSpectralMatch psm1 = new PeptideSpectralMatch(compactPeptide1, notch, score, scanIndex, scan); psm1.SetFdrValues(0, 0, 0, 0, 0, 0, 0, 0, 0, false); PeptideSpectralMatch psm2 = new PeptideSpectralMatch(compactPeptide1, notch, score, scanIndex, scan); psm2.SetFdrValues(0, 0, 0, 0, 0, 0, 0, 0, 0, false); PeptideSpectralMatch psm3 = new PeptideSpectralMatch(compactPeptide2, notch, score, scanIndex, scan); psm3.SetFdrValues(0, 0, 0, 0, 0, 0, 0, 0, 0, false); var newPsms = new List <PeptideSpectralMatch> { psm1, psm2, psm3 }; MassDiffAcceptor massDiffAcceptors = new SinglePpmAroundZeroSearchMode(5); SequencesToActualProteinPeptidesEngine stappe = new SequencesToActualProteinPeptidesEngine(newPsms, new List <Protein> { protein1, protein2, protein3 }, allKnownFixedModifications, variableModifications, new List <ProductType> { ProductType.B, ProductType.Y }, new List <IDigestionParams> { CommonParameters.DigestionParams }, CommonParameters.ReportAllAmbiguity, new List <string>()); var haha = (SequencesToActualProteinPeptidesEngineResults)stappe.Run(); var compactPeptideToProteinPeptideMatching = haha.CompactPeptideToProteinPeptideMatching; Assert.AreEqual(2, compactPeptideToProteinPeptideMatching.Count); psm1.MatchToProteinLinkedPeptides(compactPeptideToProteinPeptideMatching); bool noOneHitWonders = false; return(new Tuple <List <PeptideSpectralMatch>, Dictionary <CompactPeptideBase, HashSet <PeptideWithSetModifications> >, MassDiffAcceptor, bool, CompactPeptideBase, CompactPeptideBase> ( newPsms, compactPeptideToProteinPeptideMatching, massDiffAcceptors, noOneHitWonders, compactPeptide1, compactPeptide2 )); }
private void SaveButton_Click(object sender, RoutedEventArgs e) { string fieldNotUsed = "1"; if (!GlobalGuiSettings.CheckTaskSettingsValidity(precursorMassToleranceTextBox.Text, productMassToleranceTextBox.Text, missedCleavagesTextBox.Text, maxModificationIsoformsTextBox.Text, MinPeptideLengthTextBox.Text, MaxPeptideLengthTextBox.Text, maxThreadsTextBox.Text, minScoreAllowed.Text, fieldNotUsed, fieldNotUsed, fieldNotUsed, fieldNotUsed, fieldNotUsed, null, null, fieldNotUsed, fieldNotUsed, fieldNotUsed, fieldNotUsed)) { return; } Protease protease = (Protease)proteaseComboBox.SelectedItem; int MaxMissedCleavages = string.IsNullOrEmpty(missedCleavagesTextBox.Text) ? int.MaxValue : (int.Parse(missedCleavagesTextBox.Text, CultureInfo.InvariantCulture)); int MinPeptideLength = int.Parse(MinPeptideLengthTextBox.Text, NumberStyles.Any, CultureInfo.InvariantCulture); int MaxPeptideLength = string.IsNullOrEmpty(MaxPeptideLengthTextBox.Text) ? int.MaxValue : (int.Parse(MaxPeptideLengthTextBox.Text, NumberStyles.Any, CultureInfo.InvariantCulture)); int MinVariantDepth = int.Parse(MinVariantDepthTextBox.Text, NumberStyles.Any, CultureInfo.InvariantCulture); int MaxHeterozygousVariants = int.Parse(MaxHeterozygousVariantsTextBox.Text, NumberStyles.Any, CultureInfo.InvariantCulture); int MaxModificationIsoforms = int.Parse(maxModificationIsoformsTextBox.Text, CultureInfo.InvariantCulture); DissociationType dissociationType = GlobalVariables.AllSupportedDissociationTypes[DissociationTypeComboBox.SelectedItem.ToString()]; CustomFragmentationWindow.Close(); DigestionParams digestionParamsToSave = new DigestionParams( protease: protease.Name, maxMissedCleavages: MaxMissedCleavages, minPeptideLength: MinPeptideLength, maxPeptideLength: MaxPeptideLength, maxModificationIsoforms: MaxModificationIsoforms); var listOfModsVariable = new List <(string, string)>(); foreach (var heh in VariableModTypeForTreeViewObservableCollection) { listOfModsVariable.AddRange(heh.Children.Where(b => b.Use).Select(b => (b.Parent.DisplayName, b.ModName))); } if (!GlobalGuiSettings.VariableModCheck(listOfModsVariable)) { return; } var listOfModsFixed = new List <(string, string)>(); foreach (var heh in FixedModTypeForTreeViewObservableCollection) { listOfModsFixed.AddRange(heh.Children.Where(b => b.Use).Select(b => (b.Parent.DisplayName, b.ModName))); } Tolerance ProductMassTolerance; if (productMassToleranceComboBox.SelectedIndex == 0) { ProductMassTolerance = new AbsoluteTolerance(double.Parse(productMassToleranceTextBox.Text, CultureInfo.InvariantCulture)); } else { ProductMassTolerance = new PpmTolerance(double.Parse(productMassToleranceTextBox.Text, CultureInfo.InvariantCulture)); } Tolerance PrecursorMassTolerance; if (precursorMassToleranceComboBox.SelectedIndex == 0) { PrecursorMassTolerance = new AbsoluteTolerance(double.Parse(precursorMassToleranceTextBox.Text, CultureInfo.InvariantCulture)); } else { PrecursorMassTolerance = new PpmTolerance(double.Parse(precursorMassToleranceTextBox.Text, CultureInfo.InvariantCulture)); } bool parseMaxThreadsPerFile = int.Parse(maxThreadsTextBox.Text, CultureInfo.InvariantCulture) <= Environment.ProcessorCount && int.Parse(maxThreadsTextBox.Text, CultureInfo.InvariantCulture) > 0; CommonParameters commonParamsToSave = new CommonParameters( taskDescriptor: OutputFileNameTextBox.Text != "" ? OutputFileNameTextBox.Text : "CalibrateTask", maxThreadsToUsePerFile: parseMaxThreadsPerFile ? int.Parse(maxThreadsTextBox.Text, CultureInfo.InvariantCulture) : new CommonParameters().MaxThreadsToUsePerFile, digestionParams: digestionParamsToSave, dissociationType: dissociationType, scoreCutoff: double.Parse(minScoreAllowed.Text, CultureInfo.InvariantCulture), listOfModsFixed: listOfModsFixed, listOfModsVariable: listOfModsVariable, productMassTolerance: ProductMassTolerance, precursorMassTolerance: PrecursorMassTolerance, assumeOrphanPeaksAreZ1Fragments: protease.Name != "top-down", minVariantDepth: MinVariantDepth, maxHeterozygousVariants: MaxHeterozygousVariants); TheTask.CommonParameters = commonParamsToSave; DialogResult = true; }
public ModernSearchEngine(PeptideSpectralMatch[] globalPsms, Ms2ScanWithSpecificMass[] listOfSortedms2Scans, List <CompactPeptide> peptideIndex, List <int>[] fragmentIndex, List <ProductType> lp, int currentPartition, CommonParameters commonParameters, MassDiffAcceptor massDiffAcceptor, double maximumMassThatFragmentIonScoreIsDoubled, List <string> nestedIds) : base(commonParameters, nestedIds) { PeptideSpectralMatches = globalPsms; ListOfSortedms2Scans = listOfSortedms2Scans; PeptideIndex = peptideIndex; FragmentIndex = fragmentIndex; ProductTypes = lp; CurrentPartition = currentPartition + 1; MassDiffAcceptor = massDiffAcceptor; DissociationTypes = DetermineDissociationType(lp); MaxMassThatFragmentIonScoreIsDoubled = maximumMassThatFragmentIonScoreIsDoubled; }
public unsafe Dataset(double[][] sampleValuePerColumn, int[][] sampleIndicesPerColumn, int numCol, int[] sampleNonZeroCntPerColumn, int numSampleRow, int numTotalRow, CommonParameters cp, DatasetParameters dp, float[] labels = null, float[] weights = null, int[] groups = null) { CommonParameters = cp; DatasetParameters = dp; var pmString = ParamsToString(cp, dp); _handle = IntPtr.Zero; // Use GCHandle to pin the memory, avoid the memory relocation. GCHandle[] gcValues = new GCHandle[numCol]; GCHandle[] gcIndices = new GCHandle[numCol]; try { double *[] ptrArrayValues = new double *[numCol]; int *[] ptrArrayIndices = new int *[numCol]; for (int i = 0; i < numCol; i++) { gcValues[i] = GCHandle.Alloc(sampleValuePerColumn[i], GCHandleType.Pinned); ptrArrayValues[i] = (double *)gcValues[i].AddrOfPinnedObject().ToPointer(); gcIndices[i] = GCHandle.Alloc(sampleIndicesPerColumn[i], GCHandleType.Pinned); ptrArrayIndices[i] = (int *)gcIndices[i].AddrOfPinnedObject().ToPointer(); } ; fixed(double **ptrValues = ptrArrayValues) fixed(int **ptrIndices = ptrArrayIndices) fixed(int *ptrSampleNonZeroCntPerColumn = sampleNonZeroCntPerColumn) { PInvokeException.Check(PInvoke.DatasetCreateFromSampledColumn( (IntPtr)ptrValues, (IntPtr)ptrIndices, numCol, ptrSampleNonZeroCntPerColumn, numSampleRow, numTotalRow, pmString, ref _handle), nameof(PInvoke.DatasetCreateFromSampledColumn)); } } finally { for (int i = 0; i < numCol; i++) { if (gcValues[i].IsAllocated) { gcValues[i].Free(); } if (gcIndices[i].IsAllocated) { gcIndices[i].Free(); } } ; } if (labels != null) { SetLabels(labels); } if (weights != null) { SetWeights(weights); } if (groups != null) { SetGroups(groups); } if (NumFeatures != numCol) { throw new Exception("Expected GetNumCols to be equal to numCol"); } if (NumRows != numTotalRow) { throw new Exception("Expected GetNumRows to be equal to numTotalRow"); } }
private Dataset(IntPtr h, CommonParameters cp, DatasetParameters dp) { _handle = h; CommonParameters = cp; DatasetParameters = dp; }
public static void TestCompIons_ModernSearch() { var myMsDataFile = new TestDataFile(); var variableModifications = new List <Modification>(); var fixedModifications = new List <Modification>(); var localizeableModifications = new List <Modification>(); Dictionary <Modification, ushort> modsDictionary = new Dictionary <Modification, ushort>(); foreach (var mod in fixedModifications) { modsDictionary.Add(mod, 0); } int ii = 1; foreach (var mod in variableModifications) { modsDictionary.Add(mod, (ushort)ii); ii++; } foreach (var mod in localizeableModifications) { modsDictionary.Add(mod, (ushort)ii); ii++; } var proteinList = new List <Protein> { new Protein("MNNNKQQQ", null) }; SearchParameters SearchParameters = new SearchParameters { MassDiffAcceptorType = MassDiffAcceptorType.Exact, SearchTarget = true, }; List <DigestionMotif> motifs = new List <DigestionMotif> { new DigestionMotif("K", null, 1, null) }; Protease protease = new Protease("singleN4", CleavageSpecificity.Full, null, null, motifs); ProteaseDictionary.Dictionary.Add(protease.Name, protease); CommonParameters CommonParameters = new CommonParameters(digestionParams: new DigestionParams(protease: protease.Name, minPeptideLength: 1), scoreCutoff: 1); var fsp = new List <(string fileName, CommonParameters fileSpecificParameters)>(); fsp.Add(("", CommonParameters)); CommonParameters withCompIons = new CommonParameters(digestionParams: new DigestionParams(protease: protease.Name, minPeptideLength: 1), scoreCutoff: 1, addCompIons: true); var fspComp = new List <(string fileName, CommonParameters fileSpecificParameters)>(); fspComp.Add(("", CommonParameters)); var indexEngine = new IndexingEngine(proteinList, variableModifications, fixedModifications, null, null, null, 1, DecoyType.Reverse, CommonParameters, fsp, SearchParameters.MaxFragmentSize, false, new List <FileInfo>(), TargetContaminantAmbiguity.RemoveContaminant, new List <string>()); var indexResults = (IndexingResults)indexEngine.Run(); Tolerance DeconvolutionMassTolerance = new PpmTolerance(5); var listOfSortedms2Scans = MetaMorpheusTask.GetMs2Scans(myMsDataFile, null, new CommonParameters()).OrderBy(b => b.PrecursorMass).ToArray(); MassDiffAcceptor massDiffAcceptor = SearchTask.GetMassDiffAcceptor(CommonParameters.PrecursorMassTolerance, SearchParameters.MassDiffAcceptorType, SearchParameters.CustomMdac); // without complementary ions PeptideSpectralMatch[] allPsmsArray = new PeptideSpectralMatch[listOfSortedms2Scans.Length]; new ModernSearchEngine(allPsmsArray, listOfSortedms2Scans, indexResults.PeptideIndex, indexResults.FragmentIndex, 0, CommonParameters, fsp, massDiffAcceptor, SearchParameters.MaximumMassThatFragmentIonScoreIsDoubled, new List <string>()).Run(); // with complementary ions PeptideSpectralMatch[] allPsmsArray2 = new PeptideSpectralMatch[listOfSortedms2Scans.Length]; new ModernSearchEngine(allPsmsArray2, listOfSortedms2Scans, indexResults.PeptideIndex, indexResults.FragmentIndex, 0, withCompIons, fspComp, massDiffAcceptor, SearchParameters.MaximumMassThatFragmentIonScoreIsDoubled, new List <string>()).Run(); // Single search mode Assert.AreEqual(allPsmsArray.Length, allPsmsArray2.Length); // Single ms2 scan Assert.AreEqual(allPsmsArray.Length, allPsmsArray2.Length); Assert.That(allPsmsArray[0] != null); Assert.That(allPsmsArray2[0] != null); Assert.IsTrue(allPsmsArray2[0].Score > 1); Assert.AreEqual(allPsmsArray[0].ScanNumber, allPsmsArray2[0].ScanNumber); Assert.IsTrue(allPsmsArray2[0].Score <= allPsmsArray[0].Score * 2 && allPsmsArray2[0].Score > allPsmsArray[0].Score + 3); }
private readonly string OutputFolder; // used for storing PEP training models public FdrAnalysisEngine(List <PeptideSpectralMatch> psms, int massDiffAcceptorNumNotches, CommonParameters commonParameters, List <(string fileName, CommonParameters fileSpecificParameters)> fileSpecificParameters, List <string> nestedIds, string analysisType = "PSM", string outputFolder = null) : base(commonParameters, fileSpecificParameters, nestedIds)
public HomeParameters(CommonParameters param) : base(param) { }
public CrosslinkSearchEngine(List <CrosslinkSpectralMatch>[] globalCsms, Ms2ScanWithSpecificMass[] listOfSortedms2Scans, List <PeptideWithSetModifications> peptideIndex, List <int>[] fragmentIndex, List <int>[] secondFragmentIndex, int currentPartition, CommonParameters commonParameters, Crosslinker crosslinker, bool CrosslinkSearchTop, int CrosslinkSearchTopNum, bool quench_H2O, bool quench_NH2, bool quench_Tris, List <string> nestedIds) : base(null, listOfSortedms2Scans, peptideIndex, fragmentIndex, currentPartition, commonParameters, new OpenSearchMode(), 0, nestedIds) { this.GlobalCsms = globalCsms; this.Crosslinker = crosslinker; this.CrosslinkSearchTopN = CrosslinkSearchTop; this.TopN = CrosslinkSearchTopNum; this.QuenchH2O = quench_H2O; this.QuenchNH2 = quench_NH2; this.QuenchTris = quench_Tris; SecondFragmentIndex = secondFragmentIndex; if (CommonParameters.ChildScanDissociationType != DissociationType.Unknown && DissociationTypeGenerateSameTypeOfIons(CommonParameters.DissociationType, CommonParameters.ChildScanDissociationType)) { SecondFragmentIndex = FragmentIndex; } GenerateCrosslinkModifications(crosslinker); AllCrosslinkerSites = Crosslinker.CrosslinkerModSites.ToCharArray().Concat(Crosslinker.CrosslinkerModSites2.ToCharArray()).Distinct().ToArray(); if (commonParameters.PrecursorMassTolerance is PpmTolerance) { XLPrecusorSearchMode = new SinglePpmAroundZeroSearchMode(commonParameters.PrecursorMassTolerance.Value); } else { XLPrecusorSearchMode = new SingleAbsoluteAroundZeroSearchMode(commonParameters.PrecursorMassTolerance.Value); } }
/// <summary> /// Sets claims in the query. Use when the AAD admin has enabled conditional access. Acquiring the token normally will result in a /// <see cref="MsalServiceException"/> with the <see cref="MsalServiceException.Claims"/> property set. Retry the /// token acquisition, and use this value in the <see cref="WithClaims(string)"/> method. See https://aka.ms/msal-exceptions for details /// </summary> /// <param name="claims">A string with one or multiple claims.</param> /// <returns>The builder to chain .With methods</returns> public T WithClaims(string claims) { CommonParameters.AddApiTelemetryFeature(ApiTelemetryFeature.WithClaims); CommonParameters.Claims = claims; return((T)this); }
/// <summary> /// Localizes the deadend mod to a residue /// </summary> private CrosslinkSpectralMatch LocalizeDeadEndSite(PeptideWithSetModifications originalPeptide, Ms2ScanWithSpecificMass theScan, CommonParameters commonParameters, List <int> possiblePositions, Modification deadEndMod, int notch, int scanIndex, int peptideIndex) { double bestScore = 0; List <MatchedFragmentIon> bestMatchingFragments = new List <MatchedFragmentIon>(); PeptideWithSetModifications bestLocalizedPeptide = null; int bestPosition = 0; foreach (int location in possiblePositions) { Dictionary <int, Modification> mods = originalPeptide.AllModsOneIsNterminus.ToDictionary(p => p.Key, p => p.Value); if (mods.ContainsKey(location + 1)) { var alreadyAnnotatedMod = mods[location + 1]; double combinedMass = mods[location + 1].MonoisotopicMass.Value + deadEndMod.MonoisotopicMass.Value; Modification combinedMod = new Modification(_originalId: alreadyAnnotatedMod.OriginalId + "+" + deadEndMod.OriginalId, _modificationType: "Crosslink", _target: alreadyAnnotatedMod.Target, _locationRestriction: "Anywhere.", _monoisotopicMass: combinedMass); mods[location + 1] = combinedMod; } else { mods.Add(location + 1, deadEndMod); } var localizedPeptide = new PeptideWithSetModifications(originalPeptide.Protein, originalPeptide.DigestionParams, originalPeptide.OneBasedStartResidueInProtein, originalPeptide.OneBasedEndResidueInProtein, originalPeptide.CleavageSpecificityForFdrCategory, originalPeptide.PeptideDescription, originalPeptide.MissedCleavages, mods, originalPeptide.NumFixedMods); var products = localizedPeptide.Fragment(commonParameters.DissociationType, FragmentationTerminus.Both).ToList(); var matchedFragmentIons = MatchFragmentIons(theScan, products, commonParameters); double score = CalculatePeptideScore(theScan.TheScan, matchedFragmentIons); if (score > bestScore) { bestMatchingFragments = matchedFragmentIons; bestScore = score; bestLocalizedPeptide = localizedPeptide; bestPosition = location; } } if (bestScore < commonParameters.ScoreCutoff) { return(null); } var csm = new CrosslinkSpectralMatch(bestLocalizedPeptide, notch, bestScore, scanIndex, theScan, originalPeptide.DigestionParams, bestMatchingFragments); if (deadEndMod == TrisDeadEnd) { csm.CrossType = PsmCrossType.DeadEndTris; } else if (deadEndMod == H2ODeadEnd) { csm.CrossType = PsmCrossType.DeadEndH2O; } else if (deadEndMod == NH2DeadEnd) { csm.CrossType = PsmCrossType.DeadEndNH2; } csm.LinkPositions = new List <int> { bestPosition }; csm.XlRank = new List <int> { peptideIndex }; return(csm); }
public LocalizationEngine(IEnumerable <PeptideSpectralMatch> allResultingIdentifications, MsDataFile myMsDataFile, CommonParameters commonParameters, List <string> nestedIds) : base(commonParameters, nestedIds) { AllResultingIdentifications = allResultingIdentifications; MyMsDataFile = myMsDataFile; }
/// <summary> /// Localizes the loop to a begin and end residue /// </summary> private CrosslinkSpectralMatch LocalizeLoopSites(PeptideWithSetModifications originalPeptide, Ms2ScanWithSpecificMass theScan, CommonParameters commonParameters, List <int> possiblePositions, Modification loopMod, int notch, int scanIndex, int peptideIndex) { var possibleFragmentSets = CrosslinkedPeptide.XlLoopGetTheoreticalFragments(commonParameters.DissociationType, Loop, possiblePositions, originalPeptide); double bestScore = 0; Tuple <int, int> bestModPositionSites = null; List <MatchedFragmentIon> bestMatchingFragments = new List <MatchedFragmentIon>(); foreach (var setOfPositions in possibleFragmentSets) { var matchedFragmentIons = MatchFragmentIons(theScan, setOfPositions.Value, commonParameters); double score = CalculatePeptideScore(theScan.TheScan, matchedFragmentIons); if (score > bestScore) { bestMatchingFragments = matchedFragmentIons; bestScore = score; bestModPositionSites = setOfPositions.Key; } } if (bestScore < commonParameters.ScoreCutoff) { return(null); } var csm = new CrosslinkSpectralMatch(originalPeptide, notch, bestScore, scanIndex, theScan, originalPeptide.DigestionParams, bestMatchingFragments) { CrossType = PsmCrossType.Loop, XlRank = new List <int> { peptideIndex }, LinkPositions = new List <int> { bestModPositionSites.Item1, bestModPositionSites.Item2 } }; return(csm); }
private void SaveButton_Click(object sender, RoutedEventArgs e) { CommonParameters CommonParamsToSave = new CommonParameters(); DigestionParams digestionParamsToSave = new DigestionParams(); digestionParamsToSave.MaxMissedCleavages = int.Parse(missedCleavagesTextBox.Text, CultureInfo.InvariantCulture); digestionParamsToSave.MinPeptideLength = int.TryParse(txtMinPeptideLength.Text, NumberStyles.Any, CultureInfo.InvariantCulture, out int temp) ? (int?)temp : null; digestionParamsToSave.MaxPeptideLength = int.TryParse(txtMaxPeptideLength.Text, NumberStyles.Any, CultureInfo.InvariantCulture, out temp) ? (int?)temp : null; digestionParamsToSave.Protease = (Protease)proteaseComboBox.SelectedItem; digestionParamsToSave.MaxModificationIsoforms = int.Parse(maxModificationIsoformsTextBox.Text, CultureInfo.InvariantCulture); CommonParamsToSave.DigestionParams = digestionParamsToSave; CommonParamsToSave.BIons = bCheckBox.IsChecked.Value; CommonParamsToSave.YIons = yCheckBox.IsChecked.Value; CommonParamsToSave.CIons = cCheckBox.IsChecked.Value; CommonParamsToSave.ZdotIons = zdotCheckBox.IsChecked.Value; //CommonParamsToSave.ConserveMemory = conserveMemoryCheckBox.IsChecked.Value; CommonParamsToSave.ScoreCutoff = double.Parse(minScoreAllowed.Text, CultureInfo.InvariantCulture); //TheTask.CalibrationParameters.WriteIntermediateFiles = writeIntermediateFilesCheckBox.IsChecked.Value; if (OutputFileNameTextBox.Text != "") { CommonParamsToSave.TaskDescriptor = OutputFileNameTextBox.Text; } else { CommonParamsToSave.TaskDescriptor = "CalibrateTask"; } var listOfModsVariable = new List <(string, string)>(); foreach (var heh in variableModTypeForTreeViewObservableCollection) { listOfModsVariable.AddRange(heh.Children.Where(b => b.Use).Select(b => (b.Parent.DisplayName, b.DisplayName))); } CommonParamsToSave.ListOfModsVariable = listOfModsVariable; var listOfModsFixed = new List <(string, string)>(); foreach (var heh in fixedModTypeForTreeViewObservableCollection) { listOfModsFixed.AddRange(heh.Children.Where(b => b.Use).Select(b => (b.Parent.DisplayName, b.DisplayName))); } CommonParamsToSave.ListOfModsFixed = listOfModsFixed; //if (localizeAllCheckBox.IsChecked.Value) { CommonParamsToSave.ListOfModTypesLocalize = null; CommonParamsToSave.LocalizeAll = true; } //else //{ // CommonParamsToSave.LocalizeAll = false; // CommonParamsToSave.ListOfModTypesLocalize = localizeModTypeForTreeViewObservableCollection.Where(b => b.Use.HasValue && b.Use.Value).Select(b => b.DisplayName).ToList(); //} if (productMassToleranceComboBox.SelectedIndex == 0) { CommonParamsToSave.ProductMassTolerance = new AbsoluteTolerance(double.Parse(productMassToleranceTextBox.Text, CultureInfo.InvariantCulture)); } else { CommonParamsToSave.ProductMassTolerance = new PpmTolerance(double.Parse(productMassToleranceTextBox.Text, CultureInfo.InvariantCulture)); } if (precursorMassToleranceComboBox.SelectedIndex == 0) { CommonParamsToSave.PrecursorMassTolerance = new AbsoluteTolerance(double.Parse(precursorMassToleranceTextBox.Text, CultureInfo.InvariantCulture)); } else { CommonParamsToSave.PrecursorMassTolerance = new PpmTolerance(double.Parse(precursorMassToleranceTextBox.Text, CultureInfo.InvariantCulture)); } //if (int.TryParse(maxDegreesOfParallelism.Text, out int jsakdf)) // CommonParamsToSave.MaxParallelFilesToAnalyze = jsakdf; TheTask.CommonParameters = CommonParamsToSave; DialogResult = true; }
public static List <PeptideSpectralMatch> ResolveFdrCategorySpecificPsms(List <PeptideSpectralMatch>[] AllPsms, int numNotches, string taskId, CommonParameters commonParameters) { //update all psms with peptide info AllPsms.ToList() .Where(psmArray => psmArray != null).ToList() .ForEach(psmArray => psmArray.Where(psm => psm != null).ToList() .ForEach(psm => psm.ResolveAllAmbiguities())); foreach (List <PeptideSpectralMatch> psmsArray in AllPsms) { if (psmsArray != null) { List <PeptideSpectralMatch> cleanedPsmsArray = psmsArray.Where(b => b != null).OrderByDescending(b => b.Score) .ThenBy(b => b.PeptideMonisotopicMass.HasValue ? Math.Abs(b.ScanPrecursorMass - b.PeptideMonisotopicMass.Value) : double.MaxValue) .GroupBy(b => (b.FullFilePath, b.ScanNumber, b.PeptideMonisotopicMass)).Select(b => b.First()).ToList(); new FdrAnalysisEngine(cleanedPsmsArray, numNotches, commonParameters, new List <string> { taskId }).Run(); for (int i = 0; i < psmsArray.Count; i++) { if (psmsArray[i] != null) { if (psmsArray[i].FdrInfo == null) //if it was grouped in the cleanedPsmsArray { psmsArray[i] = null; } } } } } int[] ranking = new int[AllPsms.Length]; //high int is good ranking List <int> indexesOfInterest = new List <int>(); for (int i = 0; i < ranking.Length; i++) { if (AllPsms[i] != null) { ranking[i] = AllPsms[i].Where(x => x != null).Count(x => x.FdrInfo.QValue <= 0.01); //set ranking as number of psms above 1% FDR indexesOfInterest.Add(i); } } //get the index of the category with the highest ranking int majorCategoryIndex = indexesOfInterest[0]; for (int i = 1; i < indexesOfInterest.Count; i++) { int currentCategoryIndex = indexesOfInterest[i]; if (ranking[currentCategoryIndex] > ranking[majorCategoryIndex]) { majorCategoryIndex = currentCategoryIndex; } } //update other category q-values //There's a chance of weird categories getting a random decoy before a random target, but we don't want to give that target a q value of zero. //We can't just take the q of the first decoy, because if the target wasn't random (score = 40), but there are no other targets before the decoy (score = 5), then we're incorrectly dinging the target //The current solution is such that if a minor category has a lower q value than it's corresponding score in the major category, then its q-value is changed to what it would be in the major category List <PeptideSpectralMatch> majorCategoryPsms = AllPsms[majorCategoryIndex].Where(x => x != null).OrderByDescending(x => x.Score).ToList(); //get sorted major category for (int i = 0; i < indexesOfInterest.Count; i++) { int minorCategoryIndex = indexesOfInterest[i]; if (minorCategoryIndex != majorCategoryIndex) { List <PeptideSpectralMatch> minorCategoryPsms = AllPsms[minorCategoryIndex].Where(x => x != null).OrderByDescending(x => x.Score).ToList(); //get sorted minor category int minorPsmIndex = 0; int majorPsmIndex = 0; while (minorPsmIndex < minorCategoryPsms.Count && majorPsmIndex < majorCategoryPsms.Count) //while in the lists { PeptideSpectralMatch majorPsm = majorCategoryPsms[majorPsmIndex]; PeptideSpectralMatch minorPsm = minorCategoryPsms[minorPsmIndex]; //major needs to be a lower score than the minor if (majorPsm.Score > minorPsm.Score) { majorPsmIndex++; } else { if (majorPsm.FdrInfo.QValue > minorPsm.FdrInfo.QValue) { minorPsm.FdrInfo.QValue = majorPsm.FdrInfo.QValue; } minorPsmIndex++; } } //wrap up if we hit the end of the major category while (minorPsmIndex < minorCategoryPsms.Count) { PeptideSpectralMatch majorPsm = majorCategoryPsms[majorPsmIndex - 1]; //-1 because it's out of index right now PeptideSpectralMatch minorPsm = minorCategoryPsms[minorPsmIndex]; if (majorPsm.FdrInfo.QValue > minorPsm.FdrInfo.QValue) { minorPsm.FdrInfo.QValue = majorPsm.FdrInfo.QValue; } minorPsmIndex++; } } } int numTotalSpectraWithPrecursors = AllPsms[indexesOfInterest[0]].Count; List <PeptideSpectralMatch> bestPsmsList = new List <PeptideSpectralMatch>(); for (int i = 0; i < numTotalSpectraWithPrecursors; i++) { PeptideSpectralMatch bestPsm = null; double lowestQ = double.MaxValue; int bestIndex = -1; foreach (int index in indexesOfInterest) //foreach category { PeptideSpectralMatch currentPsm = AllPsms[index][i]; if (currentPsm != null) { double currentQValue = currentPsm.FdrInfo.QValue; if (currentQValue < lowestQ || //if the new one is better (currentQValue == lowestQ && currentPsm.Score > bestPsm.Score)) { if (bestIndex != -1) { //remove the old one so we don't use it for fdr later AllPsms[bestIndex][i] = null; } bestPsm = currentPsm; lowestQ = currentQValue; bestIndex = index; } else //remove the old one so we don't use it for fdr later { AllPsms[index][i] = null; } } } if (bestPsm != null) { bestPsmsList.Add(bestPsm); } } //It's probable that psms from some categories were removed by psms from other categories. //however, the fdr is still affected by their presence, since it was calculated before their removal. foreach (List <PeptideSpectralMatch> psmsArray in AllPsms) { if (psmsArray != null) { List <PeptideSpectralMatch> cleanedPsmsArray = psmsArray.Where(b => b != null).OrderByDescending(b => b.Score) .ThenBy(b => b.PeptideMonisotopicMass.HasValue ? Math.Abs(b.ScanPrecursorMass - b.PeptideMonisotopicMass.Value) : double.MaxValue) .ToList(); new FdrAnalysisEngine(cleanedPsmsArray, numNotches, commonParameters, new List <string> { taskId }).Run(); } } return(bestPsmsList.OrderBy(b => b.FdrInfo.QValue).ThenByDescending(b => b.Score).ToList()); }
public static void TestIndexEngine() { var proteinList = new List <Protein> { new Protein("MNNNKQQQ", null) }; var variableModifications = new List <Modification>(); var fixedModifications = new List <Modification>(); var localizeableModifications = new List <Modification>(); Dictionary <Modification, ushort> modsDictionary = new Dictionary <Modification, ushort>(); foreach (var mod in fixedModifications) { modsDictionary.Add(mod, 0); } int i = 1; foreach (var mod in variableModifications) { modsDictionary.Add(mod, (ushort)i); i++; } foreach (var mod in localizeableModifications) { modsDictionary.Add(mod, (ushort)i); i++; } List <DigestionMotif> motifs = new List <DigestionMotif> { new DigestionMotif("K", null, 1, null) }; Protease p = new Protease("Custom Protease2", CleavageSpecificity.Full, null, null, motifs); ProteaseDictionary.Dictionary.Add(p.Name, p); CommonParameters CommonParameters = new CommonParameters(scoreCutoff: 1, digestionParams: new DigestionParams(protease: p.Name, minPeptideLength: 1)); var fsp = new List <(string fileName, CommonParameters fileSpecificParameters)>(); fsp.Add(("", CommonParameters)); var engine = new IndexingEngine(proteinList, variableModifications, fixedModifications, null, null, null, 1, DecoyType.None, CommonParameters, fsp, 30000, false, new List <FileInfo>(), TargetContaminantAmbiguity.RemoveContaminant, new List <string>()); var results = (IndexingResults)engine.Run(); Assert.AreEqual(5, results.PeptideIndex.Count); var digestedList = proteinList[0].Digest(CommonParameters.DigestionParams, new List <Modification>(), variableModifications).ToList(); Assert.AreEqual(5, digestedList.Count); foreach (PeptideWithSetModifications peptide in digestedList) { Assert.Contains(peptide, results.PeptideIndex); var fragments = new List <Product>(); peptide.Fragment(CommonParameters.DissociationType, FragmentationTerminus.Both, fragments); int positionInPeptideIndex = results.PeptideIndex.IndexOf(peptide); foreach (Product fragment in fragments) { // mass of the fragment double fragmentMass = fragment.NeutralMass; int integerMassRepresentation = (int)Math.Round(fragmentMass * 1000); // look up the peptides that have fragments with this mass // the result of the lookup is a list of peptide IDs that have this fragment mass List <int> fragmentBin = results.FragmentIndex[integerMassRepresentation]; // this list should contain this peptide! Assert.Contains(positionInPeptideIndex, fragmentBin); } } }
public RegisterViewModel(CommonParameters commonParameters) : base(commonParameters) { NewUser = new User(); }
private AcquireTokenSilentParameterBuilder WithAccount(IAccount account) { CommonParameters.AddApiTelemetryFeature(ApiTelemetryFeature.WithAccount); Parameters.Account = account; return(this); }
public static void AddCompIonsCommonParams() { CommonParameters cp = new CommonParameters(null, DissociationType.HCD, DissociationType.Unknown, DissociationType.Unknown, null, true, true, 3, 12, true, true, 1, 5, 200, 0.01, null, null, false, false, true, false, null, null, null, -1, null, null, null, 1, true, 4, 1); var myMsDataFile = new TestDataFile(); var variableModifications = new List <Modification>(); var fixedModifications = new List <Modification>(); var localizeableModifications = new List <Modification>(); Dictionary <Modification, ushort> modsDictionary = new Dictionary <Modification, ushort>(); foreach (var mod in fixedModifications) { modsDictionary.Add(mod, 0); } int ii = 1; foreach (var mod in variableModifications) { modsDictionary.Add(mod, (ushort)ii); ii++; } foreach (var mod in localizeableModifications) { modsDictionary.Add(mod, (ushort)ii); ii++; } var proteinList = new List <Protein> { new Protein("MNNNKQQQ", null) }; SearchParameters SearchParameters = new SearchParameters { MassDiffAcceptorType = MassDiffAcceptorType.Exact, SearchTarget = true, }; List <DigestionMotif> motifs = new List <DigestionMotif> { new DigestionMotif("K", null, 1, null) }; Protease protease = new Protease("Test", CleavageSpecificity.Full, null, null, motifs); ProteaseDictionary.Dictionary.Add(protease.Name, protease); var fsp = new List <(string fileName, CommonParameters fileSpecificParameters)>(); fsp.Add(("", cp)); var indexEngine = new IndexingEngine(proteinList, variableModifications, fixedModifications, new List <SilacLabel>(), null, null, 1, DecoyType.Reverse, cp, fsp, SearchParameters.MaxFragmentSize, false, new List <FileInfo>(), TargetContaminantAmbiguity.RemoveContaminant, new List <string>()); var indexResults = (IndexingResults)indexEngine.Run(); Tolerance DeconvolutionMassTolerance = new PpmTolerance(5); var listOfSortedms2Scans = MetaMorpheusTask.GetMs2Scans(myMsDataFile, null, new CommonParameters()).OrderBy(b => b.PrecursorMass).ToArray(); MassDiffAcceptor massDiffAcceptor = SearchTask.GetMassDiffAcceptor(cp.PrecursorMassTolerance, SearchParameters.MassDiffAcceptorType, SearchParameters.CustomMdac); // without complementary ions PeptideSpectralMatch[] allPsmsArray = new PeptideSpectralMatch[listOfSortedms2Scans.Length]; var mse = new ModernSearchEngine(allPsmsArray, listOfSortedms2Scans, indexResults.PeptideIndex, indexResults.FragmentIndex, 0, cp, fsp, massDiffAcceptor, SearchParameters.MaximumMassThatFragmentIonScoreIsDoubled, new List <string>()).Run(); }
/// <summary> /// Specifies if the client application should force refreshing the /// token from the user token cache. By default the token is taken from the /// the application token cache (forceRefresh=false) /// </summary> /// <param name="forceRefresh">If <c>true</c>, ignore any access token in the user token cache /// and attempt to acquire new access token using the refresh token for the account /// if one is available. This can be useful in the case when the application developer wants to make /// sure that conditional access policies are applied immediately, rather than after the expiration of the access token. /// The default is <c>false</c></param> /// <returns>The builder to chain the .With methods</returns> /// <remarks>Avoid un-necessarily setting <paramref name="forceRefresh"/> to <c>true</c> true in order to /// avoid negatively affecting the performance of your application</remarks> public AcquireTokenSilentParameterBuilder WithForceRefresh(bool forceRefresh) { CommonParameters.AddApiTelemetryFeature(ApiTelemetryFeature.WithForceRefresh, forceRefresh); Parameters.ForceRefresh = forceRefresh; return(this); }
public CrosslinkSearchEngine(List <CrosslinkSpectralMatch>[] globalCsms, Ms2ScanWithSpecificMass[] listOfSortedms2Scans, List <PeptideWithSetModifications> peptideIndex, List <int>[] fragmentIndex, List <int>[] secondFragmentIndex, int currentPartition, CommonParameters commonParameters, List <(string fileName, CommonParameters fileSpecificParameters)> fileSpecificParameters, Crosslinker crosslinker, int CrosslinkSearchTopNum,