Exemple #1
0
        public string GetJsonString()
        {
            var sb         = StringBuilderCache.Acquire();
            var jsonObject = new JsonObject(sb);

            //converting empty alleles to '-'
            var refAllele = string.IsNullOrEmpty(ReferenceAllele) ? "-" : ReferenceAllele;
            var altAllele = string.IsNullOrEmpty(AlternateAllele) ? "-" : AlternateAllele;

            //the reduced alt allele should never be output
            altAllele = SupplementaryAnnotationUtilities.ReverseSaReducedAllele(altAllele);

            jsonObject.AddStringValue("id", Id);
            jsonObject.AddStringValue("reviewStatus", ReviewStatusStrings[ReviewStatus]);
            jsonObject.AddStringValue("isAlleleSpecific", IsAlleleSpecific, false);
            jsonObject.AddStringValues("alleleOrigins", AlleleOrigins);
            jsonObject.AddStringValue("refAllele", "N" == refAllele ? null : refAllele);
            jsonObject.AddStringValue("altAllele", "N" == altAllele ? null : altAllele);
            jsonObject.AddStringValues("phenotypes", Phenotypes);
            jsonObject.AddStringValues("medGenIds", MedGenIDs);
            jsonObject.AddStringValues("omimIds", OmimIDs);
            jsonObject.AddStringValues("orphanetIds", OrphanetIDs);
            jsonObject.AddStringValue("significance", Significance);

            if (LastUpdatedDate != long.MinValue)
            {
                jsonObject.AddStringValue("lastUpdatedDate", new DateTime(LastUpdatedDate).ToString("yyyy-MM-dd"));
            }

            jsonObject.AddStringValues("pubMedIds", PubmedIds?.Select(id => id.ToString()));

            return(StringBuilderCache.GetStringAndRelease(sb));
        }
        private InterimSaItem ExtractItem(string line)
        {
            var columns = line.Split('\t');

            if (columns.Length < MinNoOfColumns)
            {
                throw new InvalidDataException("Line contains too few columns:\n" + line);
            }

            var chromosome = columns[ChrIndex];
            // position, ref and alt are in VCF style. We need to reduce them to our internal representation.
            var newAlleles = SupplementaryAnnotationUtilities.GetReducedAlleles(int.Parse(columns[PositionIndex]), columns[RefAlleleIndex], columns[AltAlleleIndex]);

            var position  = newAlleles.Item1;
            var refAllele = newAlleles.Item2;
            var altAllele = newAlleles.Item3;

            var vcfString = columns[VcfStringIndex];

            var jsonStrings = new List <string>();

            for (int i = JsonStringIndex; i < columns.Length; i++)
            {
                jsonStrings.Add(columns[i]);
            }

            return(new InterimSaItem(_jsonKey, _vcfKey, chromosome, position, refAllele, altAllele, _matchByAllele, _isArray,
                                     vcfString, jsonStrings.ToArray()));
        }
        public void ReverseReducedLongDelIns()
        {
            const string originalAlt = "47ATCGGGGGAAAAAATTTTTCGCGCGTATATGAGACATTAAA";

            var altAllele = SupplementaryAnnotationUtilities.ReverseSaReducedAllele(originalAlt);

            Assert.Equal("ATCGGGGGAAAAAATTTTTCGCGCGTATATGAGACATTAAA", altAllele);
        }
        public void ReverseReducedAlleleDelIns()
        {
            const string reducedAllele = "15ATC";

            var altAllele = SupplementaryAnnotationUtilities.ReverseSaReducedAllele(reducedAllele);

            Assert.Equal("ATC", altAllele);
        }
        public void ReverseReducedAlleleMnv()
        {
            const string reducedAllele = "TCGG";

            var altAllele = SupplementaryAnnotationUtilities.ReverseSaReducedAllele(reducedAllele);

            Assert.Equal(reducedAllele, altAllele);
        }
        public void ReverseReducedAlleleInsertion()
        {
            const string reducedAllele = "iACT";

            var altAllele = SupplementaryAnnotationUtilities.ReverseSaReducedAllele(reducedAllele);

            Assert.Equal("ACT", altAllele);
        }
Exemple #7
0
        private string GetAlleleId(string chromosome, int vcfPosition, string refAllele, string altAllele)
        {
            var newAlleles = SupplementaryAnnotationUtilities.GetReducedAlleles(vcfPosition, refAllele, altAllele);
            var newStart   = newAlleles.Item1;

            if (newStart > _maxVidPosition)
            {
                _maxVidPosition = newStart;
            }

            var newAltAllele = newAlleles.Item3;

            return(chromosome + ':' + newStart + ':' + newAltAllele);
        }
