Example #1
0
        public override SupplementaryInterval GetSupplementaryInterval(ChromosomeRenamer renamer)
        {
            if (!IsInterval)
            {
                return(null);
            }

            var intValues    = new Dictionary <string, int>();
            var doubleValues = new Dictionary <string, double>();
            var freqValues   = new Dictionary <string, double>();
            var stringValues = new Dictionary <string, string>();
            var boolValues   = new List <string>();
            var stringLists  = new Dictionary <string, IEnumerable <string> >();

            var suppInterval = new SupplementaryInterval(Start, End, Chromosome, null, VariantType,
                                                         "ClinGen", renamer, intValues, doubleValues, freqValues, stringValues, boolValues, stringLists);

            if (Id != null)
            {
                suppInterval.AddStringValue("id", Id);
            }
            if (ClinicalInterpretation != ClinicalInterpretation.unknown)
            {
                suppInterval.AddStringValue("clinicalInterpretation", GetClinicalDescription(ClinicalInterpretation));
            }
            if (Phenotypes != null)
            {
                suppInterval.AddStringList("phenotypes", Phenotypes);
            }
            if (PhenotypeIds != null)
            {
                suppInterval.AddStringList("phenotypeIds", PhenotypeIds);
            }
            if (ObservedGains != 0)
            {
                suppInterval.AddIntValue("observedGains", ObservedGains);
            }
            if (ObservedLosses != 0)
            {
                suppInterval.AddIntValue("observedLosses", ObservedLosses);
            }
            if (Validated)
            {
                suppInterval.AddBoolValue("validated");
            }

            return(suppInterval);
        }
Example #2
0
        public override SupplementaryInterval GetSupplementaryInterval(ChromosomeRenamer renamer)
        {
            if (!IsInterval)
            {
                return(null);
            }

            var intValues    = new Dictionary <string, int>();
            var doubleValues = new Dictionary <string, double>();
            var freqValues   = new Dictionary <string, double>();
            var stringValues = new Dictionary <string, string>();
            var boolValues   = new List <string>();

            var suppInterval = new SupplementaryInterval(Start, End, Chromosome, null, VariantType,
                                                         "DGV", renamer, intValues, doubleValues, freqValues, stringValues, boolValues);

            if (Id != null)
            {
                suppInterval.AddStringValue("id", Id);
            }
            if (SampleSize != 0)
            {
                suppInterval.AddIntValue("sampleSize", SampleSize);
            }
            if (ObservedGains != 0)
            {
                suppInterval.AddIntValue("observedGains", ObservedGains);
            }
            if (ObservedLosses != 0)
            {
                suppInterval.AddIntValue("observedLosses", ObservedLosses);
            }
            if (VariantFreqAll != null)
            {
                suppInterval.AddFrequencyValue("variantFreqAll", VariantFreqAll.Value);
            }

            return(suppInterval);
        }
Example #3
0
        public void ReadWriteWithSuppIntervals()
        {
            // NIR-1359
            var randomPath = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName());

            // create our expected data source versions
            var dbSnpVersion = new DataSourceVersion("dbSNP", "142", DateTime.Parse("2015-01-02").Ticks);

            var expectedDataSourceVersions = new List <DataSourceVersion> {
                dbSnpVersion
            };

            // This is the case where Nirvana throws an error: Too many bytes in what should have been a 7 bit encoded Int32.

            var sa        = new SupplementaryAnnotationPosition(5073770);
            var saCreator = new SupplementaryPositionCreator(sa);


            // adding a supplementary interval
            var intValues    = new Dictionary <string, int>();
            var doubleValues = new Dictionary <string, double>();
            var freqValues   = new Dictionary <string, double>();
            var stringValues = new Dictionary <string, string>();
            var boolValues   = new List <string>();

            var suppInterval = new SupplementaryInterval(5073770, 5073970, "chr1", "<DUP>", VariantType.duplication, "ClinVar", _renamer, intValues,
                                                         doubleValues, freqValues, stringValues, boolValues);

            suppInterval.AddStringValue("ID", "RandomClin001");

            // the above code was unit tested in MergeDbSnpClinVar()
            using (var writer = new SupplementaryAnnotationWriter(randomPath, "chr9", expectedDataSourceVersions))
            {
                writer.SetIntervalList(new List <SupplementaryInterval> {
                    suppInterval
                });
                writer.Write(saCreator, sa.ReferencePosition);
            }

            // read the supplementary annotation file
            using (var reader = new SupplementaryAnnotationReader(randomPath))
            {
                // read the stored intervals
                var suppIntervals = reader.GetSupplementaryIntervals(_renamer).ToList();
                Assert.Equal(1, suppIntervals.Count);

                foreach (var interval in suppIntervals)
                {
                    Assert.Equal(5073770, interval.Start);
                    Assert.Equal(5073970, interval.End);
                    Assert.Equal("<DUP>", interval.AlternateAllele);
                    Assert.Equal("ClinVar", interval.Source);
                    Assert.Equal("duplication", interval.VariantType.ToString());

                    foreach (var keyValuePair in interval.StringValues)
                    {
                        if (keyValuePair.Key == "ID")
                        {
                            Assert.Equal("RandomClin001", keyValuePair.Value);
                        }
                        if (keyValuePair.Key == "vid")
                        {
                            Assert.Equal("1:5073770:5073970", keyValuePair.Value);
                        }
                    }
                }
            }

            File.Delete(randomPath);
            File.Delete(randomPath + ".idx");
        }
