/// <summary> /// create a VCF format header line /// </summary> /// <param name="line"> the header line </param> /// <param name="version"> the VCF header version </param> /// <param name="lineType"> the header line type /// </param> protected internal VCFCompoundHeaderLine(string line, VCFHeaderVersion version, SupportedHeaderLineType lineType) : base(lineType.ToString(), "") { IDictionary <string, string> mapping = VCFHeaderLineTranslator.parseLine(version, line, "ID", "Number", "Type", "Description"); name = mapping["ID"]; count = -1; string numberStr = mapping["Number"]; if (numberStr.Equals(VCFConstants.PER_ALTERNATE_ALLELE_COUNT)) { countType = VCFHeaderLineCount.A; } else if (numberStr.Equals(VCFConstants.PER_ALLELE_COUNT)) { countType = VCFHeaderLineCount.R; } else if (numberStr.Equals(VCFConstants.PER_GENOTYPE_COUNT)) { countType = VCFHeaderLineCount.G; } else if (((version == VCFHeaderVersion.VCF4_0 || version == VCFHeaderVersion.VCF4_1 || version == VCFHeaderVersion.VCF4_2) && numberStr.Equals(VCFConstants.UNBOUNDED_ENCODING_v4)) || ((version == VCFHeaderVersion.VCF3_2 || version == VCFHeaderVersion.VCF3_3) && numberStr.Equals(VCFConstants.UNBOUNDED_ENCODING_v3))) { countType = VCFHeaderLineCount.UNBOUNDED; } else { countType = VCFHeaderLineCount.INTEGER; count = Convert.ToInt32(numberStr); } if (count < 0 && countType == VCFHeaderLineCount.INTEGER) { throw new VCFParsingError("Count < 0 for fixed size VCF header field " + name); } try { type = (VCFHeaderLineType)Enum.Parse(typeof(VCFHeaderLineType), mapping["Type"]); } #pragma warning disable 0168 catch (Exception e) #pragma warning restore 0168 { throw new VCFParsingError(mapping["Type"] + " is not a valid type in the VCF specification (note that types are case-sensitive)"); } if (type == VCFHeaderLineType.Flag && !allowFlagValues()) { throw new ArgumentException("Flag is an unsupported type for this kind of field"); } description = mapping["Description"]; if (description == null && ALLOW_UNBOUND_DESCRIPTIONS) // handle the case where there's no description provided { description = UNBOUND_DESCRIPTION; } this.lineType = lineType; validate(); }
/// <summary> /// create a VCF info header line /// </summary> /// <param name="line"> the header line </param> /// <param name="version"> the vcf header version </param> /// <param name="key"> the key for this header line </param> /// <param name="expectedTagOrdering"> the tag ordering expected for this header line </param> public VCFSimpleHeaderLine(string line, VCFHeaderVersion version, string key, params string[] expectedTagOrdering) : this(key, VCFHeaderLineTranslator.parseLine(version, line, expectedTagOrdering), expectedTagOrdering) { }