Exemple #8
0
        // constructor
        public VariantAlternateAllele(int begin, int end, string refAllele, string altAllele, int genotypeIndex = 1)
        {
            Start           = begin;
            End             = end;
            AlternateAllele = altAllele.ToUpperInvariant();
            ReferenceAllele = refAllele.ToUpperInvariant();
            GenotypeIndex   = genotypeIndex;

            int dummyInt = Start;

            SuppAltAllele = SupplementaryAnnotationUtilities.GetReducedAlleles(dummyInt, ReferenceAllele, AlternateAllele).Item3;

            IsSymbolicAllele = StructuralVariant.IsSymbolicAllele(altAllele);
            CustomIntervals  = new List <ICustomInterval>();
        }
        public void LongDelInsTest1()
        {
            const int    start           = 1000; // represents the start position of the variant.
            const string referenceAllele = "AATGTGAAAAATATATTTTATATAATTTCAATATTTTTAACA";
            const string altAllele       = "ATTGAAAAATATATTTTATATAATTTCAATATTTTTAACAT";

            var newAlleles = SupplementaryAnnotationUtilities.GetReducedAlleles(start, referenceAllele, altAllele);

            var newAltAllele = newAlleles.Item3;
            // in this case the alt allele should be the same as new alt allele
            // and the start position should not change;

            const string expectedAltAllele = "41TTGAAAAATATATTTTATATAATTTCAATATTTTTAACAT";

            Assert.Equal(expectedAltAllele, newAltAllele);
        }
        public void InsertionTest()
        {
            const int    start           = 1000; // represents the start position of the variant.
            const string referenceAllele = "A";
            const string altAllele       = "AC";

            var newAlleles = SupplementaryAnnotationUtilities.GetReducedAlleles(start, referenceAllele, altAllele);

            var newStart     = newAlleles.Item1;
            var newAltAllele = newAlleles.Item3;

            // in this case the alt allele should be the same as new alt allele
            // and the start position should not change;
            Assert.Equal(start + 1, newStart);
            Assert.Equal("iC", newAltAllele);
        }
        public void DelInsTest()
        {
            const int    start           = 1000; // represents the start position of the variant.
            const string referenceAllele = "ATCG";
            const string altAllele       = "CGT";

            var newAlleles = SupplementaryAnnotationUtilities.GetReducedAlleles(start, referenceAllele, altAllele);

            var newRefAllele = newAlleles.Item2;
            var newAltAllele = newAlleles.Item3;

            // in this case the alt allele should be the same as new alt allele
            // and the start position should not change;
            Assert.Equal(referenceAllele, newRefAllele);
            Assert.Equal("4CGT", newAltAllele);
        }
        public void LongInsertionTest()
        {
            const int    start           = 1000; // represents the start position of the variant.
            const string referenceAllele = "AT";
            const string altAllele       = "ATCGGGGGAAAAAATTTTTCGCGCGTATATGAGACATTAAA";

            var newAlleles = SupplementaryAnnotationUtilities.GetReducedAlleles(start, referenceAllele, altAllele);

            var newRefAllele = newAlleles.Item2;
            var newAltAllele = newAlleles.Item3;

            // in this case the alt allele should be the same as new alt allele
            // and the start position should not change;
            Assert.Equal("", newRefAllele);

            var expectedAltAllele = 'i' + altAllele.Substring(2);

            Assert.Equal(expectedAltAllele, newAltAllele);
        }
Exemple #13
0
        public string GetJsonString()
        {
            var sb = StringBuilderCache.Acquire();

            var jsonObject = new JsonObject(sb);

            jsonObject.AddStringValue("id", Id);
            jsonObject.AddStringValue("isAlleleSpecific", IsAlleleSpecific, false);
            jsonObject.AddStringValue("refAllele", string.IsNullOrEmpty(ReferenceAllele) ? "-" : ReferenceAllele);
            jsonObject.AddStringValue("altAllele",
                                      SupplementaryAnnotationUtilities.ReverseSaReducedAllele(AlternateAllele));
            jsonObject.AddStringValue("gene", Gene);
            jsonObject.AddIntValue("sampleCount", SampleCount);

            jsonObject.AddStringValues("cancerTypes", GetJsonStrings(GetCancerTypeCounts()), false);
            jsonObject.AddStringValues("tissues", GetJsonStrings(GetTissueCounts()), false);

            return(StringBuilderCache.GetStringAndRelease(sb));
        }
Exemple #14
0
        private bool ValidateReference(string chromosome, int position, string refAllele)
        {
            if (_sequenceProvider == null)
            {
                return(true);
            }

            var refDictionary = _sequenceProvider.RefNameToChromosome;

            if (!refDictionary.ContainsKey(chromosome))
            {
                return(false);
            }

            var chrom = refDictionary[chromosome];

            _sequenceProvider.LoadChromosome(chrom);
            var refSequence = _sequenceProvider.Sequence.Substring(position - 1, ReferenceWindow);

            return(SupplementaryAnnotationUtilities.ValidateRefAllele(refAllele, refSequence));
        }
Exemple #15
0
        public void ReverseSaReducedAlleleTests(string saAltAllele, string expectedAltAllele)
        {
            var observedAltAllele = SupplementaryAnnotationUtilities.ReverseSaReducedAllele(saAltAllele);

            Assert.Equal(expectedAltAllele, observedAltAllele);
        }
Exemple #16
0
        public void GetReducedAllelesTests(int start, string refAllele, string altallele, int outStart, string outRef, string outAlt)
        {
            var output = Tuple.Create(outStart, outRef, outAlt);

            Assert.Equal(output, SupplementaryAnnotationUtilities.GetReducedAlleles(start, refAllele, altallele));
        }
Exemple #17
0
 public void ReverSAReducedAlleleTests(string saAltAllele, string outAllele)
 {
     Assert.Equal(outAllele, SupplementaryAnnotationUtilities.ReverseSaReducedAllele(saAltAllele));
 }
Exemple #18
0
 public void ValidateRefAlleleTests(string refAllele, string refBases, bool result)
 {
     Assert.Equal(result, SupplementaryAnnotationUtilities.ValidateRefAllele(refAllele, refBases));
 }
        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);
            //}
        }