private void ReadPanelFile(string pathToDatabase) { using ( StreamReader reader = new StreamReader(pathToDatabase)) //new StreamReader(new EncryptedFileStream(pathToDatabase, passPhrase, FileAccess.Read))) { while (!reader.EndOfStream) { string line = reader.ReadLine(); if (line == null) { break; } line = line.Trim(); //check its not a header line or comment. if (IsItAComment(line)) { continue; } string[] data = line.Split('\t'); //check its not an empty line if (data.Length > 5) { RefPanelEntry entry = new RefPanelEntry(); entry.LoadEntry(data); AddEntryToTable(entry); } } } }
public static bool CheckForMatch(RefPanelEntry entry, VcfVariant var) { bool match = (entry.Chr == var.ReferenceName) && (entry.FwdStandFirstPositionOfMutation == var.ReferencePosition) && (entry.FwdStrandRefAllele == var.ReferenceAllele) && (entry.FwdStrandAltAllele == var.VariantAlleles[0]); return(match); }
private void AddEntryToDictionaries(RefPanelEntry data) { string exonName = data.Gene.Substring(0, 1).ToUpper() + data.Exon; string mutationName = data.Chr + "_" + data.FwdStandFirstPositionOfMutation + "_" + data.FwdStrandRefAllele + "_" + data.FwdStrandAltAllele; //add entry to ExonToPositionTable DetectableMutationList.Add(mutationName); if (!ExonToPositionTable.ContainsKey(exonName)) { HashSet <string> setOfMutations = new HashSet <string>() { mutationName }; ExonToPositionTable.Add(exonName, setOfMutations); } else { ExonToPositionTable[exonName].Add(mutationName); } //Add entry to if (exonName.Equals("K2")) { string aminoAcidChangeForTherascreen = data.Gene + "_" + data.AminoAcidPosition + data.AminoAcidAlt.ToUpper(); //Console.WriteLine($"aminoAcidChangeForTherascreen = {aminoAcidChangeForTherascreen}"); if (!AminoAcidToBaseChangeForTherascreenDictionary.ContainsKey(aminoAcidChangeForTherascreen)) { List <string> newMutationNameList = new List <string>() { mutationName }; AminoAcidToBaseChangeForTherascreenDictionary.Add(aminoAcidChangeForTherascreen, newMutationNameList); } else { AminoAcidToBaseChangeForTherascreenDictionary[aminoAcidChangeForTherascreen].Add(mutationName); } } else { string aminoAcidChangeForSanger = data.Gene.Substring(0, 1).ToUpper() + data.Exon + "_" + data.Codon; //Console.WriteLine($"aminoAcidChangeForSanger = {aminoAcidChangeForSanger}"); if (!AminoAcidToBaseChangeForSangerDictionary.ContainsKey(aminoAcidChangeForSanger)) { List <string> newMutationNameList = new List <string>() { mutationName }; AminoAcidToBaseChangeForSangerDictionary.Add(aminoAcidChangeForSanger, newMutationNameList); } else { AminoAcidToBaseChangeForSangerDictionary[aminoAcidChangeForSanger].Add(mutationName); } } }
private void AddEntryToTable(RefPanelEntry entry) { if (!TableDataByChrAndPos.ContainsKey(entry.Chr)) { TableDataByChrAndPos[entry.Chr] = new Dictionary <int, List <RefPanelEntry> >(); } if (!TableDataByChrAndPos[entry.Chr].ContainsKey(entry.FwdStandFirstPositionOfMutation)) { TableDataByChrAndPos[entry.Chr][entry.FwdStandFirstPositionOfMutation] = new List <RefPanelEntry>(); } TableDataByChrAndPos[entry.Chr][entry.FwdStandFirstPositionOfMutation].Add(entry); }
//examples of Therascreen detections: //12ASP detected //12CYS //13ASP //WT //12VAL detected //INVALID public RuleApplier(string mutationDataBase) { if (!File.Exists(mutationDataBase)) { Console.WriteLine($"{mutationDataBase} does not exist"); System.Environment.Exit(1); } using (StreamReader mutationDatabaseReader = new StreamReader(mutationDataBase)) { while (!mutationDatabaseReader.EndOfStream) { string line = mutationDatabaseReader.ReadLine(); if (line == null) { break; } line = line.Trim(); //check its not a header line or comment. if (IsItAComment(line)) { continue; } string[] data = line.Split('\t'); //check its not an empty line if (data.Length > 5) { RefPanelEntry entry = new RefPanelEntry(); entry.LoadEntry(data); AddEntryToDictionaries(entry); DetectableMutationEntries.Add(entry); } } //generate the mutation information foreach (var mutationEntry in DetectableMutationEntries) { string currentMutationSource; string currentMutationConfirmed; string mutationID = mutationEntry.Chr + "_" + mutationEntry.FwdStandFirstPositionOfMutation + "_" + mutationEntry.FwdStrandRefAllele + "_" + mutationEntry.FwdStrandAltAllele; //check the possible source if (mutationEntry.Gene.Equals("KRAS") && mutationEntry.Exon.Equals("2")) { currentMutationSource = mutationEntry.Gene.Substring(0, 1).ToUpper() + mutationEntry.Exon + "_" + mutationEntry.Codon; string theraAminoAcidChange = "KRAS_" + mutationEntry.AminoAcidPosition + mutationEntry.AminoAcidAlt.ToUpper(); if (AminoAcidToBaseChangeForTherascreenDictionary[theraAminoAcidChange].Count == 1) { currentMutationConfirmed = "confirmed"; } else if (AminoAcidToBaseChangeForTherascreenDictionary[theraAminoAcidChange].Count > 1) { currentMutationConfirmed = "plausible"; } else { Console.WriteLine($"unrecogonized: {theraAminoAcidChange}"); throw new Exception("unregonized mutation in therascreen List, must something wrong"); } } else { currentMutationSource = mutationEntry.Gene.Substring(0, 1).ToUpper() + mutationEntry.Exon + "_" + mutationEntry.Codon; if (AminoAcidToBaseChangeForSangerDictionary[currentMutationSource].Count == 1) { currentMutationConfirmed = "confirmed"; } else if (AminoAcidToBaseChangeForSangerDictionary[currentMutationSource].Count > 1) { currentMutationConfirmed = "plausible"; } else { throw new Exception("unregonized mutation in sanger List, must something wrong"); } } //if (!MutationConfirmedInformationFromAminoAcid.ContainsKey(mutationID)) MutationConfirmedInformationFromAminoAcid.Add(mutationID, new List <string>() { currentMutationSource, currentMutationConfirmed }); } } }