public void XsvBvtSnpReaderSkipToChromosomePosition() { // Gets the expected sequence from the Xml string filePath = _utilityObj._xmlUtil.GetTextValue(Constants.SimpleSnpNodeName, Constants.FilePathNode); Assert.IsTrue(File.Exists(filePath)); // Logs information to the log file ApplicationLog.WriteLine(string.Format((IFormatProvider)null, "XsvSnpReader BVT: File Exists in the Path '{0}'.", filePath)); using (StreamReader strReaderObj = new StreamReader(filePath)) { XsvSnpReader rdr = new XsvSnpReader( strReaderObj, new Char[1] { '\t' }, false, true, 0, 1, 2, 3); // Validate with IsChromosomeSorted and IsChromosomePositionStarted set to false rdr.MoveNext(); Assert.IsFalse(rdr.SkipToChromosomePosition(0)); // Validates the Comment Line Property Assert.IsNull(rdr.CommentLine); rdr.Dispose(); using (StreamReader strRdrObj = new StreamReader(filePath)) { rdr = new XsvSnpReader(strRdrObj, new Char[1] { '\t' }, false, true, 0, 1, 2, 3); rdr.MoveNext(); rdr.IsChromosomeSorted = true; // Validate with IsChromosomeSorted property set Assert.IsFalse(rdr.SkipToChromosomePosition(0, 0)); rdr.MoveNext(); rdr.IsChromosomePositionSorted = true; // Validate with IsChromosomePositionSorted property set Assert.IsFalse(rdr.SkipToChromosomePosition(0, 0)); // Logs information to the log file ApplicationLog.WriteLine( "XsvSnpReader BVT: Successfully validated the SkipToChromosomePosition() method"); Console.WriteLine( "XsvSnpReader BVT: Successfully validated the SkipToChromosomePosition() method"); } } }
/// <summary> /// Parses a list of sparse sequences from the reader, one per contiguous /// chromosome present in the reader. There is one SequenceItem per SnpItem with /// either of the two alleles in the SnpItem (determined by the ParseAlleleOne property) /// and at the same position in the sequence as the SnpItem.Position. /// </summary> /// <returns>Returns a list of sparse sequences containing Snp items that were read /// from the reader, one sequence per contiguous chromosome number and /// retaining the same position in the sequence as the chromosome position.</returns> public IEnumerable <ISequence> Parse() { if (this.Filename == null) { throw new FieldAccessException("Filename"); } if (this.Alphabet == null) { this.Alphabet = AmbiguousDnaAlphabet.Instance; } using (StreamReader txtReader = new StreamReader(this.Filename)) { ISnpReader snpReader = new XsvSnpReader(txtReader, new[] { '\t' }, true, true, 0, 1, 2, 3); snpReader.MoveNext(); List <ISequence> sequenceList = new List <ISequence>(); while (snpReader.Current != null) { sequenceList.Add(ParseOne(snpReader)); } return(sequenceList); } }
/// <summary> /// Parses a list of sparse sequences from the reader, one per contiguous /// chromosome present in the reader. There is one SequenceItem per SnpItem with /// either of the two alleles in the SnpItem (determined by the ParseAlleleOne property) /// and at the same position in the sequence as the SnpItem.Position. /// </summary> /// <param name="stream">Stream to be parsed.</param> /// <returns>Returns a list of sparse sequences containing Snp items that were read /// from the reader, one sequence per contiguous chromosome number and /// retaining the same position in the sequence as the chromosome position.</returns> public IEnumerable <ISequence> Parse(Stream stream) { if (this.Alphabet == null) { this.Alphabet = AmbiguousDnaAlphabet.Instance; } using (var reader = new StreamReader(stream)) { ISnpReader snpReader = new XsvSnpReader(reader, new[] { '\t' }, true, true, 0, 1, 2, 3); snpReader.MoveNext(); while (snpReader.Current != null) { yield return(ParseOne(snpReader)); } } }