public SpectrumTask(WaveSpectrumCondition condition, bool multiThreadTask, ISpectrum[] spectrums) : base(multiThreadTask) { if (spectrums == null || spectrums.Length != 4) throw new ArgumentException("Spectrums array must have a length of 4"); m_spectrums = spectrums; Condition = condition; Size = condition.Key.Size; GridSizes = condition.GridSizes; WaveAmps = condition.WaveAmps; NumGrids = condition.Key.NumGrids; m_rnd = new System.Random(0); m_distibution = SPECTRUM_DISTRIBUTION.LINEAR; float factor = 2.0f * Mathf.PI * Size; InverseGridSizes = new Vector4(factor / GridSizes.x, factor / GridSizes.y, factor / GridSizes.z, factor / GridSizes.w); m_spectrum01 = new Color[Size * Size]; if(NumGrids > 2) m_spectrum23 = new Color[Size * Size]; m_wtable = new Color[Size * Size]; }
public static void AssertSpectrum(ISpectrum spectrum, double expectedStartRT, double expectedEndRT, int expectedDataPoints, Stopwatch timer, int minimumMillisecondsGenerationShouldTake, int maximumMillisecondsGenerationShouldTake) { Assert.AreEqual(expectedStartRT, Math.Round(spectrum.StartRT, 10)); Assert.AreEqual(expectedEndRT, Math.Round(spectrum.EndRT, 10)); Assert.AreEqual(expectedDataPoints, spectrum.YValues.Count); Assert.IsTrue( timer.ElapsedMilliseconds >= minimumMillisecondsGenerationShouldTake && timer.ElapsedMilliseconds <= maximumMillisecondsGenerationShouldTake, "The Spectrum took " + timer.ElapsedMilliseconds + " which is outside of the acceptable performance range of (" + minimumMillisecondsGenerationShouldTake + " - " + maximumMillisecondsGenerationShouldTake + ")"); }
public TriangleLight(RayEngineScene sc, int triIndex, ITriangleMesh mesh, RgbSpectrum gain = new RgbSpectrum()) : this(sc, string.Empty, gain) { Gain = (RgbSpectrumInfo)gain; triangleIndex = triIndex; this.Owner = mesh; //Configuration.Instance.Get("Integrator.ComputeNormals", false); //Configuration.Instance.Get("Integrator.InverseLightNormals", false); var multiplicator = normalInverse ? -1f : 1f; this.TriangleNormal = multiplicator * ((computeNormal || !mesh.HasNormals) ? scene.Triangles[triangleIndex].ComputeNormal(scene.Vertices) : (Normal)scene.SceneGeometry.Normals[Math.Min(scene.SceneGeometry.Normals.Length - 1, triIndex)]); this.area = Math.Max(scene.Triangles[triangleIndex].AreaV(scene.Vertices), 0.00001f); Assert.IsNotNaN(this.TriangleNormal.x); Assert.IsTrue(this.area > 0f); lightSpectra = GlobalConfiguration.Instance.SpectralRendering ? (ISpectrum)spectra : gain; }
public ISpectrum Evaluate(float u, float v) { if (SpectralRendering) { if (EmissionTexture != null) return ColorFactory.FromRgb(EmissionTexture.Sample(u, v), SpectrumType.Illuminant); if (EmissionSpectra.Length == 3) return ColorFactory.FromRgb(new RgbSpectrumInfo(EmissionSpectra), SpectrumType.Illuminant); return sspd ?? (sspd = new SampledSpectrum(EmissionSpectra)); } else { if (EmissionTexture != null) { return InvertTexture ? (RgbSpectrumInfo.UnitSpectrum() - EmissionTexture.Sample(u, v)) : EmissionTexture.Sample(u, v); } if (spd == null || spd.IsBlack()) spd = getSpectrum(); return spd; } }
public SpectrumTask(WaveSpectrumCondition condition, bool multiThreadTask, ISpectrum[] spectrums) : base(multiThreadTask) { if (spectrums == null || spectrums.Length != 4) { throw new ArgumentException("Spectrums array must have a length of 4"); } this.m_spectrums = spectrums; this.Condition = condition; this.Size = condition.Key.Size; this.GridSizes = condition.GridSizes; this.WaveAmps = condition.WaveAmps; this.NumGrids = condition.Key.NumGrids; this.m_rnd = new System.Random(0); this.m_distibution = SPECTRUM_DISTRIBUTION.LINEAR; float num = 6.28318548f * (float)this.Size; this.InverseGridSizes = new Vector4(num / this.GridSizes.x, num / this.GridSizes.y, num / this.GridSizes.z, num / this.GridSizes.w); this.m_spectrum01 = new Color[this.Size * this.Size]; if (this.NumGrids > 2) { this.m_spectrum23 = new Color[this.Size * this.Size]; } this.m_wtable = new Color[this.Size * this.Size]; }
public List <IGlycoPeptide> Match(ISpectrum spectrum) { SetPeptides(PeptidesFilter(spectrum)); return(matcher.Match(spectrum)); }
public void Run(string path, Counter counter, ISpectrumReader spectrumReader, NormalizerEngine normalizer) { NGlycanTheoryPeaksBuilder builder = new NGlycanTheoryPeaksBuilder(); builder.SetBuildType(true, false, false); List <IGlycanPeak> glycans = builder.Build(); spectrumReader.Init(path); IResultSelect resultSelect = new ResultMaxSelect(SearchingParameters.Access.Threshold, SearchingParameters.Access.PeakCutoff); List <IResult> final = new List <IResult>(); int start = spectrumReader.GetFirstScan(); int end = spectrumReader.GetLastScan(); Parallel.For(start, end, (i) => { if (spectrumReader.GetMSnOrder(i) < 2) { IResultFactory factory = new NGlycanResultFactory(); EnvelopeProcess envelopeProcess = new EnvelopeProcess( SearchingParameters.Access.Tolerance, SearchingParameters.Access.ToleranceBy); MonoisotopicSearcher monoisotopicSearcher = new MonoisotopicSearcher(factory); IProcess spectrumProcess = new LocalNeighborPicking(); ISpectrumSearch spectrumSearch = new NGlycanSpectrumSearch(glycans, spectrumProcess, envelopeProcess, monoisotopicSearcher, SearchingParameters.Access.MaxCharage, SearchingParameters.Access.Cutoff); ISpectrum spectrum = spectrumReader.GetSpectrum(i); List <IResult> results = spectrumSearch.Search(spectrum); lock (resultLock) { resultSelect.Add(results); final.AddRange(results); } } counter.Add(end - start); }); //original string outputPath = Path.Combine(Path.GetDirectoryName(path), Path.GetFileNameWithoutExtension(path) + "_one_quant.csv"); List <string> outputString = new List <string>(); foreach (IResult present in final.OrderBy(r => r.GetRetention())) { int scan = present.GetScan(); double rt = present.GetRetention(); double index = Math.Round(normalizer.Normalize(rt), 2); TIQ3XIC xicer = new TIQ3XIC(spectrumReader); double area = xicer.OneArea(present); List <string> output; if (!normalizer.Initialized()) { output = new List <string>() { scan.ToString(), rt.ToString(), present.Glycan().GetGlycan().Name(), present.GetMZ().ToString(), area.ToString(), }; } else { output = new List <string>() { scan.ToString(), rt.ToString(), index > 0? index.ToString():"0", present.Glycan().GetGlycan().Name(), present.GetMZ().ToString(), area.ToString(), }; } outputString.Add(string.Join(",", output)); } using (FileStream ostrm = new FileStream(outputPath, FileMode.OpenOrCreate, FileAccess.Write)) { using (StreamWriter writer = new StreamWriter(ostrm)) { if (!normalizer.Initialized()) { writer.WriteLine("scan,time,glycan,mz,area"); } else { writer.WriteLine("scan,time,GUI,glycan,mz,area"); } foreach (string output in outputString) { writer.WriteLine(output); } writer.Flush(); } } // merged string outputPathMerge = Path.Combine(Path.GetDirectoryName(path), Path.GetFileNameWithoutExtension(path) + "_quant.csv"); List <string> outputStringMerge = new List <string>(); Dictionary <string, List <SelectResult> > resultContainer = resultSelect.Produce(); foreach (string name in resultContainer.Keys) { List <SelectResult> selectResults = resultContainer[name]; foreach (SelectResult select in selectResults) { IResult present = select.Present; int scan = present.GetScan(); double rt = present.GetRetention(); double index = Math.Round(normalizer.Normalize(rt), 2); IXIC xicer = new TIQ3XIC(spectrumReader); double area = xicer.Area(select); List <string> output; if (!normalizer.Initialized()) { output = new List <string>() { scan.ToString(), rt.ToString(), name, present.GetMZ().ToString(), area.ToString(), }; } else { output = new List <string>() { scan.ToString(), rt.ToString(), index.ToString(), name, present.GetMZ().ToString(), area.ToString(), }; } outputStringMerge.Add(string.Join(",", output)); } } using (FileStream ostrm = new FileStream(outputPathMerge, FileMode.OpenOrCreate, FileAccess.Write)) { using (StreamWriter writer = new StreamWriter(ostrm)) { if (!normalizer.Initialized()) { writer.WriteLine("scan,time,glycan,mz,area"); } else { writer.WriteLine("scan,time,GUI,glycan,mz,area"); } foreach (string output in outputStringMerge) { writer.WriteLine(output); } writer.Flush(); } } }
float GetSpectrumSample(float i, float j, float dk, float kMin, float amp, ISpectrum spectrum) { if (spectrum == null) return 0.0f; float kx = i * dk; float ky = j * dk; float h = 0.0f; if (Math.Abs(kx) >= kMin || Math.Abs(ky) >= kMin) { float S = spectrum.Spectrum(kx, ky) * amp; h = Mathf.Sqrt(S * 0.5f) * dk; if (float.IsNaN(h) || float.IsInfinity(h)) h = 0.0f; } return h; }
/// <summary> /// Initializes a new spectrum from another spectrum /// </summary> /// <param name="spectrum">The spectrum to clone</param> protected Spectrum(ISpectrum spectrum) : this(spectrum.GetMasses(), spectrum.GetIntensities()) { }
public void Test1() { string path = @"D:\Raw\ZC_20171218_N14_R2.raw"; ISpectrumReader reader = new ThermoRawSpectrumReader(); LocalMaximaPicking picking = new LocalMaximaPicking(10); reader.Init(path); Dictionary <int, int> scanMap = new Dictionary <int, int>(); int current = -1; int start = reader.GetFirstScan(); int end = reader.GetLastScan(); for (int i = start; i < end; i++) { if (reader.GetMSnOrder(i) == 1) { current = i; } else if (reader.GetMSnOrder(i) == 2) { scanMap[i] = current; } } double searchRange = 1; int scan_num = 6223; if (scanMap.ContainsKey(scan_num)) { int paranet_scan = scanMap[scan_num]; ISpectrum ms1 = reader.GetSpectrum(paranet_scan); double mz = reader.GetPrecursorMass(scan_num, reader.GetMSnOrder(scan_num)); List <IPeak> ms1Peaks = FilterPeaks(ms1.GetPeaks(), mz, searchRange); if (ms1Peaks.Count() == 0) { return; } // insert pseudo peaks for large gap List <IPeak> peaks = new List <IPeak>(); double precision = 0.02; double last = ms1Peaks.First().GetMZ(); foreach (IPeak peak in ms1Peaks) { if (peak.GetMZ() - last > precision) { peaks.Add(new GeneralPeak(last + precision / 2, 0)); peaks.Add(new GeneralPeak(peak.GetMZ() - precision / 2, 0)); } peaks.Add(peak); last = peak.GetMZ(); } List <IPeak> majorPeaks = picking.Process(peaks); //Console.WriteLine("mz,intensity"); //foreach (IPeak pk in peaks) //{ // Console.WriteLine(pk.GetMZ().ToString() + "," + pk.GetIntensity().ToString()); //} Fourier charger = new Fourier(); int charge = charger.Charge(peaks, mz - searchRange, mz + searchRange); Patterson charger2 = new Patterson(); PattersonFourierCombine charger3 = new PattersonFourierCombine(); Console.WriteLine(charge.ToString() + " " + charger2.Charge(peaks, mz - searchRange, mz + searchRange).ToString() + " " + charger3.Charge(peaks, mz - searchRange, mz + searchRange).ToString()); } }
public SpectrumFragmentsMatch(ISpectrum spectrum) { Spectrum = spectrum; _fragmentSpectralMatches = new HashSet<FragmentSpectralMatch>(); _fragments = new HashSet<Fragment>(); }
public IDistanceDistribution?GetDistances(IRay ray, ISpectrum spectrum, IInterval interval) { return(ray.WithinBounds(interval.Entry) ? new DeltaDistance(interval.Entry) : null); }
internal void FillSpectrum(ISpectrum spectrum, int dataId, ParameterStatus status) { FillSpectrum(this.data[dataId], spectrum, status); }
public double Area(IResult glycan) { // search xic double mz = glycan.GetMZ(); int scan = glycan.GetScan(); int charge = glycan.GetCharge(); // get neighbors List <ISpectrum> neighbors = new List <ISpectrum>(); int nextScan = scan; while (nextScan > spectrumReader.GetFirstScan()) { if (spectrumReader.GetMSnOrder(nextScan) == 1) { ISpectrum spectrum = spectrumReader.GetSpectrum(nextScan); int index = BinarySearch.Search(spectrum.GetPeaks(), mz, tol, by); if (index < 0) { break; } neighbors.Add(spectrum); } nextScan--; } nextScan = scan + 1; while (nextScan <= spectrumReader.GetLastScan()) { if (spectrumReader.GetMSnOrder(nextScan) == 1) { ISpectrum spectrum = spectrumReader.GetSpectrum(nextScan); int index = BinarySearch.Search(spectrum.GetPeaks(), mz, tol, by); if (index < 0) { break; } neighbors.Add(spectrum); } nextScan++; } // each neighbor get top 3 peaks List <double> topArea = new List <double>(); List <int> delta = new List <int>() { -2, -1, 0, 1, 2 }; foreach (ISpectrum spetrum in neighbors) { List <IPeak> top = new List <IPeak>(); foreach (int j in delta) { int index = BinarySearch.BestSearch(spetrum.GetPeaks(), mz + 1.0 / charge * j, tol, by); if (index < 0) { continue; } top.Add(spetrum.GetPeaks()[index]); } topArea.Add(top.OrderByDescending(p => p.GetIntensity()). Take(3).Select(p => p.GetIntensity()).Sum()); } return(topArea.OrderByDescending(a => a).Take(3).Sum()); }
protected override IEnumerable <double> GetYValues(ISpectrum spectrum) { return(spectrum.Phase); }
public void Initialize(IRayEngineScene scen, params object[] data) { zeroSpectra = GlobalConfiguration.Instance.SpectralRendering ? (ISpectrum)ZeroCSpectrumArray : this.RgbSpectrumZeroArray; var scn = (RayEngineScene)scen; if (mesh == null && !string.IsNullOrWhiteSpace(MeshName)) { this.mesh = scn.Meshes.FirstOrDefault( item => item.MeshName.Equals(MeshName, StringComparison.CurrentCultureIgnoreCase)); if (this.mesh != null) { if (this.mesh.MeshProfile == null) { this.mesh.MeshProfile = new LightsourceProfile() { Light = this }; } else { var lightsourceProfile = this.mesh.MeshProfile as LightsourceProfile; if (lightsourceProfile != null) lightsourceProfile.Light = this; } meshMeshArea = 0; for (int i = mesh.StartTriangle; i < mesh.EndTriangle; i++) { meshMeshArea += scn.Triangles[i].AreaV(scn.Vertices); } } } if (mesh == null) { throw new ArgumentException("Cant find light mesh", this.LightName ?? this.MeshName); } triangleSampleData = new TriangleSample[this.mesh.TrianglesCount]; this.scene = scn; for (int i = mesh.StartTriangle, j = 0; i < mesh.EndTriangle; i++, j++) { triangleSampleData[j] = new TriangleSample(scene.Triangles[i].AreaV(scene.Vertices), NormalModifier * scene.Triangles[i].ComputeNormal(scene.Vertices)); } triangleSampleData.PartialSort((a, b) => a.Item1.CompareTo(a.Item1), 0, triangleSampleData.Length); if (gain.IsBlack() || infoGain == null) { gain = scn.DefaultLightGain; infoGain = new RgbSpectrumInfo(gain); } lightSpectra = GlobalConfiguration.Instance.SpectralRendering ? spectra.ToArray() : gain.ToArray(); }
public void Le(ref Vector dir, ref ISpectrum le) { var sampleN = triangleSampleData[SampleTriangleIndex()].Item2; //NormalModifier * SampleTriangle().ComputeNormal(scene.Vertices); if (Normal.Dot(ref sampleN, ref dir) <= 0f) { le.Mul(0f); } var s = GlobalConfiguration.Instance.SpectralRendering ? (ISpectrum)spectra : infoGain; le.Mul(ref s); }
public void Le(ref Vector dir, ref ISpectrum le) { var spectrum = Le(ref dir); le.Mul(ref spectrum); }
private float GetSpectrumSample(float i, float j, float dk, float kMin, float amp, ISpectrum spectrum) { if (spectrum == null) { return 0f; } float num = i * dk; float num2 = j * dk; float num3 = 0f; if (Math.Abs(num) >= kMin || Math.Abs(num2) >= kMin) { float num4 = spectrum.Spectrum(num, num2) * amp; num3 = Mathf.Sqrt(num4 * 0.5f) * dk; if (float.IsNaN(num3) || float.IsInfinity(num3)) { num3 = 0f; } } return num3; }
public void SetMS1Spectrum(ISpectrum spectrum) { msSpectrum = spectrum; }
/** * Filters spectrum by base peak percentage * @param s spectrum * @param basePeakPercentage percentage of base peak above which to retain * @return filtered spectrum */ protected ISpectrum filterSpectrum(ISpectrum s, double basePeakPercentage) { return filterSpectrum(s, -1, basePeakPercentage); }
protected override IEnumerable <double> GetYValues(ISpectrum spectrum) { return(Dsp.LinearToDb(spectrum.Magnitude, -1000)); }
public void RestoreParameter(ISpectrum spectrum, ParameterLocation location) { this.RestoreParameter(data[FindSpectrum(spectrum.Name)], spectrum, location); }
/** * Filters spectrum by number of highest abundance ions * @param s spectrum * @param topIons number of top ions to retain * @return filtered spectrum */ protected ISpectrum filterSpectrum(ISpectrum s, int topIons) { return(filterSpectrum(s, topIons, -1)); }
public void Mul(ref ISpectrum t) { var a = (RgbSpectrum)t; this.c1 *= a.c1; this.c2 *= a.c2; this.c3 *= a.c3; }
/** * Filters spectrum by base peak percentage * @param s spectrum * @param basePeakPercentage percentage of base peak above which to retain * @return filtered spectrum */ protected ISpectrum filterSpectrum(ISpectrum s, double basePeakPercentage) { return(filterSpectrum(s, -1, basePeakPercentage)); }
public string splashIt(ISpectrum spectrum) { // check spectrum var if (spectrum == null) { throw new ArgumentNullException("The spectrum can't be null"); } StringBuilder hash = new StringBuilder(); //creating first block 'splash<type><version>' hash.Append(getFirstBlock(spectrum.getSpectrumType())); hash.Append('-'); //create prefilter block var filteredSpec = filterSpectrum(spectrum, 10, 0.1); Debug.WriteLine("filtered spectrum: " + filteredSpec.ToString()); var preFilterHistogram = getHistoBlock(filteredSpec, PREFILTER_BASE, PREFILTER_LENGTH, PREFILTER_BIN_SIZE); Debug.WriteLine("prefilter block: " + preFilterHistogram); var translated = translateBase(preFilterHistogram, PREFILTER_BASE, 36, 4); hash.Append(translated); hash.Append('-'); //create similarity block hash.Append(getHistoBlock(spectrum, SIMILARITY_BASE, SIMILARITY_LENGTH, SIMILARITY_BIN_SIZE)); hash.Append('-'); //create the spetrum hash block hash.Append(getSpectrumBlock(spectrum)); return hash.ToString(); }
public void Test1() { string path = @"C:\Users\Rui Zhang\Downloads\ZC_20171218_C16_R1.raw"; string fasta = @"C:\Users\Rui Zhang\Downloads\haptoglobin.fasta"; // peptides IProteinReader proteinReader = new FastaReader(); List <IProtein> proteins = proteinReader.Read(fasta); List <IProtein> decoyProteins = new List <IProtein>(); foreach (IProtein protein in proteins) { IProtein p = new BaseProtein(); p.SetSequence(Reverse(protein.Sequence())); decoyProteins.Add(p); } List <Proteases> proteases = new List <Proteases>() { Proteases.Trypsin, Proteases.GluC }; HashSet <string> peptides = new HashSet <string>(); ProteinDigest proteinDigest = new ProteinDigest(2, 5, proteases[0]); foreach (IProtein protein in decoyProteins) { peptides.UnionWith(proteinDigest.Sequences(protein.Sequence(), ProteinPTM.ContainsNGlycanSite)); } for (int i = 1; i < proteases.Count; i++) { proteinDigest.SetProtease(proteases[i]); List <string> peptidesList = peptides.ToList(); foreach (string seq in peptidesList) { peptides.UnionWith(proteinDigest.Sequences(seq, ProteinPTM.ContainsNGlycanSite)); } } Assert.True(peptides.Contains("KDNLTYVGDGETR")); // build glycan GlycanBuilder glycanBuilder = new GlycanBuilder(); glycanBuilder.Build(); // search List <SearchResult> searchResults = new List <SearchResult>(); ThermoRawSpectrumReader reader = new ThermoRawSpectrumReader(); LocalMaximaPicking picking = new LocalMaximaPicking(); IProcess process = new LocalNeighborPicking(); reader.Init(path); double searchRange = 2; ISpectrum ms1 = null; List <IPeak> majorPeaks = new List <IPeak>(); ISearch <string> oneSearcher = new BucketSearch <string>(ToleranceBy.PPM, 10); PrecursorMatch precursorMatcher = new PrecursorMatch(oneSearcher); precursorMatcher.Init(peptides.ToList(), glycanBuilder.GlycanMaps()); ISearch <string> moreSearcher = new BucketSearch <string>(ToleranceBy.Dalton, 0.01); SequenceSearch sequenceSearcher = new SequenceSearch(moreSearcher); ISearch <int> extraSearcher = new BucketSearch <int>(ToleranceBy.Dalton, 0.01); GlycanSearch glycanSearcher = new GlycanSearch(extraSearcher, glycanBuilder.GlycanMaps()); SearchAnalyzer searchAnalyzer = new SearchAnalyzer(); for (int i = reader.GetFirstScan(); i < reader.GetLastScan(); i++) { if (reader.GetMSnOrder(i) < 2) { ms1 = reader.GetSpectrum(i); majorPeaks = picking.Process(ms1.GetPeaks()); } else { double mz = reader.GetPrecursorMass(i, reader.GetMSnOrder(i)); if (ms1.GetPeaks() .Where(p => p.GetMZ() > mz - searchRange && p.GetMZ() < mz + searchRange) .Count() == 0) { continue; } Patterson charger = new Patterson(); int charge = charger.Charge(ms1.GetPeaks(), mz - searchRange, mz + searchRange); // find evelope cluster EnvelopeProcess envelope = new EnvelopeProcess(); var cluster = envelope.Cluster(majorPeaks, mz, charge); if (cluster.Count == 0) { continue; } // find monopeak Averagine averagine = new Averagine(AveragineType.GlycoPeptide); BrainCSharp braincs = new BrainCSharp(); MonoisotopicSearcher searcher = new MonoisotopicSearcher(averagine, braincs); MonoisotopicScore result = searcher.Search(mz, charge, cluster); double precursorMZ = result.GetMZ(); // search ISpectrum ms2 = reader.GetSpectrum(i); ms2 = process.Process(ms2); //precursor match var pre_results = precursorMatcher.Match(precursorMZ, charge); if (pre_results.Count == 0) { continue; } // spectrum search var peptide_results = sequenceSearcher.Search(ms2.GetPeaks(), charge, pre_results); if (peptide_results.Count == 0) { continue; } var glycan_results = glycanSearcher.Search(ms2.GetPeaks(), charge, pre_results); if (glycan_results.Count == 0) { continue; } var temp_results = searchAnalyzer.Analyze(i, ms2.GetPeaks(), peptide_results, glycan_results); break; } } }
public DataGridViewSpectrumRow(ISpectrum spectrum) : base() { this._spectrum = spectrum; }
private void getUP(ISpectrum spectrum, IGroup group, ref double[] u, ref double p, bool includedInts, ref int compsPosition) //, Dictionary<IComponent, double[]> comps) { { int leftRange = (int)spectrum.Parameters[4].Components[0][1].Value; int rightRange = (int)spectrum.Parameters[4].Components[0][2].Value; if (u == null) { u = new double[_longestRange + 1]; } else { if (u.Length < _longestRange + 1) { u = new double[_longestRange + 1]; } else { for (int i = 0; i < u.Length; i++) { u[i] = 0; } } } ///------------------nowa wersja---------------------- ExtComponent component; int c, ch, pos = compsPosition + 1; double xbis; double searchSum = 1; // ((ContributedGroup)group).MemoryInt; //searchSum *= searchSum; //searchSum = 1; double freeRest; p = 1; //fixed intensities. xbis sum is calculated as well for (c = 1; c < group.Components.Size; c++) { component = (ExtComponent)group.Components[c]; if (isFixed(component[0])) { p -= component[0].Value; for (ch = leftRange; ch < rightRange; ch++) { u[ch] += component[0].Value * comps[pos][ch]; } } else if (isIntInSearch(component[0])) { searchSum += component[0].Value * component[0].Value; } pos++; } freeRest = p; //intensities from search (xbis) pos = compsPosition + 1; for (c = 1; c < group.Components.Size; c++) { component = (ExtComponent)group.Components[c]; if (isIntInSearch(component[0])) { xbis = freeRest * component[0].Value * component[0].Value / searchSum; p -= xbis; for (ch = leftRange; ch < rightRange; ch++) { u[ch] += xbis * comps[pos][ch]; } } pos++; } compsPosition += group.Components.Size; ///----------------------stara wersja---------------------------- //searchSum = ((ContributedGroup)group).MemoryInt; //if (searchSum == 0) searchSum = 1; //double fixedSum = 0; ////if (includedInts) { //foreach (IComponent component in group.Components) { // //if (component == group.Components[0] || !isIntInSearch(component[0])) // // continue; // if (isFixed(component[0])) // fixedSum += component[0].Value; // else if (component != group.Components[0] && isIntInSearch(component[0]) && !isFixed(component[0])) // //if (!isFixed(component[0])) // searchSum += component[0].Value; //} ////} //foreach (IComponent component in group.Components) { // if (component == group.Components[0]) // continue; // if (isFixed(component[0])) { // || includedInts // for (int k = leftRange; k <= rightRange; k++) { // u[k] += comps[component][k] * component[0].Value; // } // p += component[0].Value; // } else { // //if (includedInts || isCommonFree(component[0])) { // if (isIntInSearch(component[0])) { // double tmpInt = (1 - fixedSum) * component[0].Value / searchSum; // for (int k = leftRange; k <= rightRange; k++) { // u[k] += comps[component][k] * tmpInt; // } // p += tmpInt; // } // } //} //p = 1 - p; }
public List <IGlycoPeptide> Match(ISpectrum spectrum, double monoMass) { SetPeptides(PeptidesFilter(spectrum)); return(matcher.Match(spectrum, monoMass)); }
public SpectrumFragmentsMatch(ISpectrum spectrum) { Spectrum = spectrum; _fragmentSpectralMatches = new HashSet <FragmentSpectralMatch>(); _fragments = new HashSet <Fragment>(); }
public static RgbSpectrum ToRgb(ref ISpectrum spd) { var sp = (SampledSpectrum) spd; return ToRgb(ref sp); }
/** * Filters spectrum by number of highest abundance ions and by base peak percentage * @param s spectrum * @param topIons number of top ions to retain * @param basePeakPercentage percentage of base peak above which to retain * @return filtered spectrum */ protected ISpectrum filterSpectrum(ISpectrum s, int topIons, double basePeakPercentage) { List<Ion> ions = s.GetIons(); // Find base peak intensity double basePeakIntensity = 0.0; foreach (Ion ion in ions) { if (ion.Intensity > basePeakIntensity) basePeakIntensity = ion.Intensity; } // Filter by base peak percentage if needed if (basePeakPercentage >= 0) { List<Ion> filteredIons = new List<Ion>(); foreach (Ion ion in ions) { if (ion.Intensity + EPSILON >= basePeakPercentage * basePeakIntensity) filteredIons.Add(new Ion(ion.MZ, ion.Intensity)); } ions = filteredIons; } // Filter by top ions if necessary if (topIons > 0 && ions.Count > topIons) { ions = ions.OrderByDescending(i => i.Intensity).ThenBy(m => m.MZ).ToList(); ions = ions.GetRange(0, topIons); } return new MSSpectrum(ions); }
public GeneralAnnotatedSpectrumPeakResultProduct(ISpectrum spectrum, List <IAnnotatedPeak> peaks) { this.peaks = peaks; this.spectrum = spectrum; }
public override void Search(int scan) { ISpectrum spectrum = spectrumFactory.GetSpectrum(scan); double monoMass = monoMassSpectrumGetter.GetMonoMass(spectrum); // assume read spectrum sequentially. if (spectrum.GetMSnOrder() < 2) { return; } // ISpectrum filter if (spectrumFilter.Filter(spectrum)) { return; } // Spectrum Processing spectrumProcessing.Process(spectrum); // precursor List <IGlycoPeptide> glycoPeptides = precursorMatcher.Match(spectrum, monoMass); double charge = (spectrum as ISpectrumMSn).GetParentCharge(); List <IGlycoPeptide> decoyGlycoPeptides = precursorMatcher.Match(spectrum, monoMass + pesudoMass / charge); // search List <IScore> scores = new List <IScore>(); foreach (IGlycoPeptide glycoPeptide in glycoPeptides) { IScore score = searchEThcDRunner.Search(spectrum, glycoPeptide); if (score.GetScore() > 0) { IScoreProxy scoreProxy = new FDRScoreProxy(score, true); scores.Add(scoreProxy); } } List <IScore> decoyScores = new List <IScore>(); foreach (IGlycoPeptide decoyGlycoPeptide in decoyGlycoPeptides) { decoyGlycoPeptide.SetPeptide(decoyGlycoPeptide.GetPeptide().Clone()); decoyGlycoPeptide.GetPeptide().SetSequence(Reverse(decoyGlycoPeptide.GetPeptide().GetSequence())); IScore score = searchEThcDRunner.Search(spectrum, decoyGlycoPeptide); if (score.GetScore() > 0) { IScoreProxy scoreProxy = new FDRScoreProxy(score, false); decoyScores.Add(scoreProxy); } } // save results List <IScore> finalScore = new List <IScore>(); if (scores.Count > 0) { double maxScores = scores.Max(x => x.GetScore()); finalScore.AddRange(scores.Where(x => x.GetScore() == maxScores).ToList()); } if (decoyScores.Count > 0) { double maxScores = decoyScores.Max(x => x.GetScore()); finalScore.AddRange(decoyScores.Where(x => x.GetScore() == maxScores).ToList()); } if (finalScore.Count > 0) { results.Add(spectrum, finalScore); } }
//backup september 12, 2010 //private void setAgi(ISpectrum spectrum, bool includedInts) { // if (agi == null) { // setAgiSize(includedInts); // } else { // if (agi[0].Length < _longestRange) { // for (int i = 0; i < agi.Length; i++) // agi[i] = new double[_longestRange + 1]; // } // } // int leftRange = (int)spectrum.Parameters[4].Components[0][1].Value; // int rightRange = (int)spectrum.Parameters[4].Components[0][2].Value; // IParameter sourceContrib = null; // bool sourceCondition = false; // double alfa = 0; // double[] firstSourceComp = null; // if (sourceGroup!= null) { // sourceContrib = ((ContributedGroup)sourceGroup).contribution; // alfa = 1/(1/sourceContrib.Value - 1); // firstSourceComp = comps[sourceGroup.Components[0]]; // sourceCondition = specialSourceCondition((ContributedGroup)sourceGroup); // } // int agiIndex = 0; // // = comps[sourceGroup.Components[0]]; // //sample group // foreach (IComponent comp in sampleGroup.Components) { // if ((!includedInts && !isFixed(comp[0].Status)) || (comp == sampleGroup.Components[0])) { // for (int k = leftRange; k <= rightRange; k++) { // agi[agiIndex][k] = pg * comps[comp][k] + ug[k]; // if (sourceCondition) // agi[agiIndex][k] += alfa * (ps * firstSourceComp[k] + us[k]); // } // agiIndex++; // } // } // //source group // if (sourceGroup != null) { // foreach (IComponent component in sourceGroup.Components) { // if (component == sourceGroup.Components[0] && sourceCondition) // continue; //if sourceCondition or intensities are included to search, don't include last component // if ((!includedInts && !isFixed(component[0].Status)) || (component == sourceGroup.Components[0])) { // for (int k = leftRange; k <= rightRange; k++) { // if (sourceCondition) { // agi[agiIndex][k] = ps * (comps[component][k] - firstSourceComp[k]); // } else // agi[agiIndex][k] = ps * comps[component][k] + us[k]; // } // agiIndex++; // } // } // } // //background // if (!isFixed(rangesGroup.Components[0][3].Status) && !includedInts) { // for (int k=leftRange; k<=rightRange; k++) // agi[agiIndex][k] = 1; // } //} private int setAgi(ISpectrum spectrum, bool includedInts) { //TODO : w tym miejscu możliwe nieprzechwycone wyjątki spowodowane zbyt małym rozmiarem macierzy agi! //prawdopodobnie konieczny jest warunek sprawdzający rozmiar pierwszego wymiaru macierzy. if (agi == null) { setAgiSize(includedInts); } else { if (agi[0].Length < _longestRange) { for (int i = 0; i < agi.Length; i++) { agi[i] = new double[_longestRange + 1]; } } } int leftRange = (int)spectrum.Parameters[4].Components[0][1].Value; int rightRange = (int)spectrum.Parameters[4].Components[0][2].Value; int c, k; //IParameter sourceContrib = null; bool sourceCondition = false; double alfa = 0; double[] firstSourceComp = null; double[] shape; IComponent component; if (sourceCondition = specialSourceCondition(sourceGroup)) { double scontrib; // = Math.Abs(sourceGroup.contribution.Value); if (!isFixed(sourceGroup.contribution)) { scontrib = Math.Abs(sourceGroup.contribution.Value) / (1 + Math.Abs(sourceGroup.contribution.Value)); } else { scontrib = Math.Abs(sourceGroup.contribution.Value); } alfa = 1 / (1 / scontrib - 1); //alfa = 1 / Math.Abs(1 - sourceContrib.Value); //contrib test if (double.IsInfinity(alfa)) { alfa = 1e20; } firstSourceComp = comps[sampleGroup.Components.Size + 1]; } int agiIndex = 0; // = comps[sourceGroup.Components[0]]; //sample group for (c = 0; c < sampleGroup.Components.Size; c++) { component = sampleGroup.Components[c]; //shape = comps[component]; shape = comps[c + 1]; if ((!isIntInSearch(component[0]) && !isFixed(component[0])) || c == 0) { for (k = leftRange; k <= rightRange; k++) { agi[agiIndex][k] = pg * shape[k] + ug[k]; if (sourceCondition) { agi[agiIndex][k] += alfa * (ps * firstSourceComp[k] + us[k]); } } agiIndex++; } } //source group if (sourceGroup != null) { //foreach (IComponent component in sourceGroup.Components) { for (c = 0; c < sourceGroup.Components.Size; c++) { if (c == 0 && sourceCondition) { continue; //if sourceCondition or intensities are included to search, don't include last component } component = sourceGroup.Components[c]; //shape = comps[component]; shape = comps[sampleGroup.Components.Size + 1 + c]; if ((!isIntInSearch(component[0]) && !isFixed(component[0])) || (c == 0)) { if (sourceCondition) { for (k = leftRange; k <= rightRange; k++) { agi[agiIndex][k] = (shape[k] - ps * firstSourceComp[k]); //TODO : roznica z poprzednimi obliczeniami!!! - ps mnozylo roznice } } else { for (k = leftRange; k <= rightRange; k++) { agi[agiIndex][k] = ps * shape[k] + us[k]; } } agiIndex++; } } } //background //if (!isFixed(rangesGroup.Components[0][3]) && !includedInts) { if (!isFixed(rangesGroup.Components[0][3]) && !isIntInSearch(rangesGroup.Components[0][3])) { for (k = leftRange; k <= rightRange; k++) { agi[agiIndex][k] = 1; } agiIndex++; } return(agiIndex); }
/** * Filters spectrum by number of highest abundance ions * @param s spectrum * @param topIons number of top ions to retain * @return filtered spectrum */ protected ISpectrum filterSpectrum(ISpectrum s, int topIons) { return filterSpectrum(s, topIons, -1); }
public static void AssertSpectrum(ISpectrum spectrum, double expectedRT, int expectedDataPoints, Stopwatch timer, int minimumMillisecondsGenerationShouldTake, int maximumMillisecondsGenerationShouldTake) { AssertSpectrum(spectrum, expectedRT, expectedRT, expectedDataPoints, timer, minimumMillisecondsGenerationShouldTake, maximumMillisecondsGenerationShouldTake); }
private void getMainMatrix(ISpectrum spectrum, bool includedInts, out EquationRow[] equationRows, out double[] equationsResult, out int size) { int agiSize = setAgi(spectrum, includedInts); int leftRange = (int)spectrum.Parameters[4].Components[0][1].Value; int rightRange = (int)spectrum.Parameters[4].Components[0][2].Value; int row, col, k; //EquationRow[] result = new EquationRow[agiSize]; if (_equationRows == null || _equationRows.Length < agiSize) { _equationRows = new EquationRow[agiSize]; } if (_equationsResult == null || _equationsResult.Length < agiSize) { _equationsResult = new double[agiSize]; } //if (this._weights == null) // this._weights = new double[spectrum.ExperimentalSpectrum.Length]; //else { // if (this._weights.Length<spectrum.ExperimentalSpectrum.Length) // this._weights = new double[spectrum.ExperimentalSpectrum.Length]; //} //for (int i = 0; i < spectrum.ExperimentalSpectrum.Length; i++) // _weights[i] = 1 / Math.Sqrt(spectrum.ExperimentalSpectrum[i]); double backgroundSub = 0; double e; if (isFixed(spectrum.Parameters[4].Components[0][3]) || isIntInSearch(spectrum.Parameters[4].Components[0][3])) { backgroundSub = spectrum.Parameters[4].Components[0][3].Value; } ////performance --- begin --- //long start = 0; //long stop = 0; //long freq = 0; //Performancer.QueryPerformanceFrequency(ref freq); //Performancer.QueryPerformanceCounter(ref start); ////performance --- begin --- for (row = 0; row < agiSize; row++) { if (_equationRows[row] == null) { _equationRows[row] = new EquationRow(new double[agiSize], 0); } for (col = 0; col < agiSize; col++) { _equationRows[row].coeff[col] = 0; for (k = leftRange; k <= rightRange; k++) //{ //_equationRows[row].coeff[col] += agi[row][k] * agi[col][k] / spectrum.ExperimentalSpectrum[k]; // *spectrum.Weights[k]; // _weights[k]; { _equationRows[row].coeff[col] += agi[row][k] * agi[col][k] / _data[k + spectrum.BufferStartPos - 1]; } //} } //right side _equationRows[row].b = 0; for (k = leftRange; k <= rightRange; k++) { e = _data[k + spectrum.BufferStartPos - 1] - backgroundSub; _equationRows[row].b += e * agi[row][k] / _data[k + spectrum.BufferStartPos - 1]; // spectrum.Weights[k]; // _weights[k]; } } ////performance --- end --- //Performancer.QueryPerformanceCounter(ref stop); //this._TEST_sum += (stop - start) * 1.0 / freq; //this._TEST_counts++; ////Console.WriteLine("{0}. Shapes calculation time: {1:F6} s", _TEST_counts++, (stop - start) * 1.0 / freq); ////performance --- end --- //return _equationRows; equationRows = _equationRows; equationsResult = _equationsResult; size = agiSize; }
public IProbabilityDistribution <Normal3> GetDirections(Normal3 incomingDirection, Position3 position, Normal3 orientation, ISpectrum spectrum) { return(new SpecularReflection(orientation, incomingDirection)); }
/// <summary>Initializes a new instance of the <see cref="T:System.Object" /> class.</summary> public TracedSpectrum(ISpectrum spectrum, string tag) { _spectrum = spectrum; Tag = tag; }
public void Run(string path, Counter counter) { ISpectrumReader reader = new ThermoRawSpectrumReader(); reader.Init(path); IGUIFinder finder = new BinarySearchFinder(PPM); IProcess picking = new LocalNeighborPicking(); Dictionary <int, List <GUI> > pointMaps = new Dictionary <int, List <GUI> >(); int start = reader.GetFirstScan(); int end = reader.GetLastScan(); Parallel.For(start, end, (i) => { if (reader.GetMSnOrder(i) < 2) { ISpectrum spectrum = picking.Process(reader.GetSpectrum(i)); lock (resultLock) { pointMaps[i] = finder.FindGlucoseUnits(spectrum); } } counter.Add(end - start); }); List <List <GUI> > points = pointMaps.OrderBy(p => p.Key).Select(p => p.Value).ToList(); IGUISequencer sequencer = new DynamicProgrammingSequencer(); List <GUI> guiPoints = sequencer.Choose(points); Dictionary <int, GUI> guiSelected = new Dictionary <int, GUI>(); foreach (GUI gui in guiPoints) { if (guiSelected.ContainsKey(gui.Unit)) { if (guiSelected[gui.Unit].Peak.GetIntensity() < gui.Peak.GetIntensity()) { guiSelected[gui.Unit] = gui; } } else { guiSelected[gui.Unit] = gui; } } Retention.Clear(); Guis.Clear(); List <GUI> looped = guiSelected.Values.OrderBy(g => g.Scan).ToList(); string output = Path.Combine(Path.GetDirectoryName(path), Path.GetFileNameWithoutExtension(path) + ".csv"); using (FileStream ostrm = new FileStream(output, FileMode.OpenOrCreate, FileAccess.Write)) { using (StreamWriter writer = new StreamWriter(ostrm)) { writer.WriteLine("scan,time,gui,peak,intensity"); foreach (GUI gui in looped) { int scan = gui.Scan; double time = reader.GetRetentionTime(scan); Retention.Add(time); Guis.Add(gui.Unit); writer.WriteLine(scan.ToString() + "," + time.ToString() + "," + gui.Unit.ToString() + "," + gui.Peak.GetMZ().ToString() + "," + gui.Peak.GetIntensity().ToString()); } writer.Flush(); } } Fitter.Fit(Retention, Guis); }
/// <summary> /// Try to add up another spectrum. The added spectrum must be of the same type. /// </summary> /// <param name="another"></param> public bool TryAbsorb(ISpectrum another) { return(_spectrum.TryAbsorb(another)); }
public void FillSpectrum(ISpectrum spectrum, ParameterStatus status) { this.FillSpectrum(spectrum, FindSpectrum(spectrum.Name), status); }
public string splashIt(ISpectrum spectrum) { // check spectrum var if (spectrum == null) { throw new ArgumentNullException("The spectrum can't be null"); } StringBuilder hash = new StringBuilder(); //creating first block 'splash<type><version>' hash.Append(getFirstBlock(spectrum.getSpectrumType())); hash.Append('-'); //create prefilter block hash.Append(translateBase(getHistoBlock(spectrum, PREFILTER_BASE, PREFILTER_LENGTH, PREFILTER_BIN_SIZE), PREFILTER_BASE, 36, 4)); hash.Append('-'); //create similarity block hash.Append(getHistoBlock(spectrum, SIMILARITY_BASE, SIMILARITY_LENGTH, SIMILARITY_BIN_SIZE)); hash.Append('-'); //create the spetrum hash block hash.Append(getSpectrumBlock(spectrum)); return hash.ToString(); }
private void FillSpectrum(byte[] sdata, ISpectrum spectrum, ParameterStatus status) { //read group uint size; using (MemoryStream stream = new MemoryStream(sdata)) { BinaryReader reader = new BinaryReader(stream); try { size = reader.ReadUInt32(); reader.ReadString(); //int position = sizeof(byte) + BitConverter.ToInt16(sdata, 0); float fit = reader.ReadSingle(); if (status > 0) { spectrum.Fit = fit; // ReadSingle(sdata, ref position); } byte g, c, p, cc, cs; while (stream.Position < size) { g = reader.ReadByte(); // sdata[position++]; if (spectrum.Parameters[g] is ContributedGroup) { ReadParameter(reader, ((ContributedGroup)spectrum.Parameters[g]).contribution, status); } else { ReadParameter(reader, null, 0); } cc = reader.ReadByte(); cs = reader.ReadByte(); //resize spectrum if neccessary if (spectrum.Parameters[g].Components.Size != cc && spectrum.Parameters[g].Definition.componentCount == 0 || spectrum.Parameters[g].Components.Size != spectrum.Parameters[g].Definition.componentCount) { spectrum.Parameters[g].Components.Size = cc; } if (spectrum.Parameters[g].Components.Size > 0) { for (c = 0; c < cc; c++) { for (p = 0; p < cs; p++) { if (c < spectrum.Parameters[g].Components.Size && p < spectrum.Parameters[g].Components[0].Size) { ReadParameter(reader, spectrum.Parameters[g].Components[c][p], status); } else { ReadParameter(reader, null, 0); } } } } else { reader.ReadBytes(6 * cc * cs); //position += (sizeof(float) + sizeof(byte) + sizeof(byte)) * cc * cs; } } } catch (EndOfStreamException) { } finally { reader.Close(); } } }
/// <summary> /// calculates a histogram of the spectrum. If weighted, it sums the mz * intensities for the peaks in each bin /// </summary> /// <param name="spec">the spectrum data (in mz:int pairs)</param> /// <returns>the histogram block for the given spectrum</returns> private string getHistoBlock(ISpectrum spec, int nbase, int length, int binSize) { double[] binnedIons = new double[length]; double maxIntensity = 0; // initialize and populate bins foreach (Ion ion in ((MSSpectrum)spec).Ions) { int bin = (int)(ion.MZ / binSize) % length; binnedIons[bin] += ion.Intensity; if (binnedIons[bin] > maxIntensity) { maxIntensity = binnedIons[bin]; } } // Normalize the histogram for (int i = 0; i < length; i++) { binnedIons[i] = (nbase - 1) * binnedIons[i] / maxIntensity; } // build histogram StringBuilder histogram = new StringBuilder(); foreach (double bin in binnedIons.ToList().GetRange(0, length)) { histogram.Append(BASE36_MAP.ElementAt((int)(bin + EPSILON))); } Debug.WriteLine(string.Format("{1} block: {0}", histogram.ToString(), length==10?"histogram":"similarity")); return histogram.ToString(); }
public void Le(ref Vector dir, ref ISpectrum le) { ISpectrum ls = (Power / (Position - dir).Length2()); le.Mul(ref ls); }
/// <summary> /// calculate the hash for the whole spectrum /// </summary> /// <param name="spec">the spectrum data (in mz:int pairs)</param> /// <returns>the Hash of the spectrum data</returns> private string getSpectrumBlock(ISpectrum spec) { List<Ion> ions = spec.getSortedIonsByMZ(); StringBuilder strIons = new StringBuilder(); foreach (Ion i in ions) { strIons.Append(string.Format("{0}:{1}", formatMZ(i.MZ), formatIntensity(i.Intensity))); strIons.Append(ION_SEPERATOR); } //string to hash strIons.Remove(strIons.Length - 1, 1); byte[] message = Encoding.UTF8.GetBytes(strIons.ToString()); SHA256Managed hashString = new SHA256Managed(); hashString.ComputeHash(message); string hash = BitConverter.ToString(hashString.Hash); hash = hash.Replace("-", "").Substring(0, maxCharactersForSpectrumBlockTruncation).ToLower(); Debug.WriteLine(string.Format("hash block: {0}", hash)); return hash; }
private void GetSkySpectralRadiance(float theta, float phi, out ISpectrum spect) { float theta_fin = Math.Min(theta, (MathLab.M_PI * 0.5f) - 0.001f); float gamma = LightUtils.RiAngleBetween(theta, phi, thetaS, phiS); // Compute xyY values float x = (float)(zenith_x * LightUtils.PerezBase(perez_x, theta_fin, gamma)); float y = (float)(zenith_y * LightUtils.PerezBase(perez_y, theta_fin, gamma)); float Y = (float)(zenith_Y * LightUtils.PerezBase(perez_Y, theta_fin, gamma)); if (!GlobalConfiguration.Instance.SpectralRendering) { RgbSpectrum rgbl; LightUtils.ChromaticityToSpectrum(Y, x, y, out rgbl); rgbl = rgbl.Abs(); if (rgbl.IsBlack() || rgbl.IsNegative()) { rgbl = new RgbSpectrum(1f, 0f ,0f); } spect = rgbl.Abs(); } else { SampledSpectrum s; LightUtils.ChromaticityToSpectrum(Y, x, y, out s); spect = s; } }
public SpectramInfo(ISpectrum spectrum, int scan, string file) { Spectrum = spectrum; ScanNum = scan; FileName = file; }
public void Le(ref Vector dir, ref ISpectrum le) { var sampleN = TriangleNormal; if (Normal.Dot(ref sampleN, ref dir) <= 0f) { le.Mul(0f); return; } var s = GlobalConfiguration.Instance.SpectralRendering ? (ISpectrum)spectra : Gain; le.Mul(ref s); }
public SearchException(string code, ISpectrum spectrum) : base(code) { this._code = code; this._spectrum = spectrum; }
public void Mul(ref ISpectrum s) { if (s is RgbSpectrum) { this *= FromRGB(((RgbSpectrum) s).ToArray(), SpectrumType.Illuminant); } else { var a = (PSSpectrum) s; this *= a; } }
public void Le(ref Vector dir, ref ISpectrum le) { var s = this.Le(ref dir); le.Mul(ref s); }