private void InitiateSampleTruth(SampleTruth sampleTruthInfor) { foreach (string mutation in DetectableMutationList) { MutationTruth mutationInfor = new MutationTruth(mutation, false, "FAIL", MutationConfirmedInformationFromAminoAcid[mutation]); sampleTruthInfor.Variants.Add(mutationInfor); } }
private void setSangerResultIgnored(SampleTruth sampleTruthInfor) { setPartMutationStatus(sampleTruthInfor, "K3", "IGNORE"); setPartMutationStatus(sampleTruthInfor, "K4", "IGNORE"); setPartMutationStatus(sampleTruthInfor, "N2", "IGNORE"); setPartMutationStatus(sampleTruthInfor, "N3", "IGNORE"); setPartMutationStatus(sampleTruthInfor, "N4", "IGNORE"); }
private void setSangerResultWT(SampleTruth sampleTruthInfor) { setPartMutationStatus(sampleTruthInfor, "K3", "PASS"); setPartMutationStatus(sampleTruthInfor, "K4", "PASS"); setPartMutationStatus(sampleTruthInfor, "N2", "PASS"); setPartMutationStatus(sampleTruthInfor, "N3", "PASS"); setPartMutationStatus(sampleTruthInfor, "N4", "PASS"); }
public List <SampleTruth> ApplyRule(List <SampleRecord> sampleTruthRecords) { List <SampleTruth> SampleTruthItems = new List <SampleTruth>(); foreach (var sampleTruthRecord in sampleTruthRecords) { SampleTruth truthItem = ApplyRule(sampleTruthRecord); SampleTruthItems.Add(truthItem); } return(SampleTruthItems); }
private static void SetValueForDetectedTruthMutation(SampleTruth sampleTruthInfor, string mutationName, string mutationDetectedName) { bool foundMutationInPanel = false; foreach (var mutation in sampleTruthInfor.Variants) { if (mutation.MutationName.Equals(mutationName)) { foundMutationInPanel = true; mutation.MutationStatus = "PASS"; mutation.MutationExist = true; break; } } if (!foundMutationInPanel) { throw new Exception( $"{mutationDetectedName} exist in panel table but {mutationName} is not found\n"); } }
private void setPartMutationStatus(SampleTruth sampleTruthInfor, string failPart, string status) { if (ExonToPositionTable.ContainsKey(failPart)) { foreach (string mutationName in ExonToPositionTable[failPart]) { foreach (var variant in sampleTruthInfor.Variants) { if (variant.MutationName.Equals(mutationName)) { variant.MutationExist = false; variant.MutationStatus = status; } } } } else { throw new Exception($"unregoniced exon name {failPart}"); } }
private void setTherascreenResultWT(SampleTruth sampleTruthInfor) { setPartMutationStatus(sampleTruthInfor, "K2", "PASS"); }
public SampleTruth ApplyRule(SampleRecord sampleTruthRecord) { SampleTruth sampleTruthInfor = new SampleTruth(sampleTruthRecord.SubjectId); InitiateSampleTruth(sampleTruthInfor); //check the therascreen result //if (sampleTruthRecord.TherascreenResult.ToUpper().Equals("INVALID")) // Console.WriteLine($"sample thereascreen result is {sampleTruthRecord.TherascreenResult}\t in {sampleTruthRecord.SubjectId}"); if (sampleTruthRecord.TherascreenResult.ToUpper().Equals("WT")) { setTherascreenResultWT(sampleTruthInfor); } else { //since therascreen contain name like 12ASP and 12ASP dectected string[] theraNameItems = sampleTruthRecord.TherascreenResult.Split(); string mutationTheraName = "KRAS_" + theraNameItems[0]; if (AminoAcidToBaseChangeForTherascreenDictionary.ContainsKey(mutationTheraName)) { setSangerResultIgnored(sampleTruthInfor); setPartMutationStatus(sampleTruthInfor, "K2", "PASS"); List <string> mutationNames = AminoAcidToBaseChangeForTherascreenDictionary[mutationTheraName]; foreach (var mutationName in mutationNames) { SetValueForDetectedTruthMutation(sampleTruthInfor, mutationName, mutationTheraName); } } else if (!sampleTruthRecord.TherascreenResult.ToUpper().Equals("INVALID")) { throw new Exception("unrecogonized therascreen result: {sampleTruthRecord.TherascreenResult}"); } } //check the sanger result // Console.WriteLine($"sample sanger result is {sampleTruthRecord.SangerResult}\t in {sampleTruthRecord.SubjectId}"); string[] sangerResultItems = sampleTruthRecord.SangerResult.Split(','); if (sangerResultItems.Length == 2) { if (sangerResultItems[0].Trim().StartsWith("WT") && sangerResultItems[1].Trim().StartsWith("FAIL")) { setSangerResultWT(sampleTruthInfor); string failParts = sangerResultItems[1].Trim().Substring(4); if (failParts.Length < 2) { throw new Exception($"unrecogonized therascreen result: {sampleTruthRecord.SangerResult}"); } char GeneParts = failParts[0]; failParts = failParts.Remove(0, 1); while (failParts.Length > 0) { char currentChar = failParts[0]; if (currentChar >= '0' && currentChar <= '9') { char[] failChars = new char[2]; failChars[0] = GeneParts; failChars[1] = currentChar; string failPart = new string(failChars); setPartMutationStatus(sampleTruthInfor, failPart.ToUpper(), "FAIL"); } else if ((currentChar >= 'A' && currentChar <= 'Z') || (currentChar >= 'a' && currentChar <= 'z')) { GeneParts = currentChar; } failParts = failParts.Remove(0, 1); } } else { throw new Exception($"unrecogonized therascreen result: {sampleTruthRecord.SangerResult}"); } } else if (sangerResultItems.Length == 1) { //ignore NA case, since already processed when dealing with therascreen result if (sampleTruthRecord.SangerResult.ToUpper().Equals("NA")) { //continue } else if (sampleTruthRecord.SangerResult.ToUpper().Equals("WT")) { setSangerResultWT(sampleTruthInfor); } else if (sampleTruthRecord.SangerResult.ToUpper().Equals("FAIL")) { //need this case, in case of therascreen detected mutation but Sanger was performed and failed (unlikely) setSangerResultFail(sampleTruthInfor); } else { //detected a mutation or other unrecognized result if (AminoAcidToBaseChangeForSangerDictionary.ContainsKey(sampleTruthRecord.SangerResult)) { setSangerResultWT(sampleTruthInfor); List <string> mutationNames = AminoAcidToBaseChangeForSangerDictionary[sampleTruthRecord.SangerResult]; foreach (var mutationName in mutationNames) { SetValueForDetectedTruthMutation(sampleTruthInfor, mutationName, sampleTruthRecord.SangerResult); } } else { throw new Exception($"unrecogonized sanger result: {sampleTruthRecord.SangerResult}"); } } } else { throw new Exception($"unrecogonized sanger result: {sampleTruthRecord.SangerResult}"); } return(sampleTruthInfor); }