示例#1
0
        public static UgaGene Merge(UgaGene gene37, UgaGene gene38)
        {
            string ensemblId    = CombineField(gene37.EnsemblId, gene38.EnsemblId);
            string entrezGeneId = CombineField(gene37.EntrezGeneId, gene38.EntrezGeneId);
            int    hgncId       = CombineField(gene37.HgncId, gene38.HgncId);

            return(new UgaGene(gene37.Chromosome, gene37.GRCh37, gene38.GRCh38, gene37.OnReverseStrand, entrezGeneId,
                               ensemblId, gene37.Symbol, hgncId));
        }
示例#2
0
        public void Merge_DifferentCombinations()
        {
            var interval = new Interval(17369, 17436);
            var uga37    = new UgaGene(ChromosomeUtilities.Chr1, interval, null, true, "102466751", null, "MIR6859-1", 50039);
            var uga38    = new UgaGene(ChromosomeUtilities.Chr1, null, interval, true, null, "ENSG00000278267", "MIR6859-1", 50039);

            var observedResult = CombinerUtils.Merge(uga37, uga38);

            Assert.Equal("102466751", observedResult.EntrezGeneId);
            Assert.Equal("ENSG00000278267", observedResult.EnsemblId);
        }
示例#3
0
        public void Merge_ThrowException_IfValuesDifferent()
        {
            var interval = new Interval(17369, 17436);
            var uga37    = new UgaGene(ChromosomeUtilities.Chr1, interval, null, true, "102466751", "ENSG00000278267", "MIR6859-1", 50039);
            var uga38    = new UgaGene(ChromosomeUtilities.Chr1, null, interval, true, "000000000", "ENSG00000278267", "MIR6859-1", 50039);

            Assert.Throws <InvalidDataException>(delegate
            {
                // ReSharper disable once UnusedVariable
                var observedResult = CombinerUtils.Merge(uga37, uga38);
            });
        }
示例#4
0
        public void GetSingleValueDict_ThrowException_IfMultipleValuesShareKey()
        {
            var uga1  = new UgaGene(null, null, null, true, null, "ENSG00000278267", "MIR6859-1", 50039);
            var uga2  = new UgaGene(null, null, null, true, null, "ENSG00000278267", "MIR6859-1", 50039);
            var genes = new List <UgaGene> {
                uga1, uga2
            };

            Assert.Throws <InvalidDataException>(delegate
            {
                // ReSharper disable once UnusedVariable
                var observedResult = genes.GetSingleValueDict(x => x.EnsemblId);
            });
        }
示例#5
0
        public void GetSingleValueDict_OneKey_OneValue()
        {
            var uga1  = new UgaGene(null, null, null, true, "102466751", null, "MIR6859-1", 50039);
            var uga2  = new UgaGene(null, null, null, true, null, "ENSG00000278267", "MIR6859-1", 50039);
            var genes = new List <UgaGene> {
                uga1, uga2
            };

            var observedResult = genes.GetSingleValueDict(x => x.EnsemblId);

            Assert.NotNull(observedResult);
            Assert.Single(observedResult);
            Assert.True(observedResult.ContainsKey("ENSG00000278267"));
        }
示例#6
0
        private static bool UpdateBySymbolDict <T>(UgaGene gene, Func <UgaGene, T> idFunc, Func <T, bool> isEmpty, IReadOnlyDictionary <T, string> idToSymbol)
        {
            var key = idFunc(gene);

            if (isEmpty(key))
            {
                return(false);
            }

            if (!idToSymbol.TryGetValue(idFunc(gene), out string symbol))
            {
                return(false);
            }
            gene.Symbol = symbol;
            return(true);
        }
示例#7
0
        public void GetKeyValueDict_OneKey_OneValue()
        {
            var uga1  = new UgaGene(null, null, null, true, "102466751", null, "MIR6859-1", 50039);
            var uga2  = new UgaGene(null, null, null, true, null, "ENSG00000278267", "MIR6859-1", 50039);
            var uga3  = new UgaGene(null, null, null, true, null, "ENSG00000278267", "MIR6859-1", 50039);
            var genes = new List <UgaGene> {
                uga1, uga2, uga3
            };

            var observedResult = genes.GetKeyValueDict(x => x.EnsemblId, x => x.HgncId);

            Assert.NotNull(observedResult);
            Assert.Single(observedResult);

            var hgncId = observedResult["ENSG00000278267"];

            Assert.Equal(50039, hgncId);
        }
示例#8
0
        private void UpdateGeneSymbol(UgaGene gene)
        {
            string originalSymbol = gene.Symbol;
            bool   isUpdated      = UpdateBySymbolDict(gene, x => x.HgncId, x => x == -1, _hgncIdToSymbol);

            if (isUpdated)
            {
                if (gene.Symbol != originalSymbol)
                {
                    _numUpdatedByHgncId++;
                }
                return;
            }

            isUpdated = UpdateBySymbolDict(gene, x => x.EntrezGeneId, string.IsNullOrEmpty, _entrezGeneIdToSymbol);

            if (isUpdated)
            {
                if (gene.Symbol != originalSymbol)
                {
                    _numUpdatedByEntrezGeneId++;
                }
                return;
            }

            isUpdated = UpdateBySymbolDict(gene, x => x.EnsemblId, string.IsNullOrEmpty, _ensemblIdToSymbol);

            if (isUpdated)
            {
                if (gene.Symbol != originalSymbol)
                {
                    _numUpdatedByEnsemblId++;
                }
                return;
            }

            isUpdated = UpdateBySymbolDict(gene, x => x.EntrezGeneId, string.IsNullOrEmpty, _refseqGeneIdToSymbol);

            // ReSharper disable once InvertIf
            if (isUpdated && gene.Symbol != originalSymbol)
            {
                _numUpdatedByRefSeqGff++;
            }
        }
示例#9
0
        public void GetMultiValueDict_OneKey_WithTwoValues()
        {
            var uga1  = new UgaGene(null, null, null, true, "102466751", null, "MIR6859-1", 50039);
            var uga2  = new UgaGene(null, null, null, true, null, "ENSG00000278267", "MIR6859-1", 50039);
            var uga3  = new UgaGene(null, null, null, true, null, "ENSG00000278267", "MIR6859-1", 50039);
            var genes = new List <UgaGene> {
                uga1, uga2, uga3
            };

            var observedResult = genes.GetMultiValueDict(x => x.EnsemblId);

            Assert.NotNull(observedResult);
            Assert.Single(observedResult);

            var firstEntry = observedResult["ENSG00000278267"];

            Assert.NotNull(firstEntry);
            Assert.Equal(2, firstEntry.Count);
        }
示例#10
0
 private static string GetKey(UgaGene gene) =>
 gene.EnsemblId + '|' + gene.EntrezGeneId + '|' + (gene.OnReverseStrand ? "R" : "F");
示例#11
0
 private static int MinCoordinate(UgaGene gene, Func <IInterval, int> coordFunc) => coordFunc(gene.GRCh37 ?? gene.GRCh38);