コード例 #1
0
ファイル: Fraction.cs プロジェクト: uQlust/uQlust-ver3.0
        BestModel FindBestToModel(List<string> targets,DistanceMeasures distance,string dirName,string alignFile,string profileName,string model)
        {            
            BestModel vOut=new BestModel();
            List<string> localNames = new List<string>(2);
            List<string> fileNames = new List<string>(targets.Count);

            foreach (var item in targets)
                fileNames.Add(dirName + Path.DirectorySeparatorChar + item);

            fileNames.Add(model);

            //dist=PrepareDistance(distance,fileNames,alignFile,profileName);

            string[] aux = model.Split(Path.DirectorySeparatorChar);

            InitBestModel(distance, ref vOut);
            foreach (var item in targets)
            {
               /* localNames.Clear();
                localNames.Add(model);
                localNames.Add(item);
                dist = PrepareDistance(distance, fileNames, alignFile, profileName);*/
                int value=0;
                //value = dist.GetDistance(aux[aux.Length - 1], item);
                value = GetDist(distance, dirName, model, item);
                CheckBest(distance, value, item, ref vOut);
            }

            return vOut;
        }
コード例 #2
0
ファイル: Fraction.cs プロジェクト: uQlust/uQlust-ver3.0
        void InitBestModel(DistanceMeasures distance,ref BestModel model)
       {
           switch (distance)
           {
               case DistanceMeasures.HAMMING:
              
                   model.value = int.MinValue;
                   break;
               case DistanceMeasures.MAXSUB:
               case DistanceMeasures.RMSD:
               case DistanceMeasures.GDT_TS:
                   model.value = int.MaxValue;
                   break;
           }


       }
コード例 #3
0
ファイル: Fraction.cs プロジェクト: uQlust/uQlust-ver3.0
       void CheckBest(DistanceMeasures distance,int value,string item,ref BestModel best)
       {
           switch (distance)
           {
               case DistanceMeasures.HAMMING:        
                   if (best.value <= value)
                   {
                       best.value = value;
                       best.modelName = item;
                   }
                   break;
               case DistanceMeasures.MAXSUB:
               case DistanceMeasures.GDT_TS:
               case DistanceMeasures.RMSD:
                   if (best.value >= value)
                   {
                       best.value=value;
                       best.modelName = item;
                   }
                   break;
           }

       }
コード例 #4
0
ファイル: Fraction.cs プロジェクト: uQlust/uQlust-ver3.0
        public void GetFraction(object param)
        {

            float fraction = 0;
            float avrDiff=0;
            int counter = 0;
            int end;
            DistanceMeasures distance=((fractionParams)param).distance;
            string profileName = ((fractionParams)param).profileName;
            double distThreshold = ((fractionParams)param).distThreshold;
            int clustersNum = ((fractionParams)param).clustersNum;

            results = new DataTable();
            try
            {
                DataColumn col;
                col=results.Columns.Add("Output", typeof(string));
                col.AllowDBNull = true;
                col=results.Columns.Add("Best Model", typeof(string));
                col.AllowDBNull = true;
                col=results.Columns.Add("Distance To Native", typeof(double));
                col.AllowDBNull = true;
                col=results.Columns.Add("Best found", typeof(string));
                col.AllowDBNull = true;
                col=results.Columns.Add("Distance to best model", typeof(double));
                col.AllowDBNull = true;

                maxV = output.Count;
                foreach (var item in output)
                {
                    string[] kkk = item.dirName.Split(Path.DirectorySeparatorChar);
                    List<List<string>> clusters = item.GetClusters(10);

                    List<string> list = new List<string>();

                    foreach (var cl in clusters)
                        foreach (var target in cl)
                            list.Add(target);
                  
                    string native = item.dirName + ".pdb";
                    if (item.dirName.Contains("."))
                    {
                        string[] aux = item.dirName.Split('.');
                        native = aux[0] + ".pdb";
                    }



                    string fileBestModel = item.dirName + "_" + distance.ToString() + "_bestmodel.dat";
                    BestModel bestToNative;
                    if (!File.Exists(fileBestModel))
                    {
                        bestToNative = FindBestToModel(list, distance, item.dirName, "", "", native);
                        StreamWriter st = new StreamWriter(fileBestModel);
                        st.WriteLine(bestToNative.modelName + " " + bestToNative.value);
                        st.Close();
                    }
                    else
                    {
                        StreamReader st = new StreamReader(fileBestModel);
                        string line = st.ReadLine();
                        string[] aux = line.Split(' ');
                        bestToNative.modelName = aux[0];
                        bestToNative.value = Convert.ToInt32(aux[1], System.Globalization.CultureInfo.InvariantCulture);
                        st.Close();
                    }

                    if (bestToNative.value == int.MaxValue)
                        continue;

                   // list.Clear();

                    if (clusters.Count > 0)
                        clusters.Sort(delegate(List<string> first, List<string> second)
                        { return second.Count.CompareTo(first.Count); });

                    string represent = "";
                    //And now best five
                    
                    BestModel vOut = new BestModel();
                    InitBestModel(distance, ref vOut);
                    end = clustersNum;
                    if (clusters.Count < clustersNum)
                        end = clusters.Count;
                    for (int i = 0; i < end; i++)
                    //for (int i = 0; i < clusters.Count; i++)
                    {
                        if (profileName != null)
                            represent = CLusterRepresentJury(item.dirName, clusters[i], profileName)[0].Key;
                        else
                        {
                            if (item.juryLike != null)
                                represent = item.juryLike[i].Key;
                            else
                            {
                              /*  if (clusters.Count > 1)
                                {
                                    represent = CLusterRepresent(distance,item.dirName, clusters[i],"",profileName);                             
                                }
                                else*/
                                    represent = clusters[i][0];
                            }
                        }
                        int vDist = GetDist(distance, item.dirName, bestToNative.modelName, represent);
                        //int vDist = GetDist(distance, item.dirName, native, represent);
                        CheckBest(distance, vDist, represent, ref vOut);

                    }

                    if (bestToNative.value == errorValue || vOut.value == errorValue)
                    {
                        if (bestToNative.value == errorValue && vOut.value != errorValue)
                            results.Rows.Add(item.name, bestToNative.modelName, double.NaN, vOut.modelName, vOut.value / 100.0);
                        else
                            if(bestToNative.value != errorValue && vOut.value == errorValue)
                                results.Rows.Add(item.name, bestToNative.modelName, bestToNative.value / 100.0, vOut.modelName, double.NaN);
                            else
                                results.Rows.Add(item.name, bestToNative.modelName, double.NaN, vOut.modelName, double.NaN);
                    }
                    else
                        results.Rows.Add(item.name, bestToNative.modelName, bestToNative.value / 100.0, vOut.modelName, vOut.value / 100.0);
                    if (vOut.value!=errorValue && vOut.value-bestToNative.value < distThreshold * 100)
                    //if (vOut.value != errorValue && vOut.value < distThreshold * 100)
                    {
                        fraction++;
                    }
                    if (vOut.value!=errorValue)
                    {
                        counter++;
                        avrDiff += vOut.value;
                    }
                    //dist = null;
                    GC.Collect();

                    currentV++;

                }
                avrDiff /= counter;
                fraction /= counter;
                results.Rows.Add(null, null, null, null, null);
                results.Rows.Add("AVR:"," "+Math.Round(avrDiff / 100,2),null,"Fraction:",Math.Round(fraction,2));
            }
            catch(Exception ex)
            {
                exc = ex;
            }
           //Console.WriteLine("avrDiff=" + avrDiff + " fraction=" + fraction+" pearson="+Pearson());
            currentV = maxV;
        }
