Beispiel #1
0
        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()
                });
            }
        }
Beispiel #2
0
        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);
            }
        }