internal override Dictionary <Hla, PValueDetails> CreateHlaToPValueDetails(int nullIndex, string peptide, Dictionary <string, Set <Hla> > pidToHlaSetAll, Set <Hla> setOfHlasToConsiderAdding, TextWriter writer) { Dictionary <Hla, PValueDetails> hlaToPValueDetails = new Dictionary <Hla, PValueDetails>(); if (setOfHlasToConsiderAdding.Count == 0) { return(hlaToPValueDetails); } Dictionary <string, double> pidToReactValue = ReactTableUnfiltered[peptide]; Set <Hla> knownHlaSet = KnownTable(peptide); SpecialFunctions.CheckCondition(setOfHlasToConsiderAdding.Intersection(knownHlaSet).Count == 0); Set <Hla> bestHlaSetSoFar = Set <Hla> .GetInstance(); while (setOfHlasToConsiderAdding.Count > 0) { BestSoFar <PValueDetails, Hla> bestHlaToAddSoFar = BestSoFar <PValueDetails, Hla> .GetInstance(delegate(PValueDetails pValueDetails1, PValueDetails pValueDetails2) { return(pValueDetails1.Diff.CompareTo(pValueDetails2.Diff)); }); foreach (Hla hla in setOfHlasToConsiderAdding) //!!!only look at hla's of patients with reactivity to this peptide (how effects nulls?) { PValueDetails pValueDetails = CreateAPValueDetail(nullIndex, peptide, pidToHlaSetAll, knownHlaSet, bestHlaSetSoFar, hla); bestHlaToAddSoFar.Compare(pValueDetails, hla); } //Debug.WriteLine(""); PValueDetails bestPValueDetails = bestHlaToAddSoFar.ChampsScore; //!!!weird that PValue details is the score and the object if (bestPValueDetails.PValue() > PValueCutOff) { break; } Hla hlaToAdd = bestHlaToAddSoFar.Champ; setOfHlasToConsiderAdding.Remove(hlaToAdd); bestHlaSetSoFar = bestHlaSetSoFar.Union(hlaToAdd); hlaToPValueDetails.Add(hlaToAdd, bestPValueDetails); writer.WriteLine(bestPValueDetails); //Debug.WriteLine(bestPValueDetails); writer.Flush(); } return(hlaToPValueDetails); }
private PValueDetails CreateAPValueDetail(int nullIndex, string peptide, Dictionary <string, Set <Hla> > pidToHlaSetAll, Set <Hla> knownHlaSet, Set <Hla> bestHlaSetSoFar, Hla hla) { //Dictionary<string, Dictionary<string, double>> reactTableCustom; Dictionary <string, Set <Hla> > pidToHlaSetCustom = CreatePidToHlaSetCustom(pidToHlaSetAll, bestHlaSetSoFar, hla, knownHlaSet); //out pidToHlaSetCustom, out reactTableCustom); //!!!could cache both calls to FindBestParams double scoreBase; OptimizationParameterList baseParams = FindBestParams(peptide, bestHlaSetSoFar, Set <Hla> .GetInstance(), pidToHlaSetCustom, out scoreBase); double scoreWithOneMore; OptimizationParameterList withMoreMoreParams = FindBestParams(peptide, bestHlaSetSoFar.Union(hla), Set <Hla> .GetInstance(), pidToHlaSetCustom, out scoreWithOneMore); PValueDetails pValueDetails = PValueDetails.GetInstance(SelectionName, nullIndex, peptide, hla, scoreWithOneMore, scoreBase, knownHlaSet, bestHlaSetSoFar, withMoreMoreParams["leakProbability"].Value, withMoreMoreParams["link" + hla].Value, withMoreMoreParams); //Debug.Write(String.Format("{0}/{1}\t", hla, scoreWithOneMore)); return(pValueDetails); }
internal static PValueDetails GetInstance( string selectionName, int nullIndex, string peptide, Hla hla, double score1, double score2, Set <Hla> knownHlas, Set <Hla> bestHlaSetSoFar, double leakProbability, double linkProbability, OptimizationParameterList previousParams) { PValueDetails pValueDetails = new PValueDetails(); pValueDetails.SelectionName = selectionName; pValueDetails.NullIndex = nullIndex; pValueDetails.Peptide = peptide; pValueDetails.Hla = hla; pValueDetails.Score1 = score1; pValueDetails.Score2 = score2; pValueDetails.Diff = score1 - score2; pValueDetails.KnownHlas = knownHlas; pValueDetails.BestHlaSetSoFar = bestHlaSetSoFar; pValueDetails.LeakProbability = leakProbability; pValueDetails.LinkProbability = linkProbability; pValueDetails.PreviousParams = previousParams; return(pValueDetails); }
internal override Dictionary <Hla, PValueDetails> CreateHlaToPValueDetails(int nullIndex, string peptide, Dictionary <string, Set <Hla> > pidToHlaSet, Set <Hla> candidateHlaSet, TextWriter writer) { Dictionary <string, double> pidToReactValue = ReactTableUnfiltered[peptide]; Set <Hla> knownHlaSet = KnownTable(peptide); double scoreKnown; OptimizationParameterList knownParams = FindBestParams(peptide, Set <Hla> .GetInstance(), Set <Hla> .GetInstance(), pidToHlaSet, out scoreKnown); Dictionary <Hla, PValueDetails> hlaToPValueDetails = new Dictionary <Hla, PValueDetails>(); foreach (Hla hla in candidateHlaSet.Subtract(knownHlaSet)) //!!!only look at hla's of patients with reactivity to this peptide (how effects nulls?) { double scoreWithOne; OptimizationParameterList withHlaParams = FindBestParams(peptide, Set <Hla> .GetInstance(hla), Set <Hla> .GetInstance(), pidToHlaSet, out scoreWithOne); PValueDetails pValueDetails = PValueDetails.GetInstance(SelectionName, nullIndex, peptide, hla, scoreWithOne, scoreKnown, knownHlaSet, null, withHlaParams["leakProbability"].Value, withHlaParams["link" + hla].Value, withHlaParams); hlaToPValueDetails.Add(hla, pValueDetails); writer.WriteLine(pValueDetails); Debug.WriteLine(pValueDetails); writer.Flush(); } return(hlaToPValueDetails); }