Esempio n. 1
0
        /// <summary>
        /// returns true if we're equal to another compounder header line </summary>
        /// <param name="o"> a compound header line </param>
        /// <returns> true if equal </returns>
        public override bool Equals(object o)
        {
            if (!(o is VCFCompoundHeaderLine))
            {
                return(false);
            }
            VCFCompoundHeaderLine other = (VCFCompoundHeaderLine)o;

            return(equalsExcludingDescription(other) && description.Equals(other.description));
        }
Esempio n. 2
0
        public static VCFCompoundHeaderLine GetMetaDataForField(VCFHeader header, string field)
        {
            VCFCompoundHeaderLine metaData = header.getFormatHeaderLine(field);

            if (metaData == null)
            {
                metaData = header.getInfoHeaderLine(field);
            }
            if (metaData == null)
            {
                throw new VCFParsingError("Fully decoding VariantContext requires header line for all fields, but none was found for " + field);
            }
            return(metaData);
        }
Esempio n. 3
0
		private object decodeOne (string field, string str, VCFCompoundHeaderLine format)
		{
			try {
				if (str.Equals (VCFConstants.MISSING_VALUE_v4)) {
					return null;
				} else {
					switch (format.Type) {
					case VCFHeaderLineType.Character:
						return str;
					case VCFHeaderLineType.Flag:
						bool b = Convert.ToBoolean (str) || str.Equals ("1");
						if (b == false) {
							throw new VCFParsingError ("VariantContext FLAG fields " + field + " cannot contain false values" + " as seen at " + Chr + ":" + Start);
						}
						return b;
					case VCFHeaderLineType.String:
						return str;
					case VCFHeaderLineType.Integer:
						return Convert.ToInt32 (str);
					case VCFHeaderLineType.Float:
						return Convert.ToDouble (str);
					default:
						throw new VCFParsingError ("Unexpected type for field" + field);
					}
				}
			} catch (FormatException e) {
				throw new VCFParsingError ("Could not decode field " + field + " with value " + str + " of declared type " + format.Type);
			}
		}
Esempio n. 4
0
		private object decodeValue (string field, object value, VCFCompoundHeaderLine format)
		{
			if (value is string) {
				if (field.Equals (VCFConstants.GENOTYPE_PL_KEY)) {
					return GenotypeLikelihoods.fromPLField ((string)value);
				}

				string str = (string)value;
				if (str.IndexOf (',') != -1) {
					string[] splits = str.Split (new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
					IList<object> values = new List<object> (splits.Length);
					for (int i = 0; i < splits.Length; i++) {
						values.Add (decodeOne (field, splits [i], format));
					}
					return values;
				} else {
					return decodeOne (field, str, format);
				}
			} else if (value is IList && (((IList)value) [0]) is string) {
				IList<string> asList = (IList<string>)value;
				IList<object> values = new List<object> (asList.Count);
				foreach (String s in asList) {
					values.Add (decodeOne (field, s, format));
				}
				return values;
			} else {
				return value;
			}

			// allowMissingValuesComparedToHeader
		}
Esempio n. 5
0
		public virtual bool sameLineTypeAndName(VCFCompoundHeaderLine other)
		{
			return lineType == other.lineType && name.Equals(other.name);
		}
Esempio n. 6
0
		public virtual bool equalsExcludingDescription(VCFCompoundHeaderLine other)
		{
			return count == other.count && countType == other.countType && type == other.type && lineType == other.lineType && name.Equals(other.name);
		}
Esempio n. 7
0
 public virtual bool sameLineTypeAndName(VCFCompoundHeaderLine other)
 {
     return(lineType == other.lineType && name.Equals(other.name));
 }
Esempio n. 8
0
 public virtual bool equalsExcludingDescription(VCFCompoundHeaderLine other)
 {
     return(count == other.count && countType == other.countType && type == other.type && lineType == other.lineType && name.Equals(other.name));
 }