private static string LanlFileNormalizedOutput(string fileSuffix, HlaResolution hlaResolution) { SpecialFunctions.CheckCondition(fileSuffix == "Lanl"); //!!!raise error string sInputFileName = string.Format(@"lanl-{0}digit.Normalized.new.txt", hlaResolution.ShortName); //!!!const return(sInputFileName); }
static public HlaToLength GetInstanceABMixed(string hlaPattern) { HlaToLength aHlaToLength = new HlaToLength(); aHlaToLength.HlaResolution = HlaResolution.ABMixed; if (HlaResolution.TwoDigitHlaPatternIsOK(hlaPattern)) { aHlaToLength._hlaClass = hlaPattern.Substring(0, 1); aHlaToLength._hlaNumberToLength = int.Parse(hlaPattern.Substring(1)); SpecialFunctions.CheckCondition(aHlaToLength._hlaClass != "B" || aHlaToLength._hlaNumberToLength != 15); //!!!raise error SpecialFunctions.CheckCondition(aHlaToLength._hlaClass != "A" || aHlaToLength._hlaNumberToLength != 68); //!!!raise error } else { HlaToLength hlaToLengthFour = GetInstanceFour(hlaPattern); int twoDigits = hlaToLengthFour.TwoDigits(); if ((twoDigits == 15 && hlaToLengthFour.HlaClass == "B") || (twoDigits == 68 && hlaToLengthFour.HlaClass == "A")) { aHlaToLength._hlaClass = hlaToLengthFour.HlaClass; aHlaToLength._hlaNumberToLength = hlaToLengthFour._hlaNumberToLength; } else { aHlaToLength._hlaClass = hlaToLengthFour.HlaClass; aHlaToLength._hlaNumberToLength = twoDigits; } } return(aHlaToLength); }
static public HlaToLength GetInstance(string hlaPattern, HlaResolution hlaResolution) { HlaToLength aHlaToLength = hlaResolution.GetHlaLengthInstance(hlaPattern); SpecialFunctions.CheckCondition(aHlaToLength != null); return(aHlaToLength); }
static public void DumpCollection(string fileSuffix, HlaResolution hlaResolution, ArrayList lanlEpitopeCollection) { string sOutputFile = string.Format(@"LanlEpitopeCollection{0}{1}.New.txt", fileSuffix, hlaResolution.ShortName); using (StreamWriter streamwriterOutputFile = File.CreateText(sOutputFile)) { LanlEpitope.WriteHeaderLine(streamwriterOutputFile); foreach (LanlEpitope aLanlEpitope in lanlEpitopeCollection) { aLanlEpitope.WriteLine(streamwriterOutputFile); } } }
static private string LanlFile(string fileSuffix, HlaResolution hlaResolution) { SpecialFunctions.CheckCondition(fileSuffix == "ignore" || fileSuffix == "" || fileSuffix == "Old" || fileSuffix == "Lanl" || fileSuffix == "8910" || fileSuffix == "8910NoExpand" || fileSuffix == "8910SomeExpand" || fileSuffix == "8910Both"); //!!!raise error string sInputFileName; if (fileSuffix == "Old") { sInputFileName = string.Format(@"lanlOld.csv"); //!!!const } else { sInputFileName = string.Format(@"lanl-{0}digit.csv", hlaResolution.ShortName); //!!!const } return(sInputFileName); }
static internal HlaToLength GetInstanceTwo(string hlaPattern) { HlaToLength aHlaToLength = new HlaToLength(); aHlaToLength.HlaResolution = HlaResolution.Two; if (HlaResolution.TwoDigitHlaPatternIsOK(hlaPattern)) { aHlaToLength._hlaClass = hlaPattern.Substring(0, 1); aHlaToLength._hlaNumberToLength = int.Parse(hlaPattern.Substring(1)); } else { HlaToLength hlaToLengthFour = GetInstanceFour(hlaPattern); aHlaToLength._hlaClass = hlaToLengthFour.HlaClass; aHlaToLength._hlaNumberToLength = hlaToLengthFour.TwoDigits(); } return(aHlaToLength); }
static public ArrayList GetLanlCollection(string fileSuffix, HlaResolution hlaResolution) { //Load up known epitopes ArrayList lanlEpitopeCollection = new ArrayList(); if (fileSuffix == "ignore") { return(lanlEpitopeCollection); } string sInputFileName = LanlFile(fileSuffix, hlaResolution); Dictionary <string, bool> rgSeenIt = new Dictionary <string, bool>(); using (StreamReader streamreaderInputFile = Predictor.OpenResource(sInputFileName)) { string sLine = streamreaderInputFile.ReadLine(); SpecialFunctions.CheckCondition(sLine == PreferedHeader || sLine == @"Epitope,Protein,Hxb2locstart,Hxb2locend,Species,HLA" || sLine == @"Epitope,Protein,Hxb2locstart,Hxb2locend,Species,Hla,length"); //!!!raise error while ((sLine = streamreaderInputFile.ReadLine()) != null) { if (sLine == "") { continue; } string[] rgField = sLine.Split(',', '\t'); SpecialFunctions.CheckCondition(rgField.Length == 7 || rgField.Length == 6); //!!!raise error string aaSequence = rgField[0]; SpecialFunctions.CheckCondition(aaSequence.IndexOf('?') < 0); //!!!raise error if (rgField.Length == 7) { int iLength = int.Parse(rgField[6]); SpecialFunctions.CheckCondition(aaSequence.Length == iLength); //!!!raise error } string hlaCollection = rgField[5]; SpecialFunctions.CheckCondition(hlaCollection != ""); //!!!raise error string species = rgField[4]; if (species.IndexOf("human") < 0) { Debug.WriteLine("Skipping non-human epitope: " + species); continue; } foreach (HlaToLength aHlaToLength in HlaCollection(hlaCollection, hlaResolution)) { LanlEpitope aLanlEpitope = new LanlEpitope(); aLanlEpitope.Epitope = aaSequence; //!!!const string sProtein = rgField[1]; //!!!const int aa1 = int.Parse(rgField[2]); //!!!could raise error //!!!const aLanlEpitope.ProteinPositionNotCanonical = new ProteinPosition(sProtein, aa1); //!!!add an assert about the species pattern being one that we can work with aLanlEpitope.SpeciesPattern = "human"; //!!!would be good to assert that this matches pattern - no "HLA*" or " " aLanlEpitope.HlaToLength = aHlaToLength; string key = aLanlEpitope.Key(); if (!rgSeenIt.ContainsKey(key)) { rgSeenIt.Add(key, true); lanlEpitopeCollection.Add(aLanlEpitope); } } } } LanlEpitope.ReportNormalizedInputWithNoDup(lanlEpitopeCollection, fileSuffix, hlaResolution); lanlEpitopeCollection = FilterAndDuplicateAccordingToSuffix(lanlEpitopeCollection, fileSuffix); DumpCollection(fileSuffix, hlaResolution, lanlEpitopeCollection); return(lanlEpitopeCollection); }
internal static void ReportNormalizedInputWithNoDup(ArrayList lanlEpitopeCollection, string fileSuffix, HlaResolution hlaResolution) { string outputFileName = LanlFileNormalizedOutput(fileSuffix, hlaResolution); using (StreamWriter streamwriterOutputFile = File.CreateText(outputFileName)) { streamwriterOutputFile.WriteLine(PreferedHeader); foreach (LanlEpitope lanlEpitope in lanlEpitopeCollection) { string line = lanlEpitope.Key(); streamwriterOutputFile.WriteLine(line); } } }
private static System.Collections.Generic.IEnumerable <HlaToLength> HlaCollection(string hlaCollection, HlaResolution hlaResolution) { foreach (string sHlaPattern in hlaCollection.Split('/')) { HlaToLength hlaToLength = HlaToLength.GetInstanceOrNull(sHlaPattern, hlaResolution); SpecialFunctions.CheckCondition(hlaToLength != null); //!!!raise error yield return(hlaToLength); } }
static public HlaToLength GetInstanceOrNull(string hlaPattern, HlaResolution hlaResolution) { return(hlaResolution.GetHlaLengthInstance(hlaPattern)); }
public HlaGroup PossibleHlaGroup() { return(HlaResolution.PossibleHlaGroup(this)); }
public override int GetHashCode() { return(_hlaNumberToLength.GetHashCode() ^ _hlaClass.GetHashCode() ^ HlaResolution.GetHashCode()); }
public string ToStringWithoutLeading0() { return(HlaResolution.HlaToLengthStringWithLeading0(this)); }
public override string ToString() { return(HlaResolution.HlaToLengthString(this)); }
static public HlaToLength GetInstanceOrNull(HlaGroup hlaGroup, HlaResolution hlaResolution) { HlaToLength hlaToLength = HlaToLength.GetInstanceOrNull(hlaGroup.ToString(), hlaResolution); return(hlaToLength); }