public static Dictionary <bool, List <KeyValuePair <double, double> > > CreateListsWithWeights(HlaResolution hlaResolution, List <Dictionary <string, string> > expandedTable, Dictionary <string, double> logViralLoadTable, Hla hla) { Dictionary <bool, List <KeyValuePair <double, double> > > patientListList = new Dictionary <bool, List <KeyValuePair <double, double> > >(); patientListList[false] = new List <KeyValuePair <double, double> >(); patientListList[true] = new List <KeyValuePair <double, double> >(); foreach (Dictionary <string, string> row in expandedTable) { bool?hasHlaOrNull = QmrAlgorithms.HasHla(hla, row, hlaResolution); if (hasHlaOrNull != null) { double weight = row.ContainsKey("weight")?double.Parse(row["weight"]):1.0; string patient = row["patient"]; if (logViralLoadTable.ContainsKey(patient)) { double logViralLoad = logViralLoadTable[patient]; KeyValuePair <double, double> weightAndLogViralLoad = new KeyValuePair <double, double>(weight, logViralLoad); patientListList[(bool)hasHlaOrNull].Add(weightAndLogViralLoad); } else { Debug.WriteLine(string.Format("Can't find patient '{0}' in viralload list", patient)); } } } return(patientListList); }
public static void BioQuickTestInternal(Quickscore <Hla, int> quickscore, string fileName, string header) { List <int> patientList = quickscore.EffectList(); List <QmrJob <Hla, int> > jobList = new List <QmrJob <Hla, int> >(); foreach (List <Dictionary <string, string> > tableByPeptide in HlaAssignmentParams.QuickScoreOptimalsGroupByPeptide(fileName, header)) { Debug.Assert(tableByPeptide.Count > 0); // real assert string peptide = tableByPeptide[0]["peptide"]; List <int> patientsWhoDoNotRespond; List <int> patientsWhoRespond; QmrAlgorithms.FindPatientsWhoRespondAndWhoDoNot(patientList, tableByPeptide, out patientsWhoRespond, out patientsWhoDoNotRespond); QmrJob <Hla, int> aQuickScoreJob = QmrJob <Hla, int> .GetInstance(peptide, patientsWhoRespond, patientsWhoDoNotRespond, quickscore); jobList.Add(aQuickScoreJob); } jobList.Sort(delegate(QmrJob <Hla, int> x, QmrJob <Hla, int> y) { return(x.PresentEffectCollection.Count.CompareTo(y.PresentEffectCollection.Count)); }); foreach (QmrJob <Hla, int> job in jobList) { Debug.WriteLine(job); } foreach (QmrJob <Hla, int> job in jobList) { //if (job.Name != "RIRTWKSLVK") //{ // continue; //} Console.WriteLine(job); //job.Quickscore.Probability("B58", job.PresentEffectCollection, job.AbsentEffectCollection); Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); Dictionary <Hla, double> posteriorOfEveryCause = job.PosteriorOfEveryCause(); stopwatch.Stop(); Console.WriteLine("{0}\t{1}\t{2}\t{3}", job.Name, job.PresentEffectCollection.Count, job.AbsentEffectCollection.Count, stopwatch.Elapsed); foreach (KeyValuePair <Hla, double> causeAndPosterior in posteriorOfEveryCause) { Debug.Assert(0 <= causeAndPosterior.Value && causeAndPosterior.Value <= 1); Console.WriteLine("{0}\t{1}\t{2}\t{3}\t{4}\t{5}", job.Name, job.PresentEffectCollection.Count, job.AbsentEffectCollection.Count, stopwatch.Elapsed , causeAndPosterior.Key, causeAndPosterior.Value); } } }