CandidateSearch 1.1.2
Proof-of-concept implementation of a search engine that uses sparse matrix multiplication to identify the best peptide candidates for a given mass spectrum.
Loading...
Searching...
No Matches
Spectra.cs
Go to the documentation of this file.
2{
6 public class Spectrum
7 {
11 public double[] mz { get; }
15 public double[] intensity { get; }
19 public int scanNumber { get; }
20
27 public Spectrum(double[] Mz, double[] Intensity, int ScanNumber)
28 {
29 mz = Mz;
30 intensity = Intensity;
31 scanNumber = ScanNumber;
32 Array.Sort(mz, intensity);
33 }
34
41 public int[] getEncoding(int massRange = 5000, int massMultiplier = 100)
42 {
43 var encoding = new List<int>();
44
45 for (int i = 0; i < mz.Length; i++)
46 {
47 if (mz[i] < massRange)
48 {
49 encoding.Add((int) Math.Round(mz[i] * massMultiplier));
50 }
51 }
52
53 return encoding.Distinct().OrderBy(x => x).ToArray();
54 }
55 }
56
60 public static class MGFReader
61 {
67 public static List<Spectrum> readMGF(string filename)
68 {
69 var MSAMANDA_spectra = MSAMANDA_MGFPARSER.MGFParser.ParseNextSpectra(filename);
70
71 var spectra = new List<Spectrum>();
72
73 foreach(var spectrum in MSAMANDA_spectra)
74 {
75 var mz = new List<double>();
76 var intensity = new List<double>();
77
78 foreach (var peak in spectrum.FragmentsPeaks)
79 {
80 mz.Add(peak.Position);
81 intensity.Add(peak.Intensity);
82 }
83
84 spectra.Add(new Spectrum(mz.ToArray(), intensity.ToArray(), spectrum.ScanNumber));
85 }
86
87 return spectra;
88 }
89 }
90}
91
Simplified spectrum class implemention of a mass spectrum.
Definition Spectra.cs:7
double[] intensity
Array containing intensities of centroid peaks.
Definition Spectra.cs:15
int scanNumber
The scan number of the spectrum.
Definition Spectra.cs:19
int[] getEncoding(int massRange=5000, int massMultiplier=100)
Get the encoding vector of the spectrum.
Definition Spectra.cs:41
Spectrum(double[] Mz, double[] Intensity, int ScanNumber)
Constructor to create a new spectrum.
Definition Spectra.cs:27
double[] mz
Array containing m/z values of centroid peaks.
Definition Spectra.cs:11