public void XsvSparseParseContig() { // Gets the expected file from the Xml string filePathObj = utilityObj.xmlUtil.GetTextValue( Constants.SimpleXsvSparseNodeName, Constants.FilePathNode); Assert.IsTrue(File.Exists(filePathObj)); // Logs information to the log file ApplicationLog.WriteLine(string.Format((IFormatProvider)null, "XsvSparse Formatter BVT: File Exists in the Path '{0}'.", filePathObj)); using (XsvContigParser parserObj = new XsvContigParser(filePathObj, Alphabets.DNA, ',', '#')) { parserObj.Parse(); Contig contig = parserObj.ParseContig(); // Validate parsed temp file with original Xsv file. Assert.AreEqual(26048682, contig.Length); Assert.AreEqual(26048682, contig.Consensus.Count); Assert.AreEqual("Chr22+Chr22+Chr22+Chr22", contig.Consensus.ID); Assert.AreEqual(56, contig.Sequences.Count); } // Log to GUI. Console.WriteLine("Successfully validated the ParseConting() method with Xsv file"); ApplicationLog.WriteLine("Successfully validated the ParseConting() method with Xsv file"); }
public void XsvSparseContigFormatterWrite() { // Gets the expected sequence from the Xml string filePathObj = utilityObj.xmlUtil.GetTextValue( Constants.SimpleXsvSparseNodeName, Constants.FilePathNode); Assert.IsTrue(File.Exists(filePathObj)); // Logs information to the log file ApplicationLog.WriteLine(string.Format((IFormatProvider)null, "Xsv Contig Formatter BVT: File Exists in the Path '{0}'.", filePathObj)); Contig contig, expectedContig; using (XsvContigParser parserObj = new XsvContigParser(filePathObj, Alphabets.DNA, ',', '#')) { contig = parserObj.ParseContig(); } string seqId = string.Empty; foreach (Contig.AssembledSequence seq in contig.Sequences) { seqId += seq.Sequence.ID + ","; } // Write Xsv file. using (XsvContigFormatter formatObj = new XsvContigFormatter(Constants.XsvTempFileName, ',', '#')) { formatObj.Write(contig); } using (XsvContigParser parserObjNew = new XsvContigParser(Constants.XsvTempFileName, Alphabets.DNA, ',', '#')) { expectedContig = parserObjNew.ParseContig(); } string expectedseqId = string.Empty; foreach (Contig.AssembledSequence seq in expectedContig.Sequences) { expectedseqId += seq.Sequence.ID + ","; } // Validate parsed temp file with original Xsv file. Assert.AreEqual(contig.Length, expectedContig.Length); Assert.AreEqual(contig.Consensus.Count, expectedContig.Consensus.Count); Assert.AreEqual(contig.Consensus.ID, expectedContig.Consensus.ID); Assert.AreEqual(contig.Sequences.Count, expectedContig.Sequences.Count); Assert.AreEqual(seqId.Length, expectedseqId.Length); Assert.AreEqual(seqId, expectedseqId); // Log to VSTest GUI. Console.WriteLine("Successfully validated the Write Xsv file"); ApplicationLog.WriteLine("Successfully validated the Write Xsv file"); }
public void XsvContigFormatter() { // Gets the expected sequence from the Xml string filePathObj = Directory.GetCurrentDirectory() + XsvFilename; string XsvTempFileName = Path.GetTempFileName(); Assert.IsTrue(File.Exists(filePathObj)); XsvContigParser parserObj = new XsvContigParser(filePathObj, Alphabets.DNA, ',', '#'); Contig contig, expectedContig; contig = parserObj.ParseContig(); string seqId = string.Empty; foreach (Contig.AssembledSequence seq in contig.Sequences) { seqId += seq.Sequence.ID + ","; } // Format Xsv file. XsvContigFormatter formatObj = new XsvContigFormatter(XsvTempFileName, ',', '#'); formatObj.Write(contig); formatObj.Close(); formatObj.Dispose(); XsvContigParser parserObj1 = new XsvContigParser(XsvTempFileName, Alphabets.DNA, ',', '#'); expectedContig = parserObj1.ParseContig(); string expectedseqId = string.Empty; foreach (Contig.AssembledSequence seq in expectedContig.Sequences) { expectedseqId += seq.Sequence.ID + ","; } // Validate parsed temp file with original Xsv file. Assert.AreEqual(contig.Length, expectedContig.Length); Assert.AreEqual(contig.Consensus.Count, expectedContig.Consensus.Count); Assert.AreEqual(contig.Consensus.ID, expectedContig.Consensus.ID); Assert.AreEqual(contig.Sequences.Count, expectedContig.Sequences.Count); Assert.AreEqual(seqId.Length, expectedseqId.Length); Assert.AreEqual(seqId, expectedseqId); }
public void XsvSparseContigFormatterWrite() { // Gets the expected sequence from the Xml string filePathObj = this.utilityObj.xmlUtil.GetTextValue( Constants.SimpleXsvSparseNodeName, Constants.FilePathNode).TestDir(); Assert.IsTrue(File.Exists(filePathObj)); // Logs information to the log file ApplicationLog.WriteLine(string.Format((IFormatProvider)null, "Xsv Contig Formatter BVT: File Exists in the Path '{0}'.", filePathObj)); Contig expectedContig; XsvContigParser parserObj = new XsvContigParser(Alphabets.DNA, ',', '#'); Contig contig = parserObj.ParseContig(filePathObj); string seqId = contig.Sequences.Aggregate(string.Empty, (current, seq) => current + (seq.Sequence.ID + ",")); // Write Xsv file. XsvContigFormatter formatObj = new XsvContigFormatter(',', '#'); formatObj.Format(contig, Constants.XsvTempFileName); XsvContigParser parserObjNew = new XsvContigParser(Alphabets.DNA, ',', '#'); expectedContig = parserObjNew.ParseContig(Constants.XsvTempFileName); string expectedseqId = expectedContig.Sequences.Aggregate(string.Empty, (current, seq) => current + (seq.Sequence.ID + ",")); // Validate parsed temp file with original Xsv file. Assert.AreEqual(contig.Length, expectedContig.Length); Assert.AreEqual(contig.Consensus.Count, expectedContig.Consensus.Count); Assert.AreEqual(contig.Consensus.ID, expectedContig.Consensus.ID); Assert.AreEqual(contig.Sequences.Count, expectedContig.Sequences.Count); Assert.AreEqual(seqId.Length, expectedseqId.Length); Assert.AreEqual(seqId, expectedseqId); File.Delete(Constants.XsvTempFileName); ApplicationLog.WriteLine("Successfully validated the Write Xsv file"); }
public void XsvSparseContigFormatterFormat() { // Gets the expected sequence from the Xml string filePathObj = Utility._xmlUtil.GetTextValue( Constants.SimpleXsvSparseNodeName, Constants.FilePathNode); Assert.IsTrue(File.Exists(filePathObj)); // Logs information to the log file ApplicationLog.WriteLine(string.Format(null, "XsvSparse Formatter BVT: File Exists in the Path '{0}'.", filePathObj)); IEncoding encode = Encodings.IupacNA; XsvContigParser parserObj = new XsvContigParser(encode, Alphabets.DNA, ',', '#'); Contig contig, expectedContig; // Parse a file. using (TextReader tr = new StreamReader(File.OpenRead(filePathObj))) { contig = parserObj.ParseContig(tr, false); } string seqId = string.Empty; foreach (Contig.AssembledSequence seq in contig.Sequences) { seqId += seq.Sequence.ID + ","; } // Format Xsv file. XsvContigFormatter formatObj = new XsvContigFormatter(',', '#'); using (TextWriter tw = new StreamWriter(File.OpenWrite( Constants.XsvTempFileName))) { formatObj.Format(contig, tw); } // Parse formatted TempFile. using (TextReader tr = new StreamReader( File.OpenRead(Constants.XsvTempFileName))) { expectedContig = parserObj.ParseContig(tr, false); } string expectedseqId = string.Empty; foreach (Contig.AssembledSequence seq in expectedContig.Sequences) { expectedseqId += seq.Sequence.ID + ","; } // Validate parsed temp file with original Xsv file. Assert.AreEqual(contig.Length, expectedContig.Length); Assert.AreEqual(contig.Consensus.Count, expectedContig.Consensus.Count); Assert.AreEqual(contig.Consensus.DisplayID, expectedContig.Consensus.DisplayID); Assert.AreEqual(contig.Consensus.ID, expectedContig.Consensus.ID); Assert.AreEqual(contig.Sequences.Count, expectedContig.Sequences.Count); Assert.AreEqual(seqId.Length, expectedseqId.Length); Assert.AreEqual(seqId, expectedseqId); // Log to Nunit GUI. Console.WriteLine("Successfully validated the format Xsv file"); ApplicationLog.WriteLine("Successfully validated the format Xsv file"); }