コード例 #1
0
 public override string GetAnnotation(Polymorphism p)
 {
     if (MutationAssigner.MutationIsComplex(p.Mutation))
     {
         return(nullAnnotation);
     }
     else
     {
         var site  = p.Position;
         var refBP = Polymorphism.getReferenceBaseSingle(site);
         var alt   = MutationAssigner.getBase(p.Mutation);
         var key   = makeQueryString(site, refBP, alt);
         if (!positionToData.ContainsKey(key))
         {
             key = makeQueryString(site, BigTableData.ALL_SITE_SAME, BigTableData.ALL_SITE_SAME);
             if (positionToData.ContainsKey(key))
             {
                 return(positionToData[key].Data);
             }
             return(nullAnnotation);
         }
         else
         {
             return(positionToData[key].Data);
         }
     }
 }
コード例 #2
0
        public override string GetAnnotation(Polymorphism poly)
        {
            int    pos = poly.position;
            string reference, alt, inBestHaplotype;

            alt = "ERROR";
            //TODO: Move this logic in to polymorphism class
            if (poly.mutation == Mutations.INS)
            {
                reference = "-";
            }
            else
            {
                reference = Polymorphism.rCRS[poly.position - 1].ToString();
                alt       = poly.InsertedPolys;
            }
            if (poly.mutation == Mutations.DEL)
            {
                alt = "-";
            }
            else if (MutationAssigner.MutationIsBasePair(poly.mutation))
            {
                alt = MutationAssigner.getBase(poly.mutation);
            }
            if (!validPolys.ContainsKey(poly.position))
            {
                inBestHaplotype = "MutationExcludedFromSearch";
            }
            else
            {
                inBestHaplotype = bestMatch.MatchingPolymorphisms.Contains(poly).ToString();
            }
            return(String.Join(FIELD_DELIM, new[] { pos.ToString(), reference, alt, inBestHaplotype }));
        }
コード例 #3
0
        /// <summary>
        /// Call SNPs from the sorted list of sequences using the pile-up method.
        /// </summary>
        /// <returns>The SN ps.</returns>
        /// <param name="sequences">Sequences.</param>
        public static SNPCallerReport CallSNPs(IEnumerable <CompactSAMSequence> sequences)
        {
            // Get a pile up and convert it to genotypes
            var pileups   = PileUpProducer.CreatePileupFromReads(sequences);
            var genotypes = ContinuousGenotypeCaller.CallContinuousGenotypes(pileups).ToList();

            // Filter down to a usable set
            var usable = genotypes.Where(x => x.ResultType == GenotypeCallResult.GenotypeCalled && x.OriginalPosition.HasValue).ToList();

            if (usable.Count == 0)
            {
                return(new SNPCallerReport(AlgorithmResult.Failed));
            }

            // Get median coverage at sites
            var data_counts = usable.Select(x => x.TotalObservedBases).ToList();

            data_counts.Sort();
            var median = data_counts[data_counts.Count / 2];

            //now create a cut-off for required coverage as the square root of the median.
            var cut_off = Math.Sqrt(median);

            //Get a list of genotypes, and if a simple SNP, make a polymorphism if it doesn't match
            //the reference
            var genotypedPositions    = new HashSet <int> ();
            List <Polymorphism> polys = new List <Polymorphism> ();

            foreach (var geno in usable)
            {
                if (geno.TotalObservedBases >= cut_off)
                {
                    genotypedPositions.Add(geno.OriginalPosition.Value);
                    var org_bp = ReferenceGenome.GetReferenceBaseAt_rCRSPosition(geno.OriginalPosition.Value);
                    var cur_bp = geno.GetMostFrequentGenotype();
                    if (org_bp != cur_bp[0])
                    {
                        var poly = new Polymorphism(geno.OriginalPosition.Value, MutationAssigner.getBase(cur_bp));
                        polys.Add(poly);
                    }
                }
            }
            //Now assign haplotype
            HaplotypeSearcher  hts = new HaplotypeSearcher();
            PolymorphismFilter pf  = new PolymorphismFilter(p => p.IsSNP && genotypedPositions.Contains(p.Position));
            var simpSample         = new SimpleSample("Pileup", polys, pf);
            var hap_report         = hts.GetHaplotypeReport(simpSample);

            return(new SNPCallerReport(genotypes, hap_report));
        }