コード例 #1
0
        /// <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();
        }
コード例 #2
0
 /// <summary>
 /// create a VCF format header line
 /// </summary>
 /// <param name="name">         the name for this header line </param>
 /// <param name="count">        the count type for this header line </param>
 /// <param name="type">         the type for this header line </param>
 /// <param name="description">  the description for this header line </param>
 /// <param name="lineType">     the header line type </param>
 protected internal VCFCompoundHeaderLine(string name, VCFHeaderLineCount count, VCFHeaderLineType type, string description, SupportedHeaderLineType lineType) : base(lineType.ToString(), "")
 {
     this.name        = name;
     this.countType   = count;
     this.type        = type;
     this.description = description;
     this.lineType    = lineType;
     validate();
 }
コード例 #3
0
ファイル: VCFInfoHeaderLine.cs プロジェクト: w3he/Bio.VCF
		public VCFInfoHeaderLine(string name, VCFHeaderLineCount count, VCFHeaderLineType type, string description) : base(name, count, type, description, SupportedHeaderLineType.INFO)
		{
		}
コード例 #4
0
ファイル: VCFCompoundHeaderLine.cs プロジェクト: w3he/Bio.VCF
		/// <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_ALLELE_COUNT))
			{
				countType = VCFHeaderLineCount.A;
			}
			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"]);
			}
			catch (Exception e)
			{
				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 System.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();
		}
コード例 #5
0
ファイル: VCFCompoundHeaderLine.cs プロジェクト: w3he/Bio.VCF
		/// <summary>
		/// create a VCF format header line
		/// </summary>
		/// <param name="name">         the name for this header line </param>
		/// <param name="count">        the count type for this header line </param>
		/// <param name="type">         the type for this header line </param>
		/// <param name="description">  the description for this header line </param>
		/// <param name="lineType">     the header line type </param>
		protected internal VCFCompoundHeaderLine(string name, VCFHeaderLineCount count, VCFHeaderLineType type, string description, SupportedHeaderLineType lineType) : base(lineType.ToString(), "")
		{
			this.name = name;
			this.countType = count;
			this.type = type;
			this.description = description;
			this.lineType = lineType;
			validate();
		}
コード例 #6
0
ファイル: VCFCompoundHeaderLine.cs プロジェクト: w3he/Bio.VCF
		public virtual void setNumberToUnbounded()
		{
			countType = VCFHeaderLineCount.UNBOUNDED;
			count = -1;
		}
コード例 #7
0
 public VCFFormatHeaderLine(string name, VCFHeaderLineCount count, VCFHeaderLineType type, string description)
     : base(name, count, type, description, SupportedHeaderLineType.FORMAT)
 {
 }
コード例 #8
0
ファイル: VCFFormatHeaderLine.cs プロジェクト: w3he/Bio.VCF
		public VCFFormatHeaderLine(string name, VCFHeaderLineCount count, VCFHeaderLineType type, string description) 
            : base(name, count, type, description, SupportedHeaderLineType.FORMAT)
		{
		}
コード例 #9
0
 public virtual void setNumberToUnbounded()
 {
     countType = VCFHeaderLineCount.UNBOUNDED;
     count     = -1;
 }
コード例 #10
0
 public VCFInfoHeaderLine(string name, VCFHeaderLineCount count, VCFHeaderLineType type, string description) : base(name, count, type, description, SupportedHeaderLineType.INFO)
 {
 }