internal static HlaSeq GetInstance(int pos, bool treatHlaAsPrefix) { SpecialFunctions.CheckCondition(pos > 0, "pos must be 1 or greater"); HlaSeq hlaSeq = new HlaSeq(); hlaSeq.Pos = pos; hlaSeq.TreatHlaAsPrefix = treatHlaAsPrefix; return(hlaSeq); }
private static void SetUpInterestingHlaPositionsForAAFeaturesTable(Dictionary <string, string> hlaNameToSequence) { int sumOfNonMaxMin = ReadSumOfNonMaxMin(); string firstSequence = SpecialFunctions.First(hlaNameToSequence.Values); InterestingToAAExact = Set <HlaSeq> .GetInstance(); InterestingToAAAsPrefix = Set <HlaSeq> .GetInstance(); InterestingHlaSeqToPropertiesExact = new Dictionary <HlaSeq, Set <string> >(); InterestingHlaSeqToPropertiesAsPrefix = new Dictionary <HlaSeq, Set <string> >(); for (int posBase0 = 0; posBase0 < firstSequence.Length; ++posBase0) { Dictionary <char, int> aaToCount = new Dictionary <char, int>(); Dictionary <string, Dictionary <bool, int> > propertyToValueToCount = new Dictionary <string, Dictionary <bool, int> >(); foreach (string sequence in hlaNameToSequence.Values) { char aa = sequence[posBase0]; aaToCount[aa] = SpecialFunctions.GetValueOrDefault(aaToCount, aa) + 1; //string aaAsString = Biology.GetInstance().OneLetterAminoAcidAbbrevTo3Letter[aa]; foreach (KeyValuePair <string, Set <char> > propertyAndAASet in VirusCount.KmerProperties.GetInstance().PropertyToAACharSet) { string property = propertyAndAASet.Key; Set <char> aaSet = propertyAndAASet.Value; bool val = aaSet.Contains(aa); Dictionary <bool, int> valueToCount = SpecialFunctions.GetValueOrDefault(propertyToValueToCount, property); valueToCount[val] = 1 + SpecialFunctions.GetValueOrDefault(valueToCount, val); } } if (SumOfNonMax(aaToCount.Values) >= sumOfNonMaxMin) { HlaSeq hlaSeqExact = HlaSeq.GetInstance(posBase0 + 1, false); InterestingToAAExact.AddNew(hlaSeqExact); HlaSeq hlaSeqAsPrefix = HlaSeq.GetInstance(posBase0 + 1, true); InterestingToAAAsPrefix.AddNew(hlaSeqAsPrefix); foreach (string property in propertyToValueToCount.Keys) { Dictionary <bool, int> valueToCount = propertyToValueToCount[property]; if (SumOfNonMax(valueToCount.Values) >= sumOfNonMaxMin) { Set <string> interestingPropertiesExact = SpecialFunctions.GetValueOrDefault(InterestingHlaSeqToPropertiesExact, hlaSeqExact); interestingPropertiesExact.AddNew(property); Set <string> interestingPropertiesAsPrefix = SpecialFunctions.GetValueOrDefault(InterestingHlaSeqToPropertiesAsPrefix, hlaSeqAsPrefix); interestingPropertiesAsPrefix.AddNew(property); } } } } }
internal static Set <string> InterestingProperties(HlaSeq featureHlaSeq) { if (featureHlaSeq.TreatHlaAsPrefix) { return(InterestingHlaSeqToPropertiesAsPrefix[featureHlaSeq]); } else { return(InterestingHlaSeqToPropertiesExact[featureHlaSeq]); } }
public override bool Equals(object obj) { HlaSeq other = obj as HlaSeq; if (other == null) { return(false); } else { return(Pos == other.Pos && TreatHlaAsPrefix == other.TreatHlaAsPrefix); } }