Ejemplo n.º 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()
                });
            }
        }
Ejemplo n.º 2
0
        private void AddAdditionalItems(SupplementaryDataItem minSupplementaryDataItem, SupplementaryPositionCreator sa)
        {
            if (_additionalItemsList.Count <= 0)
            {
                return;
            }

            if (_additionalItemsList.Count > 1)
            {
                _additionalItemsList.Sort();
            }
            while (_additionalItemsList.Count > 0)
            {
                var firstItem = _additionalItemsList[0];
                if (firstItem.Equals(minSupplementaryDataItem))
                {
                    firstItem.SetSupplementaryAnnotations(sa);
                    _additionalItemsList.RemoveAt(0);
                }
                else
                {
                    break;
                }
            }
        }
Ejemplo n.º 3
0
        private SupplementaryDataItem CurrentMinSupplementaryDataItem()
        {
            SupplementaryDataItem minSupplementaryDataItem = null;

            foreach (var iDataEnumerator in _iSupplementaryDataItemList)
            {
                if (minSupplementaryDataItem == null)
                {
                    minSupplementaryDataItem = iDataEnumerator.Current;
                }
                else
                if (minSupplementaryDataItem.CompareTo(iDataEnumerator.Current) > 0)
                {
                    minSupplementaryDataItem = iDataEnumerator.Current;
                }
            }

            // checking if one of the additional items is the min.
            if (_additionalItemsList.Count <= 0)
            {
                return(minSupplementaryDataItem);
            }

            if (minSupplementaryDataItem == null)
            {
                return(_additionalItemsList[0]);
            }

            if (minSupplementaryDataItem.CompareTo(_additionalItemsList[0]) > 0)
            {
                minSupplementaryDataItem = _additionalItemsList[0];
            }
            return(minSupplementaryDataItem);
        }
Ejemplo n.º 4
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);
            }
        }