Exemple #1
0
        public DepthOnleElementModel readDepthOneElementInput(string path)
        {
            string readText             = string.Empty;
            var    pattern              = @"\{(.*?)\}";
            DepthOnleElementModel model = new DepthOnleElementModel();

            if (File.Exists(path))
            {
                readText = File.ReadAllText(path);
            }
            else
            {
                return(new DepthOnleElementModel());
            }
            if (!string.IsNullOrEmpty(readText))
            {
                var             matches   = Regex.Matches(readText, pattern);
                List <TreeNode> TreeNodes = new List <TreeNode>();
                TreeNode        node;
                int             i = 1;
                foreach (Match m in matches)
                {
                    string   values = m.Groups[1].Value.Trim();
                    string[] array  = values.Split(',');

                    node           = new TreeNode();
                    node._Position = i;
                    List <Taxa> taxas = new List <Taxa>();
                    foreach (string v in array)
                    {
                        Taxa t = new Taxa();
                        t._Taxa_Value = v.Trim();
                        taxas.Add(t);
                    }
                    if (taxas.Count != 0)
                    {
                        node.TaxaList = taxas;
                        TreeNodes.Add(node);
                    }
                    i++;
                }

                if (TreeNodes.Count != 0)
                {
                    model.NodeList = new List <TreeNode>(TreeNodes);
                }
            }

            return(model);
        }
Exemple #2
0
        public void CalculateFinalTree()
        {
            DepthOnleElementModel model = new DepthOnleElementModel();
            List <TreeNode>       nodes = new List <TreeNode>();
            List <Taxa>           tx    = new List <Taxa>();
            TreeNode node = new TreeNode();

            string checkTaxa = string.Empty;

            foreach (Pair p in ListOfPairWithWrongTaxa)
            {
                if (p.tx1 == p.wrongTaxa)
                {
                    checkTaxa = p.tx2;
                }
                else
                {
                    checkTaxa = p.tx1;
                }

                Taxa t1    = getTaxa(checkTaxa);
                int  p1    = getPosition(t1);
                Taxa wTaxa = getTaxa(p.wrongTaxa);

                foreach (TreeNode n in depth1Elements.NodeList)
                {
                    if (n._Position == p1)
                    {
                        n.TaxaList.Add(wTaxa);
                        break;
                    }
                }
            }

            OutputProcessing.printDepthOneWithNewDuplicationMethod(PathOutputAfterNewDuplication, depth1Elements.NodeList);
            OutputProcessing.printWrongPositionedTaxa(PathOutputForWrongPositionedTaxa, ListOfPairWithWrongTaxa);
        }
Exemple #3
0
        /*
         * public FinalPartition readFinalPartitionInput(string path)
         * {
         *
         *  string readText = string.Empty;
         *  var pattern = @"\{(.*?)\}";
         *  FinalPartition model = new FinalPartition();
         *  if (File.Exists(path))
         *  {
         *      readText = File.ReadAllText(path);
         *
         *  }
         *  else
         *  {
         *      return new FinalPartition();
         *  }
         *  if (!string.IsNullOrEmpty(readText))
         *  {
         *      var matches = Regex.Matches(readText, pattern);
         *      List<TreeNode> TreeNodes = new List<TreeNode>();
         *      TreeNode node;
         *      int i = 1;
         *      int count = 0;
         *      foreach (Match m in matches)
         *      {
         *          TreeNodes = new List<TreeNode>();
         *          string values = m.Groups[1].Value.Trim();
         *          string[] array = values.Split(',');
         *
         *          node = new TreeNode();
         *          node._Position = i;
         *          List<Taxa> taxas = new List<Taxa>();
         *          foreach (string v in array)
         *          {
         *
         *              Taxa t = new Taxa();
         *              t._Taxa_Value = v.Trim();
         *              taxas.Add(t);
         *
         *          }
         *          if (taxas.Count != 0)
         *          {
         *              node.TaxaList = taxas;
         *              TreeNodes.Add(node);
         *          }
         *
         *          if (TreeNodes.Count != 0 && count == 0)
         *          {
         *              model.LeftPart = new List<TreeNode>(TreeNodes);
         *          }
         *          if (TreeNodes.Count != 0 && count == 1)
         *          {
         *              model.RightPart = new List<TreeNode>(TreeNodes);
         *          }
         *
         *          i++;
         *          count++;
         *      }
         *
         *
         *
         *  }
         *
         *  return model;
         *
         *
         * }
         */
        #endregion

        //Constructor
        public NewDuplicationCalculation()
        {
            depth1Elements     = readDepthOneElementInput(PathDepthOne);
            ListOfInconsistent = readInconsistentQuatret(PathInconsistentQuatret);
            //finalPartitionAfterDepthOneElement = readFinalPartitionInput(PathFinalPartitionAfterDepthOne);
        }