/// <summary>
        /// Phylogenetic Tree Formatter General Tests
        /// </summary>
        /// <param name="nodeName">Xml node Name.</param>
        /// <param name="formatParam">Additional parameter</param>
        void PhylogeneticTreeFormatterGeneralTests(string nodeName,
            FormatterParameters formatParam)
        {
            // Gets the expected sequence from the Xml
            string filePath = string.Empty;

            NewickParser parser = new NewickParser();
            {
                Tree rootTree;

                switch (formatParam)
                {
                    case FormatterParameters.Object:
                        rootTree = GetFormattedObject();
                        break;
                    default:
                        filePath = _utilityObj.xmlUtil.GetTextValue(nodeName,
                         Constants.FilePathNode);
                        Assert.IsTrue(File.Exists(filePath));

                        // Logs information to the log file
                        ApplicationLog.WriteLine(string.Format((IFormatProvider)null,
                            "Phylogenetic Tree Parser BVT: File Exists in the Path '{0}'.",
                            filePath));

                        rootTree = parser.Parse(filePath);
                        break;
                }

                string outputFilepath = _utilityObj.xmlUtil.GetTextValue(nodeName,
                         Constants.OutputFilePathNode);

                NewickFormatter format = new NewickFormatter();
                switch (formatParam)
                {
                    case FormatterParameters.Stream:
                        using (var writer = File.Create(outputFilepath))
                        {
                            format.Format(writer, rootTree);
                        }
                        break;
                    case FormatterParameters.FormatString:
                        // Validate format String
                        var formatString = format.FormatString(rootTree);

                        string expectedFormatString =
                            _utilityObj.xmlUtil.GetTextValue(nodeName,
                            Constants.FormatStringNode);

                        Assert.AreEqual(expectedFormatString, formatString);

                        ApplicationLog.WriteLine(string.Format((IFormatProvider)null,
                            "Phylogenetic Tree Parser BVT: Format string '{0}' is as expected.",
                            formatString));
                        break;
                    default:
                        format.Format(rootTree, outputFilepath);
                        break;
                }

                // Validate only if not a Format String
                if (FormatterParameters.FormatString != formatParam)
                {
                    // Re-parse the created file and validate the tree.
                    NewickParser newparserObj = new NewickParser();
                    {
                        Tree newrootTreeObj = null;

                        Assert.IsTrue(File.Exists(outputFilepath));

                        // Logs information to the log file
                        ApplicationLog.WriteLine(string.Format((IFormatProvider)null,
                            "Phylogenetic Tree Parser BVT: New File Exists in the Path '{0}'.",
                            outputFilepath));

                        newrootTreeObj = newparserObj.Parse(outputFilepath);

                        Node rootNode = newrootTreeObj.Root;

                        string rootBranchCount = _utilityObj.xmlUtil.GetTextValue(nodeName,
                           Constants.RootBranchCountNode);

                        // Validate the root branch count
                        Assert.AreEqual(rootBranchCount,
                            rootNode.Children.Count.ToString((IFormatProvider)null));

                        ApplicationLog.WriteLine(string.Format((IFormatProvider)null,
                            "Phylogenetic Tree Parser BVT: Number of Root Branches found are '{0}'.",
                            rootNode.Children.Count.ToString((IFormatProvider)null)));

                        List<string> leavesName = new List<string>();
                        List<double> leavesDistance = new List<double>();

                        // Gets all the leaves in the root node list
                        GetAllNodesAndEdges(rootNode, ref leavesName, ref leavesDistance);

                        string[] expectedLeavesName = _utilityObj.xmlUtil.GetTextValue(nodeName,
                           Constants.NodeNamesNode).Split(',');

                        string[] expectedLeavesDistance = _utilityObj.xmlUtil.GetTextValue(nodeName,
                           Constants.EdgeDistancesNode).Split(',');

                        for (int i = 0; i < expectedLeavesName.Length; i++)
                        {
                            Assert.AreEqual(expectedLeavesName[i], leavesName[i]);
                        }

                        for (int i = 0; i < expectedLeavesDistance.Length; i++)
                        {
                            Assert.AreEqual(expectedLeavesDistance[i],
                                leavesDistance[i].ToString((IFormatProvider)null));
                        }
                    }

                    ApplicationLog.WriteLine(
                        "Phylogenetic Tree Parser BVT: The Node Names and Distance are as expected.");
                }

                if (File.Exists(outputFilepath))
                    File.Delete(outputFilepath);
            }
        }
        /// <summary>
        /// Phylogenetic Tree Parsers General Tests
        /// </summary>
        /// <param name="nodeName">Xml node Name.</param>
        /// <param name="addParam">Additional parameter</param>
        void PhylogeneticTreeParserGeneralTests(string nodeName, AdditionalParameters addParam)
        {
            // Gets the expected sequence from the Xml
            string filePath = _utilityObj.xmlUtil.GetTextValue(nodeName,
                Constants.FilePathNode);

            Assert.IsTrue(File.Exists(filePath));

            NewickParser parser = new NewickParser();
            {
                Tree rootTree = null;

                switch (addParam)
                {
                    case AdditionalParameters.Stream:
                        using (var reader = File.OpenRead(filePath))
                        {
                            rootTree = parser.Parse(reader);
                        }
                        break;
                    case AdditionalParameters.StringBuilder:
                        using (StreamReader reader = File.OpenText(filePath))
                        {
                            StringBuilder strBuilderObj = new StringBuilder(reader.ReadToEnd());
                            rootTree = parser.Parse(strBuilderObj);
                        }
                        break;
                    default:
                        rootTree = parser.Parse(filePath);
                        break;
                }

                Node rootNode = rootTree.Root;

                string rootBranchCount = _utilityObj.xmlUtil.GetTextValue(nodeName,
                    Constants.RootBranchCountNode);

                // Validate the root branch count
                Assert.AreEqual(rootBranchCount,
                    rootNode.Children.Count.ToString((IFormatProvider)null));

                ApplicationLog.WriteLine(string.Format((IFormatProvider)null,
                    "Phylogenetic Tree Parser BVT: Number of Root Branches found are '{0}'.",
                    rootNode.Children.Count.ToString((IFormatProvider)null)));

                List<string> leavesName = new List<string>();
                List<double> leavesDistance = new List<double>();

                // Gets all the nodes and edges
                GetAllNodesAndEdges(rootNode, ref leavesName, ref leavesDistance);

                string[] expectedLeavesName = _utilityObj.xmlUtil.GetTextValue(nodeName,
                    Constants.NodeNamesNode).Split(',');

                string[] expectedLeavesDistance = _utilityObj.xmlUtil.GetTextValue(nodeName,
                    Constants.EdgeDistancesNode).Split(',');

                for (int i = 0; i < expectedLeavesName.Length; i++)
                {
                    Assert.AreEqual(expectedLeavesName[i], leavesName[i]);
                }

                for (int i = 0; i < expectedLeavesDistance.Length; i++)
                {
                    Assert.AreEqual(expectedLeavesDistance[i],
                        leavesDistance[i].ToString((IFormatProvider)null));
                }

            }
            ApplicationLog.WriteLine(
                "Phylogenetic Tree Parser BVT: The Node Names and Distance are as expected.");
        }
 public void TestNamesOnInternalNodes()
 {
     const string filename = @"TestUtils\\positives.newick";
     var parser = new NewickParser();
     var tree = parser.Parse(filename);
     Assert.AreEqual(3, tree.Root.Children.Count);
 }
        public void PhylogeneticTreeBvtParserValidateNewickExtended()
        {
            NewickParser parser = new NewickParser();
            {
                using (var reader = File.OpenRead(@"TestUtils\NewickExtended.nhx"))
                {
                    Tree rootTree = parser.Parse(reader);

                    //Verify metadata at root
                    Assert.AreEqual("40",rootTree.Root.MetaData["N"]);
                    //Verify name at root
                    Assert.AreEqual("Euteleostomi",rootTree.Root.Name);
                    //now verify it also worked for a somewhat arbitrary internal node
                    var internalNode = rootTree.Root.Children.Keys.First().Children.Keys.First();
                    Assert.AreEqual("Tetrapoda", internalNode.Name);
                    Assert.AreEqual("0.00044378",internalNode.MetaData["PVAL"]);
                    Assert.AreEqual(8,internalNode.MetaData.Count);
                }
                
            }
        }
 public void PhylogeneticTreeP2ParserInvalidateParseBuilder()
 {
     try
     {
         NewickParser nwParserObj = new NewickParser();
         {
             nwParserObj.Parse((Stream)null);
         }
         Assert.Fail();
     }
     catch (ArgumentNullException)
     {
         ApplicationLog.WriteLine(
            "GFF Parser P2 : All the features validated successfully.");
     }
 }
        /// <summary>
        /// General method to invalidate Newick Parser.
        /// <param name="nodeName">xml node name.</param>
        /// <param name="method">Newick Parse method parameters</param>
        /// </summary>        
        void PhylogeneticTreeParserGeneralTests(
            string nodeName,
            AdditionalParameters method)
        {
            try
            {
                string filePath = _utilityObj.xmlUtil.GetTextValue(nodeName, Constants.FilePathNode);
                switch (method)
                {
                    case AdditionalParameters.TextReader:
                        using (var reader = File.OpenRead(filePath))
                        {
                            NewickParser nwParserObj = new NewickParser();
                            nwParserObj.Parse(reader);
                        }
                        break;
                    case AdditionalParameters.StringBuilder:
                        using (var reader = new StreamReader(filePath))
                        {
                            NewickParser nwParserObj = new NewickParser();
                            StringBuilder strBuilderObj = new StringBuilder(reader.ReadToEnd());
                            nwParserObj.Parse(strBuilderObj);
                        }
                        break;
                    default:
                        break;
                }

                Assert.Fail();
            }
            catch (FormatException)
            {
                ApplicationLog.WriteLine(
                    "GFF Parser P2 : All the features validated successfully.");
            }
        }