Esempio n. 1
0
        public static void FieldDoesNotContain(ISupplementaryAnnotationReader saReader,
                                               string vcfLine, string expected, int vcfColumn)
        {
            var column = GetVcfColumn(saReader, vcfLine, vcfColumn);

            Assert.DoesNotContain(expected, column);
        }
Esempio n. 2
0
        internal static IAnnotatedVariant GetVariant(string cacheFile, ISupplementaryAnnotationReader saReader,
                                                     string vcfLine)
        {
            var annotationSource = ResourceUtilities.GetAnnotationSource(cacheFile, saReader);

            return(GetVariant(annotationSource, vcfLine));
        }
Esempio n. 3
0
        public static void FieldEquals(ISupplementaryAnnotationReader saReader, string vcfLine,
                                       string expected, int vcfColumn)
        {
            var column = GetVcfColumn(saReader, vcfLine, vcfColumn);

            Assert.Equal(expected, column);
        }
Esempio n. 4
0
        internal static IAnnotatedVariant GetVariant(string cachePath, ISupplementaryAnnotationReader saReader,
                                                     string vcfLine, IConservationScoreReader csReader)
        {
            var annotationSource = ResourceUtilities.GetAnnotationSource(cachePath, saReader, csReader);

            return(GetVariant(annotationSource, vcfLine));
        }
Esempio n. 5
0
        /// <summary>
        /// constructor
        /// </summary>
        public MockSupplementaryAnnotationProvider(ISupplementaryAnnotationReader saReader, ChromosomeRenamer renamer)
        {
            if (saReader == null)
            {
                return;
            }
            _saReader = saReader;

            _overlappingSupplementaryIntervals = new List <ISupplementaryInterval>();
            _suppIntervalForest = _saReader.GetIntervalForest(renamer);
        }
Esempio n. 6
0
        /// <summary>
        /// creates a new annotation source with data from the micro-cache file
        /// </summary>
        internal static IAnnotationSource GetAnnotationSource(string cachePath, ISupplementaryAnnotationReader saReader,
                                                              IConservationScoreReader conservationScoreReader          = null,
                                                              ISupplementaryAnnotationProvider customAnnotationProvider = null,
                                                              ISupplementaryAnnotationProvider customIntervalProvider   = null)
        {
            var streams    = GetAnnotationSourceStreams(cachePath);
            var renamer    = ChromosomeRenamer.GetChromosomeRenamer(GetReadStream($"{cachePath}.bases"));
            var saProvider = new MockSupplementaryAnnotationProvider(saReader, renamer);

            PerformanceMetrics.DisableOutput = true;

            return(new NirvanaAnnotationSource(streams, saProvider, conservationScoreReader, customAnnotationProvider,
                                               customIntervalProvider, null));
        }
Esempio n. 7
0
        /// <summary>
        /// sets the supplementary annotation record for each allele in this record
        /// </summary>
        public void SetSupplementaryAnnotation(ISupplementaryAnnotationReader saReader)
        {
            // for ref variants, alternate alleles will be empty. We will need to pull the SA from reference position.
            // If this is a ref minor position, I will add an alt allele with the ref as alt and GMAF as ref
            if (IsReference)
            {
                // checking the index for refMinor using the index before actually going to disk
                IsRefMinor = saReader.IsRefMinor(VcfReferenceBegin);

                if (!IsRefMinor)
                {
                    return;
                }

                SupplementaryAnnotationPosition = saReader.GetAnnotation(VcfReferenceBegin);
                if (SupplementaryAnnotationPosition == null)
                {
                    return;
                }


                // if we have a ref minor, we do not care about ref no call
                IsRefNoCall = false;

                AlternateAlleles[0].AlternateAllele = AlternateAlleles[0].ReferenceAllele;// ref becomes alt for ref minor

                if (SupplementaryAnnotationPosition.GlobalMajorAllele != null)
                {
                    AlternateAlleles[0].ReferenceAllele = SupplementaryAnnotationPosition.GlobalMajorAllele;
                }

                AlternateAlleles[0].NirvanaVariantType = VariantType.SNV;
                AlternateAlleles[0].VepVariantType     = VariantType.SNV;
                AlternateAlleles[0].SuppAltAllele      = AlternateAlleles[0].AlternateAllele; // for SNVs there is nothing to reduce
                AlternateAlleles[0].VariantId          = _vid.Create(_renamer, EnsemblReferenceName, AlternateAlleles[0]);
                AlternateAlleles[0].SetSupplementaryAnnotation(SupplementaryAnnotationPosition);

                return;
            }

            foreach (var altAllele in AlternateAlleles)
            {
                var sa = saReader.GetAnnotation(altAllele.Start);
                if (sa != null)
                {
                    altAllele.SetSupplementaryAnnotation(sa);
                }
            }
        }
Esempio n. 8
0
        public static string GetVcfColumn(ISupplementaryAnnotationReader saReader, string vcfLine,
                                          int vcfColumn)
        {
            var vcfVariant       = GetVcfVariant(vcfLine);
            var annotationSource = ResourceUtilities.GetAnnotationSource(DataUtilities.EmptyCachePrefix, saReader);

            UnifiedJson.NeedsVariantComma = false;
            var annotatedVariant = annotationSource?.Annotate(vcfVariant);

            Assert.NotNull(annotatedVariant);

            var vcf = new VcfConversion();

            return(vcf.Convert(vcfVariant, annotatedVariant).Split('\t')[vcfColumn]);
        }
Esempio n. 9
0
        public void Load(string ucscReferenceName, IChromosomeRenamer renamer)
        {
            if (string.IsNullOrEmpty(_saDir) || ucscReferenceName == _currentUcscReferenceName)
            {
                return;
            }

            var saPath = Path.Combine(_saDir, ucscReferenceName + ".nsa");

            _saReader = File.Exists(saPath) ? new SupplementaryAnnotationReader(saPath) : null;

            _intervalForest = _saReader?.GetIntervalForest(renamer);
            _hasIntervals   = !(_intervalForest is NullIntervalSearch <ISupplementaryInterval>);

            _currentUcscReferenceName = ucscReferenceName;
        }
Esempio n. 10
0
 public void Clear() => _saReader = null;
Esempio n. 11
0
 public void Clear()
 {
     _hasIntervals = false;
     _saReader     = null;
 }