Ejemplo n.º 1
0
        private GenomeType?GetResult([CanBeNull] string sampleName,
                                     [NotNull] IMutableWittyerResult mutableResult, GenomeType targetType)
        {
            var bndSet = new Dictionary <IGeneralBnd, IVcfVariant>(BreakendPairComparer.Default);

            var        errorList  = new List <string>();
            GenomeType?genomeType = null;

            foreach (var baseVariant in _baseVariants)
            {
                if (genomeType == null)
                {
                    genomeType = baseVariant.Contig.GetGenomeType();
                }
                var sample = sampleName == null ? null : baseVariant.Samples[sampleName];
                var result = CreateVariant(baseVariant.ConvertGenomeType(targetType),
                                           sample, mutableResult.IsTruth, sampleName, _inputSpec, bndSet, errorList,
                                           _mode == EvaluationMode.CrossTypeAndSimpleCounting);
                switch (result)
                {
                //ugly implementation, first of breakend pair will return left as IGeneralBnd
                case IGeneralBnd _:
                    continue;

                case IVcfVariant vcfVariant:
                    mutableResult.AddUnsupported(vcfVariant);
                    break;

                case IMutableWittyerSimpleVariant simpleVariant:
                    mutableResult.AddTarget(simpleVariant);
                    break;
                }
            }

            if (errorList.Count > 0)
            {
                var msg = (errorList.Count > MaxNonSupportedVariantToPrint
                    ? errorList.Take(MaxNonSupportedVariantToPrint)
                    : errorList).StringJoin("\n");

                Console.Error.WriteLine(
                    $"Fail to parse {errorList.Count} variants from truth, check first {MaxNonSupportedVariantToPrint} or less: \n{msg}");
            }

            if (bndSet.Count == 0)
            {
                return(genomeType ?? GenomeType.Unknown);
            }

            Console.Error.WriteLine(
                $"Found single breakend in truth!!!! Those entries will be completely exclude from stats. First {MaxNonSupportedVariantToPrint} or less:");

            Console.Error.WriteLine(bndSet.Values.Take(MaxNonSupportedVariantToPrint).StringJoin("\n"));
            foreach (var kvp in bndSet)
            {
                mutableResult.AddUnsupported(CreateUnsupportedVariant(kvp.Value,
                                                                      sampleName == null ? null : kvp.Value.Samples[sampleName], FailedReason.UnpairedBnd, mutableResult.IsTruth));
            }

            return(genomeType ?? GenomeType.Unknown);
        }