//!!!Yikes tons of repeated code and stuff re-run internal static HlaAssignmentWithResponses CreateHlaAssignment(Quickscore <Hla, int> quickscore, string hlaListAsString, ICollection <int> patientsWhoRespond) { Qmrr.HlaFactory hlaFactory = Qmrr.HlaFactory.GetFactory("noConstraint"); //!!!this code is repeated elsewhere Dictionary <Hla, List <int> > hlaToRespondingPatientsUnfiltered = quickscore.CreateCauseToSubsetOfEffects(patientsWhoRespond); Dictionary <Hla, List <int> > hlaToRespondingPatients = Filter9xs(hlaToRespondingPatientsUnfiltered); List <Hla> hlaListFromRepondingPatients = new List <Hla>(hlaToRespondingPatients.Keys); Dictionary <Hla, bool> hlaAssignmentDicationary = new Dictionary <Hla, bool>(); foreach (string hlaName in hlaListAsString.Split(';')) { Hla hla = hlaFactory.GetGroundInstance(hlaName); hlaAssignmentDicationary[hla] = true; } List <int> indexCollection = new List <int>(); for (int hlaIndex = 0; hlaIndex < hlaListFromRepondingPatients.Count; ++hlaIndex) { Hla hla = hlaListFromRepondingPatients[hlaIndex]; if (hlaAssignmentDicationary.ContainsKey(hla)) { indexCollection.Add(hlaIndex); } } HlaAssignmentWithResponses hlaAssignment = HlaAssignmentWithResponses.GetInstance(quickscore, hlaListFromRepondingPatients, indexCollection, hlaToRespondingPatients); return(hlaAssignment); }
//private Dictionary<string, bool> GetAList(Dictionary<string, string> row) //{ // Dictionary<string, bool> alist = new Dictionary<string, bool>(); // string alistValue = row["HLA In Fixed List"]; // foreach (string hla in alistValue.Split(' ')) // { // Debug.Assert((hla.Length == 3 && !hla.StartsWith("B15")) || (hla.Length == 5 && hla.StartsWith("B15"))); // alist.Add(hla, true); // } // return alist; //} public static HlaAssignmentWithResponses CreateHlaAssignment(List <Dictionary <string, string> > rowsOfThisPeptide, IEnumerable <Hla> hlaList, HlaResolution hlaResolution, Quickscore <Hla, int> quickscore, List <int> patientsWhoRespond) { //!!!this code is repeated elsewhere Dictionary <Hla, List <int> > hlaToRespondingPatientsUnfiltered = quickscore.CreateCauseToSubsetOfEffects(patientsWhoRespond); Dictionary <Hla, List <int> > hlaToRespondingPatients = Filter9xs(hlaToRespondingPatientsUnfiltered); List <Hla> hlaListFromRepondingPatients = new List <Hla>(hlaToRespondingPatients.Keys); Dictionary <Hla, bool> hlaAssignmentDicationary = new Dictionary <Hla, bool>(); foreach (Dictionary <string, string> causeAssignmentRow in rowsOfThisPeptide) { Hla hla = GetHlaFromRow(causeAssignmentRow, hlaResolution); hlaAssignmentDicationary[hla] = true; } HlaAssignmentWithResponses hlaAssignment = HlaAssignmentWithResponses.GetInstance(hlaAssignmentDicationary.Keys, quickscore, hlaListFromRepondingPatients, hlaToRespondingPatients); return(hlaAssignment); }
//!!!Yikes tons of repeated code and stuff re-run public static HlaAssignmentWithResponses CreateHlaAssignment(List <Dictionary <string, string> > rowsOfThisPeptide, IEnumerable <Hla> hlaList, HlaResolution hlaResolution, Quickscore <Hla, int> quickscore, List <int> patientsWhoRespond, Hla hlaToReplace, Hla hlaWithWhichToReplaceItOrNull) { //!!!this code is repeated elsewhere Dictionary <Hla, List <int> > hlaToRespondingPatientsUnfiltered = quickscore.CreateCauseToSubsetOfEffects(patientsWhoRespond); Dictionary <Hla, List <int> > hlaToRespondingPatients = Filter9xs(hlaToRespondingPatientsUnfiltered); List <Hla> hlaListFromRepondingPatients = new List <Hla>(hlaToRespondingPatients.Keys); Dictionary <Hla, bool> hlaAssignmentDicationary = new Dictionary <Hla, bool>(); foreach (Dictionary <string, string> causeAssignmentRow in rowsOfThisPeptide) { Hla hla = GetHlaFromRow(causeAssignmentRow, hlaResolution); hlaAssignmentDicationary[hla] = true; } hlaAssignmentDicationary.Remove(hlaToReplace); if (hlaWithWhichToReplaceItOrNull != null) { hlaAssignmentDicationary.Add(hlaWithWhichToReplaceItOrNull, true); } List <int> indexCollection = new List <int>(); for (int hlaIndex = 0; hlaIndex < hlaListFromRepondingPatients.Count; ++hlaIndex) { Hla hla = hlaListFromRepondingPatients[hlaIndex]; if (hlaAssignmentDicationary.ContainsKey(hla)) { indexCollection.Add(hlaIndex); } } HlaAssignmentWithResponses hlaAssignment = HlaAssignmentWithResponses.GetInstance(quickscore, hlaListFromRepondingPatients, indexCollection, hlaToRespondingPatients); return(hlaAssignment); }