/// <param name="reader"> the line reader to take header lines from </param> /// <returns> the number of header lines </returns> public virtual VCFHeader readHeader(StreamReader reader) { IList <string> headerStrings = new List <string>(); string line; try { bool foundHeaderVersion = false; while ((line = reader.ReadLine()) != null) { lineNo++; if (line.StartsWith(VCFHeader.METADATA_INDICATOR)) { string[] lineFields = line.Substring(2).Split('='); if (lineFields.Length == 2 && VCFHeaderVersion.IsFormatString(lineFields[0])) { if (!VCFHeaderVersion.IsVersionString(lineFields[1])) { throw new VCFParsingError("Header: " + lineFields[1] + " is not a supported version"); } foundHeaderVersion = true; version = VCFHeaderVersion.ToHeaderVersion(lineFields[1]); if (!this.AcceptableVersions.Contains(version)) { throw new VCFParsingError("This codec is strictly for " + Name + "; please use a different codec for " + lineFields[1]); } } headerStrings.Add(line); } else if (line.StartsWith(VCFHeader.HEADER_INDICATOR)) {//should be only one such line if (!foundHeaderVersion) { throw new VCFParsingError("We never saw a header line specifying VCF version"); } headerStrings.Add(line); return(parseHeaderFromLines(headerStrings, version)); } else { throw new VCFParsingError("We never saw the required CHROM header line (starting with one #) for the input VCF file"); } } } catch (IOException e) { throw new Exception("IO Exception ", e); } throw new VCFParsingError("We never saw the required CHROM header line (starting with one #) for the input VCF file"); }