コード例 #5
0
ファイル: Fraction.cs プロジェクト: uQlust/uQlust-ver1.0
        public void GetFraction(object param)
        {

            float fraction = 0;
            float avrDiff=0;
            int counter = 0;
            int end;
            DistanceMeasures distance=((fractionParams)param).distance;
            string profileName = ((fractionParams)param).profileName;
            double distThreshold = ((fractionParams)param).distThreshold;
            int clustersNum = ((fractionParams)param).clustersNum;

            results = new DataTable();
            try
            {
                DataColumn col;
                col=results.Columns.Add("Output", typeof(string));
                col.AllowDBNull = true;
                col=results.Columns.Add("Best Model", typeof(string));
                col.AllowDBNull = true;
                col=results.Columns.Add("Distance To Native", typeof(double));
                col.AllowDBNull = true;
                col=results.Columns.Add("Best found", typeof(string));
                col.AllowDBNull = true;
                col=results.Columns.Add("Distance to best model", typeof(double));
                col.AllowDBNull = true;

                maxV = output.Count;
                foreach (var item in output)
                {
                    string[] kkk = item.dirName.Split(Path.DirectorySeparatorChar);
                    List<List<string>> clusters = item.GetClusters(10);

                    List<string> list = new List<string>();

                    foreach (var cl in clusters)
                        foreach (var target in cl)
                            list.Add(target);


                    string native = item.dirName + ".pdb";
                    if (item.dirName.Contains("."))
                    {
                        string[] aux = item.dirName.Split('.');
                        native = aux[0] + ".pdb";
                    }



                    string fileBestModel = item.dirName + "_" + distance.ToString() + "_bestmodel.dat";
                    BestModel bestToNative;
                    if (!File.Exists(fileBestModel))
                    {
                        bestToNative = FindBestToModel(list, distance, item.dirName, "", "", native);
                        StreamWriter st = new StreamWriter(fileBestModel);
                        st.WriteLine(bestToNative.modelName + " " + bestToNative.value);
                        st.Close();
                    }
                    else
                    {
                        StreamReader st = new StreamReader(fileBestModel);
                        string line = st.ReadLine();
                        string[] aux = line.Split(' ');
                        bestToNative.modelName = aux[0];
                        bestToNative.value = Convert.ToInt32(aux[1]);
                        st.Close();
                    }

                    if (bestToNative.value == int.MaxValue)
                        continue;

                   // list.Clear();

                    if (clusters.Count > 0)
                        clusters.Sort(delegate(List<string> first, List<string> second)
                        { return second.Count.CompareTo(first.Count); });

                    string represent = "";
                    //And now best five
                    
                    BestModel vOut = new BestModel();
                    InitBestModel(distance, ref vOut);
                    end = clustersNum;
                    if (clusters.Count < clustersNum)
                        end = clusters.Count;
                    for (int i = 0; i < end; i++)
                    //for (int i = 0; i < clusters.Count; i++)
                    {
                        if (profileName != null)
                            represent = CLusterRepresentJury(item.dirName, clusters[i], profileName)[0].Key;
                        else
                        {
                            if (item.juryLike != null)
                                represent = item.juryLike[i].Key;
                            else
                            {
                               /* if (clusters.Count > 1)
                                {
                                    represent = CLusterRepresent(distance,item.dirName, clusters[i],"",profileName);                             
                                }
                                else*/
                                    represent = clusters[i][0];
                            }
                        }
                        //int vDist = GetDist(distance, item.dirName, bestToNative.modelName, represent);
                        int vDist = GetDist(distance, item.dirName, native, represent);
                        CheckBest(distance, vDist, represent, ref vOut);

                    }

                    if (bestToNative.value == errorValue || vOut.value == errorValue)
                    {
                        if (bestToNative.value == errorValue && vOut.value != errorValue)
                            results.Rows.Add(item.name, bestToNative.modelName, double.NaN, vOut.modelName, vOut.value / 100.0);
                        else
                            if(bestToNative.value != errorValue && vOut.value == errorValue)
                                results.Rows.Add(item.name, bestToNative.modelName, bestToNative.value / 100.0, vOut.modelName, double.NaN);
                            else
                                results.Rows.Add(item.name, bestToNative.modelName, double.NaN, vOut.modelName, double.NaN);
                    }
                    else
                        results.Rows.Add(item.name, bestToNative.modelName, bestToNative.value / 100.0, vOut.modelName, vOut.value / 100.0);
                    if (vOut.value!=errorValue && Math.Abs(vOut.value-bestToNative.value) < distThreshold * 100)
                    {
                        fraction++;
                    }
                    if (vOut.value!=errorValue)
                    {
                        counter++;
                        avrDiff += vOut.value;
                    }
                    dist = null;
                    GC.Collect();

                    currentV++;

                }
                avrDiff /= counter;
                fraction /= counter;
                results.Rows.Add(null, null, null, null, null);
                results.Rows.Add("AVR:"," "+Math.Round(avrDiff / 100,2),null,"Fraction:",Math.Round(fraction,2));
            }
            catch(Exception ex)
            {
                exc = ex;
            }
           //Console.WriteLine("avrDiff=" + avrDiff + " fraction=" + fraction+" pearson="+Pearson());
            currentV = maxV;
        }
