Exemplo n.º 1
0
        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");
        }
Exemplo n.º 2
0
        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);
        }