public void WritePosition(IEnumerable <SupplementaryDataItem> saItems) { if (saItems == null) { return; } var gnomadItems = new List <GnomadItem>(); foreach (var item in saItems) { if (!(item is GnomadItem gnomadItem)) { throw new InvalidDataException("Expected GnomadItems list!!"); } gnomadItems.Add(gnomadItem); } SupplementaryDataItem.RemoveConflictingAlleles(gnomadItems); foreach (var gnomadItem in gnomadItems) { _writer.AddEntry(gnomadItem.Chromosome.EnsemblName, gnomadItem.Start, gnomadItem.ReferenceAllele, gnomadItem.AlternateAllele, null, new List <string> { gnomadItem.GetJsonString() }); } }
public void WritePosition(IEnumerable <SupplementaryDataItem> saItems) { if (saItems == null) { return; } var customItems = new List <CustomItem>(); foreach (var item in saItems) { if (!(item is CustomItem customItem)) { throw new InvalidDataException("Expected customItem list!!"); } customItems.Add(customItem); } if (customItems.Count == 0) { return; } var alleleGroupedItems = customItems.GroupBy(x => x.AlternateAllele); foreach (var groupedItem in alleleGroupedItems) { var jsonStrings = groupedItem.Select(x => x.GetJsonString()).ToList(); // since the reference allele for different items in the group may be different, we only use the first base as it is supposed to be the common padding base. _writer.AddEntry(groupedItem.First().Chromosome.EnsemblName, groupedItem.First().Start, groupedItem.First().ReferenceAllele, groupedItem.Key, null, jsonStrings); } }
public void WritePosition(IEnumerable <SupplementaryDataItem> saItems) { if (saItems == null) { return; } var clinvarItems = new List <ClinVarItem>(); foreach (var item in saItems) { if (!(item is ClinVarItem clinvarItem)) { throw new InvalidDataException("Expected ClinvarItems list!!"); } clinvarItems.Add(clinvarItem); } if (clinvarItems.Count == 0) { return; } var alleleGroupDict = GroupByAltAllele(clinvarItems); foreach (var kvp in alleleGroupDict) { var refAllele = kvp.Key.ReferenceAllele; var altAllele = kvp.Key.AlternateAllele; var groupedItems = kvp.Value; var vcfString = string.Join(",", groupedItems.OrderBy(x => x.Id).Select(x => SupplementaryAnnotationUtilities.ConvertToVcfInfoString(x.Significance))); var jsonStrings = groupedItems.OrderBy(x => x.Id).Select(x => x.GetJsonString()).ToList(); var firstItem = groupedItems[0]; _writer.AddEntry(firstItem.Chromosome.EnsemblName, firstItem.Start, refAllele, altAllele, vcfString, jsonStrings); } // var alleleGroupedItems = clinvarItems.GroupBy(x => x.AlternateAllele); //foreach (var groupedItem in alleleGroupedItems) //{ // var uniqueItems = groupedItem.GroupBy(p => p.ID).Select(x => x.First()).ToList(); // var vcfString = string.Join(",", uniqueItems.Select(x => SupplementaryAnnotationUtilities.ConvertToVcfInfoString(x.Significance))); // var jsonStrings = uniqueItems.Select(x => x.GetVariantJsonString()).ToList(); // // since the reference allele for different items in the group may be different, we only use the first base as it is supposed to be the common padding base. // _writer.AddEntry(groupedItem.First().Chromosome, // groupedItem.First().Start, // groupedItem.First().ReferenceAllele, // groupedItem.Key, vcfString, jsonStrings); //} }
public void WritePosition(IEnumerable <SupplementaryDataItem> saItems) { if (saItems == null) { return; } var onekGenItems = new List <OneKGenItem>(); foreach (var item in saItems) { if (!(item is OneKGenItem onekGenItem)) { throw new InvalidDataException("Expected OnekGenItems list!!"); } onekGenItems.Add(onekGenItem); } SupplementaryDataItem.RemoveConflictingAlleles(onekGenItems); var totalAltAlleleFreq = 0.0; var alleleFrequencies = new Dictionary <string, double>(); foreach (var onekGenItem in onekGenItems) { _onekgWriter.AddEntry(onekGenItem.Chromosome.EnsemblName, onekGenItem.Start, onekGenItem.ReferenceAllele, onekGenItem.AlternateAllele, onekGenItem.GetVcfString(), new List <string> { onekGenItem.GetJsonString() }); if (!IsSnv(onekGenItem.ReferenceAllele) || !IsSnv(onekGenItem.AlternateAllele)) { continue; } if (onekGenItem.AllAlleleNumber != null && onekGenItem.AllAlleleCount != null) { var freq = 1.0 * onekGenItem.AllAlleleCount.Value / onekGenItem.AllAlleleNumber.Value; totalAltAlleleFreq += freq; alleleFrequencies[onekGenItem.AlternateAllele] = freq; } } var isRefMinor = totalAltAlleleFreq >= SaDataBaseCommon.RefMinorThreshold; if (isRefMinor) { _refMinorWriter.AddEntry(onekGenItems[0].Chromosome.EnsemblName, onekGenItems[0].Start, GetMajorAllele(alleleFrequencies), onekGenItems[0].ReferenceAllele); } }
public void WritePosition(IEnumerable <SupplementaryDataItem> saItems) { if (saItems == null) { return; } var cosmicItems = new List <CosmicItem>(); foreach (var item in saItems) { if (!(item is CosmicItem cosmicItem)) { throw new InvalidDataException("Expected CosmicItem list!!"); } cosmicItems.Add(cosmicItem); } if (cosmicItems.Count == 0) { return; } var combineStudies = CombineStudies(cosmicItems); var alleleGroupDict = GroupByAltAllele(combineStudies); foreach (var kvp in alleleGroupDict) { var refAllele = kvp.Key.Item1; var altAllele = kvp.Key.Item2; var groupedItems = kvp.Value; var vcfString = string.Join(",", groupedItems.OrderBy(x => x.Id).Select(x => x.Id)); var jsonStrings = groupedItems.OrderBy(x => x.Id).Select(x => x.GetJsonString()).ToList(); var firstItem = groupedItems[0]; _writer.AddEntry(firstItem.Chromosome.EnsemblName, firstItem.Start, refAllele, altAllele, vcfString, jsonStrings); } }
public void WritePosition(IEnumerable <SupplementaryDataItem> saItems) { if (saItems == null) { return; } var mitoMapMutItems = saItems.Select(x => x as MitoMapItem).ToList(); var uniqueMutations = MitoMapItem.AggregatedMutationsSomePosition(mitoMapMutItems); foreach (var mutation in uniqueMutations) { _mitoMapVarWriter.AddEntry( mutation.Value.Chromosome.EnsemblName, mutation.Value.Start, mutation.Key.Item1, mutation.Key.Item2, null, new List <string> { mutation.Value.GetVariantJsonString() }); } }