├── .gitignore
├── .nuget
├── NuGet.Config
├── NuGet.exe
└── NuGet.targets
├── CSMSL.Examples.sln
├── CSMSL.Examples
├── CSMSL.Examples.csproj
├── Examples.cs
├── FileOutputExamples.cs
├── MorpheusSearch.cs
├── MsDataFileExamples.cs
├── PepXmlExamples.cs
├── PeptideCalculatorForm.Designer.cs
├── PeptideCalculatorForm.cs
├── PeptideCalculatorForm.resx
├── Properties
│ └── AssemblyInfo.cs
├── ProteinGroupingExample.cs
├── Resources
│ ├── AgilentDDirectoryMS1MS2.d
│ │ ├── AcqData
│ │ │ ├── AcqMethod.xml
│ │ │ ├── Contents.xml
│ │ │ ├── DefaultMassCal.xml
│ │ │ ├── DeviceConfigInfo.xml
│ │ │ ├── Devices.xml
│ │ │ ├── MSActualDefs.xml
│ │ │ ├── MSPeak.bin
│ │ │ ├── MSPeriodicActuals.bin
│ │ │ ├── MSScan.bin
│ │ │ ├── MSScan.xsd
│ │ │ ├── MSTS.xml
│ │ │ ├── Worklist.xml
│ │ │ └── sample_info.xml
│ │ └── desktop.ini
│ ├── Enolase_repeats_AQv1.4.2.wiff
│ ├── Enolase_repeats_AQv1.4.2.wiff.scan
│ ├── Omssa_yeast.csv
│ ├── TMT_6plex_yeast.raw
│ ├── TMT_6plex_yeast_omssa_psms.csv
│ ├── ThermoRawFileMS1MS2.raw
│ ├── ThermoRawFileMS1MS2_Centroided.mzML
│ ├── ThermoRawFileMS1MS2_Profile.mzML
│ ├── omssa_example.mzid
│ ├── tiny.pwiz.1.1.mzML
│ └── yeast_uniprot_120226.fasta
├── ThermoRawFileExamples.cs
├── TrypticDigestion.cs
└── app.config
├── CSMSL.Tests
├── CSMSL.Tests.csproj
├── Chemistry
│ ├── ChemicalFormulaGeneratorTestFixture.cs
│ ├── ChemicalFormulaTestFixture.cs
│ ├── MassTestFixture.cs
│ └── PeriodicTableTestFixture.cs
├── MassToleranceTestFixture.cs
├── Properties
│ └── AssemblyInfo.cs
├── Proteomics
│ ├── AminoAcidTestFixture.cs
│ ├── FragmentTestFixture.cs
│ ├── PeptideTestFixture.cs
│ └── ProteaseTestFixture.cs
├── RangeTestFixture.cs
├── Spectral
│ └── SpectrumTestFixture.cs
├── Util
│ └── Collections
│ │ └── SortedMaxSizedContainerTestFixture.cs
└── packages.config
├── CSMSL.sln
├── CSMSL
├── Analysis
│ ├── ExperimentalDesign
│ │ ├── ExperimentalCondition.cs
│ │ ├── ExperimentalSet.cs
│ │ ├── Replicate.cs
│ │ └── Sample.cs
│ ├── Identification
│ │ ├── FalseDiscoveryRate.cs
│ │ ├── FragmentSpectralMatch.cs
│ │ ├── IFalseDiscovery.cs
│ │ ├── MSSearchEngine.cs
│ │ ├── MorpheusSearchEngine.cs
│ │ ├── PeptideSpectralMatch.cs
│ │ ├── PeptideSpectralMatchScoreType.cs
│ │ └── SpectrumFragmentsMatch.cs
│ └── Quantitation
│ │ ├── IQuantitationChannel.cs
│ │ ├── IntensityWeightingType.cs
│ │ ├── IsobaricTag.cs
│ │ ├── IsobaricTagPurityCorrection.cs
│ │ ├── QuantitationChannelSet.cs
│ │ ├── QuantitationChannelSetMassType.cs
│ │ └── QuantitationTypes.cs
├── CSMSL.csproj
├── Chemistry
│ ├── ChemicalFormula.cs
│ ├── ChemicalFormulaGenerator.cs
│ ├── Element.cs
│ ├── IChemicalFormula.cs
│ ├── IMass.cs
│ ├── Isotope.cs
│ ├── IsotopicDistribution.cs
│ ├── Mass.cs
│ └── PeriodicTable.cs
├── ClassExtensions.cs
├── Constants.cs
├── DoubleRange.cs
├── IO
│ ├── ABSciex
│ │ ├── ABSciex.csproj
│ │ ├── Properties
│ │ │ └── AssemblyInfo.cs
│ │ ├── WiffFile.cs
│ │ └── include
│ │ │ ├── Clearcore2.Compression.dll
│ │ │ ├── Clearcore2.Data.AnalystDataProvider.dll
│ │ │ ├── Clearcore2.Data.CommonInterfaces.dll
│ │ │ ├── Clearcore2.Data.WiffReader.dll
│ │ │ ├── Clearcore2.Data.dll
│ │ │ ├── Clearcore2.InternalRawXYProcessing.dll
│ │ │ ├── Clearcore2.Muni.dll
│ │ │ ├── Clearcore2.ProjectUtilities.dll
│ │ │ ├── Clearcore2.RawXYProcessing.dll
│ │ │ ├── Clearcore2.StructuredStorage.dll
│ │ │ └── Clearcore2.Utility.dll
│ ├── Agilent
│ │ ├── Agilent.csproj
│ │ ├── AgilentDDirectory.cs
│ │ ├── Properties
│ │ │ └── AssemblyInfo.cs
│ │ └── include
│ │ │ ├── x64
│ │ │ ├── BaseCommon.dll
│ │ │ ├── BaseDataAccess.dll
│ │ │ ├── BaseError.dll
│ │ │ ├── BaseTof.dll
│ │ │ └── MassSpecDataReader.dll
│ │ │ └── x86
│ │ │ ├── BaseCommon.dll
│ │ │ ├── BaseDataAccess.dll
│ │ │ ├── BaseError.dll
│ │ │ ├── BaseTof.dll
│ │ │ └── MassSpecDataReader.dll
│ ├── Bruker
│ │ ├── Bruker.csproj
│ │ ├── BrukerDDirectory.cs
│ │ ├── ParameterOptions.txt
│ │ ├── Properties
│ │ │ └── AssemblyInfo.cs
│ │ └── include
│ │ │ └── Interop.EDAL.dll
│ ├── CVParamater.cs
│ ├── Dta.cs
│ ├── DtaReader.cs
│ ├── DtaWriter.cs
│ ├── Fasta.cs
│ ├── FastaReader.cs
│ ├── FastaWriter.cs
│ ├── IMSDataFile.cs
│ ├── IMSDataScan.cs
│ ├── IMsnDataScan.cs
│ ├── MsDataFile.cs
│ ├── MsDataFileType.cs
│ ├── MzIdentML
│ │ ├── AnalysisSoftware.cs
│ │ ├── MzIdentML.csproj
│ │ ├── MzidReader.cs
│ │ ├── Properties
│ │ │ └── AssemblyInfo.cs
│ │ ├── XSD
│ │ │ ├── mzIdentML1.1.0.designer.cs
│ │ │ └── mzIdentML1.1.0.xsd
│ │ └── psi-ms.obo
│ ├── MzML
│ │ ├── MzML.csproj
│ │ ├── Mzml.cs
│ │ ├── Properties
│ │ │ └── AssemblyInfo.cs
│ │ ├── XSD
│ │ │ ├── mzML1.1.0.xsd
│ │ │ ├── mzML1.1.2_idx.designer.cs
│ │ │ └── mzML1.1.2_idx.xsd
│ │ └── mzML1.1.0.designer.cs
│ ├── MzTab
│ │ ├── MzTab.cs
│ │ ├── MzTabEntity.cs
│ │ ├── MzTabMetaData.cs
│ │ ├── MzTabMultipleSet.cs
│ │ ├── MzTabPSM.cs
│ │ ├── MzTabPeptide.cs
│ │ ├── MzTabProtein.cs
│ │ ├── MzTabReader.cs
│ │ ├── MzTabSection.cs
│ │ ├── MzTabSmallMolecule.cs
│ │ ├── MzTabSoftware.cs
│ │ └── MzTabWriter.cs
│ ├── OMSSA
│ │ ├── OMSSA.csproj
│ │ ├── OmssaModification.cs
│ │ ├── Properties
│ │ │ └── AssemblyInfo.cs
│ │ └── Resources
│ │ │ └── mods.xml
│ ├── PepXml
│ │ ├── PepXml.csproj
│ │ ├── PepXmlReader.cs
│ │ ├── PepXmlWriter.cs
│ │ └── Properties
│ │ │ └── AssemblyInfo.cs
│ ├── PsmReader.cs
│ └── Thermo
│ │ ├── Properties
│ │ └── AssemblyInfo.cs
│ │ ├── Thermo.csproj
│ │ ├── ThermoMzPeak.cs
│ │ ├── ThermoRawFile.cs
│ │ └── ThermoSpectrum.cs
├── IRange.cs
├── MassRange.cs
├── MzRange.cs
├── Polarity.cs
├── Properties
│ └── AssemblyInfo.cs
├── Proteomics
│ ├── AminoAcid.cs
│ ├── AminoAcidPolymer.cs
│ ├── ChemicalFormulaFragment.cs
│ ├── ChemicalFormulaModification.cs
│ ├── DissociationType.cs
│ ├── Fragment.cs
│ ├── FragmentCollection.cs
│ ├── FragmentTypes.cs
│ ├── IAminoAcid.cs
│ ├── IAminoAcidSequence.cs
│ ├── IIsotopologue.cs
│ ├── IProtease.cs
│ ├── Isotopologue.cs
│ ├── Modification.cs
│ ├── ModificationCollection.cs
│ ├── ModificationDictionary.cs
│ ├── ModificationSites.cs
│ ├── Peptide.cs
│ ├── Protease.cs
│ ├── Protein.cs
│ ├── ProteinGroup.cs
│ └── Terminus.cs
├── Range.cs
├── Resources
│ ├── Elements.xml
│ ├── Modifications.xml
│ └── Proteases.xml
├── Spectral
│ ├── Chromatogram.cs
│ ├── ChromatogramType.cs
│ ├── ChromatographicElutionProfile.cs
│ ├── ChromatographicPeak.cs
│ ├── IMassSpectrum.cs
│ ├── IPeak.cs
│ ├── ISpectrum.cs
│ ├── ISpectrumTime.cs
│ ├── MSDataScan.cs
│ ├── MZPeak.cs
│ ├── MassRangeChromatogram.cs
│ ├── MsnDataScan.cs
│ ├── MzAnalyzerType.cs
│ ├── MzSpectrum.cs
│ ├── SmoothingType.cs
│ └── Spectrum.cs
├── Tolerance.cs
├── ToleranceType.cs
├── ToleranceUnit.cs
└── Util
│ ├── Collections
│ ├── SortedMaxSizedContainer.cs
│ ├── VennDiagram.cs
│ └── VennSet.cs
│ ├── Combinatorics.cs
│ └── LinearRegression.cs
├── LICENSE.txt
└── README.md
/.gitignore:
--------------------------------------------------------------------------------
1 | # Compiled Source #
2 | ###################
3 | *.com
4 | *.dll
5 | *.exe
6 |
7 | # Packages #
8 | ############
9 | *.7z
10 | *.dmg
11 | *.gz
12 | *.iso
13 | *.iso
14 | *.jar
15 | *.rar
16 | *.tar
17 | *.zip
18 | *.raw
19 |
20 | # Logs and databases #
21 | ######################
22 | *.log
23 | *.sql
24 | *.sqlite
25 | # OS generated files #
26 | ######################
27 | .DS_Store
28 | .DS_Store?
29 | ._*
30 | .Spotlight-V100
31 | .Trashes
32 | Icon?
33 | ehthumbs.db
34 | [Tt]humbs.db
35 |
36 | # Visual Studios #
37 | ##################
38 | *.user
39 | *.suo
40 | *.sln.cache
41 | *.xap
42 | [bB]in/
43 | [oO]bj/
44 |
45 | # TESTS #
46 | #########
47 | TestResults/
48 | *.psess
49 | *.vsp
50 |
51 | # Nuget #
52 | #########
53 | !NuGet.exe
54 | packages/
55 | *.nupkg
56 |
57 | # MonoDevelop #
58 | ###############
59 | *.userprefs
60 |
61 |
--------------------------------------------------------------------------------
/.nuget/NuGet.Config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.nuget/NuGet.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dbaileychess/CSMSL/8bd6409bb0c231783c85978cf2119af498238e06/.nuget/NuGet.exe
--------------------------------------------------------------------------------
/CSMSL.Examples/MorpheusSearch.cs:
--------------------------------------------------------------------------------
1 | // Copyright 2022 Derek J. Bailey
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 | using CSMSL.Analysis.Identification;
15 | using CSMSL.IO;
16 | using CSMSL.IO.Thermo;
17 | using CSMSL.Proteomics;
18 | using System;
19 | using System.Collections.Generic;
20 | using System.Diagnostics;
21 |
22 | namespace CSMSL.Examples
23 | {
24 | public class MorpheusSearch
25 | {
26 | public static void Start(IProtease protease, int maxMissed = 3, int minLength = 5, int maxLength = 35)
27 | {
28 | Console.WriteLine("**Start Morpheus Search**");
29 | Stopwatch watch = new Stopwatch();
30 | watch.Start();
31 | List hashCodes = new List();
32 | // Generate peptide candidates
33 |
34 | HashSet peptides = new HashSet();
35 | using (FastaReader reader = new FastaReader("Resources/yeast_uniprot_120226.fasta"))
36 | {
37 | foreach (Protein protein in reader.ReadNextProtein())
38 | {
39 | foreach (Peptide peptide in protein.Digest(protease, maxMissed, minLength, maxLength))
40 | {
41 | peptides.Add(peptide);
42 | }
43 | }
44 | }
45 |
46 | MSSearchEngine engine = new MorpheusSearchEngine();
47 | engine.PrecursorMassTolerance = Tolerance.FromPPM(100);
48 | engine.ProductMassTolerance = Tolerance.FromPPM(10);
49 |
50 | engine.LoadPeptides(peptides);
51 |
52 | watch.Stop();
53 | Console.WriteLine("Time elapsed: {0}", watch.Elapsed);
54 | Console.WriteLine("Memory used: {0:N0} MB", Environment.WorkingSet/(1024*1024));
55 | Console.WriteLine("**End Morpheus Search**");
56 | }
57 | }
58 | }
--------------------------------------------------------------------------------
/CSMSL.Examples/MsDataFileExamples.cs:
--------------------------------------------------------------------------------
1 | // Copyright 2022 Derek J. Bailey
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | using System.Linq;
16 | using CSMSL.IO;
17 | using CSMSL.IO.Agilent;
18 | using CSMSL.IO.MzML;
19 | using CSMSL.IO.Thermo;
20 | using CSMSL.Spectral;
21 | using System;
22 | using System.Collections.Generic;
23 | using System.Diagnostics;
24 |
25 |
26 | namespace CSMSL.Examples
27 | {
28 | public static class MsDataFileExamples
29 | {
30 | ///
31 | /// Code to show how one could write one set of code to interact with multiple different types of MS data files.
32 | ///
33 | ///
34 | public static void VendorNeutralDataAccess()
35 | {
36 |
37 | Console.WriteLine("**MS I/O Examples**");
38 | Console.WriteLine("{0,-4} {1,3} {2,-6} {3,-5} {4,7} {5,-10} {6}", "SN", "Msn", "RT", "Polarity", "# Peaks", "Analyzer", "M/Z Range");
39 |
40 | // Generic MS data file reader
41 | List exampleRawFiles = new List
42 | {
43 | new ThermoRawFile("Resources/ThermoRawFileMS1MS2.raw"),
44 | new AgilentDDirectory(@"Resources\AgilentDDirectoryMS1MS2.d"),
45 | new Mzml("Resources/ThermoRawFileMS1MS2_Profile.mzML")
46 | };
47 |
48 | foreach (IMSDataFile dataFile in exampleRawFiles)
49 | {
50 | dataFile.Open();
51 | Stopwatch watch = new Stopwatch();
52 | watch.Start();
53 | foreach (IMSDataScan scan in dataFile.Where(s => s.MassSpectrum.Count > 1).Take(4))
54 | {
55 | Console.WriteLine("{0,-4} {1,3} {2,-6:F4} {3,-5} {4,7} {5,-10} {6}", scan.SpectrumNumber, scan.MsnOrder, scan.RetentionTime,
56 | scan.Polarity, scan.MassSpectrum.Count, scan.MzAnalyzer, scan.MzRange);
57 | }
58 | watch.Stop();
59 | Console.WriteLine("File: {0}", dataFile);
60 | Console.WriteLine("Time: {0}", watch.Elapsed);
61 | Console.WriteLine("Memory used: {0:N0} MB", Environment.WorkingSet/(1024*1024));
62 | }
63 | }
64 |
65 |
66 | }
67 | }
--------------------------------------------------------------------------------
/CSMSL.Examples/PepXmlExamples.cs:
--------------------------------------------------------------------------------
1 | // Copyright 2022 Derek J. Bailey
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | using System;
16 | using System.Collections.Generic;
17 | using System.IO;
18 | using CSMSL.IO.PepXML;
19 | using CSMSL.Proteomics;
20 | using CSMSL.Analysis.Identification;
21 |
22 | namespace CSMSL.Examples
23 | {
24 | public static class PepXmlExamples
25 | {
26 | public static void WritePepXml()
27 | {
28 | string filePath = Path.Combine(Examples.BASE_DIRECTORY, "example.pepXML");
29 |
30 | Console.WriteLine("Writting to " + filePath);
31 | using (PepXmlWriter writer = new PepXmlWriter(filePath))
32 | {
33 | writer.WriteSampleProtease(Protease.GetProtease("Trypsin"));
34 |
35 | writer.StartSearchSummary("OMSSA", true, true);
36 |
37 | writer.WriteProteinDatabase("Resources/yeast_uniprot_120226.fasta");
38 |
39 | writer.WriteSearchProtease(Protease.GetProtease("Trypsin"), 3);
40 |
41 | writer.WriteModification(ModificationDictionary.GetModification("Acetyl"), ModificationSites.K | ModificationSites.NPep);
42 | writer.WriteModification(ModificationDictionary.GetModification("CAM"), ModificationSites.C);
43 |
44 | writer.WriteModification(ModificationDictionary.GetModification("Phospho"), ModificationSites.S | ModificationSites.T | ModificationSites.Y, false);
45 |
46 | writer.SetCurrentStage(PepXmlWriter.Stage.Spectra, true);
47 |
48 | writer.StartSpectrum(15, 1.234, 523.4324, 3);
49 |
50 | PeptideSpectralMatch psm = new PeptideSpectralMatch(PeptideSpectralMatchScoreType.OmssaEvalue);
51 | psm.Score = 1.5e-5;
52 | Protein protein = new Protein("", "Test Protein");
53 | psm.Peptide = new Peptide("DEREK", protein);
54 | psm.Charge = 3;
55 | writer.WritePSM(psm);
56 |
57 | writer.EndSpectrum();
58 | }
59 | }
60 |
61 | public static void ReadPepXml()
62 | {
63 | WritePepXml();
64 | //string filePath = Path.Combine(Examples.BASE_DIRECTORY, "example.pepXML");
65 | string filePath = @"E:\Desktop\test\27Nov2013_CEM_WellsProtein_CAD_filter.pep.xml";
66 | Console.WriteLine("Reading from " + filePath);
67 | using (PepXmlReader reader = new PepXmlReader(filePath))
68 | {
69 | Protease protease = reader.GetSampleProtease();
70 | Console.WriteLine("Protease: " + protease);
71 | Console.WriteLine();
72 | List fixedMods = reader.GetFixedModifications();
73 | Console.WriteLine("==Fixed Modifications==");
74 | foreach (Modification mod in fixedMods)
75 | {
76 | Console.WriteLine("\t" + mod);
77 | }
78 | Console.WriteLine();
79 | List varMods = reader.GetVariableModifications();
80 | Console.WriteLine("==Variable Modifications==");
81 | foreach (Modification mod in varMods)
82 | {
83 | Console.WriteLine("\t" + mod);
84 | }
85 | }
86 | }
87 | }
88 | }
--------------------------------------------------------------------------------
/CSMSL.Examples/PeptideCalculatorForm.cs:
--------------------------------------------------------------------------------
1 | // Copyright 2022 Derek J. Bailey
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | using System;
16 | using System.Windows.Forms;
17 | using CSMSL.Chemistry;
18 | using CSMSL.Proteomics;
19 |
20 | namespace CSMSL.Examples
21 | {
22 | public partial class PeptideCalculatorForm : Form
23 | {
24 | public PeptideCalculatorForm()
25 | {
26 | InitializeComponent();
27 | }
28 |
29 | private void DisplayPeptide(string sequence)
30 | {
31 | try
32 | {
33 | Peptide peptide = new Peptide(sequence);
34 | peptideMassTB.Text = peptide.MonoisotopicMass.ToString();
35 | peptideMZTB.Text = peptide.ToMz(1).ToString();
36 | }
37 | catch (Exception)
38 | {
39 | peptideMZTB.Text = peptideMassTB.Text = "Not a valid Sequence";
40 | }
41 | }
42 |
43 | private void sequenceTB_TextChanged(object sender, EventArgs e)
44 | {
45 | DisplayPeptide(sequenceTB.Text);
46 | }
47 | }
48 | }
--------------------------------------------------------------------------------
/CSMSL.Examples/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | // Copyright 2012, 2013, 2014 Derek J. Bailey
2 | //
3 | // This file (AssemblyInfo.cs) is part of CSMSL.
4 | //
5 | // CSMSL is free software: you can redistribute it and/or modify it
6 | // under the terms of the GNU Lesser General Public License as published
7 | // by the Free Software Foundation, either version 3 of the License, or
8 | // (at your option) any later version.
9 | //
10 | // CSMSL is distributed in the hope that it will be useful, but WITHOUT
11 | // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 | // FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
13 | // License for more details.
14 | //
15 | // You should have received a copy of the GNU Lesser General Public
16 | // License along with CSMSL. If not, see .
17 |
18 | using System.Reflection;
19 | using System.Runtime.InteropServices;
20 |
21 | // General Information about an assembly is controlled through the following
22 | // set of attributes. Change these attribute values to modify the information
23 | // associated with an assembly.
24 |
25 | [assembly: AssemblyTitle("ExamplesCSMSL")]
26 | [assembly: AssemblyDescription("")]
27 | [assembly: AssemblyConfiguration("")]
28 | [assembly: AssemblyCompany("")]
29 | [assembly: AssemblyProduct("ExamplesCSMSL")]
30 | [assembly: AssemblyCopyright("Copyright © 2012")]
31 | [assembly: AssemblyTrademark("")]
32 | [assembly: AssemblyCulture("")]
33 | // Setting ComVisible to false makes the types in this assembly not visible
34 | // to COM components. If you need to access a type in this assembly from
35 | // COM, set the ComVisible attribute to true on that type.
36 |
37 | [assembly: ComVisible(false)]
38 | // The following GUID is for the ID of the typelib if this project is exposed to COM
39 |
40 | [assembly: Guid("dab9d462-f70a-4e6a-89a8-605387f45c4d")]
41 | // Version information for an assembly consists of the following four values:
42 | //
43 | // Major Version
44 | // Minor Version
45 | // Build Number
46 | // Revision
47 | //
48 | // You can specify all the values or you can default the Build and Revision Numbers
49 | // by using the '*' as shown below:
50 | // [assembly: AssemblyVersion("1.0.*")]
51 |
52 | [assembly: AssemblyVersion("1.0.0.0")]
53 | [assembly: AssemblyFileVersion("1.0.0.0")]
--------------------------------------------------------------------------------
/CSMSL.Examples/Resources/AgilentDDirectoryMS1MS2.d/AcqData/Contents.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 3
5 |
6 |
7 | 2012-08-29T20:19:48Z
8 |
9 | 2
10 |
11 | Instrument 1
12 |
13 | 0
14 |
15 | 0
16 |
17 | 0
18 |
19 | 95.64
20 |
21 | 6200 series TOF/6500 series Q-TOF B.05.00 (B5042.2)
22 |
--------------------------------------------------------------------------------
/CSMSL.Examples/Resources/AgilentDDirectoryMS1MS2.d/AcqData/DefaultMassCal.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 1
4 |
5 |
6 |
7 | ExternalReference
8 | Traditional
9 | 2
10 | 0
11 |
12 | 0.000572870298405703
13 | 1026.40825677916
14 |
15 | 0
16 |
17 |
18 | ExternalReference
19 | Polynomial
20 | 8
21 | 122
22 |
23 | 19995.5479314169
24 | 92097.2179913925
25 | 3.28990241955302E-07
26 | -1.04405923881504E-15
27 | 3.19355184842222E-20
28 | -3.42606123615378E-25
29 | 1.23815256814168E-30
30 | 0
31 |
32 |
33 |
34 |
35 |
36 | ExternalReference
37 | Traditional
38 | 2
39 | 0
40 |
41 | 0.00057253
42 | 1011.13
43 |
44 |
45 |
46 | ExternalReference
47 | Polynomial
48 | 8
49 | 0
50 |
51 | 0
52 | 0
53 | 0
54 | 0
55 | 0
56 | 0
57 | 0
58 | 0
59 |
60 |
61 |
62 |
63 |
--------------------------------------------------------------------------------
/CSMSL.Examples/Resources/AgilentDDirectoryMS1MS2.d/AcqData/DeviceConfigInfo.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | ChipCube_1
4 | ChipCube
5 |
6 |
7 | MSQTOF_1
8 | Q-TOF
9 |
10 |
11 | ChipCube_1
12 | ExtendedRunInformation
13 | RunStart_ChipId
14 |
15 |
16 | Run Start Chip ID
17 |
18 |
19 | MSQTOF_1
20 | config
21 | REG[ACTUAL].OBJ[1].NDR[BASEADCINTERVAL]
22 | 0.5
23 |
24 | Base ADC Interval
25 |
26 |
27 | MSQTOF_1
28 | config
29 | REG[ACTUAL].OBJ[1].NDR[DUALGAINRATIO]
30 | 12
31 |
32 | Dual Gain Ratio
33 |
34 |
35 | MSQTOF_1
36 | config
37 | REG[ACTUAL].OBJ[1].NDR[MSPROCESSINGMODE]
38 | 4
39 |
40 | MS Processing Mode
41 |
42 |
43 | MSQTOF_1
44 | config
45 | REG[ACTUAL].OBJ[1].NDR[NOMINALMASSRESOLUTION]
46 | 14000
47 | m/z
48 | Nominal Mass Resolution
49 |
50 |
51 | MSQTOF_1
52 | config
53 | REG[ACTUAL].OBJ[1].NDR[PREAMPOFFSETHIGAIN]
54 | -0.0879999995231628
55 |
56 | Preamp Offset High Gain
57 |
58 |
59 | MSQTOF_1
60 | config
61 | REG[ACTUAL].OBJ[1].NDR[PREAMPOFFSETLOWGAIN]
62 | 49917
63 |
64 | Preamp Offset Low Gain
65 |
66 |
67 | MSQTOF_1
68 | config
69 | REG[ACTUAL].OBJ[1].NDR[TUNEMASSRANGEMAX]
70 | 3200
71 | m/z
72 | Tune Mass Range Max.
73 |
74 |
75 | MSQTOF_1
76 | config
77 | REG[ACTUAL].OBJ[1].NDR[TUNEMASSRANGEMIN]
78 | 20
79 | m/z
80 | Tune Mass Range Min.
81 |
82 |
83 | ChipCube_1
84 | ExtendedRunInformation
85 | RunStop_ChipId
86 |
87 |
88 | Run Stop Chip ID
89 |
90 |
--------------------------------------------------------------------------------
/CSMSL.Examples/Resources/AgilentDDirectoryMS1MS2.d/AcqData/Devices.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 1
4 |
5 | QTOF
6 | 5.00.02
7 | 3.570
8 | G6530A
9 | 1
10 | US10092003
11 | 6
12 | 8
13 | 0
14 | 1
15 |
16 |
--------------------------------------------------------------------------------
/CSMSL.Examples/Resources/AgilentDDirectoryMS1MS2.d/AcqData/MSPeak.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dbaileychess/CSMSL/8bd6409bb0c231783c85978cf2119af498238e06/CSMSL.Examples/Resources/AgilentDDirectoryMS1MS2.d/AcqData/MSPeak.bin
--------------------------------------------------------------------------------
/CSMSL.Examples/Resources/AgilentDDirectoryMS1MS2.d/AcqData/MSPeriodicActuals.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dbaileychess/CSMSL/8bd6409bb0c231783c85978cf2119af498238e06/CSMSL.Examples/Resources/AgilentDDirectoryMS1MS2.d/AcqData/MSPeriodicActuals.bin
--------------------------------------------------------------------------------
/CSMSL.Examples/Resources/AgilentDDirectoryMS1MS2.d/AcqData/MSScan.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dbaileychess/CSMSL/8bd6409bb0c231783c85978cf2119af498238e06/CSMSL.Examples/Resources/AgilentDDirectoryMS1MS2.d/AcqData/MSScan.bin
--------------------------------------------------------------------------------
/CSMSL.Examples/Resources/AgilentDDirectoryMS1MS2.d/AcqData/MSTS.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 3
4 |
5 |
6 | 0.03655
7 |
8 | 0.967216666666667
9 | 38
10 |
11 | 0
12 |
13 | 0
14 |
--------------------------------------------------------------------------------
/CSMSL.Examples/Resources/AgilentDDirectoryMS1MS2.d/desktop.ini:
--------------------------------------------------------------------------------
1 | [.ShellClassInfo]
2 | IconFile=C:\WINDOWS\system32\agtMassHunter.ico
3 | IconIndex=0
4 |
--------------------------------------------------------------------------------
/CSMSL.Examples/Resources/Enolase_repeats_AQv1.4.2.wiff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dbaileychess/CSMSL/8bd6409bb0c231783c85978cf2119af498238e06/CSMSL.Examples/Resources/Enolase_repeats_AQv1.4.2.wiff
--------------------------------------------------------------------------------
/CSMSL.Examples/Resources/Enolase_repeats_AQv1.4.2.wiff.scan:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dbaileychess/CSMSL/8bd6409bb0c231783c85978cf2119af498238e06/CSMSL.Examples/Resources/Enolase_repeats_AQv1.4.2.wiff.scan
--------------------------------------------------------------------------------
/CSMSL.Examples/Resources/TMT_6plex_yeast.raw:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dbaileychess/CSMSL/8bd6409bb0c231783c85978cf2119af498238e06/CSMSL.Examples/Resources/TMT_6plex_yeast.raw
--------------------------------------------------------------------------------
/CSMSL.Examples/Resources/ThermoRawFileMS1MS2.raw:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dbaileychess/CSMSL/8bd6409bb0c231783c85978cf2119af498238e06/CSMSL.Examples/Resources/ThermoRawFileMS1MS2.raw
--------------------------------------------------------------------------------
/CSMSL.Examples/ThermoRawFileExamples.cs:
--------------------------------------------------------------------------------
1 | // Copyright 2022 Derek J. Bailey
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | using System;
16 | using System.Collections.Generic;
17 | using CSMSL.IO;
18 | using CSMSL.IO.Thermo;
19 | using CSMSL.Spectral;
20 |
21 | namespace CSMSL.Examples
22 | {
23 | public static class ThermoRawFileExamples
24 | {
25 | public static void RecalibrateThermoRawFile()
26 | {
27 | List spectra = new List();
28 | using (ThermoRawFile rawFile = new ThermoRawFile("Resources/ThermoRawFileMS1MS2.raw"))
29 | {
30 | rawFile.Open();
31 | for (int i = rawFile.FirstSpectrumNumber; i <= rawFile.LastSpectrumNumber; i++)
32 | {
33 | ThermoSpectrum spectrum = rawFile.GetLabeledSpectrum(i);
34 | ThermoSpectrum correctedSpectrum = spectrum.CorrectMasses((mz) => mz - 5); // shift all masses 5 Th lower
35 | spectra.Add(correctedSpectrum);
36 | }
37 | }
38 | }
39 |
40 | public static void LoopOverEveryScan()
41 | {
42 | using (ThermoRawFile rawFile = new ThermoRawFile("Resources/ThermoRawFileMS1MS2.raw"))
43 | {
44 | rawFile.Open();
45 | foreach (var scan in rawFile)
46 | {
47 | Console.WriteLine("{0,-4} {1,3} {2,-6:F4} {3,-5} {4,7} {5,-10} {6} {7}", scan.SpectrumNumber, scan.MsnOrder, scan.RetentionTime,
48 | scan.Polarity, scan.MassSpectrum.Count, scan.MzAnalyzer, scan.MzRange, scan.MassSpectrum.IsHighResolution);
49 | }
50 | }
51 | }
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/CSMSL.Examples/TrypticDigestion.cs:
--------------------------------------------------------------------------------
1 | // Copyright 2022 Derek J. Bailey
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | using System.Linq;
16 | using CSMSL.Chemistry;
17 | using CSMSL.IO;
18 | using CSMSL.Proteomics;
19 | using System;
20 | using System.Collections.Generic;
21 | using System.Diagnostics;
22 |
23 | namespace CSMSL.Examples
24 | {
25 | public class TrypticDigestion
26 | {
27 | public static void Start(IProtease protease, int maxMissed = 1, int minLength = 0, int maxLength = int.MaxValue, bool storeSequenceString = true)
28 | {
29 | Console.WriteLine("**Start Digestion**");
30 | Stopwatch watch = new Stopwatch();
31 | watch.Start();
32 | List peps = new List();
33 | List prots = new List();
34 | List allMzs = new List();
35 | AminoAcidPolymer.StoreSequenceString = storeSequenceString;
36 | using (FastaReader reader = new FastaReader("Resources/yeast_uniprot_120226.fasta"))
37 | {
38 | foreach (Protein protein in reader.ReadNextProtein())
39 | {
40 | foreach (Peptide peptide in protein.Digest(protease, maxMissed, minLength, maxLength))
41 | {
42 | peps.Add(peptide);
43 | allMzs.Add(peptide.ToMz(2)); // forces the calculation of the mass and thus chemical formula
44 | }
45 | prots.Add(protein);
46 | }
47 | }
48 | watch.Stop();
49 | Console.WriteLine("{0:N0} proteins produced {1:N0} peptides using {2:N0} missed cleavages", prots.Count, peps.Count, maxMissed);
50 | Console.WriteLine("Time elapsed: {0}", watch.Elapsed);
51 | Console.WriteLine("Memory used: {0:N0} MB", Environment.WorkingSet/(1024*1024));
52 | Console.WriteLine("**End Digestion**");
53 | }
54 |
55 | public static void ExampleDigestion()
56 | {
57 | const string fastaFilePath = "Resources/yeast_uniprot_120226.fasta";
58 | IProtease trypsin = Protease.GetProtease("Trypsin");
59 | const int maxMissedCleavages = 3;
60 | const int minPeptideLength = 5;
61 | const int maxPeptideLength = 50;
62 | List masses = new List();
63 | Stopwatch watch = new Stopwatch();
64 | watch.Start();
65 | using (FastaReader reader = new FastaReader(fastaFilePath))
66 | {
67 | foreach (Protein protein in reader.ReadNextProtein())
68 | {
69 | foreach (Peptide peptide in protein.Digest(trypsin, maxMissedCleavages, minPeptideLength, maxPeptideLength))
70 | {
71 | masses.Add(peptide.MonoisotopicMass);
72 | }
73 | }
74 | }
75 | //Console.WriteLine("Average Peptide Mass = {0:F4}", masses.Average());
76 | watch.Stop();
77 | Console.WriteLine("Time elapsed: {0}", watch.Elapsed);
78 | }
79 | }
80 | }
--------------------------------------------------------------------------------
/CSMSL.Examples/app.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/CSMSL.Tests/Chemistry/ChemicalFormulaGeneratorTestFixture.cs:
--------------------------------------------------------------------------------
1 | // Copyright 2022 Derek J. Bailey
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | using CSMSL.Chemistry;
16 | using NUnit.Framework;
17 | using System.Collections.Generic;
18 | using System.Linq;
19 |
20 | namespace CSMSL.Tests.Chemistry
21 | {
22 | [TestFixture]
23 | [Category("Chemical Formula")]
24 | public class ChemicalFormulaGeneratorTestFixture
25 | {
26 | [Test]
27 | public void ChemicalFormulaGeneratorContainsFormula()
28 | {
29 | ChemicalFormulaGenerator generator = new ChemicalFormulaGenerator(new ChemicalFormula("H2O"));
30 |
31 | List formulas = generator.AllFormulas().ToList();
32 | ChemicalFormula ho = new ChemicalFormula("HO");
33 |
34 | Assert.Contains(ho, formulas);
35 | }
36 | }
37 | }
--------------------------------------------------------------------------------
/CSMSL.Tests/Chemistry/PeriodicTableTestFixture.cs:
--------------------------------------------------------------------------------
1 | // Copyright 2022 Derek J. Bailey
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | using NUnit.Framework;
16 | using CSMSL.Chemistry;
17 | using System.IO;
18 | using System.Threading;
19 | using System.Globalization;
20 |
21 | namespace CSMSL.Tests.Chemistry
22 | {
23 | [TestFixture, Category("Periodic Table")]
24 | public sealed class PeriodicTableTestFixture
25 | {
26 | [TestFixtureTearDown]
27 | public void CleanUP()
28 | {
29 | // We need to restore the default table before each test, or other tests will fail
30 | PeriodicTable.RestoreDefaults();
31 | }
32 |
33 |
34 | [Test]
35 | public void LoadUserDefineTable()
36 | {
37 | string xml = @"
38 |
39 |
40 |
41 |
42 |
43 | ";
44 |
45 | string fileName = Path.Combine(Path.GetTempPath(), "testTable.xml");
46 |
47 | File.WriteAllText(fileName, xml);
48 |
49 | PeriodicTable.Load(fileName);
50 |
51 | File.Delete(fileName);
52 |
53 | Assert.AreEqual(5.00782503207, PeriodicTable.GetIsotope("H", 1).AtomicMass, 0.0000001);
54 | }
55 |
56 | [SetCulture("de")]
57 | [Test]
58 | public void LoadUserDefineTableInternational()
59 | {
60 | string xml = @"
61 |
62 |
63 |
64 |
65 |
66 | ";
67 |
68 | string fileName = Path.Combine(Path.GetTempPath(), "testTableInt.xml");
69 |
70 | File.WriteAllText(fileName, xml);
71 |
72 | PeriodicTable.Load(fileName);
73 |
74 | File.Delete(fileName);
75 |
76 | Assert.AreEqual(5.00782503207, PeriodicTable.GetIsotope("H", 1).AtomicMass, 0.0000001);
77 | }
78 |
79 |
80 | }
81 | }
82 |
--------------------------------------------------------------------------------
/CSMSL.Tests/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | // Copyright 2022 Derek J. Bailey
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | using System.Reflection;
16 | using System.Runtime.InteropServices;
17 |
18 | // General Information about an assembly is controlled through the following
19 | // set of attributes. Change these attribute values to modify the information
20 | // associated with an assembly.
21 |
22 | [assembly: AssemblyTitle("CSMSL.Tests")]
23 | [assembly: AssemblyDescription("")]
24 | [assembly: AssemblyConfiguration("")]
25 | [assembly: AssemblyCompany("")]
26 | [assembly: AssemblyProduct("CSMSL.Tests")]
27 | [assembly: AssemblyCopyright("Copyright © 2013")]
28 | [assembly: AssemblyTrademark("")]
29 | [assembly: AssemblyCulture("")]
30 |
31 | // Setting ComVisible to false makes the types in this assembly not visible
32 | // to COM components. If you need to access a type in this assembly from
33 | // COM, set the ComVisible attribute to true on that type.
34 |
35 | [assembly: ComVisible(false)]
36 |
37 | // The following GUID is for the ID of the typelib if this project is exposed to COM
38 |
39 | [assembly: Guid("5c85b9d7-9012-4f7d-bd03-e4935280752d")]
40 |
41 | // Version information for an assembly consists of the following four values:
42 | //
43 | // Major Version
44 | // Minor Version
45 | // Build Number
46 | // Revision
47 | //
48 | // You can specify all the values or you can default the Build and Revision Numbers
49 | // by using the '*' as shown below:
50 | // [assembly: AssemblyVersion("1.0.*")]
51 | [assembly: AssemblyVersion("1.0.0.0")]
52 | [assembly: AssemblyFileVersion("1.0.0.0")]
--------------------------------------------------------------------------------
/CSMSL.Tests/Proteomics/AminoAcidTestFixture.cs:
--------------------------------------------------------------------------------
1 | // Copyright 2022 Derek J. Bailey
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 | using CSMSL.Proteomics;
15 | using NUnit.Framework;
16 |
17 | namespace CSMSL.Tests.Proteomics
18 | {
19 | [TestFixture, Category("Amino Acid")]
20 | public sealed class AminoAcidTestFixture
21 | {
22 | [Test]
23 | public void GetResidueByCharacter()
24 | {
25 | AminoAcid aa = AminoAcid.GetResidue('A');
26 |
27 | Assert.AreEqual(aa.Name, "Alanine");
28 | }
29 |
30 | [Test]
31 | public void GetResidueByCharacterString()
32 | {
33 | AminoAcid aa = AminoAcid.GetResidue("A");
34 |
35 | Assert.AreEqual(aa.Name, "Alanine");
36 | }
37 |
38 | [Test]
39 | public void GetResidueBy3LetterSymbol()
40 | {
41 | AminoAcid aa = AminoAcid.GetResidue("Ala");
42 |
43 | Assert.AreEqual(aa.Name, "Alanine");
44 | }
45 |
46 | [Test]
47 | public void GetResidueByName()
48 | {
49 | AminoAcid aa = AminoAcid.GetResidue("Alanine");
50 |
51 | Assert.AreEqual(aa.Name, "Alanine");
52 | }
53 | }
54 | }
--------------------------------------------------------------------------------
/CSMSL.Tests/Proteomics/FragmentTestFixture.cs:
--------------------------------------------------------------------------------
1 | // Copyright 2022 Derek J. Bailey
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | using CSMSL.Chemistry;
16 | using CSMSL.Proteomics;
17 | using NUnit.Framework;
18 | using System;
19 | using System.Collections.Generic;
20 | using System.Linq;
21 |
22 | namespace CSMSL.Tests.Proteomics
23 | {
24 | [TestFixture, Category("Peptide Fragmentation")]
25 | public sealed class FragmentTestFixture
26 | {
27 | private Peptide _mockPeptideEveryAminoAcid;
28 |
29 | [SetUp]
30 | public void SetUp()
31 | {
32 | _mockPeptideEveryAminoAcid = new Peptide("ACDEFGHIKLMNPQRSTVWY");
33 | }
34 |
35 | [Test]
36 | public void FragmentNumberToLow()
37 | {
38 | Assert.Throws(() => _mockPeptideEveryAminoAcid.Fragment(FragmentTypes.b, 0).ToList());
39 | }
40 |
41 | [Test]
42 | public void FragmentNumberToHigh()
43 | {
44 | Assert.Throws(() => _mockPeptideEveryAminoAcid.Fragment(FragmentTypes.b, 25).ToList());
45 | }
46 |
47 | [Test]
48 | public void FragmentName()
49 | {
50 | Fragment fragment = _mockPeptideEveryAminoAcid.Fragment(FragmentTypes.a, 1).ToArray()[0];
51 |
52 | Assert.AreEqual("a1", fragment.ToString());
53 | }
54 |
55 | [Test]
56 | public void FragmentAllBIons()
57 | {
58 | List fragments = _mockPeptideEveryAminoAcid.Fragment(FragmentTypes.b).ToList();
59 |
60 | Assert.AreEqual(19, fragments.Count);
61 | }
62 |
63 | [Test]
64 | public void FragmentChemicalFormulaAIon()
65 | {
66 | Fragment fragment = _mockPeptideEveryAminoAcid.Fragment(FragmentTypes.a, 1).ToArray()[0];
67 |
68 | Assert.IsTrue(fragment.MassEquals(43.04219916514));
69 | }
70 |
71 | [Test]
72 | public void FragmentChemicalFormulaBIon()
73 | {
74 | Fragment fragment = _mockPeptideEveryAminoAcid.Fragment(FragmentTypes.b, 1).ToArray()[0];
75 |
76 | Assert.AreEqual(71.037113784709987, fragment.MonoisotopicMass);
77 | }
78 |
79 | [Test]
80 | public void FragmentChemicalFormulaCIon()
81 | {
82 | Fragment fragment = _mockPeptideEveryAminoAcid.Fragment(FragmentTypes.c, 1).ToArray()[0];
83 |
84 | Assert.AreEqual(88.063662885719992, fragment.MonoisotopicMass);
85 | }
86 |
87 | [Test]
88 | public void FragmentChemicalFormulaXIon()
89 | {
90 | Fragment fragment = _mockPeptideEveryAminoAcid.Fragment(FragmentTypes.x, 1).ToArray()[0];
91 |
92 | Assert.AreEqual(207.05315777167004, fragment.MonoisotopicMass);
93 | }
94 |
95 | [Test]
96 | public void FragmentChemicalFormulaYIon()
97 | {
98 | Fragment fragment = _mockPeptideEveryAminoAcid.Fragment(FragmentTypes.y, 1).ToArray()[0];
99 |
100 | Assert.AreEqual(181.07389321625004, fragment.MonoisotopicMass);
101 | }
102 |
103 | [Test]
104 | public void FragmentChemicalFormulaZIon()
105 | {
106 | Fragment fragment = _mockPeptideEveryAminoAcid.Fragment(FragmentTypes.z, 1).ToArray()[0];
107 |
108 | Assert.AreEqual(164.04734411524004, fragment.MonoisotopicMass);
109 | }
110 | }
111 | }
--------------------------------------------------------------------------------
/CSMSL.Tests/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/CSMSL.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 2013
4 | VisualStudioVersion = 12.0.30501.0
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CSMSL", "CSMSL\CSMSL.csproj", "{3C8C9F05-9C19-4251-95FA-05D7EDC8CAE6}"
7 | EndProject
8 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{87E563B1-0EB9-49D7-98BD-8EA282FB9BAC}"
9 | ProjectSection(SolutionItems) = preProject
10 | .nuget\NuGet.Config = .nuget\NuGet.Config
11 | .nuget\NuGet.exe = .nuget\NuGet.exe
12 | .nuget\NuGet.targets = .nuget\NuGet.targets
13 | EndProjectSection
14 | EndProject
15 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CSMSL.Tests", "CSMSL.Tests\CSMSL.Tests.csproj", "{156FA2E7-48A5-4940-B4BF-1154B052579A}"
16 | EndProject
17 | Global
18 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
19 | Debug|Any CPU = Debug|Any CPU
20 | Debug|x64 = Debug|x64
21 | Debug|x86 = Debug|x86
22 | Release|Any CPU = Release|Any CPU
23 | Release|x64 = Release|x64
24 | Release|x86 = Release|x86
25 | EndGlobalSection
26 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
27 | {3C8C9F05-9C19-4251-95FA-05D7EDC8CAE6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
28 | {3C8C9F05-9C19-4251-95FA-05D7EDC8CAE6}.Debug|Any CPU.Build.0 = Debug|Any CPU
29 | {3C8C9F05-9C19-4251-95FA-05D7EDC8CAE6}.Debug|x64.ActiveCfg = Debug|x64
30 | {3C8C9F05-9C19-4251-95FA-05D7EDC8CAE6}.Debug|x64.Build.0 = Debug|x64
31 | {3C8C9F05-9C19-4251-95FA-05D7EDC8CAE6}.Debug|x86.ActiveCfg = Debug|x86
32 | {3C8C9F05-9C19-4251-95FA-05D7EDC8CAE6}.Debug|x86.Build.0 = Debug|x86
33 | {3C8C9F05-9C19-4251-95FA-05D7EDC8CAE6}.Release|Any CPU.ActiveCfg = Release|Any CPU
34 | {3C8C9F05-9C19-4251-95FA-05D7EDC8CAE6}.Release|Any CPU.Build.0 = Release|Any CPU
35 | {3C8C9F05-9C19-4251-95FA-05D7EDC8CAE6}.Release|x64.ActiveCfg = Release|x64
36 | {3C8C9F05-9C19-4251-95FA-05D7EDC8CAE6}.Release|x64.Build.0 = Release|x64
37 | {3C8C9F05-9C19-4251-95FA-05D7EDC8CAE6}.Release|x86.ActiveCfg = Release|x86
38 | {3C8C9F05-9C19-4251-95FA-05D7EDC8CAE6}.Release|x86.Build.0 = Release|x86
39 | {156FA2E7-48A5-4940-B4BF-1154B052579A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
40 | {156FA2E7-48A5-4940-B4BF-1154B052579A}.Debug|Any CPU.Build.0 = Debug|Any CPU
41 | {156FA2E7-48A5-4940-B4BF-1154B052579A}.Debug|x64.ActiveCfg = Debug|x64
42 | {156FA2E7-48A5-4940-B4BF-1154B052579A}.Debug|x64.Build.0 = Debug|x64
43 | {156FA2E7-48A5-4940-B4BF-1154B052579A}.Debug|x86.ActiveCfg = Debug|x86
44 | {156FA2E7-48A5-4940-B4BF-1154B052579A}.Debug|x86.Build.0 = Debug|x86
45 | {156FA2E7-48A5-4940-B4BF-1154B052579A}.Release|Any CPU.ActiveCfg = Release|Any CPU
46 | {156FA2E7-48A5-4940-B4BF-1154B052579A}.Release|Any CPU.Build.0 = Release|Any CPU
47 | {156FA2E7-48A5-4940-B4BF-1154B052579A}.Release|x64.ActiveCfg = Release|x64
48 | {156FA2E7-48A5-4940-B4BF-1154B052579A}.Release|x64.Build.0 = Release|x64
49 | {156FA2E7-48A5-4940-B4BF-1154B052579A}.Release|x86.ActiveCfg = Release|x86
50 | {156FA2E7-48A5-4940-B4BF-1154B052579A}.Release|x86.Build.0 = Release|x86
51 | EndGlobalSection
52 | GlobalSection(SolutionProperties) = preSolution
53 | HideSolutionNode = FALSE
54 | EndGlobalSection
55 | EndGlobal
56 |
--------------------------------------------------------------------------------
/CSMSL/Analysis/ExperimentalDesign/ExperimentalCondition.cs:
--------------------------------------------------------------------------------
1 | // Copyright 2022 Derek J. Bailey
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | using CSMSL.Proteomics;
16 | using System.Collections;
17 | using System.Collections.Generic;
18 |
19 | namespace CSMSL.Analysis.ExperimentalDesign
20 | {
21 | public class ExperimentalCondition : IEnumerable
22 | {
23 | public string Name { get; private set; }
24 |
25 | public string Description { get; private set; }
26 |
27 | public int Count
28 | {
29 | get { return Modifications.Count; }
30 | }
31 |
32 | public HashSet Modifications { get; set; }
33 |
34 | public ExperimentalCondition(string name, string description = "")
35 | {
36 | Name = name;
37 | Description = description;
38 | Modifications = new HashSet();
39 | }
40 |
41 | public void AddModification(Modification mod)
42 | {
43 | Modifications.Add(mod);
44 | }
45 |
46 | public void AddModifications(params Modification[] mods)
47 | {
48 | foreach (Modification mod in mods)
49 | {
50 | Modifications.Add(mod);
51 | }
52 | }
53 |
54 | public override string ToString()
55 | {
56 | return Name;
57 | }
58 |
59 | public IEnumerator GetEnumerator()
60 | {
61 | return Modifications.GetEnumerator();
62 | }
63 |
64 | IEnumerator IEnumerable.GetEnumerator()
65 | {
66 | return Modifications.GetEnumerator();
67 | }
68 | }
69 | }
--------------------------------------------------------------------------------
/CSMSL/Analysis/ExperimentalDesign/ExperimentalSet.cs:
--------------------------------------------------------------------------------
1 | // Copyright 2022 Derek J. Bailey
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | using CSMSL.Proteomics;
16 | using System.Collections;
17 | using System.Collections.Generic;
18 | using System.Linq;
19 |
20 | namespace CSMSL.Analysis.ExperimentalDesign
21 | {
22 | public class ExperimentalSet : IEnumerable
23 | {
24 | private readonly HashSet _conditions;
25 |
26 | public string Name { get; private set; }
27 |
28 | public ExperimentalSet(string name = "")
29 | {
30 | Name = name;
31 | _conditions = new HashSet();
32 | }
33 |
34 | public void Add(ExperimentalCondition condition)
35 | {
36 | _conditions.Add(condition);
37 | }
38 |
39 | public IEnumerable GetAllModifications()
40 | {
41 | return _conditions.SelectMany(c => c.Modifications);
42 | }
43 |
44 | public bool Contains(Modification mod)
45 | {
46 | return _conditions.Any(c => c.Modifications.Contains(mod));
47 | }
48 |
49 | public override string ToString()
50 | {
51 | return Name;
52 | }
53 |
54 | public IEnumerator GetEnumerator()
55 | {
56 | return _conditions.GetEnumerator();
57 | }
58 |
59 | IEnumerator IEnumerable.GetEnumerator()
60 | {
61 | return _conditions.GetEnumerator();
62 | }
63 | }
64 | }
--------------------------------------------------------------------------------
/CSMSL/Analysis/ExperimentalDesign/Replicate.cs:
--------------------------------------------------------------------------------
1 | // Copyright 2022 Derek J. Bailey
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | namespace CSMSL.Analysis.ExperimentalDesign
16 | {
17 | public class Replicate
18 | {
19 | public Sample Sample { get; set; }
20 |
21 | public string Name { get; set; }
22 |
23 | public string Description { get; set; }
24 |
25 | public int Number { get; set; }
26 |
27 | public bool IsTechnical { get; set; }
28 |
29 | public bool IsBiological { get; set; }
30 | }
31 | }
--------------------------------------------------------------------------------
/CSMSL/Analysis/ExperimentalDesign/Sample.cs:
--------------------------------------------------------------------------------
1 | // Copyright 2022 Derek J. Bailey
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | using System.Collections;
16 | using System.Collections.Generic;
17 |
18 |
19 | namespace CSMSL.Analysis.ExperimentalDesign
20 | {
21 | public class Sample : IEnumerable
22 | {
23 | public string Name { get; set; }
24 |
25 | public string Description { get; set; }
26 |
27 | private readonly List _conditions;
28 |
29 | public ExperimentalCondition AddCondition(string name, string description = "")
30 | {
31 | ExperimentalCondition condition = new ExperimentalCondition(name, description);
32 | _conditions.Add(condition);
33 | return condition;
34 | }
35 |
36 | public Sample(string name, string description = "")
37 | {
38 | Name = name;
39 | Description = description;
40 | _conditions = new List();
41 | }
42 |
43 | public override string ToString()
44 | {
45 | return Name;
46 | }
47 |
48 | public IEnumerator GetEnumerator()
49 | {
50 | return _conditions.GetEnumerator();
51 | }
52 |
53 | IEnumerator IEnumerable.GetEnumerator()
54 | {
55 | return _conditions.GetEnumerator();
56 | }
57 | }
58 | }
--------------------------------------------------------------------------------
/CSMSL/Analysis/Identification/FragmentSpectralMatch.cs:
--------------------------------------------------------------------------------
1 | // Copyright 2022 Derek J. Bailey
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | using CSMSL.Chemistry;
16 | using CSMSL.Proteomics;
17 | using CSMSL.Spectral;
18 | using System;
19 |
20 | namespace CSMSL.Analysis.Identification
21 | {
22 | public class FragmentSpectralMatch : IMass, IEquatable
23 | {
24 | public ISpectrum Spectrum { get; private set; }
25 |
26 | public Fragment Fragment { get; private set; }
27 |
28 | public int Charge { get; private set; }
29 |
30 | public Tolerance Tolerance { get; private set; }
31 |
32 | public double MonoisotopicMass
33 | {
34 | get { return Fragment.ToMz(Charge); }
35 | }
36 |
37 | public FragmentSpectralMatch(ISpectrum spectrum, Fragment fragment, Tolerance tolerance, int charge = 1)
38 | {
39 | Spectrum = spectrum;
40 | Fragment = fragment;
41 | Tolerance = tolerance;
42 | Charge = charge;
43 | }
44 |
45 | public override int GetHashCode()
46 | {
47 | return Fragment.GetHashCode() + Charge;
48 | }
49 |
50 | public bool Equals(FragmentSpectralMatch other)
51 | {
52 | return Fragment.Equals(other.Fragment) && Charge.Equals(other.Charge);
53 | }
54 | }
55 | }
--------------------------------------------------------------------------------
/CSMSL/Analysis/Identification/IFalseDiscovery.cs:
--------------------------------------------------------------------------------
1 | // Copyright 2022 Derek J. Bailey
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | using System;
16 |
17 | namespace CSMSL.Analysis.Identification
18 | {
19 | ///
20 | /// An interface to filter lists based on the detection of decoy hits that are known to be wrong
21 | ///
22 | /// The type of scoring metric of the object (must implement IComparable)
23 | public interface IFalseDiscovery where T : IComparable
24 | {
25 | ///
26 | /// States whether the object is a Decoy hit (Known False Positive) or a Foward Hit (Unknown True Positive)
27 | ///
28 | bool IsDecoy { get; }
29 |
30 | ///
31 | /// The scoring metric for the object
32 | ///
33 | T FdrScoreMetric { get; }
34 | }
35 | }
--------------------------------------------------------------------------------
/CSMSL/Analysis/Identification/MSSearchEngine.cs:
--------------------------------------------------------------------------------
1 | // Copyright 2022 Derek J. Bailey
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | using CSMSL.Chemistry;
16 | using CSMSL.Proteomics;
17 | using CSMSL.Spectral;
18 | using CSMSL.Util.Collections;
19 | using System.Collections.Generic;
20 |
21 | namespace CSMSL.Analysis.Identification
22 | {
23 | public abstract class MSSearchEngine
24 | {
25 | public Tolerance PrecursorMassTolerance { get; set; }
26 |
27 | public Tolerance ProductMassTolerance { get; set; }
28 |
29 | protected List Peptides;
30 |
31 | ///
32 | /// Gets or sets the maximum number of peptide spectral matches to record per spectrum
33 | ///
34 | public int MaxMatchesPerSpectrum { get; set; }
35 |
36 | public int MaxProductIonChargeState { get; set; }
37 |
38 | public int MaxVariableModificationsPerPeptide { get; set; }
39 |
40 | public PeptideSpectralMatchScoreType DefaultPsmScoreType { get; protected set; }
41 |
42 | public FragmentTypes DefaultFragmentType { get; protected set; }
43 |
44 | public virtual PeptideSpectralMatch Search(IMassSpectrum massSpectrum, Peptide peptide)
45 | {
46 | return Search(massSpectrum, peptide, DefaultFragmentType, ProductMassTolerance);
47 | }
48 |
49 | public abstract PeptideSpectralMatch Search(IMassSpectrum massSpectrum, Peptide peptide, FragmentTypes fragmentTypes, Tolerance productMassTolerance);
50 |
51 | public virtual SortedMaxSizedContainer Search(IMassSpectrum massSpectrum, IEnumerable peptides)
52 | {
53 | return Search(massSpectrum, peptides, DefaultFragmentType, ProductMassTolerance);
54 | }
55 |
56 | public virtual SortedMaxSizedContainer Search(IMassSpectrum massSpectrum, IEnumerable peptides, FragmentTypes fragmentTypes, Tolerance productMassTolerance)
57 | {
58 | SortedMaxSizedContainer results = new SortedMaxSizedContainer(MaxMatchesPerSpectrum);
59 |
60 | foreach (var peptide in peptides)
61 | {
62 | results.Add(Search(massSpectrum, peptide, fragmentTypes, productMassTolerance));
63 | }
64 |
65 | return results;
66 | }
67 |
68 | public void LoadPeptides(IEnumerable peptides)
69 | {
70 | }
71 |
72 | public void AddVariableModification(IMass modification, char residue)
73 | {
74 | }
75 |
76 | public void AddVariableModification(IMass modificaiton, IAminoAcid aminoAcid)
77 | {
78 | }
79 |
80 | public void AddVariableModification(IMass modificaiton, Terminus terminus)
81 | {
82 | }
83 |
84 | public void AddVariableModification(IMass modificaiton, ModificationSites sites)
85 | {
86 | }
87 |
88 | public void ClearVariableModifications()
89 | {
90 | }
91 |
92 | protected MSSearchEngine()
93 | {
94 | MaxMatchesPerSpectrum = 10;
95 | }
96 | }
97 | }
--------------------------------------------------------------------------------
/CSMSL/Analysis/Identification/PeptideSpectralMatchScoreType.cs:
--------------------------------------------------------------------------------
1 | // Copyright 2022 Derek J. Bailey
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 | namespace CSMSL.Analysis.Identification
15 | {
16 | public enum PeptideSpectralMatchScoreType
17 | {
18 | OmssaEvalue = 3,
19 | EValue = 1,
20 | LowerIsBetter = 2,
21 | HigherIsBetter = -3,
22 | XCorr = -1,
23 | Morpheus = -2,
24 | MSAmanda = -4
25 | }
26 | }
--------------------------------------------------------------------------------
/CSMSL/Analysis/Identification/SpectrumFragmentsMatch.cs:
--------------------------------------------------------------------------------
1 | // Copyright 2022 Derek J. Bailey
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 | using CSMSL.Chemistry;
15 | using CSMSL.Proteomics;
16 | using CSMSL.Spectral;
17 | using System.Collections.Generic;
18 |
19 | namespace CSMSL.Analysis.Identification
20 | {
21 | public class SpectrumFragmentsMatch
22 | {
23 | public ISpectrum Spectrum { get; private set; }
24 |
25 | private readonly HashSet _fragmentSpectralMatches;
26 |
27 | private readonly HashSet _fragments;
28 |
29 | public int Matches
30 | {
31 | get { return _fragmentSpectralMatches.Count; }
32 | }
33 |
34 | public double PercentTIC { get; private set; }
35 |
36 | public bool Contains(Fragment fragment)
37 | {
38 | return _fragments.Contains(fragment);
39 | }
40 |
41 | public void Add(FragmentSpectralMatch fsm)
42 | {
43 | _fragmentSpectralMatches.Add(fsm);
44 | _fragments.Add(fsm.Fragment);
45 | }
46 |
47 | public SpectrumFragmentsMatch(ISpectrum spectrum)
48 | {
49 | Spectrum = spectrum;
50 | _fragmentSpectralMatches = new HashSet();
51 | _fragments = new HashSet();
52 | }
53 |
54 | public override string ToString()
55 | {
56 | return string.Format("{0} Matches", Matches);
57 | }
58 |
59 | public IEnumerable MatchFragments(IEnumerable fragments, Tolerance tolerance, double percentCutoff, params int[] chargeStates)
60 | {
61 | double basePeakInt = Spectrum.GetBasePeakIntensity();
62 | double lowThreshold = basePeakInt*percentCutoff;
63 | double summedIntensity = 0;
64 | double totalIntensity = Spectrum.GetTotalIonCurrent();
65 | foreach (Fragment fragment in fragments)
66 | {
67 | foreach (int chargeState in chargeStates)
68 | {
69 | double mz = fragment.ToMz(chargeState);
70 | var peak = Spectrum.GetClosestPeak(tolerance.GetRange(mz));
71 | if (peak != null && peak.Intensity >= lowThreshold)
72 | {
73 | Add(new FragmentSpectralMatch(Spectrum, fragment, tolerance, chargeState));
74 | yield return fragment;
75 | summedIntensity += peak.Intensity;
76 | }
77 | }
78 | }
79 | PercentTIC = 100.0*summedIntensity/totalIntensity;
80 | }
81 | }
82 | }
--------------------------------------------------------------------------------
/CSMSL/Analysis/Quantitation/IQuantitationChannel.cs:
--------------------------------------------------------------------------------
1 | // Copyright 2022 Derek J. Bailey
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 | using CSMSL.Chemistry;
15 |
16 | namespace CSMSL.Analysis.Quantitation
17 | {
18 | public interface IQuantitationChannel : IMass
19 | {
20 | ///
21 | /// Does this channel depend upon the peptide sequence to calculate its mass?
22 | ///
23 | bool IsSequenceDependent { get; }
24 |
25 | ///
26 | /// The mass of the reporter
27 | ///
28 | double ReporterMass { get; }
29 |
30 | ///
31 | /// The name of the channel
32 | ///
33 | string Name { get; }
34 | }
35 | }
--------------------------------------------------------------------------------
/CSMSL/Analysis/Quantitation/IntensityWeightingType.cs:
--------------------------------------------------------------------------------
1 | // Copyright 2022 Derek J. Bailey
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | namespace CSMSL.Analysis.Quantitation
16 | {
17 | public enum IntensityWeightingType
18 | {
19 | Summed = 0,
20 | Average = 1,
21 | Median = 2
22 | }
23 | }
--------------------------------------------------------------------------------
/CSMSL/Analysis/Quantitation/IsobaricTag.cs:
--------------------------------------------------------------------------------
1 | // Copyright 2022 Derek J. Bailey
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | using CSMSL.Chemistry;
16 | using CSMSL.Proteomics;
17 |
18 | namespace CSMSL.Analysis.Quantitation
19 | {
20 | public sealed class IsobaricTag : ChemicalFormulaModification, IQuantitationChannel
21 | {
22 | private readonly ChemicalFormula _reporterFormula;
23 |
24 | private readonly ChemicalFormula _balanceFormula;
25 |
26 | public ChemicalFormula totalFormula
27 | {
28 | get { return _reporterFormula + _balanceFormula; }
29 | }
30 |
31 | public double reporterMass
32 | {
33 | get { return _reporterFormula.MonoisotopicMass; }
34 | }
35 |
36 | public IsobaricTag(string chemicalFormula, string name)
37 | : base(chemicalFormula, name)
38 | {
39 | }
40 |
41 | public IsobaricTag(ChemicalFormula chemicalFormula, string name)
42 | : base(chemicalFormula, name)
43 | {
44 | }
45 |
46 | public IsobaricTag(string reporterFormula, string balanceFormula, string name)
47 | : base(reporterFormula + balanceFormula, name)
48 | {
49 | _reporterFormula = new ChemicalFormula(reporterFormula);
50 | _balanceFormula = new ChemicalFormula(balanceFormula);
51 | }
52 |
53 | public bool IsMS1Based
54 | {
55 | get { return false; }
56 | }
57 |
58 | public bool IsSequenceDependent
59 | {
60 | get { return false; }
61 | }
62 |
63 | double IQuantitationChannel.ReporterMass
64 | {
65 | get { return _reporterFormula.MonoisotopicMass; }
66 | }
67 | }
68 | }
--------------------------------------------------------------------------------
/CSMSL/Analysis/Quantitation/IsobaricTagPurityCorrection.cs:
--------------------------------------------------------------------------------
1 | // Copyright 2022 Derek J. Bailey
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | using System;
16 | using System.Collections.Generic;
17 | using System.Linq;
18 |
19 | namespace CSMSL.Analysis.Quantitation
20 | {
21 | public class IsobaricTagPurityCorrection
22 | {
23 | //private readonly Matrix _purityMatrix;
24 |
25 | private readonly double[,] _purityMatrix;
26 | private readonly double[,] _purityLUMatrix;
27 | private readonly int[] _purityLUMatrixIndex;
28 |
29 | private IsobaricTagPurityCorrection(double[,] matrix)
30 | {
31 | _purityMatrix = matrix;
32 | int[] index;
33 | _purityLUMatrix = _purityMatrix.LUDecompose(out index);
34 | _purityLUMatrixIndex = index;
35 | }
36 |
37 | public double[,] GetMatrix()
38 | {
39 | return _purityMatrix.Copy();
40 | //return _purityMatrix;
41 | }
42 |
43 | //public double Determinant()
44 | //{
45 | // return _purityMatrix.Determinant();
46 | //}
47 |
48 | public double[] ApplyPurityCorrection(IEnumerable rawData)
49 | {
50 | return ApplyPurityCorrection(rawData.ToArray());
51 | }
52 |
53 | public double[] ApplyPurityCorrection(double[] rawData)
54 | {
55 | if (rawData.Length != _purityLUMatrix.GetLength(0))
56 | {
57 | throw new ArgumentException("Not enough data points");
58 | }
59 | double[] result = _purityLUMatrix.Solve(rawData, _purityLUMatrixIndex);
60 | return result;
61 | }
62 |
63 | ///
64 | /// Creates a matrix with the solutions to isobaric purity corrections
65 | ///
66 | ///
67 | ///
68 | public static IsobaricTagPurityCorrection Create(double[,] purityValues)
69 | {
70 | int rows = purityValues.GetLength(0);
71 | int inputCount = purityValues.GetLength(1);
72 |
73 | double[,] purityMatrix = new double[rows, rows];
74 |
75 | //w x y z part of iTracker Paper
76 | for (int i = 0; i < rows; i++)
77 | {
78 | double startvalue = 100;
79 | for (int j = 0; j < inputCount; j++)
80 | {
81 | startvalue -= purityValues[i, j];
82 | }
83 |
84 | for (int j = 0; j < rows; j++)
85 | {
86 | if (j == i) continue; // Handled in the above code
87 | double value = 0; // Zero fill;
88 |
89 | int k = (j > i) ? 2 - j + i : i - j + 1;
90 |
91 | if (k < inputCount && k >= 0)
92 | value = purityValues[j, k];
93 |
94 | purityMatrix[i, j] = value;
95 | }
96 |
97 | purityMatrix[i, i] = startvalue;
98 | }
99 |
100 | return new IsobaricTagPurityCorrection(purityMatrix);
101 | }
102 | }
103 | }
--------------------------------------------------------------------------------
/CSMSL/Analysis/Quantitation/QuantitationChannelSetMassType.cs:
--------------------------------------------------------------------------------
1 | // Copyright 2022 Derek J. Bailey
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | namespace CSMSL.Analysis.Quantitation
16 | {
17 | public enum QuantitationChannelSetMassType
18 | {
19 | Lightest,
20 | Average,
21 | Median,
22 | Heaviest
23 | }
24 | }
--------------------------------------------------------------------------------
/CSMSL/Analysis/Quantitation/QuantitationTypes.cs:
--------------------------------------------------------------------------------
1 | // Copyright 2022 Derek J. Bailey
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | using System;
16 |
17 | namespace CSMSL.Analysis.Quantitation
18 | {
19 | [Flags]
20 | public enum QuantitationTypes
21 | {
22 | None = 0,
23 | ReporterTag = 1,
24 | SILAC = 2,
25 | Chemical = 4,
26 | Metabolic = 8,
27 | MS1Based = 16,
28 | MS2Based = 32
29 | }
30 | }
--------------------------------------------------------------------------------
/CSMSL/Chemistry/IChemicalFormula.cs:
--------------------------------------------------------------------------------
1 | // Copyright 2022 Derek J. Bailey
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | using System;
16 | using System.Collections.Generic;
17 |
18 | namespace CSMSL.Chemistry
19 | {
20 | ///
21 | /// An object that has a chemical formula
22 | ///
23 | public interface IChemicalFormula : IMass
24 | {
25 | ///
26 | /// The chemical formula of this object
27 | ///
28 | ChemicalFormula ChemicalFormula { get; }
29 | }
30 |
31 | public static class ChemicalFormulaExtensions
32 | {
33 | [Flags]
34 | public enum FilterTypes
35 | {
36 | None = 0,
37 | Valence = 1,
38 | HydrogenCarbonRatio = 2,
39 | All = 3,
40 | }
41 |
42 | public static IEnumerable Validate(this IEnumerable formulas, FilterTypes filters = FilterTypes.All)
43 | {
44 | bool useValence = filters.HasFlag(FilterTypes.Valence);
45 | bool useHydrogenCarbonRatio = filters.HasFlag(FilterTypes.HydrogenCarbonRatio);
46 |
47 | foreach (IChemicalFormula formula in formulas)
48 | {
49 | if (useHydrogenCarbonRatio)
50 | {
51 | double ratio = formula.ChemicalFormula.GetCarbonHydrogenRatio();
52 |
53 | if (ratio < 0.5 || ratio > 2.0)
54 | continue;
55 | }
56 |
57 | if (useValence)
58 | {
59 | int totalValence = 0;
60 | int maxValence = 0;
61 | int oddValences = 0;
62 | int atomCount = 0;
63 | int[] isotopes = formula.ChemicalFormula.GetIsotopes();
64 | for (int i = 0; i < isotopes.Length; i++)
65 | {
66 | int numAtoms = isotopes[i];
67 | if (numAtoms != 0)
68 | continue;
69 | Isotope isotope = PeriodicTable.GetIsotope(i);
70 |
71 | int numValenceElectrons = isotope.ValenceElectrons;
72 | totalValence += numValenceElectrons*numAtoms;
73 | atomCount += numAtoms;
74 | if (numValenceElectrons > maxValence)
75 | {
76 | maxValence = numValenceElectrons;
77 | }
78 | if (numValenceElectrons%2 != 0)
79 | {
80 | oddValences += numAtoms;
81 | }
82 | }
83 | if (!((totalValence%2 == 0 || oddValences%2 == 0) && (totalValence >= 2*maxValence) && (totalValence >= ((2*atomCount) - 1))))
84 | {
85 | continue;
86 | }
87 | }
88 |
89 | yield return formula;
90 | }
91 | }
92 | }
93 | }
--------------------------------------------------------------------------------
/CSMSL/Chemistry/IMass.cs:
--------------------------------------------------------------------------------
1 | // Copyright 2022 Derek J. Bailey
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 | using System;
15 |
16 | namespace CSMSL.Chemistry
17 | {
18 | ///
19 | ///
20 | ///
21 | public interface IMass
22 | {
23 | ///
24 | /// The monoisotopic mass of this object
25 | ///
26 | double MonoisotopicMass { get; }
27 | }
28 |
29 | public static class MassExtensions
30 | {
31 | ///
32 | /// The mass difference tolerance for having identical masses
33 | ///
34 | public const double MassEqualityEpsilon = 1e-10;
35 |
36 | ///
37 | /// Converts the object that has a mass into a m/z value based on the charge state
38 | ///
39 | ///
40 | ///
41 | ///
42 | ///
43 | public static double ToMz(this IMass mass, int charge, int c13Isotope = 0)
44 | {
45 | return Mass.MzFromMass(mass.MonoisotopicMass + c13Isotope*Constants.C13C12Difference, charge);
46 | }
47 |
48 | ///
49 | /// Converts the object that has a m/z into a mass value based on the charge state
50 | ///
51 | ///
52 | ///
53 | ///
54 | ///
55 | public static double ToMass(this IMass mz, int charge, int c13Isotope = 0)
56 | {
57 | return Mass.MassFromMz(mz.MonoisotopicMass + c13Isotope*Constants.C13C12Difference, charge);
58 | }
59 |
60 | public static bool MassEquals(this double mass1, IMass mass2, double epsilon = MassEqualityEpsilon)
61 | {
62 | if (mass2 == null)
63 | return false;
64 | return Math.Abs(mass1 - mass2.MonoisotopicMass) < epsilon;
65 | }
66 |
67 | public static bool MassEquals(this double mass1, double mass2, double epsilon = MassEqualityEpsilon)
68 | {
69 | return Math.Abs(mass1 - mass2) < epsilon;
70 | }
71 |
72 | public static bool MassEquals(this IMass mass1, double mass2, double epsilon = MassEqualityEpsilon)
73 | {
74 | if (mass1 == null)
75 | return false;
76 | return Math.Abs(mass1.MonoisotopicMass - mass2) < epsilon;
77 | }
78 |
79 | public static bool MassEquals(this IMass mass1, IMass mass2, double epsilon = MassEqualityEpsilon)
80 | {
81 | if (mass1 == null || mass2 == null)
82 | return false;
83 | return Math.Abs(mass1.MonoisotopicMass - mass2.MonoisotopicMass) < epsilon;
84 | }
85 |
86 | public static int Compare(this IMass mass1, IMass mass2, double epsilon = MassEqualityEpsilon)
87 | {
88 | double difference = mass1.MonoisotopicMass - mass2.MonoisotopicMass;
89 | if (difference < -epsilon)
90 | return -1;
91 | return difference > epsilon ? 1 : 0;
92 | }
93 | }
94 | }
--------------------------------------------------------------------------------
/CSMSL/Constants.cs:
--------------------------------------------------------------------------------
1 | // Copyright 2022 Derek J. Bailey
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | namespace CSMSL
16 | {
17 | ///
18 | /// A collection of immutable constants and physical properties.
19 | /// Masses are given for the most abundant isotope unless otherwise stated
20 | ///
21 | /// Sources include:
22 | /// http://physics.nist.gov/cuu/Constants/index.html
23 | ///
24 | public static class Constants
25 | {
26 | #region Subatomic
27 |
28 | ///
29 | /// The mass of the subatomic particle with a single negative elementary charge in
30 | /// atomic units (u)
31 | ///
32 | public const double Electron = 0.00054857990946;
33 |
34 | ///
35 | /// The mass of the subatomic particle with a single elementary charge in atomic
36 | /// units (u)
37 | ///
38 | public const double Proton = 1.007276466812;
39 |
40 | #endregion Subatomic
41 |
42 | #region Atomic
43 |
44 | ///
45 | /// The mass of the most common isotope of carbon in atomic units (u)
46 | ///
47 | public const double Carbon = 12.00000000000;
48 |
49 | public const double Carbon13 = 13.0033548378;
50 |
51 | ///
52 | /// The mass difference between carbon 13 and 12 isotopes, often used for isotopic distributions
53 | ///
54 | public const double C13C12Difference = Carbon13 - Carbon;
55 |
56 | ///
57 | /// The mass of the most common isotope of hydrogen in atomic units (u)
58 | ///
59 | public const double Hydrogen = 1.00782503207;
60 |
61 | public const double Deuterium = 2.0141017778;
62 |
63 | public const double Nitrogen = 14.0030740048;
64 |
65 | public const double Nitrogen15 = 15.0001088982;
66 |
67 | ///
68 | /// The mass of the most common isotope of hydrogen in atomic units (u)
69 | ///
70 | public const double Oxygen = 15.99491461956;
71 |
72 | public const double Oxygen18 = 17.9991610;
73 |
74 | public const double Sulfur = 31.97207100;
75 |
76 | public const double Sulfur34 = 33.96786690;
77 |
78 | #endregion Atomic
79 |
80 | #region Molecular
81 |
82 | ///
83 | /// The mass of the molecule H20 given in atomic units (u) of the most common isotopes
84 | ///
85 | public const double Water = Hydrogen*2 + Oxygen;
86 |
87 | #endregion Molecular
88 | }
89 | }
--------------------------------------------------------------------------------
/CSMSL/IO/ABSciex/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | // Copyright 2022 Derek J. Bailey
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | using System.Reflection;
16 | using System.Runtime.CompilerServices;
17 | using System.Runtime.InteropServices;
18 |
19 | // General Information about an assembly is controlled through the following
20 | // set of attributes. Change these attribute values to modify the information
21 | // associated with an assembly.
22 | [assembly: AssemblyTitle("ABSciex")]
23 | [assembly: AssemblyDescription("")]
24 | [assembly: AssemblyConfiguration("")]
25 | [assembly: AssemblyCompany("")]
26 | [assembly: AssemblyProduct("ABSciex")]
27 | [assembly: AssemblyCopyright("Copyright © 2013")]
28 | [assembly: AssemblyTrademark("")]
29 | [assembly: AssemblyCulture("")]
30 |
31 | // Setting ComVisible to false makes the types in this assembly not visible
32 | // to COM components. If you need to access a type in this assembly from
33 | // COM, set the ComVisible attribute to true on that type.
34 | [assembly: ComVisible(false)]
35 |
36 | // The following GUID is for the ID of the typelib if this project is exposed to COM
37 | [assembly: Guid("85c6ffca-0dac-4bc5-853c-d2518fdff991")]
38 |
39 | // Version information for an assembly consists of the following four values:
40 | //
41 | // Major Version
42 | // Minor Version
43 | // Build Number
44 | // Revision
45 | //
46 | // You can specify all the values or you can default the Build and Revision Numbers
47 | // by using the '*' as shown below:
48 | // [assembly: AssemblyVersion("1.0.*")]
49 | [assembly: AssemblyVersion("1.0.0.0")]
50 | [assembly: AssemblyFileVersion("1.0.0.0")]
51 |
--------------------------------------------------------------------------------
/CSMSL/IO/ABSciex/include/Clearcore2.Compression.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dbaileychess/CSMSL/8bd6409bb0c231783c85978cf2119af498238e06/CSMSL/IO/ABSciex/include/Clearcore2.Compression.dll
--------------------------------------------------------------------------------
/CSMSL/IO/ABSciex/include/Clearcore2.Data.AnalystDataProvider.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dbaileychess/CSMSL/8bd6409bb0c231783c85978cf2119af498238e06/CSMSL/IO/ABSciex/include/Clearcore2.Data.AnalystDataProvider.dll
--------------------------------------------------------------------------------
/CSMSL/IO/ABSciex/include/Clearcore2.Data.CommonInterfaces.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dbaileychess/CSMSL/8bd6409bb0c231783c85978cf2119af498238e06/CSMSL/IO/ABSciex/include/Clearcore2.Data.CommonInterfaces.dll
--------------------------------------------------------------------------------
/CSMSL/IO/ABSciex/include/Clearcore2.Data.WiffReader.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dbaileychess/CSMSL/8bd6409bb0c231783c85978cf2119af498238e06/CSMSL/IO/ABSciex/include/Clearcore2.Data.WiffReader.dll
--------------------------------------------------------------------------------
/CSMSL/IO/ABSciex/include/Clearcore2.Data.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dbaileychess/CSMSL/8bd6409bb0c231783c85978cf2119af498238e06/CSMSL/IO/ABSciex/include/Clearcore2.Data.dll
--------------------------------------------------------------------------------
/CSMSL/IO/ABSciex/include/Clearcore2.InternalRawXYProcessing.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dbaileychess/CSMSL/8bd6409bb0c231783c85978cf2119af498238e06/CSMSL/IO/ABSciex/include/Clearcore2.InternalRawXYProcessing.dll
--------------------------------------------------------------------------------
/CSMSL/IO/ABSciex/include/Clearcore2.Muni.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dbaileychess/CSMSL/8bd6409bb0c231783c85978cf2119af498238e06/CSMSL/IO/ABSciex/include/Clearcore2.Muni.dll
--------------------------------------------------------------------------------
/CSMSL/IO/ABSciex/include/Clearcore2.ProjectUtilities.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dbaileychess/CSMSL/8bd6409bb0c231783c85978cf2119af498238e06/CSMSL/IO/ABSciex/include/Clearcore2.ProjectUtilities.dll
--------------------------------------------------------------------------------
/CSMSL/IO/ABSciex/include/Clearcore2.RawXYProcessing.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dbaileychess/CSMSL/8bd6409bb0c231783c85978cf2119af498238e06/CSMSL/IO/ABSciex/include/Clearcore2.RawXYProcessing.dll
--------------------------------------------------------------------------------
/CSMSL/IO/ABSciex/include/Clearcore2.StructuredStorage.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dbaileychess/CSMSL/8bd6409bb0c231783c85978cf2119af498238e06/CSMSL/IO/ABSciex/include/Clearcore2.StructuredStorage.dll
--------------------------------------------------------------------------------
/CSMSL/IO/ABSciex/include/Clearcore2.Utility.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dbaileychess/CSMSL/8bd6409bb0c231783c85978cf2119af498238e06/CSMSL/IO/ABSciex/include/Clearcore2.Utility.dll
--------------------------------------------------------------------------------
/CSMSL/IO/Agilent/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | // Copyright 2012, 2013, 2014 Derek J. Bailey
2 | //
3 | // This file (AssemblyInfo.cs) is part of CSMSL.
4 | //
5 | // CSMSL is free software: you can redistribute it and/or modify it
6 | // under the terms of the GNU Lesser General Public License as published
7 | // by the Free Software Foundation, either version 3 of the License, or
8 | // (at your option) any later version.
9 | //
10 | // CSMSL is distributed in the hope that it will be useful, but WITHOUT
11 | // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 | // FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
13 | // License for more details.
14 | //
15 | // You should have received a copy of the GNU Lesser General Public
16 | // License along with CSMSL. If not, see .
17 |
18 | using System.Reflection;
19 | using System.Runtime.InteropServices;
20 |
21 | // General Information about an assembly is controlled through the following
22 | // set of attributes. Change these attribute values to modify the information
23 | // associated with an assembly.
24 |
25 | [assembly: AssemblyTitle("Agilent")]
26 | [assembly: AssemblyDescription("")]
27 | [assembly: AssemblyConfiguration("")]
28 | [assembly: AssemblyCompany("")]
29 | [assembly: AssemblyProduct("Agilent")]
30 | [assembly: AssemblyCopyright("Copyright © 2012")]
31 | [assembly: AssemblyTrademark("")]
32 | [assembly: AssemblyCulture("")]
33 |
34 | // Setting ComVisible to false makes the types in this assembly not visible
35 | // to COM components. If you need to access a type in this assembly from
36 | // COM, set the ComVisible attribute to true on that type.
37 |
38 | [assembly: ComVisible(false)]
39 |
40 | // The following GUID is for the ID of the typelib if this project is exposed to COM
41 |
42 | [assembly: Guid("6165ad55-2697-447e-b5e3-8107fb3fb3a2")]
43 |
44 | // Version information for an assembly consists of the following four values:
45 | //
46 | // Major Version
47 | // Minor Version
48 | // Build Number
49 | // Revision
50 | //
51 | // You can specify all the values or you can default the Build and Revision Numbers
52 | // by using the '*' as shown below:
53 | // [assembly: AssemblyVersion("1.0.*")]
54 |
55 | [assembly: AssemblyVersion("1.0.0.0")]
56 | [assembly: AssemblyFileVersion("1.0.0.0")]
--------------------------------------------------------------------------------
/CSMSL/IO/Agilent/include/x64/BaseCommon.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dbaileychess/CSMSL/8bd6409bb0c231783c85978cf2119af498238e06/CSMSL/IO/Agilent/include/x64/BaseCommon.dll
--------------------------------------------------------------------------------
/CSMSL/IO/Agilent/include/x64/BaseDataAccess.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dbaileychess/CSMSL/8bd6409bb0c231783c85978cf2119af498238e06/CSMSL/IO/Agilent/include/x64/BaseDataAccess.dll
--------------------------------------------------------------------------------
/CSMSL/IO/Agilent/include/x64/BaseError.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dbaileychess/CSMSL/8bd6409bb0c231783c85978cf2119af498238e06/CSMSL/IO/Agilent/include/x64/BaseError.dll
--------------------------------------------------------------------------------
/CSMSL/IO/Agilent/include/x64/BaseTof.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dbaileychess/CSMSL/8bd6409bb0c231783c85978cf2119af498238e06/CSMSL/IO/Agilent/include/x64/BaseTof.dll
--------------------------------------------------------------------------------
/CSMSL/IO/Agilent/include/x64/MassSpecDataReader.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dbaileychess/CSMSL/8bd6409bb0c231783c85978cf2119af498238e06/CSMSL/IO/Agilent/include/x64/MassSpecDataReader.dll
--------------------------------------------------------------------------------
/CSMSL/IO/Agilent/include/x86/BaseCommon.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dbaileychess/CSMSL/8bd6409bb0c231783c85978cf2119af498238e06/CSMSL/IO/Agilent/include/x86/BaseCommon.dll
--------------------------------------------------------------------------------
/CSMSL/IO/Agilent/include/x86/BaseDataAccess.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dbaileychess/CSMSL/8bd6409bb0c231783c85978cf2119af498238e06/CSMSL/IO/Agilent/include/x86/BaseDataAccess.dll
--------------------------------------------------------------------------------
/CSMSL/IO/Agilent/include/x86/BaseError.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dbaileychess/CSMSL/8bd6409bb0c231783c85978cf2119af498238e06/CSMSL/IO/Agilent/include/x86/BaseError.dll
--------------------------------------------------------------------------------
/CSMSL/IO/Agilent/include/x86/BaseTof.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dbaileychess/CSMSL/8bd6409bb0c231783c85978cf2119af498238e06/CSMSL/IO/Agilent/include/x86/BaseTof.dll
--------------------------------------------------------------------------------
/CSMSL/IO/Agilent/include/x86/MassSpecDataReader.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dbaileychess/CSMSL/8bd6409bb0c231783c85978cf2119af498238e06/CSMSL/IO/Agilent/include/x86/MassSpecDataReader.dll
--------------------------------------------------------------------------------
/CSMSL/IO/Bruker/Bruker.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {F1976BEF-8756-46C2-830B-A638FF4A2E8C}
8 | Library
9 | Properties
10 | CSMSL.IO.Bruker
11 | CSMSL.Bruker
12 | v4.0
13 | 512
14 |
15 |
16 |
17 | true
18 | bin\x64\Debug\
19 | DEBUG;TRACE
20 | full
21 | x64
22 | prompt
23 | MinimumRecommendedRules.ruleset
24 |
25 |
26 | bin\x64\Release\
27 | TRACE
28 | true
29 | pdbonly
30 | x64
31 | prompt
32 | MinimumRecommendedRules.ruleset
33 |
34 |
35 | true
36 | bin\x86\Debug\
37 | DEBUG;TRACE
38 | full
39 | x86
40 | prompt
41 | MinimumRecommendedRules.ruleset
42 |
43 |
44 | bin\x86\Release\
45 | TRACE
46 | true
47 | pdbonly
48 | x86
49 | prompt
50 | MinimumRecommendedRules.ruleset
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 | {3c8c9f05-9c19-4251-95fa-05d7edc8cae6}
66 | CSMSL
67 |
68 |
69 |
70 |
71 | {8E79B9A2-107E-4E91-A0FF-01F2591103F3}
72 | 1
73 | 0
74 | 0
75 | tlbimp
76 | False
77 |
78 |
79 |
80 |
81 |
82 |
83 |
90 |
--------------------------------------------------------------------------------
/CSMSL/IO/Bruker/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | // Copyright 2022 Derek J. Bailey
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | using System.Reflection;
16 | using System.Runtime.CompilerServices;
17 | using System.Runtime.InteropServices;
18 |
19 | // General Information about an assembly is controlled through the following
20 | // set of attributes. Change these attribute values to modify the information
21 | // associated with an assembly.
22 | [assembly: AssemblyTitle("Bruker")]
23 | [assembly: AssemblyDescription("")]
24 | [assembly: AssemblyConfiguration("")]
25 | [assembly: AssemblyCompany("")]
26 | [assembly: AssemblyProduct("Bruker")]
27 | [assembly: AssemblyCopyright("Copyright © 2013")]
28 | [assembly: AssemblyTrademark("")]
29 | [assembly: AssemblyCulture("")]
30 |
31 | // Setting ComVisible to false makes the types in this assembly not visible
32 | // to COM components. If you need to access a type in this assembly from
33 | // COM, set the ComVisible attribute to true on that type.
34 | [assembly: ComVisible(false)]
35 |
36 | // The following GUID is for the ID of the typelib if this project is exposed to COM
37 | [assembly: Guid("bb2e8ab8-297f-4bd5-978a-24feaaeb2950")]
38 |
39 | // Version information for an assembly consists of the following four values:
40 | //
41 | // Major Version
42 | // Minor Version
43 | // Build Number
44 | // Revision
45 | //
46 | // You can specify all the values or you can default the Build and Revision Numbers
47 | // by using the '*' as shown below:
48 | // [assembly: AssemblyVersion("1.0.*")]
49 | [assembly: AssemblyVersion("1.0.0.0")]
50 | [assembly: AssemblyFileVersion("1.0.0.0")]
51 |
--------------------------------------------------------------------------------
/CSMSL/IO/Bruker/include/Interop.EDAL.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dbaileychess/CSMSL/8bd6409bb0c231783c85978cf2119af498238e06/CSMSL/IO/Bruker/include/Interop.EDAL.dll
--------------------------------------------------------------------------------
/CSMSL/IO/CVParamater.cs:
--------------------------------------------------------------------------------
1 | // Copyright 2022 Derek J. Bailey
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | using System;
16 | using System.Text.RegularExpressions;
17 |
18 | namespace CSMSL.IO
19 | {
20 | public class CVParamater
21 | {
22 | private static readonly Regex CvRegex = new Regex(@"\[(.*),(.*),(.*),(.*)\]", RegexOptions.Compiled);
23 |
24 | public string Label { get; set; }
25 | public string Accession { get; set; }
26 | public string Name { get; set; }
27 | public string Value { get; set; }
28 |
29 | public CVParamater(string label, string accession, string name, string value)
30 | {
31 | Label = label;
32 | Accession = accession;
33 | Name = name;
34 | Value = value;
35 | }
36 |
37 | public CVParamater(string parameter)
38 | {
39 | Match m = CvRegex.Match(parameter);
40 | if (!m.Success)
41 | throw new ArgumentException("Unable to parse this CV Parameter correctly: " + parameter);
42 | Label = m.Groups[1].Value.Trim();
43 | Accession = m.Groups[2].Value.Trim();
44 | Name = m.Groups[3].Value.Trim();
45 | Value = m.Groups[4].Value.Trim();
46 | }
47 |
48 | public override string ToString()
49 | {
50 | string name = Name;
51 | if (name.Contains(","))
52 | {
53 | name = "\"" + name + "\"";
54 | }
55 | return string.Format("[{0},{1},{2},{3}]", Label, Accession, name, Value);
56 | }
57 |
58 | public static implicit operator CVParamater(string parameter)
59 | {
60 | return new CVParamater(parameter);
61 | }
62 | }
63 | }
--------------------------------------------------------------------------------
/CSMSL/IO/Dta.cs:
--------------------------------------------------------------------------------
1 | // Copyright 2022 Derek J. Bailey
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | using CSMSL.Spectral;
16 | using System.Text;
17 |
18 | namespace CSMSL.IO
19 | {
20 | public class Dta
21 | {
22 | public int ID { get; set; }
23 |
24 | public string Name { get; set; }
25 |
26 | public double PrecursorMass { get; set; }
27 |
28 | public int PrecursorCharge { get; set; }
29 |
30 | public MZSpectrum MzSpectrum { get; set; }
31 |
32 | public Dta(string name, int id, double precursorMass, int precursorCharge, MZSpectrum mzSpectrum)
33 | {
34 | Name = name;
35 | ID = id;
36 | PrecursorMass = precursorMass;
37 | PrecursorCharge = precursorCharge;
38 | MzSpectrum = mzSpectrum;
39 | }
40 |
41 | public string ToOutput(string precursormassFormat = "F5", string massFormat = "F4", string intensityFormat = "F2")
42 | {
43 | StringBuilder sb = new StringBuilder();
44 | sb.AppendFormat("", ID, Name);
45 | sb.AppendLine();
46 | sb.AppendFormat("{0} {1}", PrecursorMass.ToString(precursormassFormat), PrecursorCharge);
47 | sb.AppendLine();
48 | foreach (var peak in MzSpectrum)
49 | {
50 | sb.AppendFormat(" {0} {1}", peak.MZ.ToString(massFormat), peak.Intensity.ToString(intensityFormat));
51 | sb.AppendLine();
52 | }
53 | return sb.ToString();
54 | }
55 | }
56 | }
--------------------------------------------------------------------------------
/CSMSL/IO/DtaReader.cs:
--------------------------------------------------------------------------------
1 | // Copyright 2022 Derek J. Bailey
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | using CSMSL.Spectral;
16 | using System;
17 | using System.Collections.Generic;
18 | using System.IO;
19 | using System.Text.RegularExpressions;
20 |
21 | namespace CSMSL.IO
22 | {
23 | public sealed class DtaReader : IDisposable
24 | {
25 | private static Regex dtaheaderRegex = new Regex(@"id=""(\d+)""\s*name=""(.+)""", RegexOptions.Compiled);
26 |
27 | private StreamReader _reader;
28 |
29 | public DtaReader(string filePath)
30 | {
31 | FilePath = filePath;
32 |
33 | _reader = new StreamReader(FilePath);
34 | }
35 |
36 | public string FilePath { get; set; }
37 |
38 | public void Dispose()
39 | {
40 | if (_reader != null)
41 | _reader.Dispose();
42 | }
43 |
44 | public IEnumerable ReadNextDta()
45 | {
46 | List mz = new List();
47 | List intensities = new List();
48 |
49 | string name = "";
50 | int id = -1;
51 | bool first = true;
52 | bool precursor = false;
53 | double precursorMass = 0;
54 | int precursorCharge = 0;
55 | while (!_reader.EndOfStream)
56 | {
57 | string line = _reader.ReadLine();
58 | if (string.IsNullOrEmpty(line))
59 | continue;
60 |
61 | if (line.StartsWith(" dtas)
45 | {
46 | foreach (Dta dta in dtas)
47 | {
48 | _writer.WriteLine(dta.ToOutput());
49 | }
50 | }
51 | }
52 | }
--------------------------------------------------------------------------------
/CSMSL/IO/FastaReader.cs:
--------------------------------------------------------------------------------
1 | // Copyright 2022 Derek J. Bailey
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | using CSMSL.Proteomics;
16 | using System;
17 | using System.Collections.Generic;
18 | using System.IO;
19 | using System.Linq;
20 | using System.Text;
21 |
22 | namespace CSMSL.IO
23 | {
24 | public sealed class FastaReader : IDisposable
25 | {
26 | private readonly StreamReader _reader;
27 |
28 | public char Delimiter { get; private set; }
29 |
30 | public FastaReader(string fileName, char delimiter = '>')
31 | {
32 | FileName = fileName;
33 | Delimiter = delimiter;
34 | _reader = new StreamReader(fileName);
35 | }
36 |
37 | public string FileName { get; set; }
38 |
39 | public void Dispose()
40 | {
41 | if (_reader != null)
42 | _reader.Dispose();
43 | }
44 |
45 | public IEnumerable ReadNextFasta()
46 | {
47 | StringBuilder sequenceSb = new StringBuilder(500);
48 | StringBuilder headerSb = new StringBuilder(80);
49 |
50 | while (!_reader.EndOfStream)
51 | {
52 | string line = _reader.ReadLine();
53 | if (string.IsNullOrEmpty(line))
54 | continue;
55 |
56 | if (line[0] == Delimiter)
57 | {
58 | if (sequenceSb.Length > 0)
59 | {
60 | yield return new Fasta(sequenceSb.ToString().TrimEnd('*'), headerSb.ToString());
61 | sequenceSb.Clear();
62 | headerSb.Clear();
63 | }
64 | headerSb.Append(line.TrimStart(Delimiter));
65 | }
66 | else
67 | {
68 | sequenceSb.Append(line);
69 | }
70 | }
71 | if (sequenceSb.Length > 0)
72 | yield return new Fasta(sequenceSb.ToString().TrimEnd('*'), headerSb.ToString());
73 | }
74 |
75 | public IEnumerable ReadNextProtein()
76 | {
77 | return ReadNextFasta().Select(f => new Protein(f.Sequence, f.Description));
78 | }
79 |
80 | public override string ToString()
81 | {
82 | return FileName;
83 | }
84 |
85 | public static int NumberOfEntries(string filePath, char delimiter = '>')
86 | {
87 | int entries = 0;
88 | using (StreamReader reader = new StreamReader(filePath))
89 | {
90 | string line;
91 | while ((line = reader.ReadLine()) != null)
92 | {
93 | if (line[0] == delimiter)
94 | entries++;
95 | }
96 | }
97 | return entries;
98 | }
99 | }
100 | }
--------------------------------------------------------------------------------
/CSMSL/IO/FastaWriter.cs:
--------------------------------------------------------------------------------
1 | // Copyright 2022 Derek J. Bailey
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | using CSMSL.Proteomics;
16 | using System;
17 | using System.Collections.Generic;
18 | using System.IO;
19 |
20 | namespace CSMSL.IO
21 | {
22 | public sealed class FastaWriter : IDisposable
23 | {
24 | public int CharactersPerLine { get; private set; }
25 |
26 | public char Delimiter { get; private set; }
27 |
28 | public string FilePath { get; private set; }
29 |
30 | private readonly StreamWriter _writer;
31 |
32 | public FastaWriter(string filename, char delimiter = '>', int charperline = 80)
33 | {
34 | FilePath = filename;
35 | Delimiter = delimiter;
36 | CharactersPerLine = charperline;
37 | _writer = new StreamWriter(filename) {AutoFlush = true};
38 | }
39 |
40 | public void Dispose()
41 | {
42 | if (_writer != null)
43 | _writer.Dispose();
44 | }
45 |
46 | public void Write(IEnumerable proteins)
47 | {
48 | foreach (Protein protein in proteins)
49 | {
50 | Write(protein);
51 | }
52 | }
53 |
54 | public void Write(Protein protein)
55 | {
56 | Write(protein.Sequence, protein.Description);
57 | }
58 |
59 | public void Write(IEnumerable fastas)
60 | {
61 | foreach (Fasta fasta in fastas)
62 | {
63 | Write(fasta.Sequence, fasta.Description);
64 | }
65 | }
66 |
67 | public void Write(Fasta fasta)
68 | {
69 | Write(fasta.Sequence, fasta.Description);
70 | }
71 |
72 | public void Write(string sequence, string description)
73 | {
74 | _writer.WriteLine("{0}{1}", Delimiter, description);
75 | for (int i = 0; i < sequence.Length; i += CharactersPerLine)
76 | {
77 | _writer.WriteLine(sequence.Substring(i, (i + CharactersPerLine < sequence.Length) ?
78 | CharactersPerLine :
79 | sequence.Length - i));
80 | }
81 | }
82 |
83 | public void WriteLine(string line)
84 | {
85 | _writer.WriteLine(line);
86 | }
87 | }
88 | }
--------------------------------------------------------------------------------
/CSMSL/IO/IMSDataFile.cs:
--------------------------------------------------------------------------------
1 | // Copyright 2022 Derek J. Bailey
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 | using System;
15 | using CSMSL.Proteomics;
16 | using CSMSL.Spectral;
17 | using System.Collections.Generic;
18 |
19 | namespace CSMSL.IO
20 | {
21 | public interface IMSDataFile : IEnumerable, IDisposable, IEquatable
22 | {
23 | void Open();
24 | string Name { get; }
25 | bool IsOpen { get; }
26 | int FirstSpectrumNumber { get; }
27 | int LastSpectrumNumber { get; }
28 | int GetMsnOrder(int spectrumNumber);
29 | double GetInjectionTime(int spectrumNumber);
30 | double GetPrecursorMz(int spectrumNumber, int msnOrder = 2);
31 | double GetRetentionTime(int spectrumNumber);
32 | DissociationType GetDissociationType(int spectrumNumber, int msnOrder = 2);
33 | Polarity GetPolarity(int spectrumNumber);
34 | ISpectrum GetSpectrum(int spectrumNumber);
35 | IMSDataScan this[int spectrumNumber] { get; }
36 | }
37 |
38 | public interface IMSDataFile : IMSDataFile, IEnumerable>
39 | where TSpectrum : ISpectrum
40 | {
41 | new TSpectrum GetSpectrum(int spectrumNumber);
42 | new IMSDataScan this[int spectrumNumber] { get; }
43 | }
44 | }
--------------------------------------------------------------------------------
/CSMSL/IO/IMSDataScan.cs:
--------------------------------------------------------------------------------
1 | // Copyright 2022 Derek J. Bailey
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | using CSMSL.Spectral;
16 |
17 | namespace CSMSL.IO
18 | {
19 | public interface IMSDataScan : IMassSpectrum
20 | {
21 | int SpectrumNumber { get; }
22 | int MsnOrder { get; }
23 | double RetentionTime { get; }
24 | Polarity Polarity { get; }
25 | MZAnalyzerType MzAnalyzer { get; }
26 | DoubleRange MzRange { get; }
27 | }
28 |
29 | public interface IMSDataScan : IMSDataScan
30 | where TSpectrum : ISpectrum
31 | {
32 | new TSpectrum MassSpectrum { get; }
33 | }
34 | }
--------------------------------------------------------------------------------
/CSMSL/IO/IMsnDataScan.cs:
--------------------------------------------------------------------------------
1 | // Copyright 2022 Derek J. Bailey
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | using CSMSL.Proteomics;
16 | using CSMSL.Spectral;
17 |
18 | namespace CSMSL.IO
19 | {
20 | public interface IMsnDataScan : IMSDataScan
21 | {
22 | int GetParentSpectrumNumber();
23 | double GetPrecursorMz();
24 | DoubleRange GetIsolationRange();
25 | int GetPrecursorCharge();
26 | DissociationType GetDissociationType();
27 | double GetInjectionTime();
28 | }
29 |
30 | public interface IMsnDataScan : IMsnDataScan
31 | where TSpectrum : ISpectrum
32 | {
33 | new TSpectrum MassSpectrum { get; }
34 | }
35 | }
--------------------------------------------------------------------------------
/CSMSL/IO/MsDataFileType.cs:
--------------------------------------------------------------------------------
1 | // Copyright 2022 Derek J. Bailey
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | namespace CSMSL.IO
16 | {
17 | public enum MSDataFileType
18 | {
19 | UnKnown = 0,
20 | Mzml = 1,
21 | ThermoRawFile = 2,
22 | AgilentRawFile = 3,
23 | BrukerRawFile = 4,
24 | WiffRawFile = 5
25 | }
26 | }
--------------------------------------------------------------------------------
/CSMSL/IO/MzIdentML/AnalysisSoftware.cs:
--------------------------------------------------------------------------------
1 | // Copyright 2022 Derek J. Bailey
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | using System;
16 | using System.Collections.Generic;
17 | using System.Text;
18 | using System.Threading.Tasks;
19 |
20 | namespace MzIdentML
21 | {
22 | public class AnalysisSoftware
23 | {
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/CSMSL/IO/MzIdentML/MzIdentML.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {88488504-BA7F-41DD-9965-AE951810C612}
8 | Library
9 | Properties
10 | MzIdentML
11 | MzIdentML
12 | v4.5
13 | 512
14 |
15 |
16 | true
17 | full
18 | false
19 | bin\Debug\
20 | DEBUG;TRACE
21 | prompt
22 | 4
23 |
24 |
25 | pdbonly
26 | true
27 | bin\Release\
28 | TRACE
29 | prompt
30 | 4
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 | Designer
47 |
48 |
49 |
50 |
57 |
--------------------------------------------------------------------------------
/CSMSL/IO/MzIdentML/MzidReader.cs:
--------------------------------------------------------------------------------
1 | // Copyright 2022 Derek J. Bailey
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | using System;
16 | using System.Collections.Generic;
17 | using System.Text;
18 | using System.Threading.Tasks;
19 | using System.Xml.Serialization;
20 | using System.IO;
21 | using MzIdentML;
22 |
23 | namespace CSMSL.IO.MzIdentML
24 | {
25 | public class MzidReader
26 | {
27 | private MzIdentMLType _connection;
28 |
29 | public string Version {
30 | get { return _connection.version; }
31 | set { _connection.version = value; }
32 | }
33 |
34 | public string FilePath {get; private set;}
35 |
36 | public MzidReader(string filePath)
37 | {
38 | FilePath = filePath;
39 | }
40 |
41 | public void GetAnalysis()
42 | {
43 |
44 |
45 | }
46 |
47 | public void Open()
48 | {
49 | if (File.Exists(FilePath))
50 | {
51 | _connection = MzIdentMLType.LoadFromFile(FilePath);
52 | }
53 | else
54 | {
55 | // Create a new file
56 | _connection = new MzIdentMLType();
57 | }
58 | }
59 |
60 | public void Save()
61 | {
62 | SaveAs(FilePath);
63 | }
64 |
65 | public void SaveAs(string filePath)
66 | {
67 | _connection.SaveToFile(filePath);
68 | }
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/CSMSL/IO/MzIdentML/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | // Copyright 2022 Derek J. Bailey
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | using System.Reflection;
16 | using System.Runtime.CompilerServices;
17 | using System.Runtime.InteropServices;
18 |
19 | // General Information about an assembly is controlled through the following
20 | // set of attributes. Change these attribute values to modify the information
21 | // associated with an assembly.
22 | [assembly: AssemblyTitle("MzIdentML")]
23 | [assembly: AssemblyDescription("")]
24 | [assembly: AssemblyConfiguration("")]
25 | [assembly: AssemblyCompany("")]
26 | [assembly: AssemblyProduct("MzIdentML")]
27 | [assembly: AssemblyCopyright("Copyright © 2014")]
28 | [assembly: AssemblyTrademark("")]
29 | [assembly: AssemblyCulture("")]
30 |
31 | // Setting ComVisible to false makes the types in this assembly not visible
32 | // to COM components. If you need to access a type in this assembly from
33 | // COM, set the ComVisible attribute to true on that type.
34 | [assembly: ComVisible(false)]
35 |
36 | // The following GUID is for the ID of the typelib if this project is exposed to COM
37 | [assembly: Guid("f660d817-3e75-4de4-9f06-b2888aa6cc34")]
38 |
39 | // Version information for an assembly consists of the following four values:
40 | //
41 | // Major Version
42 | // Minor Version
43 | // Build Number
44 | // Revision
45 | //
46 | // You can specify all the values or you can default the Build and Revision Numbers
47 | // by using the '*' as shown below:
48 | // [assembly: AssemblyVersion("1.0.*")]
49 | [assembly: AssemblyVersion("1.0.0.0")]
50 | [assembly: AssemblyFileVersion("1.0.0.0")]
51 |
--------------------------------------------------------------------------------
/CSMSL/IO/MzML/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | // Copyright 2022 Derek J. Bailey
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | using System.Reflection;
16 | using System.Runtime.InteropServices;
17 |
18 | // General Information about an assembly is controlled through the following
19 | // set of attributes. Change these attribute values to modify the information
20 | // associated with an assembly.
21 |
22 | [assembly: AssemblyTitle("MzML")]
23 | [assembly: AssemblyDescription("")]
24 | [assembly: AssemblyConfiguration("")]
25 | [assembly: AssemblyCompany("")]
26 | [assembly: AssemblyProduct("MzML")]
27 | [assembly: AssemblyCopyright("Copyright © 2013")]
28 | [assembly: AssemblyTrademark("")]
29 | [assembly: AssemblyCulture("")]
30 |
31 | // Setting ComVisible to false makes the types in this assembly not visible
32 | // to COM components. If you need to access a type in this assembly from
33 | // COM, set the ComVisible attribute to true on that type.
34 |
35 | [assembly: ComVisible(false)]
36 |
37 | // The following GUID is for the ID of the typelib if this project is exposed to COM
38 |
39 | [assembly: Guid("0cc84336-eb46-49d3-9964-96023ce48ba2")]
40 |
41 | // Version information for an assembly consists of the following four values:
42 | //
43 | // Major Version
44 | // Minor Version
45 | // Build Number
46 | // Revision
47 | //
48 | // You can specify all the values or you can default the Build and Revision Numbers
49 | // by using the '*' as shown below:
50 | // [assembly: AssemblyVersion("1.0.*")]
51 |
52 | [assembly: AssemblyVersion("1.0.0.0")]
53 | [assembly: AssemblyFileVersion("1.0.0.0")]
--------------------------------------------------------------------------------
/CSMSL/IO/MzTab/MzTabMultipleSet.cs:
--------------------------------------------------------------------------------
1 | // Copyright 2022 Derek J. Bailey
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | using System;
16 | using System.Collections.Generic;
17 | using System.Linq;
18 | using System.Text;
19 |
20 | namespace CSMSL.IO.MzTab
21 | {
22 | public class MzTabMultipleSet
23 | {
24 | private readonly Dictionary> _data;
25 |
26 | public int MaxIndex1
27 | {
28 | get { return _data.Keys.Max(); }
29 | }
30 |
31 | public int MaxIndex2
32 | {
33 | get { return _data.Values.Max(i => i.Count); }
34 | }
35 |
36 | public MzTabMultipleSet()
37 | {
38 | _data = new Dictionary>();
39 | }
40 |
41 | public MzTabMultipleSet(int index1, T value)
42 | {
43 | _data = new Dictionary>();
44 | var temp = new List {value};
45 | _data.Add(index1, temp);
46 | }
47 |
48 | public T this[int index1, int index2]
49 | {
50 | get { return GetValue(index1, index2); }
51 | set { SetValue(index1, index2, value); }
52 | }
53 |
54 | public T GetValue(int index1, int index2)
55 | {
56 | index2 = index2 - MzTab.IndexBased;
57 | List temp;
58 | if (_data.TryGetValue(index1, out temp))
59 | {
60 | return temp[index2];
61 | }
62 | return default(T);
63 | }
64 |
65 | public int AddValue(int index1, T value)
66 | {
67 | List temp;
68 | if (!_data.TryGetValue(index1, out temp))
69 | {
70 | temp = new List();
71 | _data.Add(index1, temp);
72 | }
73 |
74 | temp.Add(value);
75 | return temp.Count - 1 + MzTab.IndexBased;
76 | }
77 |
78 | public void SetValue(int index1, int index2, T value)
79 | {
80 | index2 = index2 - MzTab.IndexBased;
81 | List temp;
82 | if (_data.TryGetValue(index1, out temp))
83 | {
84 | temp[index2] = value;
85 | }
86 | else
87 | {
88 | temp = new List(index2 + 1);
89 | temp[index2] = value;
90 | _data.Add(index1, temp);
91 | }
92 | }
93 |
94 | public bool TryGetValue(int index1, int index2, out T value)
95 | {
96 | index2 = index2 - MzTab.IndexBased;
97 | value = default(T);
98 | List temp;
99 | if (_data.TryGetValue(index1, out temp))
100 | {
101 | if (temp.Count >= index2)
102 | return false;
103 | value = temp[index2];
104 | return true;
105 | }
106 | return false;
107 | }
108 |
109 | public IEnumerable> GetKeyValuePairs(string baseName)
110 | {
111 | foreach (KeyValuePair> values in _data)
112 | {
113 | int index1 = values.Key;
114 | for (int index2 = 0; index2 < values.Value.Count; index2++)
115 | {
116 | string name = MzTab.GetArrayName(baseName, index1, index2 + MzTab.IndexBased);
117 | string value = values.Value[index2].ToString();
118 | yield return new KeyValuePair(name, value);
119 | }
120 | }
121 | }
122 | }
123 | }
--------------------------------------------------------------------------------
/CSMSL/IO/MzTab/MzTabSection.cs:
--------------------------------------------------------------------------------
1 | // Copyright 2022 Derek J. Bailey
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | namespace CSMSL.IO.MzTab
16 | {
17 | ///
18 | /// The sections of a mzTab file
19 | ///
20 | public enum MzTabSection
21 | {
22 | MetaData,
23 | Protein,
24 | Peptide,
25 | PSM,
26 | SmallMolecule
27 | }
28 | }
--------------------------------------------------------------------------------
/CSMSL/IO/MzTab/MzTabSoftware.cs:
--------------------------------------------------------------------------------
1 | // Copyright 2022 Derek J. Bailey
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | using System.Collections.Generic;
16 |
17 | namespace CSMSL.IO.MzTab
18 | {
19 | public class MzTabSoftware
20 | {
21 | public CVParamater Parameter { get; set; }
22 | public List Settings { get; set; }
23 |
24 | public MzTabSoftware(CVParamater paramater)
25 | {
26 | Parameter = paramater;
27 | Settings = new List();
28 | }
29 |
30 | public void AddSetting(string setting)
31 | {
32 | Settings.Add(setting);
33 | }
34 |
35 | public override string ToString()
36 | {
37 | return Parameter.ToString();
38 | }
39 | }
40 | }
--------------------------------------------------------------------------------
/CSMSL/IO/OMSSA/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | // Copyright 2022 Derek J. Bailey
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | using System.Reflection;
16 | using System.Runtime.InteropServices;
17 |
18 | // General Information about an assembly is controlled through the following
19 | // set of attributes. Change these attribute values to modify the information
20 | // associated with an assembly.
21 |
22 | [assembly: AssemblyTitle("OMSSA")]
23 | [assembly: AssemblyDescription("")]
24 | [assembly: AssemblyConfiguration("")]
25 | [assembly: AssemblyCompany("")]
26 | [assembly: AssemblyProduct("OMSSA")]
27 | [assembly: AssemblyCopyright("Copyright © 2013")]
28 | [assembly: AssemblyTrademark("")]
29 | [assembly: AssemblyCulture("")]
30 |
31 | // Setting ComVisible to false makes the types in this assembly not visible
32 | // to COM components. If you need to access a type in this assembly from
33 | // COM, set the ComVisible attribute to true on that type.
34 |
35 | [assembly: ComVisible(false)]
36 |
37 | // The following GUID is for the ID of the typelib if this project is exposed to COM
38 |
39 | [assembly: Guid("e4459445-bff1-464e-9b16-f3bafe609930")]
40 |
41 | // Version information for an assembly consists of the following four values:
42 | //
43 | // Major Version
44 | // Minor Version
45 | // Build Number
46 | // Revision
47 | //
48 | // You can specify all the values or you can default the Build and Revision Numbers
49 | // by using the '*' as shown below:
50 | // [assembly: AssemblyVersion("1.0.*")]
51 |
52 | [assembly: AssemblyVersion("1.0.0.0")]
53 | [assembly: AssemblyFileVersion("1.0.0.0")]
--------------------------------------------------------------------------------
/CSMSL/IO/PepXml/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | // Copyright 2022 Derek J. Bailey
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | using System.Reflection;
16 | using System.Runtime.InteropServices;
17 |
18 | // General Information about an assembly is controlled through the following
19 | // set of attributes. Change these attribute values to modify the information
20 | // associated with an assembly.
21 |
22 | [assembly: AssemblyTitle("PepXml")]
23 | [assembly: AssemblyDescription("")]
24 | [assembly: AssemblyConfiguration("")]
25 | [assembly: AssemblyCompany("")]
26 | [assembly: AssemblyProduct("PepXml")]
27 | [assembly: AssemblyCopyright("Copyright © 2014")]
28 | [assembly: AssemblyTrademark("")]
29 | [assembly: AssemblyCulture("")]
30 |
31 | // Setting ComVisible to false makes the types in this assembly not visible
32 | // to COM components. If you need to access a type in this assembly from
33 | // COM, set the ComVisible attribute to true on that type.
34 |
35 | [assembly: ComVisible(false)]
36 |
37 | // The following GUID is for the ID of the typelib if this project is exposed to COM
38 |
39 | [assembly: Guid("f4163c29-68bf-4991-bbb0-a92a0f55d24e")]
40 |
41 | // Version information for an assembly consists of the following four values:
42 | //
43 | // Major Version
44 | // Minor Version
45 | // Build Number
46 | // Revision
47 | //
48 | // You can specify all the values or you can default the Build and Revision Numbers
49 | // by using the '*' as shown below:
50 | // [assembly: AssemblyVersion("1.0.*")]
51 |
52 | [assembly: AssemblyVersion("1.0.0.0")]
53 | [assembly: AssemblyFileVersion("1.0.0.0")]
--------------------------------------------------------------------------------
/CSMSL/IO/Thermo/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | // Copyright 2022 Derek J. Bailey
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | using System.Reflection;
16 | using System.Runtime.InteropServices;
17 |
18 | // General Information about an assembly is controlled through the following
19 | // set of attributes. Change these attribute values to modify the information
20 | // associated with an assembly.
21 |
22 | [assembly: AssemblyTitle("Thermo")]
23 | [assembly: AssemblyDescription("")]
24 | [assembly: AssemblyConfiguration("")]
25 | [assembly: AssemblyCompany("")]
26 | [assembly: AssemblyProduct("Thermo")]
27 | [assembly: AssemblyCopyright("Copyright © 2012")]
28 | [assembly: AssemblyTrademark("")]
29 | [assembly: AssemblyCulture("")]
30 |
31 | // Setting ComVisible to false makes the types in this assembly not visible
32 | // to COM components. If you need to access a type in this assembly from
33 | // COM, set the ComVisible attribute to true on that type.
34 |
35 | [assembly: ComVisible(false)]
36 |
37 | // The following GUID is for the ID of the typelib if this project is exposed to COM
38 |
39 | [assembly: Guid("37b9843e-9966-4c54-9645-ed35f5a3b79f")]
40 |
41 | // Version information for an assembly consists of the following four values:
42 | //
43 | // Major Version
44 | // Minor Version
45 | // Build Number
46 | // Revision
47 | //
48 | // You can specify all the values or you can default the Build and Revision Numbers
49 | // by using the '*' as shown below:
50 | // [assembly: AssemblyVersion("1.0.*")]
51 |
52 | [assembly: AssemblyVersion("1.0.0.0")]
53 | [assembly: AssemblyFileVersion("1.0.0.0")]
--------------------------------------------------------------------------------
/CSMSL/IO/Thermo/ThermoMzPeak.cs:
--------------------------------------------------------------------------------
1 | // Copyright 2022 Derek J. Bailey
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | using CSMSL.Spectral;
16 |
17 | namespace CSMSL.IO.Thermo
18 | {
19 | public class ThermoMzPeak : MZPeak
20 | {
21 | public int Charge { get; private set; }
22 |
23 | public double Noise { get; private set; }
24 |
25 | public double Resolution { get; private set; }
26 |
27 | public double SignalToNoise
28 | {
29 | get
30 | {
31 | if (Noise.Equals(0)) return float.NaN;
32 | return Intensity/Noise;
33 | }
34 | }
35 |
36 | public bool IsHighResolution { get { return Resolution > 0;} }
37 |
38 | public override string ToString()
39 | {
40 | return string.Format("{0} z = {1:+#;-#;?} SN = {2:F2}", base.ToString(), Charge, SignalToNoise);
41 | }
42 |
43 | public ThermoMzPeak()
44 | {
45 | }
46 |
47 | public ThermoMzPeak(double mz, double intensity, int charge = 0, double noise = 0.0, double resolution = 0.0)
48 | : base(mz, intensity)
49 | {
50 | Charge = charge;
51 | Noise = noise;
52 | Resolution = resolution;
53 | }
54 |
55 | public double GetSignalToNoise()
56 | {
57 | return SignalToNoise;
58 | }
59 |
60 | public double GetDenormalizedIntensity(double injectionTime)
61 | {
62 | return Intensity*injectionTime;
63 | }
64 | }
65 | }
--------------------------------------------------------------------------------
/CSMSL/IRange.cs:
--------------------------------------------------------------------------------
1 | // Copyright 2022 Derek J. Bailey
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | using System;
16 |
17 | namespace CSMSL
18 | {
19 | ///
20 | /// A range of values with a well defined minimum and maximum value
21 | ///
22 | /// Any type that uses IComparable
23 | public interface IRange : IEquatable> where T : IComparable
24 | {
25 | ///
26 | /// The minimum value of this range
27 | ///
28 | T Minimum { get; }
29 |
30 | ///
31 | /// The maximum value of this range
32 | ///
33 | T Maximum { get; }
34 |
35 | ///
36 | /// Checks if an item is within the range
37 | ///
38 | /// The item to check
39 | /// True if the item is within minimum and maximum (inclusive)
40 | bool Contains(T item);
41 |
42 | ///
43 | /// Checks if an item is below, within, or above this range
44 | ///
45 | /// The item to check
46 | /// -1 if the item is below, 0 if within (inclusive), or 1 if above
47 | int CompareTo(T item);
48 |
49 | ///
50 | /// Checks to see if this range is a proper sub range of another range (inclusive)
51 | ///
52 | /// The other range to compare to
53 | /// True if this range is fully enclosed by the other range, false otherwise
54 | bool IsSubRange(IRange other);
55 |
56 | bool IsSuperRange(IRange other);
57 |
58 | bool IsOverlapping(IRange other);
59 | }
60 | }
--------------------------------------------------------------------------------
/CSMSL/MassRange.cs:
--------------------------------------------------------------------------------
1 | // Copyright 2022 Derek J. Bailey
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | namespace CSMSL
16 | {
17 | public class MassRange : DoubleRange
18 | {
19 | public MassRange()
20 | {
21 | }
22 |
23 | public MassRange(double minMass, double maxMass)
24 | : base(minMass, maxMass)
25 | {
26 | }
27 |
28 | public MassRange(double meanMass, Tolerance toleranceWidth)
29 | : base(meanMass, toleranceWidth)
30 | {
31 | }
32 |
33 | public override string ToString()
34 | {
35 | return ToString("G9");
36 | }
37 |
38 | public override string ToString(string format)
39 | {
40 | return string.Format("{0} - {1} Da", Minimum.ToString(format), Maximum.ToString(format));
41 | }
42 |
43 | #region Static
44 |
45 | public new static MassRange FromPPM(double mean, double ppmTolerance)
46 | {
47 | return new MassRange(mean, new Tolerance(ToleranceUnit.PPM, ppmTolerance));
48 | }
49 |
50 | #endregion Static
51 | }
52 | }
--------------------------------------------------------------------------------
/CSMSL/MzRange.cs:
--------------------------------------------------------------------------------
1 | // Copyright 2022 Derek J. Bailey
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | namespace CSMSL
16 | {
17 | public class MzRange : DoubleRange
18 | {
19 | public MzRange()
20 | {
21 | }
22 |
23 | public MzRange(double minMZ, double maxMZ)
24 | : base(minMZ, maxMZ)
25 | {
26 | }
27 |
28 | public MzRange(double meanMZ, Tolerance toleranceWidth)
29 | : base(meanMZ, toleranceWidth)
30 | {
31 | }
32 |
33 | public override string ToString()
34 | {
35 | return ToString("G9");
36 | }
37 |
38 | public override string ToString(string format)
39 | {
40 | return string.Format("{0} - {1} m/z", Minimum.ToString(format), Maximum.ToString(format));
41 | }
42 |
43 | #region Static
44 |
45 | public new static MzRange FromPPM(double mean, double ppmTolerance)
46 | {
47 | return new MzRange(mean, new Tolerance(ToleranceUnit.PPM, ppmTolerance));
48 | }
49 |
50 | #endregion Static
51 | }
52 | }
--------------------------------------------------------------------------------
/CSMSL/Polarity.cs:
--------------------------------------------------------------------------------
1 | // Copyright 2022 Derek J. Bailey
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | namespace CSMSL
16 | {
17 | ///
18 | /// The polarity of a charge particle
19 | ///
20 | public enum Polarity
21 | {
22 | ///
23 | /// Negative charge
24 | ///
25 | Negative = -1,
26 |
27 | ///
28 | /// Neutral charge
29 | ///
30 | Neutral = 0,
31 |
32 | ///
33 | /// Positive charge
34 | ///
35 | Positive = 1
36 | }
37 | }
--------------------------------------------------------------------------------
/CSMSL/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | // Copyright 2022 Derek J. Bailey
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | using System.Reflection;
16 | using System.Resources;
17 | using System.Runtime.InteropServices;
18 |
19 | // General Information about an assembly is controlled through the following
20 | // set of attributes. Change these attribute values to modify the information
21 | // associated with an assembly.
22 |
23 | [assembly: AssemblyTitle("CSMSL")]
24 | [assembly: AssemblyDescription("C# Mass Spectrometry Library")]
25 | [assembly: AssemblyConfiguration("")]
26 | [assembly: AssemblyCompany("")]
27 | [assembly: AssemblyProduct("CSMSL")]
28 | [assembly: AssemblyCopyright("Copyright 2012, 2013, 2014 Derek J bailey")]
29 | [assembly: AssemblyTrademark("")]
30 | [assembly: AssemblyCulture("")]
31 | // Setting ComVisible to false makes the types in this assembly not visible
32 | // to COM components. If you need to access a type in this assembly from
33 | // COM, set the ComVisible attribute to true on that type.
34 |
35 | [assembly: ComVisible(false)]
36 | // The following GUID is for the ID of the typelib if this project is exposed to COM
37 |
38 | [assembly: Guid("7d4d417d-8e49-4ce4-8f7c-cb3373794c78")]
39 | // Version information for an assembly consists of the following four values:
40 | //
41 | // Major Version
42 | // Minor Version
43 | // Build Number
44 | // Revision
45 | //
46 | // You can specify all the values or you can default the Build and Revision Numbers
47 | // by using the '*' as shown below:
48 | // [assembly: AssemblyVersion("1.0.*")]
49 |
50 | [assembly: AssemblyVersion("0.3.*")]
51 | //[assembly: AssemblyFileVersion("0.3.0.0")]
52 |
53 | [assembly: NeutralResourcesLanguage("en-US")]
--------------------------------------------------------------------------------
/CSMSL/Proteomics/ChemicalFormulaFragment.cs:
--------------------------------------------------------------------------------
1 | // Copyright 2022 Derek J. Bailey
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | using CSMSL.Chemistry;
16 |
17 | namespace CSMSL.Proteomics
18 | {
19 | public class ChemicalFormulaFragment : Fragment, IChemicalFormula
20 | {
21 | public ChemicalFormula ChemicalFormula { get; private set; }
22 |
23 | public ChemicalFormulaFragment(FragmentTypes type, int number, string chemicalFormula, AminoAcidPolymer parent)
24 | : this(type, number, new ChemicalFormula(chemicalFormula), parent)
25 | {
26 | }
27 |
28 | public ChemicalFormulaFragment(FragmentTypes type, int number, ChemicalFormula formula, AminoAcidPolymer parent)
29 | : base(type, number, formula.MonoisotopicMass, parent)
30 | {
31 | ChemicalFormula = new ChemicalFormula(formula);
32 | }
33 | }
34 | }
--------------------------------------------------------------------------------
/CSMSL/Proteomics/ChemicalFormulaModification.cs:
--------------------------------------------------------------------------------
1 | // Copyright 2022 Derek J. Bailey
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 | using CSMSL.Chemistry;
15 |
16 | namespace CSMSL.Proteomics
17 | {
18 | public class ChemicalFormulaModification : Modification, IChemicalFormula
19 | {
20 | ///
21 | /// The Chemical Formula of this modifications
22 | ///
23 | public ChemicalFormula ChemicalFormula { get; private set; }
24 |
25 | public ChemicalFormulaModification(string chemicalFormula, ModificationSites sites = ModificationSites.Any)
26 | : this(new ChemicalFormula(chemicalFormula), "", sites)
27 | {
28 | Name = ChemicalFormula.ToString();
29 | }
30 |
31 | public ChemicalFormulaModification(string chemicalFormula, string name, ModificationSites sites = ModificationSites.Any)
32 | : this(new ChemicalFormula(chemicalFormula), name, sites)
33 | {
34 | }
35 |
36 | public ChemicalFormulaModification(ChemicalFormula chemicalFormula, string name, ModificationSites sites = ModificationSites.Any)
37 | : base(chemicalFormula.MonoisotopicMass, name, sites)
38 | {
39 | ChemicalFormula = chemicalFormula;
40 | }
41 |
42 | public ChemicalFormulaModification(ChemicalFormulaModification other)
43 | : this(new ChemicalFormula(other.ChemicalFormula), other.Name, other.Sites)
44 | {
45 | }
46 | }
47 | }
--------------------------------------------------------------------------------
/CSMSL/Proteomics/DissociationType.cs:
--------------------------------------------------------------------------------
1 | // Copyright 2022 Derek J. Bailey
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 | namespace CSMSL.Proteomics
15 | {
16 | public enum DissociationType
17 | {
18 | UnKnown = -1,
19 | None = 6,
20 | CID = 0,
21 | HCD = 5,
22 | ETD = 4,
23 | MPD = 1,
24 | ECD = 2,
25 | PQD = 3,
26 | SA = 7,
27 | PTR = 8,
28 | NETD = 9,
29 | NPTR = 10,
30 | CI = 11
31 | }
32 | }
--------------------------------------------------------------------------------
/CSMSL/Proteomics/Fragment.cs:
--------------------------------------------------------------------------------
1 | // Copyright 2022 Derek J. Bailey
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 | using CSMSL.Chemistry;
15 | using System;
16 | using System.Collections.Generic;
17 |
18 | namespace CSMSL.Proteomics
19 | {
20 | public class Fragment : IMass, IEquatable
21 | {
22 | public Fragment(FragmentTypes type, int number, double monoisotopicMass, AminoAcidPolymer parent)
23 | {
24 | Type = type;
25 | Number = number;
26 | Parent = parent;
27 | MonoisotopicMass = monoisotopicMass;
28 | }
29 |
30 | public double MonoisotopicMass { get; private set; }
31 |
32 | public int Number { get; private set; }
33 |
34 | public AminoAcidPolymer Parent { get; private set; }
35 |
36 | public FragmentTypes Type { get; private set; }
37 |
38 | // TODO figure if this is the best way to do chemical formula fragments
39 | //public bool TryGetFormula(out ChemicalFormula formula)
40 | //{
41 | // Might add this
42 | //}
43 |
44 | public IEnumerable GetModifications()
45 | {
46 | if (Parent == null)
47 | yield break;
48 |
49 | var mods = Parent.Modifications;
50 | if (Type.GetTerminus() == Terminus.N)
51 | {
52 | for (int i = 0; i <= Number; i++)
53 | {
54 | if (mods[i] != null)
55 | yield return mods[i];
56 | }
57 | }
58 | else
59 | {
60 | int length = Parent.Length + 1;
61 | for (int i = length - Number; i <= length; i++)
62 | {
63 | if (mods[i] != null)
64 | yield return mods[i];
65 | }
66 | }
67 | }
68 |
69 | public string GetSequence()
70 | {
71 | if (Parent == null)
72 | return "";
73 |
74 | string parentSeq = Parent.Sequence;
75 | if (Type.GetTerminus() == Terminus.N)
76 | {
77 | return parentSeq.Substring(0, Number);
78 | }
79 |
80 | return parentSeq.Substring(parentSeq.Length - Number, Number);
81 | }
82 |
83 | public override string ToString()
84 | {
85 | return string.Format("{0}{1}", Enum.GetName(typeof (FragmentTypes), Type), Number);
86 | }
87 |
88 | public override int GetHashCode()
89 | {
90 | unchecked
91 | {
92 | int hCode = 23;
93 | hCode = hCode*31 + Number;
94 | hCode = hCode*31 + (int) Type;
95 | hCode = hCode*31 + Math.Round(MonoisotopicMass).GetHashCode();
96 | return hCode;
97 | }
98 | }
99 |
100 | public bool Equals(Fragment other)
101 | {
102 | return Type.Equals(other.Type) && Number.Equals(other.Number) && MonoisotopicMass.MassEquals(other.MonoisotopicMass);
103 | }
104 | }
105 | }
--------------------------------------------------------------------------------
/CSMSL/Proteomics/FragmentCollection.cs:
--------------------------------------------------------------------------------
1 | // Copyright 2022 Derek J. Bailey
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | using System;
16 | using System.Collections;
17 | using System.Collections.Generic;
18 | using System.Linq;
19 |
20 | namespace CSMSL.Proteomics
21 | {
22 | public class FragmentCollection : ICollection
23 | {
24 | private readonly AminoAcidPolymer _parent;
25 |
26 | private readonly List _fragments;
27 |
28 | public int Count
29 | {
30 | get { return _fragments.Count; }
31 | }
32 |
33 | public AminoAcidPolymer Parent
34 | {
35 | get { return _parent; }
36 | }
37 |
38 | public int NTerminalFragments
39 | {
40 | get { return _fragments.Count(frag => frag.Type < FragmentTypes.x); }
41 | }
42 |
43 | public int CTerminalFragments
44 | {
45 | get { return _fragments.Count(frag => frag.Type >= FragmentTypes.x); }
46 | }
47 |
48 | public FragmentCollection(IEnumerable fragments, AminoAcidPolymer parent = null)
49 | {
50 | _fragments = new List(fragments);
51 | _parent = parent;
52 | }
53 |
54 | public FragmentCollection(AminoAcidPolymer parent = null)
55 | {
56 | _fragments = new List();
57 | _parent = parent;
58 | }
59 |
60 | public FragmentCollection Filter(Func predicate)
61 | {
62 | return new FragmentCollection(_fragments.Where(predicate));
63 | }
64 |
65 | public IEnumerator GetEnumerator()
66 | {
67 | return _fragments.GetEnumerator();
68 | }
69 |
70 | IEnumerator IEnumerable.GetEnumerator()
71 | {
72 | return _fragments.GetEnumerator();
73 | }
74 |
75 | public void Add(Fragment item)
76 | {
77 | _fragments.Add(item);
78 | }
79 |
80 | public void Clear()
81 | {
82 | _fragments.Clear();
83 | }
84 |
85 | public bool Contains(Fragment item)
86 | {
87 | return _fragments.Contains(item);
88 | }
89 |
90 | public void CopyTo(Fragment[] array, int arrayIndex)
91 | {
92 | _fragments.CopyTo(array, arrayIndex);
93 | }
94 |
95 | public bool IsReadOnly
96 | {
97 | get { return false; }
98 | }
99 |
100 | public bool Remove(Fragment item)
101 | {
102 | return _fragments.Remove(item);
103 | }
104 | }
105 | }
--------------------------------------------------------------------------------
/CSMSL/Proteomics/FragmentTypes.cs:
--------------------------------------------------------------------------------
1 | // Copyright 2022 Derek J. Bailey
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | using CSMSL.Chemistry;
16 | using System;
17 | using System.Collections.Generic;
18 |
19 | namespace CSMSL.Proteomics
20 | {
21 | [Flags]
22 | public enum FragmentTypes
23 | {
24 | None = 0,
25 | a = 1 << 0,
26 | adot = 1 << 1,
27 | b = 1 << 2,
28 | bdot = 1 << 3,
29 | c = 1 << 4,
30 | cdot = 1 << 5,
31 | x = 1 << 6,
32 | xdot = 1 << 7,
33 | y = 1 << 8,
34 | ydot = 1 << 9,
35 | z = 1 << 10,
36 | zdot = 1 << 11,
37 | Internal = 1 << 12,
38 | All = (1 << 12) - 1, // Handy way of setting all below the 12th bit
39 | }
40 |
41 | public static class FragmentTypesExtension
42 | {
43 | public static IEnumerable GetIndividualFragmentTypes(this FragmentTypes fragmentTypes)
44 | {
45 | if (fragmentTypes == FragmentTypes.None)
46 | yield break;
47 | foreach (FragmentTypes site in Enum.GetValues(typeof (FragmentTypes)))
48 | {
49 | if (site == FragmentTypes.None || site == FragmentTypes.All || site == FragmentTypes.Internal)
50 | {
51 | continue;
52 | }
53 | if ((fragmentTypes & site) == site)
54 | {
55 | yield return site;
56 | }
57 | }
58 | }
59 |
60 | public static Terminus GetTerminus(this FragmentTypes fragmentType)
61 | {
62 | // Super handy: http://stackoverflow.com/questions/4624248/c-logical-riddle-with-bit-operations-only-one-bit-is-set
63 | if (fragmentType == FragmentTypes.None || (fragmentType & (fragmentType - 1)) != FragmentTypes.None)
64 | {
65 | throw new ArgumentException("Fragment Type must be a single value to determine the terminus", "fragmentType");
66 | }
67 | return fragmentType >= FragmentTypes.x ? Terminus.C : Terminus.N;
68 | }
69 |
70 | public static ChemicalFormula GetIonCap(this FragmentTypes fragmentType)
71 | {
72 | if (fragmentType == FragmentTypes.None || (fragmentType & (fragmentType - 1)) != FragmentTypes.None)
73 | {
74 | throw new ArgumentException("Fragment Type must be a single value to determine the ion cap", "fragmentType");
75 | }
76 | return FragmentIonCaps[fragmentType];
77 | }
78 |
79 | private static readonly Dictionary FragmentIonCaps = new Dictionary
80 | {
81 | {FragmentTypes.a, new ChemicalFormula("C-1H-1O-1")},
82 | {FragmentTypes.adot, new ChemicalFormula("C-1O-1")},
83 | {FragmentTypes.b, new ChemicalFormula("H-1")},
84 | {FragmentTypes.bdot, new ChemicalFormula()},
85 | {FragmentTypes.c, new ChemicalFormula("NH2")},
86 | {FragmentTypes.cdot, new ChemicalFormula("NH3")},
87 | {FragmentTypes.x, new ChemicalFormula("COH-1")},
88 | {FragmentTypes.xdot, new ChemicalFormula("CO")},
89 | {FragmentTypes.y, new ChemicalFormula("H")},
90 | {FragmentTypes.ydot, new ChemicalFormula("H2")},
91 | {FragmentTypes.z, new ChemicalFormula("N-1H-2")},
92 | {FragmentTypes.zdot, new ChemicalFormula("N-1H-1")},
93 | };
94 | }
95 | }
--------------------------------------------------------------------------------
/CSMSL/Proteomics/IAminoAcid.cs:
--------------------------------------------------------------------------------
1 | // Copyright 2022 Derek J. Bailey
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | using CSMSL.Chemistry;
16 |
17 | namespace CSMSL.Proteomics
18 | {
19 | public interface IAminoAcid : IChemicalFormula
20 | {
21 | char Letter { get; }
22 |
23 | string Symbol { get; }
24 |
25 | ModificationSites Site { get; }
26 | }
27 | }
--------------------------------------------------------------------------------
/CSMSL/Proteomics/IAminoAcidSequence.cs:
--------------------------------------------------------------------------------
1 | // Copyright 2022 Derek J. Bailey
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | using System;
16 | using System.Collections.Generic;
17 | using System.Linq;
18 |
19 | namespace CSMSL.Proteomics
20 | {
21 | public interface IAminoAcidSequence
22 | {
23 | ///
24 | /// The amino acid sequence
25 | ///
26 | string Sequence { get; }
27 |
28 | ///
29 | /// The amino acid sequence with all 'I' replaced with 'L'
30 | ///
31 | ///
32 | string GetLeucineSequence();
33 |
34 | ///
35 | /// The length of the amino acid sequence
36 | ///
37 | int Length { get; }
38 | }
39 |
40 | public static class IAminoAcidSequenceExtensions
41 | {
42 | public static double GetSequenceCoverageFraction(this IAminoAcidSequence baseSequence, IEnumerable sequences, bool useLeucineSequence = true)
43 | {
44 | int[] counts = baseSequence.GetSequenceCoverage(sequences, useLeucineSequence);
45 | return ((double) counts.Count(x => x > 0))/baseSequence.Length;
46 | }
47 |
48 | public static int[] GetSequenceCoverage(this IAminoAcidSequence baseSequence, IEnumerable sequences, bool useLeucineSequence = true)
49 | {
50 | int[] bits = new int[baseSequence.Length];
51 |
52 | string masterSequence = useLeucineSequence ? baseSequence.GetLeucineSequence() : baseSequence.Sequence;
53 |
54 | foreach (IAminoAcidSequence sequence in sequences)
55 | {
56 | string seq = useLeucineSequence ? sequence.GetLeucineSequence() : sequence.Sequence;
57 |
58 | int startIndex = 0;
59 | while (true)
60 | {
61 | int index = masterSequence.IndexOf(seq, startIndex, StringComparison.InvariantCulture);
62 |
63 | if (index < 0)
64 | {
65 | break;
66 | }
67 |
68 | for (int aa = index; aa < index + sequence.Length; aa++)
69 | {
70 | bits[aa]++;
71 | }
72 |
73 | startIndex = index + 1;
74 | }
75 | }
76 | return bits;
77 | }
78 | }
79 |
80 | public class AminoAcidSequenceComparer : IEqualityComparer
81 | {
82 | public bool Equals(IAminoAcidSequence x, IAminoAcidSequence y)
83 | {
84 | return x.Sequence.Equals(y.Sequence);
85 | }
86 |
87 | public int GetHashCode(IAminoAcidSequence obj)
88 | {
89 | return obj.Sequence.GetHashCode();
90 | }
91 | }
92 |
93 | public class AminoAcidLeucineSequenceComparer : IEqualityComparer
94 | {
95 | public int GetHashCode(IAminoAcidSequence obj)
96 | {
97 | return obj.GetLeucineSequence().GetHashCode();
98 | }
99 |
100 | public bool Equals(IAminoAcidSequence x, IAminoAcidSequence y)
101 | {
102 | return x.GetLeucineSequence().Equals(y.GetLeucineSequence());
103 | }
104 | }
105 | }
--------------------------------------------------------------------------------
/CSMSL/Proteomics/IIsotopologue.cs:
--------------------------------------------------------------------------------
1 | // Copyright 2022 Derek J. Bailey
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | using CSMSL.Chemistry;
16 | using System.Collections.Generic;
17 |
18 | namespace CSMSL.Proteomics
19 | {
20 | public interface IIsotopologue : IMass, IEnumerable
21 | {
22 | }
23 | }
--------------------------------------------------------------------------------
/CSMSL/Proteomics/IProtease.cs:
--------------------------------------------------------------------------------
1 | // Copyright 2022 Derek J. Bailey
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | using System.Collections.Generic;
16 |
17 | namespace CSMSL.Proteomics
18 | {
19 | ///
20 | /// A proteolyic enzyme that cuts amino acids at specific residues.
21 | ///
22 | public interface IProtease
23 | {
24 | ///
25 | /// Finds the indicies of where this protease would cut in
26 | /// the given amino acid sequence
27 | ///
28 | /// The Amino Acid Polymer to cut
29 | /// A set of the 1-based indicies to cut at
30 | IEnumerable GetDigestionSites(string aminoAcidSequence);
31 |
32 | IEnumerable GetDigestionSites(IAminoAcidSequence aminoAcidSequence);
33 |
34 | int MissedCleavages(string sequence);
35 |
36 | int MissedCleavages(IAminoAcidSequence aminoAcidSequence);
37 | }
38 | }
--------------------------------------------------------------------------------
/CSMSL/Proteomics/ModificationCollection.cs:
--------------------------------------------------------------------------------
1 | // Copyright 2022 Derek J. Bailey
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | using CSMSL.Chemistry;
16 | using System;
17 | using System.Collections;
18 | using System.Collections.Generic;
19 | using System.Linq;
20 | using System.Text;
21 |
22 | namespace CSMSL.Proteomics
23 | {
24 | public class ModificationCollection : ICollection, IMass, IEquatable
25 | {
26 | private readonly List _modifications;
27 |
28 | public double MonoisotopicMass { get; private set; }
29 |
30 | public override string ToString()
31 | {
32 | StringBuilder sb = new StringBuilder();
33 | foreach (IMass mod in _modifications)
34 | {
35 | sb.Append(mod);
36 | sb.Append(" | ");
37 | }
38 | if (sb.Length > 0)
39 | {
40 | sb.Remove(sb.Length - 3, 3);
41 | }
42 | return sb.ToString();
43 | }
44 |
45 | public ModificationCollection(params IMass[] mods)
46 | {
47 | _modifications = mods.ToList();
48 | MonoisotopicMass = _modifications.Sum(m => m.MonoisotopicMass);
49 | }
50 |
51 | public void Add(IMass item)
52 | {
53 | _modifications.Add(item);
54 | MonoisotopicMass += item.MonoisotopicMass;
55 | }
56 |
57 | public void Clear()
58 | {
59 | _modifications.Clear();
60 | MonoisotopicMass = 0;
61 | }
62 |
63 | public bool Contains(IMass item)
64 | {
65 | return _modifications.Contains(item);
66 | }
67 |
68 | public void CopyTo(IMass[] array, int arrayIndex)
69 | {
70 | _modifications.CopyTo(array, arrayIndex);
71 | }
72 |
73 | public int Count
74 | {
75 | get { return _modifications.Count; }
76 | }
77 |
78 | public bool IsReadOnly
79 | {
80 | get { return false; }
81 | }
82 |
83 | public bool Remove(IMass item)
84 | {
85 | if (!_modifications.Remove(item))
86 | return false;
87 | MonoisotopicMass -= item.MonoisotopicMass;
88 | return true;
89 | }
90 |
91 | public IEnumerator GetEnumerator()
92 | {
93 | return _modifications.GetEnumerator();
94 | }
95 |
96 | IEnumerator IEnumerable.GetEnumerator()
97 | {
98 | return _modifications.GetEnumerator();
99 | }
100 |
101 | public override int GetHashCode()
102 | {
103 | int hCode = _modifications.GetHashCode();
104 |
105 | return Count + hCode;
106 | }
107 |
108 | public override bool Equals(object obj)
109 | {
110 | ModificationCollection col = obj as ModificationCollection;
111 | return col != null && Equals(col);
112 | }
113 |
114 | public bool Equals(ModificationCollection other)
115 | {
116 | return Count == other.Count && _modifications.ScrambledEquals(other._modifications);
117 | }
118 | }
119 | }
--------------------------------------------------------------------------------
/CSMSL/Proteomics/ModificationSites.cs:
--------------------------------------------------------------------------------
1 | // Copyright 2022 Derek J. Bailey
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | using System;
16 | using System.Collections.Generic;
17 |
18 | namespace CSMSL.Proteomics
19 | {
20 | [Flags]
21 | public enum ModificationSites
22 | {
23 | None = 0,
24 | A = 1 << 0,
25 | R = 1 << 1,
26 | N = 1 << 2,
27 | D = 1 << 3,
28 | C = 1 << 4,
29 | E = 1 << 5,
30 | Q = 1 << 6,
31 | G = 1 << 7,
32 | H = 1 << 8,
33 | I = 1 << 9,
34 | L = 1 << 10,
35 | K = 1 << 11,
36 | M = 1 << 12,
37 | F = 1 << 13,
38 | P = 1 << 14,
39 | S = 1 << 15,
40 | T = 1 << 16,
41 | U = 1 << 17,
42 | W = 1 << 18,
43 | Y = 1 << 19,
44 | V = 1 << 20,
45 | NPep = 1 << 21,
46 | PepC = 1 << 22,
47 | NProt = 1 << 23,
48 | ProtC = 1 << 24,
49 | All = (1 << 25) - 1, // Handy way of setting all below the 24th bit
50 | NTerminus = NPep | NProt,
51 | TerminusC = PepC | ProtC,
52 | Any = 1 << 31 // Acts like none, but is equal to all
53 | }
54 |
55 | public static class ModificationSiteExtensions
56 | {
57 | public static ModificationSites Set(this ModificationSites sites, char aminoacid)
58 | {
59 | AminoAcid aa;
60 | if (AminoAcid.TryGetResidue(aminoacid, out aa))
61 | {
62 | sites |= aa.Site;
63 | }
64 | return sites;
65 | }
66 |
67 | public static ModificationSites Set(this ModificationSites sites, AminoAcid aminoacid)
68 | {
69 | if (aminoacid != null)
70 | sites |= aminoacid.Site;
71 |
72 | return sites;
73 | }
74 |
75 | public static IEnumerable GetActiveSites(this ModificationSites sites)
76 | {
77 | foreach (ModificationSites site in Enum.GetValues(typeof (ModificationSites)))
78 | {
79 | if (site == ModificationSites.None)
80 | {
81 | continue;
82 | }
83 | if ((sites & site) == site)
84 | {
85 | yield return site;
86 | }
87 | }
88 | }
89 |
90 | public static bool ContainsSite(this ModificationSites sites, ModificationSites otherSites)
91 | {
92 | // By convention, if the other site is 'Any', they are always equal
93 | if (otherSites == ModificationSites.Any)
94 | return true;
95 |
96 | if (otherSites == ModificationSites.None)
97 | return sites == ModificationSites.None;
98 |
99 | return sites == otherSites;
100 | }
101 | }
102 | }
--------------------------------------------------------------------------------
/CSMSL/Proteomics/Protein.cs:
--------------------------------------------------------------------------------
1 | // Copyright 2022 Derek J. Bailey
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | using CSMSL.IO;
16 | using System.Collections.Generic;
17 | using System.Linq;
18 |
19 | namespace CSMSL.Proteomics
20 | {
21 | public class Protein : AminoAcidPolymer
22 | {
23 | public Protein(string sequence, string description = "", bool isDecoy = false)
24 | : base(sequence)
25 | {
26 | Description = description;
27 | IsDecoy = isDecoy;
28 | }
29 |
30 | ///
31 | /// The description for the protein
32 | ///
33 | public string Description { get; set; }
34 |
35 | ///
36 | /// Indicates whether this is a decoy protein or not
37 | ///
38 | public bool IsDecoy { get; set; }
39 |
40 | ///
41 | /// Converts this protein into the fasta format
42 | ///
43 | ///
44 | public Fasta ToFasta()
45 | {
46 | return new Fasta(Sequence, Description);
47 | }
48 |
49 | #region Digestion
50 |
51 | ///
52 | /// Digests this protein into peptides.
53 | ///
54 | /// The protease to digest with
55 | /// The max number of missed cleavages generated, 0 means no missed cleavages
56 | /// The minimum length (in amino acids) of the peptide
57 | /// The maximum length (in amino acids) of the peptide
58 | ///
59 | ///
60 | ///
61 | /// A list of digested peptides
62 | public virtual IEnumerable Digest(IProtease protease, int maxMissedCleavages = 3, int minLength = 1, int maxLength = int.MaxValue, bool initiatorMethonine = true, bool includeModifications = false, bool semiDigestion = false)
63 | {
64 | return Digest(new[] {protease}, maxMissedCleavages, minLength, maxLength, initiatorMethonine, includeModifications, semiDigestion);
65 | }
66 |
67 | ///
68 | /// Digests this protein into peptides.
69 | ///
70 | /// The proteases to digest with
71 | /// The max number of missed cleavages generated, 0 means no missed cleavages
72 | /// The minimum length (in amino acids) of the peptide
73 | /// The maximum length (in amino acids) of the peptide
74 | ///
75 | ///
76 | ///
77 | /// A list of digested peptides
78 | public virtual IEnumerable Digest(IEnumerable proteases, int maxMissedCleavages = 3, int minLength = 1, int maxLength = int.MaxValue, bool initiatorMethonine = true, bool includeModifications = false, bool semiDigestion = false)
79 | {
80 | return GetDigestionPoints(Sequence, proteases, maxMissedCleavages, minLength, maxLength, initiatorMethonine, semiDigestion).Select(points => new Peptide(this, points.Item1, points.Item2, includeModifications));
81 | }
82 |
83 | #endregion Digestion
84 | }
85 | }
--------------------------------------------------------------------------------
/CSMSL/Proteomics/Terminus.cs:
--------------------------------------------------------------------------------
1 | // Copyright 2022 Derek J. Bailey
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | using System;
16 |
17 | namespace CSMSL.Proteomics
18 | {
19 | ///
20 | /// The terminus of an amino acid polymer N-[Amino Acids]-C
21 | ///
22 | [Flags]
23 | public enum Terminus
24 | {
25 | ///
26 | /// The N-terminus (amino-terminus)
27 | ///
28 | N = 1,
29 |
30 | ///
31 | /// The C-terminus (carboxyl-terminus)
32 | ///
33 | C = 2
34 | }
35 | }
--------------------------------------------------------------------------------
/CSMSL/Resources/Modifications.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | C2H2O
5 | K
6 | Acetylation
7 |
8 |
9 | C2H3NO
10 | C
11 | CAM
12 |
13 |
14 | O
15 | M
16 |
17 |
18 | HPO3
19 | S
20 | T
21 | Y
22 | Phospho
23 |
24 |
--------------------------------------------------------------------------------
/CSMSL/Resources/Proteases.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/CSMSL/Spectral/ChromatogramType.cs:
--------------------------------------------------------------------------------
1 | // Copyright 2022 Derek J. Bailey
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | namespace CSMSL.Spectral
16 | {
17 | public enum ChromatogramType
18 | {
19 | ///
20 | /// Takes the base peak of a spectrum and plots its intensity over time
21 | ///
22 | BasePeak,
23 |
24 | ///
25 | /// Sums the intensity of peaks within a specific m/z range
26 | ///
27 | MzRange,
28 |
29 | ///
30 | /// The total ion current of the spectrum
31 | ///
32 | TotalIonCurrent
33 | }
34 | }
--------------------------------------------------------------------------------
/CSMSL/Spectral/ChromatographicElutionProfile.cs:
--------------------------------------------------------------------------------
1 | // Copyright 2022 Derek J. Bailey
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | using System.Collections.Generic;
16 | using System.Linq;
17 | using System.Security.Cryptography.X509Certificates;
18 |
19 | namespace CSMSL.Spectral
20 | {
21 | public class ChromatographicElutionProfile where T : IPeak
22 | {
23 | public T StartPeak
24 | {
25 | get { return _peaks[0]; }
26 | }
27 |
28 | public T EndPeak
29 | {
30 | get { return _peaks[Count - 1]; }
31 | }
32 |
33 | private readonly int _maxPeakIndex = 0;
34 | public T MaxPeak
35 | {
36 | get { return _peaks[_maxPeakIndex]; }
37 | }
38 |
39 | public DoubleRange TimeRange {get; private set;}
40 |
41 | public int Count {get; private set;}
42 |
43 | public double SummedArea { get; private set; }
44 |
45 | private readonly T[] _peaks;
46 |
47 | public ChromatographicElutionProfile(ICollection peaks)
48 | {
49 | Count = peaks.Count;
50 | if (Count == 0)
51 | {
52 | return;
53 | }
54 | _peaks = peaks.ToArray();
55 |
56 | _maxPeakIndex = _peaks.MaxIndex(p => p.Y);
57 | SummedArea = _peaks.Sum(p => p.Y);
58 | TimeRange = new DoubleRange(_peaks[0].X, _peaks[Count - 1].X);
59 | }
60 |
61 | public double TrapezoidalArea()
62 | {
63 | double area = 0;
64 | for (int i = 0; i < Count - 1; i++)
65 | {
66 | T peak1 = _peaks[i];
67 | T peak2 = _peaks[i+1];
68 | area += (peak2.X - peak1.X) * (peak2.Y + peak1.Y);
69 | }
70 | return area / 2.0;
71 | }
72 |
73 |
74 |
75 |
76 |
77 | }
78 | }
79 |
--------------------------------------------------------------------------------
/CSMSL/Spectral/ChromatographicPeak.cs:
--------------------------------------------------------------------------------
1 | // Copyright 2022 Derek J. Bailey
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | namespace CSMSL.Spectral
16 | {
17 | public sealed class ChromatographicPeak : IPeak
18 | {
19 | public double Time { get; private set; }
20 |
21 | public double Intensity { get; private set; }
22 |
23 | public ChromatographicPeak(double time, double intensity)
24 | {
25 | Time = time;
26 | Intensity = intensity;
27 | }
28 |
29 | public override string ToString()
30 | {
31 | return string.Format("({0:G4}, {1:G4})", Time, Intensity);
32 | }
33 |
34 | public int CompareTo(double time)
35 | {
36 | return Time.CompareTo(time);
37 | }
38 |
39 | public int CompareTo(IPeak other)
40 | {
41 | return Time.CompareTo(other.X);
42 | }
43 |
44 | public int CompareTo(ChromatographicPeak other)
45 | {
46 | return Time.CompareTo(other.Time);
47 | }
48 |
49 | public int CompareTo(object other)
50 | {
51 | return 0;
52 | }
53 |
54 | double IPeak.X
55 | {
56 | get { return Time; }
57 | }
58 |
59 | double IPeak.Y
60 | {
61 | get { return Intensity; }
62 | }
63 | }
64 | }
--------------------------------------------------------------------------------
/CSMSL/Spectral/IMassSpectrum.cs:
--------------------------------------------------------------------------------
1 | // Copyright 2022 Derek J. Bailey
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | namespace CSMSL.Spectral
16 | {
17 | ///
18 | /// An object that contains a mass spectrum
19 | ///
20 | public interface IMassSpectrum
21 | {
22 | ISpectrum MassSpectrum { get; }
23 | }
24 | }
--------------------------------------------------------------------------------
/CSMSL/Spectral/IPeak.cs:
--------------------------------------------------------------------------------
1 | // Copyright 2022 Derek J. Bailey
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | using System;
16 |
17 | namespace CSMSL.Spectral
18 | {
19 | ///
20 | /// Represents a peak in a 2-dimensional spectra
21 | ///
22 | public interface IPeak : IComparable, IComparable, IComparable
23 | {
24 | ///
25 | /// The X value of this peak
26 | ///
27 | double X { get; }
28 |
29 | ///
30 | /// The Y value of this peak
31 | ///
32 | double Y { get; }
33 | }
34 | }
--------------------------------------------------------------------------------
/CSMSL/Spectral/ISpectrumTime.cs:
--------------------------------------------------------------------------------
1 | // Copyright 2022 Derek J. Bailey
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | using System;
16 | using System.Collections.Generic;
17 |
18 | namespace CSMSL.Spectral
19 | {
20 | public interface ISpectrumTime : ISpectrum
21 | {
22 | ///
23 | /// The time associated with this spectrum
24 | ///
25 | double Time { get; }
26 | }
27 |
28 | public static class ISpectrumTimeExtension
29 | {
30 | public static Chromatogram GetExtractedIonChromatogram(this IEnumerable spectra, DoubleRange range)
31 | {
32 | if (range == null)
33 | {
34 | throw new ArgumentException("A range must be declared for a m/z range chromatogram");
35 | }
36 |
37 | List times = new List();
38 | List intensities = new List();
39 |
40 | foreach (ISpectrumTime spectrum in spectra)
41 | {
42 | double intensity;
43 | spectrum.TryGetIntensities(range, out intensity);
44 | times.Add(spectrum.Time);
45 | intensities.Add(intensity);
46 | }
47 |
48 | return new MassRangeChromatogram(times.ToArray(), intensities.ToArray(), range);
49 | }
50 |
51 | public static Chromatogram GetClosetsPeakChromatogram(this IEnumerable spectra, DoubleRange range)
52 | {
53 | if (range == null)
54 | {
55 | throw new ArgumentException("A range must be declared for a m/z range chromatogram");
56 | }
57 |
58 | List times = new List();
59 | List intensities = new List();
60 |
61 | foreach (ISpectrumTime spectrum in spectra)
62 | {
63 | times.Add(spectrum.Time);
64 | var peak = spectrum.GetClosestPeak(range);
65 | intensities.Add((peak != null) ? peak.Intensity : 0);
66 | }
67 |
68 | return new MassRangeChromatogram(times.ToArray(), intensities.ToArray(), range);
69 | }
70 | }
71 | }
--------------------------------------------------------------------------------
/CSMSL/Spectral/MZPeak.cs:
--------------------------------------------------------------------------------
1 | // Copyright 2022 Derek J. Bailey
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | using System;
16 | using System.Security.Cryptography.X509Certificates;
17 |
18 | namespace CSMSL.Spectral
19 | {
20 | ///
21 | /// A peak in a mass spectrum that has a well defined m/z and intenisty value
22 | ///
23 | public class MZPeak : IPeak, IEquatable
24 | {
25 | public double Intensity { get; private set; }
26 |
27 | public double MZ { get; private set; }
28 |
29 | public MZPeak(double mz = 0.0, double intensity = 0.0)
30 | {
31 | MZ = mz;
32 | Intensity = intensity;
33 | }
34 |
35 | public bool Equals(IPeak other)
36 | {
37 | if (ReferenceEquals(this, other)) return true;
38 | return MZ.FussyEquals(other.X) && Intensity.FussyEquals(other.Y);
39 | }
40 |
41 | public override string ToString()
42 | {
43 | return string.Format("({0:F4},{1:G5})", MZ, Intensity);
44 | }
45 |
46 | public int CompareTo(double other)
47 | {
48 | return MZ.CompareTo(other);
49 | }
50 |
51 | public int CompareTo(IPeak other)
52 | {
53 | if (other == null)
54 | return 1;
55 | return MZ.CompareTo(other.X);
56 | }
57 |
58 | public int CompareTo(object other)
59 | {
60 | if (other is double)
61 | return MZ.CompareTo((double) other);
62 | var peak = other as IPeak;
63 | if (peak != null)
64 | return CompareTo(peak);
65 | throw new InvalidOperationException("Unable to compare types");
66 | }
67 |
68 | protected double X
69 | {
70 | get { return MZ; }
71 | }
72 |
73 | protected double Y
74 | {
75 | get { return Intensity; }
76 | }
77 |
78 | double IPeak.X
79 | {
80 | get { return X; }
81 | }
82 |
83 | double IPeak.Y
84 | {
85 | get { return Y; }
86 | }
87 |
88 | public override bool Equals(object obj)
89 | {
90 | return obj is MZPeak && Equals((MZPeak) obj);
91 | }
92 |
93 | public override int GetHashCode()
94 | {
95 | return MZ.GetHashCode() ^ Intensity.GetHashCode();
96 | }
97 |
98 | public bool Equals(MZPeak other)
99 | {
100 | // Odd to use mass equals on intensity, might have to make that more generic sometime
101 | return MZ.FussyEquals(other.MZ) && Intensity.FussyEquals(other.Intensity);
102 | }
103 | }
104 | }
--------------------------------------------------------------------------------
/CSMSL/Spectral/MassRangeChromatogram.cs:
--------------------------------------------------------------------------------
1 | // Copyright 2022 Derek J. Bailey
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | namespace CSMSL.Spectral
16 | {
17 | public class MassRangeChromatogram : Chromatogram
18 | {
19 | public DoubleRange Range { get; private set; }
20 |
21 | public MassRangeChromatogram(double[] times, double[] intensities, DoubleRange range)
22 | : base(times, intensities)
23 | {
24 | Range = range;
25 | }
26 |
27 | public MassRangeChromatogram(double[,] timeintensities, DoubleRange range)
28 | : base(timeintensities)
29 | {
30 | Range = range;
31 | }
32 |
33 | public MassRangeChromatogram(MassRangeChromatogram chromatogram)
34 | : base(chromatogram)
35 | {
36 | Range = chromatogram.Range;
37 | }
38 |
39 | public MassRangeChromatogram(Chromatogram chromatogram, DoubleRange range)
40 | : base(chromatogram)
41 | {
42 | Range = range;
43 | }
44 |
45 | public new MassRangeChromatogram Smooth(SmoothingType smoothing, int points)
46 | {
47 | Chromatogram chrom = base.Smooth(smoothing, points);
48 | return new MassRangeChromatogram(chrom, Range);
49 | }
50 | }
51 | }
--------------------------------------------------------------------------------
/CSMSL/Spectral/MzAnalyzerType.cs:
--------------------------------------------------------------------------------
1 | // Copyright 2022 Derek J. Bailey
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 | namespace CSMSL.Spectral
15 | {
16 | public enum MZAnalyzerType
17 | {
18 | Unknown = 0,
19 | Quadrupole = 1,
20 | IonTrap2D = 2,
21 | IonTrap3D = 3,
22 | Orbitrap = 4,
23 | TOF = 5,
24 | FTICR = 6,
25 | Sector = 7
26 | }
27 | }
--------------------------------------------------------------------------------
/CSMSL/Spectral/SmoothingType.cs:
--------------------------------------------------------------------------------
1 | // Copyright 2022 Derek J. Bailey
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | namespace CSMSL.Spectral
16 | {
17 | ///
18 | /// Types of peak smoothing
19 | ///
20 | public enum SmoothingType
21 | {
22 | ///
23 | /// No smoothing
24 | ///
25 | None,
26 |
27 | ///
28 | /// Box Car smoothing
29 | ///
30 | /// A Moving Average
31 | ///
32 | ///
33 | BoxCar,
34 |
35 | ///
36 | /// Savitzky-Golay smoothing
37 | ///
38 | SavitzkyGolay
39 | }
40 | }
--------------------------------------------------------------------------------
/CSMSL/ToleranceType.cs:
--------------------------------------------------------------------------------
1 | // Copyright 2022 Derek J. Bailey
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | namespace CSMSL
16 | {
17 | ///
18 | /// The type of tolerance
19 | ///
20 | public enum ToleranceType
21 | {
22 | ///
23 | /// Plus and Minus (±)
24 | ///
25 | PlusAndMinus,
26 |
27 | ///
28 | /// Full Width
29 | ///
30 | FullWidth
31 | }
32 | }
--------------------------------------------------------------------------------
/CSMSL/ToleranceUnit.cs:
--------------------------------------------------------------------------------
1 | // Copyright 2022 Derek J. Bailey
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | namespace CSMSL
16 | {
17 | ///
18 | /// The units of tolerance
19 | ///
20 | public enum ToleranceUnit
21 | {
22 | ///
23 | /// Parts per million
24 | ///
25 | PPM,
26 |
27 | ///
28 | /// Daltons
29 | ///
30 | DA,
31 |
32 | ///
33 | /// Milli Mass Units
34 | ///
35 | /// Equivalent to mDa
36 | ///
37 | ///
38 | MMU
39 | }
40 | }
--------------------------------------------------------------------------------
/CSMSL/Util/Collections/VennSet.cs:
--------------------------------------------------------------------------------
1 | // Copyright 2022 Derek J. Bailey
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | using System;
16 | using System.Collections;
17 | using System.Collections.Generic;
18 | using System.Linq;
19 |
20 | namespace CSMSL.Util.Collections
21 | {
22 | public class VennSet : IEnumerable where T : IEquatable
23 | {
24 | private readonly Dictionary _data;
25 |
26 | public int Count
27 | {
28 | get { return _data.Count; }
29 | }
30 |
31 | public VennSet(IEnumerable items, string name = "")
32 | {
33 | Name = name;
34 | _data = items.ToDictionary(item => item);
35 | }
36 |
37 | public VennSet(string name = "")
38 | {
39 | Name = name;
40 | _data = new Dictionary();
41 | }
42 |
43 | public string Name { get; set; }
44 |
45 | public void Add(T item)
46 | {
47 | _data[item] = item;
48 | }
49 |
50 | public void Add(IEnumerable items)
51 | {
52 | foreach (T item in items)
53 | {
54 | _data[item] = item;
55 | }
56 | }
57 |
58 | public bool TryGetValue(T key, out T value)
59 | {
60 | return _data.TryGetValue(key, out value);
61 | }
62 |
63 | public override string ToString()
64 | {
65 | return string.Format("{0} Count = {1:G0}", Name, Count);
66 | }
67 |
68 | public IEnumerator GetEnumerator()
69 | {
70 | return _data.Values.GetEnumerator();
71 | }
72 |
73 | IEnumerator IEnumerable.GetEnumerator()
74 | {
75 | return _data.Values.GetEnumerator();
76 | }
77 | }
78 | }
--------------------------------------------------------------------------------