Example #1
0
 private static IEnumerable <IMetaInfoLine> MergeTypedMetaLines(
     [NotNull] this IReadOnlyDictionary <string, ITypedMetaInfoLine> truthLines,
     [NotNull] string lineKey, [NotNull] IReadOnlyDictionary <string, ITypedMetaInfoLine> queryLines)
 => MergeMetaLines(truthLines, queryLines,
                   (t, q) => t.Type == q.Type && t.Number == q.Number && IsDescriptionEqual(t, q),
                   (t, q) => TypedMetaInfoLine.Create(MetaInfoLine.Create(lineKey, t.Id, MergeDescription(t, q)),
                                                      t.Type == q.Type ? t.Type : TypeField.String, t.Number == q.Number ? t.Number : NumberField.Any));
Example #2
0
        internal static VcfHeader.Builder AddSampleMetaInfo([NotNull] this VcfHeader.Builder builder,
                                                            [NotNull] IVcfHeader truthHeader, [CanBeNull] ISamplePair samplePair,
                                                            [NotNull] IVcfHeader queryHeader, [NotNull] IEnumerable <IBasicMetaLine> mergedMetaLines)
        {
            // todo: for vcf 4.3, this has ids, so should be merged via AddSampleMetaInfo.
            // get rid of pedigree lines since we don't have all the sample columns
            //builder = truthHeader.PedigreeLines.Concat(queryHeader.PedigreeLines)
            //    .Aggregate(builder, (acc, line) => acc.AddPedigreeLine(line));

            var truth = samplePair?.TruthSampleName ?? truthHeader.SampleNames.FirstOrDefault();
            var query = samplePair?.QuerySampleName ?? queryHeader.SampleNames.FirstOrDefault();

            if (truth != query && truth != null) // only add sample lines that are not the same sample names otherwise, error out.
            {
                AddSampleLine(truth, DefaultTruthSampleName);
                AddSampleLine(query, DefaultQuerySampleName);
            }

            return(mergedMetaLines
                   .Aggregate(builder, (acc, line) => acc.AddLine(line)));

            void AddSampleLine(string sampleName, string defaultSampleName)
            {
                if (sampleName == null)
                {
                    return;
                }
                builder.AddOtherLine(MetaInfoLine.Create(OriginalSampleNameLineKey, defaultSampleName, sampleName));
                var truthLine = truthHeader.ColumnMetaInfoLines.SampleLines
                                .FirstOrException(l => sampleName.Equals(l.Value.Id)).GetOrNull()?.Value;

                if (truthLine != null)
                {
                    builder.AddLine(truthLine);
                }
            }
        }
Example #3
0
 private static IEnumerable <IMetaInfoLine> MergeMetaInfoLines(
     [NotNull] this IReadOnlyDictionary <string, IMetaInfoLine> truthLines,
     [NotNull] string lineKey, [NotNull] IReadOnlyDictionary <string, IMetaInfoLine> queryLines)
 => MergeMetaLines(truthLines, queryLines, IsDescriptionEqual,
                   (t, q) => MetaInfoLine.Create(lineKey, t.Id, MergeDescription(t, q)));