private List <IIdentifiedSpectrum> DoCalculateNoDuplicated(List <IIdentifiedSpectrum> preFiltered, OptimalResult optimalResult) { QValueFunc(preFiltered, ScoreFunc, FdrCalc); List <IIdentifiedSpectrum> result = new List <IIdentifiedSpectrum>(); optimalResult.PeptideCountFromDecoyDB = 0; optimalResult.PeptideCountFromTargetDB = 0; for (int i = preFiltered.Count - 1; i >= 0; i--) { if (preFiltered[i].QValue <= FdrValue) { result.AddRange(preFiltered.GetRange(0, i + 1)); optimalResult.Score = ScoreFunc.GetScore(preFiltered[i]); optimalResult.ExpectValue = preFiltered[i].ExpectValue; optimalResult.FalseDiscoveryRate = preFiltered[i].QValue; int decoyCount = 0; int targetCount = 0; foreach (IIdentifiedSpectrum spectrum in result) { if (spectrum.FromDecoy) { decoyCount++; } else { targetCount++; } } optimalResult.PeptideCountFromDecoyDB = decoyCount; optimalResult.PeptideCountFromTargetDB = targetCount; Console.WriteLine("{0} / {1} ==> {2} / {3}", preFiltered.Count(m => m.FromDecoy), preFiltered.Count(m => !m.FromDecoy), decoyCount, targetCount); break; } } return(result); }
/// <summary> /// Interact with nearby object of given type (layer) in wedge in front of character. /// </summary> /// <param name="character">The character attempting the interaction.</param> /// <param name="layerMask">Bit mask of layers to attempt interaction with.</param> /// <param name="angle">Maximum angle of the hit attempt.</param> /// <param name="distance">The maximum reach of the hit attempt.</param> /// <param name="calcScore">The function to calculate target likelihood.</param> /// <returns>Object interacted with, or null if none.</returns> static public GameObject actOnLayer(GameObject character, int layerMask, float angle, float distance, ScoreFunc calcScore) { return(actOnLayer(wedgeLOS, character, layerMask, angle, distance, calcScore)); }
// ================================ // * ACT ON LAYER PUBLIC FUNCTION * // ================================ /// <summary> /// Interact with nearby object of given type (layer). /// </summary> /// <param name="rayFunc">The method for attempting a hit.</param> /// <param name="character">The character attempting the interaction.</param> /// <param name="layerMask">Bit mask of layers to attempt interaction with.</param> /// <param name="angle">Angle of cone.</param> /// <param name="distance">The maximum reach of the hit attempt.</param> /// <param name="calcScore">The function to calculate target likelihood.</param> /// <returns>Object interacted with, or null if none.</returns> static public GameObject actOnLayer(RayFunc rayFunc, GameObject character, int layerMask, float angle, float distance, ScoreFunc calcScore) { GameObject ret = null; // game object returned by function float bestScore; // score for best candidate for target float currScore; // score for current object UGen.PseudoTransform charTrans; // character transform, whose position has been moved to the collider's center // set charTrans to character's transform information, but move position to center of character charTrans = UGen.setPseudo(character.transform); charTrans.position = UGen.getCenter(character); // Get list of nearby objects in desired layers Collider[] objects = Physics.OverlapSphere(charTrans.position, distance, layerMask); // get the likeliest target object bestScore = float.MinValue; // initialize bestScore foreach (Collider obj in objects) // check each nearby object { if (rayFunc(charTrans, obj, angle, distance)) // if object was hit, check its target score { currScore = calcScore(charTrans, obj); if (currScore >= bestScore) // if it's likelier to be the target, set it as the target { bestScore = currScore; ret = obj.gameObject; } } } return(ret); }
private List <IIdentifiedSpectrum> DoCalculateDuplicated(List <IIdentifiedSpectrum> preFiltered, OptimalResult optimalResult) { preFiltered.ForEach(m => m.QValue = -1); ScoreFunc.SortSpectrum(preFiltered); //Use top score spectra for Qvalue calculation var topSpectra = new List <IIdentifiedSpectrum>(preFiltered); IdentifiedSpectrumUtils.KeepTopPeptideFromSameEngineDifferentParameters(topSpectra, ScoreFunc); //计算QValue。 QValueFunc(topSpectra, ScoreFunc, FdrCalc); //将非top的肽段的QValue填充。 for (int i = 1; i < preFiltered.Count; i++) { if (preFiltered[i].QValue == -1) { preFiltered[i].QValue = preFiltered[i - 1].QValue; } } List <IIdentifiedSpectrum> result = new List <IIdentifiedSpectrum>(); optimalResult.PeptideCountFromDecoyDB = 0; optimalResult.PeptideCountFromTargetDB = 0; for (int i = preFiltered.Count - 1; i >= 0; i--) { if (preFiltered[i].QValue <= FdrValue) { result.AddRange(preFiltered.GetRange(0, i + 1)); optimalResult.Score = ScoreFunc.GetScore(preFiltered[i]); optimalResult.ExpectValue = preFiltered[i].ExpectValue; optimalResult.FalseDiscoveryRate = preFiltered[i].QValue; int decoyCount = 0; int targetCount = 0; HashSet <string> filenames = new HashSet <string>(); foreach (IIdentifiedSpectrum spectrum in result) { if (filenames.Contains(spectrum.Query.FileScan.LongFileName)) { continue; } filenames.Add(spectrum.Query.FileScan.LongFileName); if (spectrum.FromDecoy) { decoyCount++; } else { targetCount++; } } optimalResult.PeptideCountFromDecoyDB = decoyCount; optimalResult.PeptideCountFromTargetDB = targetCount; Console.WriteLine("{0} -> {1} ==> {2} / {3}", preFiltered.Count, topSpectra.Count, decoyCount, targetCount); break; } } return(result); }
public BinaryHeap(ScoreFunc scoreFunc) { m_Content = new List <GridNode>(); m_ScoreFunction = scoreFunc; }