コード例 #1
0
 public void PopulateBAMPaths()
 {
     BAMPaths = Directory.GetFiles(BAMFolder, "*.bam");
     if (!BAMPaths.Any())
     {
         throw new ArgumentException(string.Format("No BAM files found in {0}", BAMFolder));
     }
 }
コード例 #2
0
        public void Validate()
        {
            var bamPathsSpecified  = BAMPaths != null && BAMPaths.Length > 0;
            var bamFolderSpecified = !string.IsNullOrWhiteSpace(BAMFolder);

            //Either BAMPath(s) or BAMFolder should be specified.
            if (!bamPathsSpecified && !bamFolderSpecified)
            {
                throw new ArgumentException("Specify either BAMPath(s) or BAMFolder");
            }

            if (bamPathsSpecified && bamFolderSpecified)
            {
                throw new ArgumentException("Specify either BAMPath(s) or BAMFolder");
            }

            if (GenomePaths == null || GenomePaths.Length == 0)
            {
                throw new ArgumentException("No GenomePaths specified.");
            }

            if (bamPathsSpecified)
            {
                if (BAMPaths.Length > 96)
                {
                    throw new ArgumentException("Number of BAMPaths specified exceeds maximum of 96.");
                }

                if (BAMPaths.Distinct().Count() != BAMPaths.Count())
                {
                    throw new ArgumentException("Duplicate BAMPaths detected.");
                }

                if (BAMPaths.Length != GenomePaths.Length && GenomePaths.Length > 1)
                {
                    throw new ArgumentException(
                              "Multiple GenomePaths specified, but number does not correspond with number of BAMPaths.");
                }

                if (IntervalPaths != null && BAMPaths.Length != IntervalPaths.Length && IntervalPaths.Length > 1)
                {
                    throw new ArgumentException(
                              "Multiple IntervalPaths specified, but number does not correspond with number of BAMPaths.");
                }

                // check files and directories exist
                foreach (var bamPath in BAMPaths)
                {
                    if (!File.Exists(bamPath))
                    {
                        throw new ArgumentException(string.Format("BAMPath '{0}' does not exist.", bamPath));
                    }
                }
            }

            if (bamFolderSpecified)
            {
                if (!Directory.Exists(BAMFolder))
                {
                    throw new ArgumentException(string.Format("BAMFolder {0} not found", BAMFolder));
                }

                if (GenomePaths.Length > 1)
                {
                    throw new ArgumentException("Only 1 Genome Path should be specified when BAMFolder is specified.");
                }

                if (IntervalPaths != null && IntervalPaths.Length > 1)
                {
                    throw new ArgumentException("At most 1 Interval Path should be specified when BAMFolder is specified.");
                }
            }

            foreach (var genomePath in GenomePaths)
            {
                if (!Directory.Exists(genomePath))
                {
                    throw new ArgumentException(string.Format("GenomePath '{0}' does not exist.", genomePath));
                }
            }

            if (IntervalPaths != null)
            {
                foreach (var intervalPath in IntervalPaths)
                {
                    if (!File.Exists(intervalPath))
                    {
                        throw new ArgumentException(string.Format("IntervalPath '{0}' does not exist.", intervalPath));
                    }
                }
            }

            ValidationHelper.VerifyRange(MinimumVariantQScore, 0, int.MaxValue, "MinimumVariantQscore");
            ValidationHelper.VerifyRange(MaximumVariantQScore, 0, int.MaxValue, "MaximumVariantQScore");
            if (MaximumVariantQScore < MinimumVariantQScore)
            {
                throw new ArgumentException("MinimumVariantQScore must be less than or equal to MaximumVariantQScore.");
            }

            ValidationHelper.VerifyRange(MinimumBaseCallQuality, 0, int.MaxValue, "MinimumBaseCallQuality");
            ValidationHelper.VerifyRange(MinimumFrequency, 0f, 1f, "MinimumFrequency");
            ValidationHelper.VerifyRange(FilteredVariantQScore, MinimumVariantQScore, MaximumVariantQScore, "FilteredVariantQScore");

            ValidationHelper.VerifyRange((float)FilteredVariantFrequency, 0, 1f, "FilteredVariantFrequency");

            if (LowGenotypeQualityFilter != null)
            {
                ValidationHelper.VerifyRange((float)LowGenotypeQualityFilter, 0, int.MaxValue, "FilteredLowGenomeQuality");
            }
            if (IndelRepeatFilter != null)
            {
                ValidationHelper.VerifyRange((int)IndelRepeatFilter, 0, 10, "FilteredIndelRepeats");
            }
            if (LowDepthFilter != null)
            {
                ValidationHelper.VerifyRange((int)LowDepthFilter, MinimumDepth, int.MaxValue, "FilteredLowDepth");
            }

            if ((LowDepthFilter == null) || (LowDepthFilter < MinimumDepth))
            {
                LowDepthFilter = MinimumDepth;
            }

            if (AppliedNoiseLevel != -1)
            {
                ValidationHelper.VerifyRange(AppliedNoiseLevel, 0, int.MaxValue, "AppliedNoiseLevel");
            }
            if (CallMNVs)
            {
                ValidationHelper.VerifyRange(MaxSizeMNV, 1, GlobalConstants.RegionSize, "MaxPhaseSNPLength");
                ValidationHelper.VerifyRange(MaxGapBetweenMNV, 0, int.MaxValue, "MaxGapPhasedSNP");
            }
            ValidationHelper.VerifyRange(MinimumMapQuality, 0, int.MaxValue, "MinimumMapQuality");
            ValidationHelper.VerifyRange(StrandBiasAcceptanceCriteria, 0f, int.MaxValue, "Strand bias cutoff");
            ValidationHelper.VerifyRange(MaxNumThreads, 1, int.MaxValue, "MaxNumThreads");
            ValidationHelper.VerifyRange(CollapseFreqThreshold, 0f, float.MaxValue, "CollapseFreqThreshold");
            ValidationHelper.VerifyRange(CollapseFreqRatioThreshold, 0f, float.MaxValue, "CollapseFreqRatioThreshold");

            if (!string.IsNullOrEmpty(PriorsPath))
            {
                if (!File.Exists(PriorsPath))
                {
                    throw new ArgumentException(string.Format("PriorsPath '{0}' does not exist.", PriorsPath));
                }
            }

            if (PloidyModel == PloidyModel.Diploid)
            {
                MinimumFrequency = DiploidThresholdingParameters.MinorVF;
            }


            if (FilteredVariantFrequency < MinimumFrequency)
            {
                FilteredVariantFrequency = MinimumFrequency;
            }

            if (RMxNFilterMaxLengthRepeat != null || RMxNFilterMinRepetitions != null)
            {
                if (RMxNFilterMaxLengthRepeat == null || RMxNFilterMinRepetitions == null)
                {
                    throw new ArgumentException(string.Format("If specifying RMxN filter thresholds, you must supply both RMxNFilterMaxLengthRepeat and RMxNFilterMinRepetitions."));
                }
                ValidationHelper.VerifyRange((int)RMxNFilterMaxLengthRepeat, 0, 100, "RMxNFilterMaxLengthRepeat");
                ValidationHelper.VerifyRange((int)RMxNFilterMinRepetitions, 0, 100, "RMxNFilterMinRepetitions");
            }

            if (ThreadByChr && !InsideSubProcess && !string.IsNullOrEmpty(ChromosomeFilter))
            {
                throw new ArgumentException("Cannot thread by chromosome when filtering on a particular chromosome.");
            }

            if (!string.IsNullOrEmpty(OutputFolder) && bamPathsSpecified && (BAMPaths.Length > 1))
            {
                //make sure none of the input BAMS have the same name. Or else we will have an output collision.
                for (int i = 0; i < BAMPaths.Length; i++)
                {
                    for (int j = i + 1; j < BAMPaths.Length; j++)
                    {
                        if (i == j)
                        {
                            continue;
                        }

                        var fileA = Path.GetFileName(BAMPaths[i]);
                        var fileB = Path.GetFileName(BAMPaths[j]);

                        if (fileA == fileB)
                        {
                            throw new ArgumentException(string.Format("VCF file name collision. Cannot process two different bams with the same name {0} into the same output folder {1}.", fileA, OutputFolder));
                        }
                    }
                }
            }
        }