コード例 #6
0
ファイル: Fraction.cs プロジェクト: uQlust/uQlust-ver1.0
        BestModel FindBestToModel(List<string> targets,DistanceMeasures distance,string dirName,string alignFile,string profileName,string model)
        {            
            BestModel vOut=new BestModel();
            List<string> localNames = new List<string>(2);
            List<string> fileNames = new List<string>(targets.Count);

            foreach (var item in targets)
                fileNames.Add(dirName + Path.DirectorySeparatorChar + item);

            fileNames.Add(model);

            //dist=PrepareDistance(distance,fileNames,alignFile,profileName);

            string[] aux = model.Split(Path.DirectorySeparatorChar);

            InitBestModel(distance, ref vOut);
            foreach (var item in targets)
            {
               /* localNames.Clear();
                localNames.Add(model);
                localNames.Add(item);
                dist = PrepareDistance(distance, fileNames, alignFile, profileName);*/
                int value=0;
                //value = dist.GetDistance(aux[aux.Length - 1], item);
                value = GetDist(distance, dirName, model, item);
                CheckBest(distance, value, item, ref vOut);
            }

            return vOut;
        }
コード例 #7
0
ファイル: Fraction.cs プロジェクト: uQlust/uQlust-ver1.0
       void CheckBest(DistanceMeasures distance,int value,string item,ref BestModel best)
       {
           switch (distance)
           {
               case DistanceMeasures.HAMMING:        
                   if (best.value <= value)
                   {
                       best.value = value;
                       best.modelName = item;
                   }
                   break;
               case DistanceMeasures.MAXSUB:
               case DistanceMeasures.GDT_TS:
               case DistanceMeasures.RMSD:
                   if (best.value >= value)
                   {
                       best.value=value;
                       best.modelName = item;
                   }
                   break;
           }

       }
コード例 #8
0
ファイル: Fraction.cs プロジェクト: uQlust/uQlust-ver1.0
        void InitBestModel(DistanceMeasures distance,ref BestModel model)
       {
           switch (distance)
           {
               case DistanceMeasures.HAMMING:
              
                   model.value = int.MinValue;
                   break;
               case DistanceMeasures.MAXSUB:
               case DistanceMeasures.RMSD:
               case DistanceMeasures.GDT_TS:
                   model.value = int.MaxValue;
                   break;
           }


       }