Beispiel #1
0
 public static void Process(BaseCalledAllele allele, GenotypeModel model,
                            float minFrequency, int minCoverage, int?filterVariantQscore, bool filterSingleStrandVariants)
 {
     SetFractionNoCall(allele);
     ApplyFilters(allele, minCoverage, filterVariantQscore, filterSingleStrandVariants);
     SetGenotype(allele, model, minFrequency);
 }
Beispiel #2
0
        private static void SetGenotype(BaseCalledAllele allele, GenotypeModel model, float minFrequency)
        {
            if (allele.Filters.Contains(FilterType.LowDepth))
            {
                allele.Genotype = allele is CalledReference ? Genotype.RefLikeNoCall : Genotype.AltLikeNoCall;
            }
            else if (allele is CalledVariant && model != GenotypeModel.None)
            {
                var variant = (CalledVariant)allele;

                // if we see no evidence of a reference allele, according to the genotype model
                // then presume our variant is a homozygous alt
                if (variant.RefFrequency < (model == GenotypeModel.Symmetrical ? minFrequency : 0.25f))
                {
                    //if we are using the thresholding model, if we see less than 25% reference,
                    variant.Genotype = Genotype.HomozygousAlt;
                }
            }
        }
        public ApplicationOptions UpdateOptions(string[] arguments)
        {
            string lastArgumentField = string.Empty;

            try
            {
                int argumentIndex = 0;
                while (argumentIndex < arguments.Length)
                {
                    if (arguments[argumentIndex] == null || arguments[argumentIndex].Length == 0)
                    {
                        argumentIndex++;
                        continue;
                    }
                    string value = null;
                    if (argumentIndex < arguments.Length - 1)
                    {
                        value = arguments[argumentIndex + 1];
                    }

                    lastArgumentField = arguments[argumentIndex];

                    switch (lastArgumentField)
                    {
                    case "-a":
                        MinimumVariantQScore = int.Parse(value);
                        break;

                    case "-b":
                        MinimumBaseCallQuality = int.Parse(value);
                        break;

                    case "-B":
                        BAMPaths = value.Split(_delimiter);
                        break;

                    case "-BAMFolder":
                        BAMFolder = value;
                        break;

                    case "-c":
                        MinimumCoverage = int.Parse(value);
                        break;

                    case "-d":
                        DebugMode = bool.Parse(value);
                        break;

                    case "-debug":
                        DebugMode = bool.Parse(value);
                        break;

                    case "-f":
                        MinimumFrequency = float.Parse(value);
                        break;

                    case "-F":
                        FilteredVariantQScore = int.Parse(value);
                        break;

                    case "-fo":
                        FilterOutVariantsPresentOnlyOneStrand = bool.Parse(value);
                        break;

                    case "-g":
                        GenomePaths = value.Split(_delimiter);
                        break;

                    case "-NL":
                        AppliedNoiseLevel = int.Parse(value);
                        break;

                    case "-gVCF":
                        OutputgVCFFiles = bool.Parse(value);
                        break;

                    case "-CallMNVs":
                    case "-PhaseSNPs":
                        CallMNVs = bool.Parse(value);
                        break;

                    case "-MaxMNVLength":
                    case "-MaxPhaseSNPLength":
                        MaxSizeMNV = int.Parse(value);
                        break;

                    case "-MaxGapBetweenMNV":
                    case "-MaxGapPhasedSNP":
                        MaxGapBetweenMNV = int.Parse(value);
                        break;

                    case "-i":
                        IntervalPaths = value.Split(_delimiter);
                        break;

                    case "-m":
                        MinimumMapQuality = int.Parse(value);
                        break;

                    case "-GT":
                        if (value.ToLower().Contains("none"))
                        {
                            GTModel = GenotypeModel.None;
                        }
                        else if (value.ToLower().Contains("threshold"))
                        {
                            GTModel = GenotypeModel.Thresholding;
                        }
                        else if (value.ToLower().Contains("symmetric"))
                        {
                            GTModel = GenotypeModel.Symmetrical;
                        }
                        else
                        {
                            throw new ArgumentException(string.Format("Unknown genotype model '{0}'", value));
                        }
                        break;

                    case "-SBModel":
                        if (value.ToLower().Contains("poisson"))
                        {
                            StrandBiasModel = StrandBiasModel.Poisson;
                        }
                        else if (value.ToLower().Contains("extended"))
                        {
                            StrandBiasModel = StrandBiasModel.Extended;
                        }
                        else
                        {
                            throw new ArgumentException(string.Format("Unknown strand bias model '{0}'", value));
                        }
                        break;

                    case "-o":
                        OutputBiasFiles = bool.Parse(value);
                        break;

                    case "-p":
                        OnlyUseProperPairs = bool.Parse(value);
                        break;

                    case "-q":
                        MaximumVariantQScore = int.Parse(value);
                        break;

                    case "-s":
                        StrandBiasAcceptanceCriteria = float.Parse(value);
                        break;

                    case "-StitchPairedReads":
                        StitchReads = bool.Parse(value);
                        break;

                    case "-t":
                        MaxNumThreads = int.Parse(value);
                        break;

                    case "-ThreadByChr":
                        ThreadByChr = bool.Parse(value);
                        break;

                    case "-ReportNoCalls":
                        ReportNoCalls = bool.Parse(value);
                        break;

                    case "-requireXC":
                        RequireXCTagToStitch = bool.Parse(value);
                        break;

                    case "-xcStitcher":
                        UseXCStitcher = bool.Parse(value);
                        break;

                    case "-OutFolder":
                        OutputFolder = value;
                        break;

                    default:
                        throw new Exception(string.Format("Unknown argument '{0}'", arguments[argumentIndex]));
                    }

                    argumentIndex += 2;
                }

                CommandLineArguments = string.Join(" ", arguments);

                return(this);
            }
            catch (Exception ex)
            {
                if (string.IsNullOrEmpty(lastArgumentField))
                {
                    throw new Exception("Unable to parse arguments: " + ex.Message);
                }

                throw new Exception(string.Format("Unable to parse argument {0}: {1}", lastArgumentField, ex.Message));
            }
        }
Beispiel #4
0
        private void ExecuteGenotypeTest(int totalCoverage, float refFrequency, bool isReference, GenotypeModel model, Genotype expectedGenotype)
        {
            var variant = CreatePassingVariant(isReference);

            variant.TotalCoverage = totalCoverage;
            if (!isReference)
            {
                var refSupport = (int)(refFrequency * totalCoverage);
                variant.AlleleSupport = totalCoverage - refSupport;
                ((CalledVariant)variant).ReferenceSupport = refSupport;
            }
            AlleleProcessor.Process(variant, model, 0.01f, 100, 20, false);

            Assert.Equal(expectedGenotype, variant.Genotype);
        }