Example #4
0
        public override SupplementaryInterval GetSupplementaryInterval(ChromosomeRenamer renamer)
        {
            if (!IsInterval)
            {
                return(null);
            }

            var seqAltType = SequenceAlterationUtilities.GetSequenceAlteration(SvType, ObservedGains, ObservedLosses);

            var intValues    = new Dictionary <string, int>();
            var doubleValues = new Dictionary <string, double>();
            var freqValues   = new Dictionary <string, double>();
            var stringValues = new Dictionary <string, string>();
            var boolValues   = new List <string>();

            var suppInterval = new SupplementaryInterval(Start, SvEnd, Chromosome, AlternateAllele, seqAltType,
                                                         "1000 Genomes Project", renamer, intValues, doubleValues, freqValues, stringValues, boolValues);

            if (Id != null)
            {
                suppInterval.AddStringValue("id", Id);
            }
            if (AfrFreq != null)
            {
                suppInterval.AddFrequencyValue("variantFreqAfr", Convert.ToDouble(AfrFreq));
            }
            if (AllFreq != null)
            {
                suppInterval.AddFrequencyValue("variantFreqAll", Convert.ToDouble(AllFreq));
            }
            if (AmrFreq != null)
            {
                suppInterval.AddFrequencyValue("variantFreqAmr", Convert.ToDouble(AmrFreq));
            }
            if (EasFreq != null)
            {
                suppInterval.AddFrequencyValue("variantFreqEas", Convert.ToDouble(EasFreq));
            }
            if (EurFreq != null)
            {
                suppInterval.AddFrequencyValue("variantFreqEur", Convert.ToDouble(EurFreq));
            }
            if (SasFreq != null)
            {
                suppInterval.AddFrequencyValue("variantFreqSas", Convert.ToDouble(SasFreq));
            }

            if (AllAlleleNumber != null && AllAlleleNumber.Value > 0)
            {
                suppInterval.AddIntValue("sampleSize", AllAlleleNumber.Value);
            }
            if (AfrAlleleNumber != null && AfrAlleleNumber.Value > 0)
            {
                suppInterval.AddIntValue("sampleSizeAfr", AfrAlleleNumber.Value);
            }
            if (AmrAlleleNumber != null && AmrAlleleNumber.Value > 0)
            {
                suppInterval.AddIntValue("sampleSizeAmr", AmrAlleleNumber.Value);
            }
            if (EasAlleleNumber != null && EasAlleleNumber.Value > 0)
            {
                suppInterval.AddIntValue("sampleSizeEas", EasAlleleNumber.Value);
            }
            if (EurAlleleNumber != null && EurAlleleNumber.Value > 0)
            {
                suppInterval.AddIntValue("sampleSizeEur", EurAlleleNumber.Value);
            }
            if (SasAlleleNumber != null && SasAlleleNumber.Value > 0)
            {
                suppInterval.AddIntValue("sampleSizeSas", SasAlleleNumber.Value);
            }

            if (ObservedGains != 0)
            {
                suppInterval.AddIntValue("observedGains", ObservedGains);
            }
            if (ObservedLosses != 0)
            {
                suppInterval.AddIntValue("observedLosses", ObservedLosses);
            }

            return(suppInterval);
        }