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