Esempio n. 1
0
        private void button2_Click(object sender, EventArgs e)
        {
            if (Rmsd.Checked)
            {
                dist = DistanceMeasures.RMSD;
            }
            else
            if (MaxSub.Checked)
            {
                dist = DistanceMeasures.MAXSUB;
            }
            else
            {
                dist = DistanceMeasures.GDT_TS;
            }

            if (jury1D.Checked)
            {
                profileName = jury1DSetup1.profileName;
                if (profileName == null || profileName.Length == 0)
                {
                    this.DialogResult = DialogResult.None;
                }
            }
            else
            {
                profileName = null;
            }

            distThreshold      = Convert.ToDouble(textBox1.Text, System.Globalization.CultureInfo.InvariantCulture);
            consideredClusters = (int)numClusters.Value;
            this.DialogResult  = DialogResult.OK;
        }
Esempio n. 2
0
        private DistanceMeasure CreateMeasureForDCD(DCDFile dcd, DistanceMeasures measure, PDB.PDBMODE atoms, bool jury1d, string alignFileName,
                                                    string profileName = null, string refJuryProfile = null)
        {
            DistanceMeasure dist = null;

            switch (measure)
            {
            case DistanceMeasures.HAMMING:
                if (refJuryProfile == null || !jury1d)
                {
                    throw new Exception("Sorry but for jury measure you have to define 1djury profile to find reference structure");
                }
                else
                {
                    dist = new JuryDistance(dcd, alignFileName, true, profileName, refJuryProfile);
                }
                break;

            case DistanceMeasures.RMSD:
                dist = new Rmsd(dcd, alignFileName, jury1d, atoms, refJuryProfile);
                break;

            case DistanceMeasures.MAXSUB:
                dist = new MaxSub(dcd, alignFileName, jury1d, refJuryProfile);
                break;

            case DistanceMeasures.GDT_TS:
                dist = new GDT_TS(dcd, alignFileName, jury1d, refJuryProfile);
                break;
            }

            dist.InitMeasure();
            return(dist);
        }
Esempio n. 3
0
        private void button3_Click(object sender, EventArgs e)
        {
            DistanceMeasures measure = distanceControl1.distDef;

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

            dirName = textBox2.Text;

            try
            {
                if (textBox1.Text != null && textBox1.Text.Length > 5 && File.Exists(textBox1.Text))
                {
                    string[] tmp = textBox1.Text.Split(Path.DirectorySeparatorChar);
                    native = tmp[tmp.Length - 1];
                }

                currentV = 0;
                ResultsForm fr = new ResultsForm();
                Progress    pr = new Progress(this, fr);
                pr.Start();
                pr.Show();
                pr.Focus();
                pr.BringToFront();
                Thread startProg = new Thread(CalcStat);
                startProg.Start();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Exception: " + ex.Message);
            }
        }
Esempio n. 4
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;
        }
Esempio n. 5
0
/*        private Dictionary<string,double> SableDist(List<string> refStructures)
 *      {
 *          StreamReader sableFile = new StreamReader(textBox3.Text);
 *          string line = sableFile.ReadLine();
 *          string prefix=refStructures[0];
 *          protInfo pr_SS=new protInfo();
 *          protInfo pr_SA = new protInfo();
 *          string seq, ss, sa;
 *          if(prefix.Contains("\\"))
 *          {
 *              string []aux=prefix.Split('\\');
 *              prefix=aux[aux.Length-2];
 *          }
 *          while (line !=null)
 *          {
 *              if(line.StartsWith("Query:"))
 *              {
 *                  string[] aux = line.Split(' ');
 *                  aux = aux[1].Split('.');
 *                  if (prefix.Contains(aux[0]))
 *                  {
 *                      pr_SS.sequence = sableFile.ReadLine();
 *                      string ww=sableFile.ReadLine();
 *                      pr_SS.profile = new List<byte>();
 *                      for (int i = 0; i < ww.Length;i++ )
 *                          pr_SS.profile.Add(ww[i].ToString());
 *                      line = sableFile.ReadLine();
 *                      pr_SA.sequence = pr_SS.sequence;
 *                      pr_SA.profile = new List<string>(Regex.Replace(sableFile.ReadLine(),@"\s+"," ").Trim().Split(' '));
 *                      for (int i = 0; i < pr_SA.profile.Count; i++)
 *                          pr_SA.profile[i] = (Convert.ToInt16(pr_SA.profile[i]) / 10).ToString();
 *
 *                  }
 *              }
 *              line = sableFile.ReadLine();
 *          }
 *
 *          sableFile.Close();
 *          Settings set=new Settings();
 *          set.Load();
 *          Alignment al=new Alignment(refStructures,set,"H:\\profiels\\SS3_SA9_internal.profiles");
 *          al.MyAlign(null);
 *          al.AddStructureToAlignment("sable_res","SS", ref pr_SS);
 *          al.AddStructureToAlignment("sable_res", "SA", ref pr_SA);
 *
 *          Dictionary<string, Dictionary<string, protInfo>> allProf = new Dictionary<string, Dictionary<string, protInfo>>();
 *          allProf.Add("SS", new Dictionary<string, protInfo>());
 *          allProf["SS"].Add("sable_res", pr_SS);
 *          allProf.Add("SA", new Dictionary<string, protInfo>());
 *          allProf["SA"].Add("sable_res", pr_SA);
 *          Dictionary<string,List<string>> protCombineStates = al.CombineProfiles("sable_res", allProf);
 *
 *
 *          JuryDistance dist = new JuryDistance(al, false);
 *
 *          Dictionary<string, double> distRes = new Dictionary<string, double>();
 *
 *          foreach (var item in refStructures)
 *          {
 *              distRes.Add(Path.GetFileName(item), dist.GetDistance("sable_res",Path.GetFileName(item)));
 *              currentV++;
 *          }
 *
 *
 *          return distRes;
 *
 *      }*/
        private DistanceMeasure PrepareDistanceMeasure(List <string> cluster, DistanceMeasures measure, string dirName)
        {
            DistanceMeasure distRes    = null;
            List <string>   clustFiles = new List <string>();

            foreach (var item in cluster)
            {
                clustFiles.Add(dirName + Path.DirectorySeparatorChar + item);
            }
            switch (measure)
            {
            case DistanceMeasures.HAMMING:
                distRes = new JuryDistance(clustFiles, alignFile, true, distanceControl1.profileName);
                break;

            case DistanceMeasures.MAXSUB:
            {
                distRes = new MaxSub(clustFiles, alignFile, distanceControl1.reference);
            }
            break;

            case DistanceMeasures.RMSD:
                distRes = new Rmsd(clustFiles, alignFile, distanceControl1.reference, distanceControl1.CAtoms, distanceControl1.referenceProfile);
                break;
            }
            distRes.InitMeasure();
            return(distRes);
        }
Esempio n. 6
0
       int GetDist(DistanceMeasures distance,string dirName,string item1,string item2)
       {
           DistanceMeasure dist = null;
           List<string> targets = new List<string>();


           if(!item1.Contains(dirName))
            targets.Add(dirName + Path.DirectorySeparatorChar + item1);
           else
            targets.Add(item1);
           targets.Add(dirName + Path.DirectorySeparatorChar + item2);

           switch (distance)
           {
               case DistanceMeasures.HAMMING:
                   dist = new JuryDistance(targets, "", false, "");
                   break;
               case DistanceMeasures.MAXSUB:
                   dist = new MaxSub(targets, "", false);
                   break;
               case DistanceMeasures.RMSD:
                   dist = new Rmsd(targets, "", false, PDB.PDBMODE.ONLY_CA);
                   break;
               case DistanceMeasures.GDT_TS:
                   dist = new GDT_TS(targets, "", false);
                   break;
           }
           dist.InitMeasure();          
           return GetDist(dist, item1, item2);
       }
Esempio n. 7
0
       string CLusterRepresent(DistanceMeasures distance,string dirName, List<string> targets,string alignFile, string profileName)
        {
            DistanceMeasure dist;
            List<string> fileNames=new List<string>();

            foreach (var item in targets)
                fileNames.Add(dirName + Path.DirectorySeparatorChar + item);
            dist = PrepareDistance(distance, fileNames, alignFile, profileName);
            return dist.GetReferenceStructure(targets);
        }
Esempio n. 8
0
 public HashClusterDendrog(DCDFile dcd, HashCInput input, HierarchicalCInput dendrogOpt) : base(dcd, input)
 {
     this.dMeasure       = dendrogOpt.distance;
     this.linkageType    = dendrogOpt.linkageType;
     this.atoms          = dendrogOpt.atoms;
     this.jury1d         = dendrogOpt.reference1DjuryH;
     this.profileName    = dendrogOpt.hammingProfile;
     this.refJuryProfile = dendrogOpt.jury1DProfileH;
     hier = dendrogOpt;
 }
Esempio n. 9
0
  public HashClusterDendrog(string dirName, string alignFile, HashCInput input, DistanceMeasures dMeasure, AglomerativeType linkageType, PDB.PDBMODE atoms, bool jury1d, string alignFileName,
                                       string profileName = null, string refJuryProfile = null):base(dirName,alignFile,input)
 {
     this.dMeasure=dMeasure;
     this.linkageType=linkageType;
     this.atoms = atoms;
     this.jury1d = jury1d;
     this.profileName = profileName;
     this.refJuryProfile = refJuryProfile;
     this.dirName = dirName;
 }
Esempio n. 10
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;
           }


       }
Esempio n. 11
0
       DistanceMeasure PrepareDistance(DistanceMeasures distance,List <string> targets,string alignFile,string profileName)
        {
            DistanceMeasure dist=null;
          
            switch (distance)
            {
                case DistanceMeasures.HAMMING:
                    dist = new JuryDistance(targets, alignFile, false, profileName);
                    break;
                case DistanceMeasures.MAXSUB:
                    dist = new MaxSub(targets, alignFile, false);
                    break;
                case DistanceMeasures.RMSD:
                    dist = new Rmsd(targets, alignFile, false, PDB.PDBMODE.ONLY_CA);
                    break;
                case DistanceMeasures.GDT_TS:
                    dist = new GDT_TS(targets, alignFile, false);
                    break;
            }

            dist.InitMeasure();
            return dist;
        }
Esempio n. 12
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;
           }

       }
Esempio n. 13
0
       int GetDist(DistanceMeasures distance,string dirName,string item1,string item2)
       {
           DistanceMeasure dist = null;
           List<string> targets = new List<string>();

          // targets.Add(dirName + Path.DirectorySeparatorChar + item1);
           targets.Add(item1);
           targets.Add(dirName + Path.DirectorySeparatorChar + item2);

           switch (distance)
           {
               case DistanceMeasures.HAMMING:
                   dist = new JuryDistance(targets, "", false, "");
                   break;
               case DistanceMeasures.MAXSUB:
                   dist = new MaxSub(targets, "", false);
                   break;
               case DistanceMeasures.RMSD:
                   dist = new Rmsd(targets, "", false, PDB.PDBMODE.ONLY_CA);
                   break;
               case DistanceMeasures.GDT_TS:
                   dist = new GDT_TS(targets, "", false);
                   break;
           }
           dist.InitMeasure();          
           return GetDist(dist, item1, item2);
       }
Esempio n. 14
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;
           }


       }
Esempio n. 15
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;
        }
Esempio n. 16
0
        public void CalcStat()
        {
            List <string>    fileNames     = new List <string>();
            List <string>    refStructures = new List <string>();
            DistanceMeasures measure       = distanceControl1.distDef;
            DistanceMeasure  distTemp      = null;
            double           distRes       = 0;

            maxV = selected.Count;
            distList.Clear();
            try
            {
                tableRes = new DataTable();

                tableRes.Columns.Add("Cluster Size", typeof(int));
                tableRes.Columns.Add("Reference structure", typeof(string));
                tableRes.Columns.Add("Distance", typeof(double));
                tableRes.Columns.Add("Hidden1", typeof(int));
                tableRes.Columns.Add("Hidden2", typeof(string));


                if (checkBoxSable.Checked)
                {
                    tableRes.Columns.Add("Dist to Sable", typeof(double));
                    maxV *= 2;
                }
                if (checkBox1.Checked)
                {
                    for (int i = 0; i < selected.Count; i++)
                    {
                        maxV += selected[i].Count;
                    }
                }
                fileNames.Add(textBox1.Text);

                jury1D jury = new jury1D();
                if (distanceControl1.reference)
                {
                    jury.PrepareJury(dirName, alignFile, distanceControl1.referenceProfile);
                }

                refStructures.Clear();
                selected.Sort(delegate(List <string> first, List <string> second)
                              { return(first.Count.CompareTo(second.Count)); });

                selected.Reverse();
                //    dataGridView1.Rows.Add(selected.Count);

                for (int i = 0; i < selected.Count; i++)
                {
                    string        refD  = selected[i][0];
                    ClusterOutput juryO = null;
                    if (distanceControl1.reference)
                    {
                        if (selected[i].Count > 5)
                        {
                            juryO = jury.JuryOptWeights(selected[i]);
                            if (juryO == null)
                            {
                                continue;
                            }
                            refD = juryO.juryLike[0].Key;
                            if (!fileNames.Contains(dirName + Path.DirectorySeparatorChar + juryO.juryLike[0].Key))
                            {
                                fileNames.Add(dirName + Path.DirectorySeparatorChar + juryO.juryLike[0].Key);
                                refStructures.Add(dirName + Path.DirectorySeparatorChar + refD);
                            }
                        }
                        else
                        if (!fileNames.Contains(dirName + Path.DirectorySeparatorChar + selected[i][0]))
                        {
                            fileNames.Add(dirName + Path.DirectorySeparatorChar + selected[i][0]);
                            refStructures.Add(dirName + Path.DirectorySeparatorChar + selected[i][0]);
                        }
                    }
                    else
                    {
                        dist     = PrepareDistanceMeasure(selected[i], measure, dirName);
                        distTemp = dist;
                        refD     = dist.GetReferenceStructure(selected[i]);
                        fileNames.Add(dirName + Path.DirectorySeparatorChar + refD);
                        refStructures.Add(dirName + Path.DirectorySeparatorChar + refD);
                    }

                    if (fileNames.Count == 2)
                    {
                        switch (measure)
                        {
                        case DistanceMeasures.HAMMING:
                            dist = new JuryDistance(fileNames, alignFile, false, distanceControl1.profileName);
                            break;

                        case DistanceMeasures.MAXSUB:
                            dist = new MaxSub(fileNames, null, false);
                            break;

                        case DistanceMeasures.RMSD:
                            dist = new Rmsd(fileNames, null, false, distanceControl1.CAtoms);
                            break;
                        }
                        dist.InitMeasure();
                        distRes = Convert.ToDouble(String.Format("{0:0.00}", dist.GetDistance(native, refD) / 100.0));
                    }
                    fileNames.RemoveAt(fileNames.Count - 1);
                    if (checkBoxSable.Checked && refStructures.Count > 0)
                    {
                        tableRes.Rows.Add(selected[i].Count, refD, distRes, i, dirName, 0.0);
                    }
                    else
                    {
                        tableRes.Rows.Add(selected[i].Count, refD, distRes, i, dirName);
                    }
                    currentV++;
                }
                if (checkBoxSable.Checked && refStructures.Count > 0)
                {
                    Dictionary <string, double> res = null;// SableDist(refStructures);
                    for (int i = 0; i < refStructures.Count; i++)
                    {
                        if (res.ContainsKey(Path.GetFileName(refStructures[i])))
                        {
                            DataRow dr = tableDist.Rows[i];
                            dr[5] = Convert.ToDouble(String.Format("{0:0.00}", res[Path.GetFileName(refStructures[i])]));
                        }
                    }
                }
                if (checkBox1.Checked)
                {
                    CalculateDistToAll();
                }
            }
            catch (Exception ex)
            {
                exc = ex;
            }
        }
Esempio n. 17
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;
        }
Esempio n. 18
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;
           }

       }
Esempio n. 19
0
       string CLusterRepresent(DistanceMeasures distance,string dirName, List<string> targets,string alignFile, string profileName)
        {
            DistanceMeasure dist;
            List<string> fileNames=new List<string>();

            foreach (var item in targets)
                fileNames.Add(dirName + Path.DirectorySeparatorChar + item);
            dist = PrepareDistance(distance, fileNames, alignFile, profileName);
            return dist.GetReferenceStructure(targets);
        }
Esempio n. 20
0
        private DistanceMeasure CreateMeasureForDCD(DCDFile dcd, DistanceMeasures measure, PDB.PDBMODE atoms, bool jury1d, string alignFileName,
                                                      string profileName = null, string refJuryProfile = null)
        {
            DistanceMeasure dist=null;
            switch (measure)
            {
                case DistanceMeasures.HAMMING:
                    if (refJuryProfile == null || !jury1d)
                        throw new Exception("Sorry but for jury measure you have to define 1djury profile to find reference structure");
                    else
                        dist = new JuryDistance(dcd, alignFileName, true, profileName, refJuryProfile);
                    break;
                case DistanceMeasures.RMSD:
                    dist = new Rmsd(dcd, alignFileName, jury1d, atoms, refJuryProfile);
                    break;
                case DistanceMeasures.MAXSUB:
                    dist = new MaxSub(dcd, alignFileName, jury1d, refJuryProfile);
                    break;
                case DistanceMeasures.GDT_TS:
                    dist = new GDT_TS(dcd, alignFileName, jury1d, refJuryProfile);
                    break;

            }

            dist.InitMeasure();
            return dist;

        }
Esempio n. 21
0
        private DistanceMeasure CreateMeasure(string processName, string dirName, DistanceMeasures measure, PDB.PDBMODE atoms, bool jury1d, string alignFileName,
                                              string profileName = null, string refJuryProfile = null)
        {
            DistanceMeasure dist = null;

            switch (measure)
            {
            case DistanceMeasures.HAMMING:
                if (alignFileName != null)
                {
                    dist = new JuryDistance(alignFileName, jury1d, profileName, refJuryProfile);
                }
                else
                {
                    dist = new JuryDistance(dirName, alignFileName, jury1d, profileName, refJuryProfile);
                }
                break;

            case DistanceMeasures.TANIMOTO:
                if (alignFileName != null)
                {
                    dist = new Tanimoto(alignFileName, jury1d, profileName, refJuryProfile);
                }
                else
                {
                    dist = new Tanimoto(dirName, alignFileName, jury1d, profileName, refJuryProfile);
                }
                break;

            case DistanceMeasures.COSINE:
                if (alignFileName != null)
                {
                    dist = new CosineDistance(alignFileName, jury1d, profileName, refJuryProfile);
                }
                else
                {
                    dist = new CosineDistance(dirName, alignFileName, jury1d, profileName, refJuryProfile);
                }
                break;

            case DistanceMeasures.RMSD:
                if (dirName == null)
                {
                    throw new Exception("RMSD and MAXSUB measures cannot be used for aligned profiles!");
                }
                dist = new Rmsd(dirName, alignFileName, jury1d, atoms, refJuryProfile);
                break;

            case DistanceMeasures.MAXSUB:
                if (dirName == null)
                {
                    throw new Exception("RMSD and MAXSUB measures cannot be used for aligned profiles!");
                }
                dist = new MaxSub(dirName, alignFileName, jury1d, refJuryProfile);
                break;

            case DistanceMeasures.GDT_TS:
                if (dirName == null)
                {
                    throw new Exception("RMSD and MAXSUB measures cannot be used for aligned profiles!");
                }
                dist = new GDT_TS(dirName, alignFileName, jury1d, refJuryProfile);
                break;
            }
            return(dist);
        }
Esempio n. 22
0
       DistanceMeasure PrepareDistance(DistanceMeasures distance,List <string> targets,string alignFile,string profileName)
        {
            DistanceMeasure dist=null;
          
            switch (distance)
            {
                case DistanceMeasures.HAMMING:
                    dist = new JuryDistance(targets, alignFile, false, profileName);
                    break;
                case DistanceMeasures.MAXSUB:
                    dist = new MaxSub(targets, alignFile, false);
                    break;
                case DistanceMeasures.RMSD:
                    dist = new Rmsd(targets, alignFile, false, PDB.PDBMODE.ONLY_CA);
                    break;
                case DistanceMeasures.GDT_TS:
                    dist = new GDT_TS(targets, alignFile, false);
                    break;
            }

            dist.InitMeasure();
            return dist;
        }
Esempio n. 23
0
        public void AddItemToList(string item,string clType,string dirName,DistanceMeasures measure)
        {
            int num;
            if (dataGridView1.InvokeRequired)
                dataGridView1.Invoke(new AddListBoxItem(AddItemToList), new object[] { item, clType, dirName, measure });
            else
            {

                dataGridView1.Rows.Add(1);
                num = dataGridView1.Rows.Count-1;
                dataGridView1.Rows[num].DefaultCellStyle.ForeColor = Color.Red;
                dataGridView1.Rows[num].Cells[0].Value = item;
                dataGridView1.Rows[num].Cells[1].Value = clType;
                dataGridView1.Rows[num].Cells[2].Value = measure;
                dataGridView1.Rows[num].Cells[3].Value = dirName;
            }

        }
Esempio n. 24
0
/*        private Dictionary<string,double> SableDist(List<string> refStructures)
        {
            StreamReader sableFile = new StreamReader(textBox3.Text);
            string line = sableFile.ReadLine();
            string prefix=refStructures[0];
            protInfo pr_SS=new protInfo();
            protInfo pr_SA = new protInfo();
            string seq, ss, sa;
            if(prefix.Contains("\\"))
            {
                string []aux=prefix.Split('\\');
                prefix=aux[aux.Length-2];
            }
            while (line !=null)
            {               
                if(line.StartsWith("Query:"))
                {
                    string[] aux = line.Split(' ');
                    aux = aux[1].Split('.');
                    if (prefix.Contains(aux[0]))
                    {                        
                        pr_SS.sequence = sableFile.ReadLine();
                        string ww=sableFile.ReadLine();
                        pr_SS.profile = new List<byte>();
                        for (int i = 0; i < ww.Length;i++ )
                            pr_SS.profile.Add(ww[i].ToString());
                        line = sableFile.ReadLine();
                        pr_SA.sequence = pr_SS.sequence;
                        pr_SA.profile = new List<string>(Regex.Replace(sableFile.ReadLine(),@"\s+"," ").Trim().Split(' '));
                        for (int i = 0; i < pr_SA.profile.Count; i++)
                            pr_SA.profile[i] = (Convert.ToInt16(pr_SA.profile[i]) / 10).ToString();

                    }
                }
                line = sableFile.ReadLine();
            }

            sableFile.Close();
            Settings set=new Settings();
            set.Load();
            Alignment al=new Alignment(refStructures,set,"H:\\profiels\\SS3_SA9_internal.profiles");
            al.MyAlign(null);
            al.AddStructureToAlignment("sable_res","SS", ref pr_SS);
            al.AddStructureToAlignment("sable_res", "SA", ref pr_SA);

            Dictionary<string, Dictionary<string, protInfo>> allProf = new Dictionary<string, Dictionary<string, protInfo>>();
            allProf.Add("SS", new Dictionary<string, protInfo>());
            allProf["SS"].Add("sable_res", pr_SS);
            allProf.Add("SA", new Dictionary<string, protInfo>());
            allProf["SA"].Add("sable_res", pr_SA);
            Dictionary<string,List<string>> protCombineStates = al.CombineProfiles("sable_res", allProf);


            JuryDistance dist = new JuryDistance(al, false);

            Dictionary<string, double> distRes = new Dictionary<string, double>();

            foreach (var item in refStructures)
            {
                distRes.Add(Path.GetFileName(item), dist.GetDistance("sable_res",Path.GetFileName(item)));
                currentV++;
            }


            return distRes;

        }*/
        private DistanceMeasure PrepareDistanceMeasure(List <string> cluster,DistanceMeasures measure,string dirName)
        {
            DistanceMeasure distRes=null;
            List<string> clustFiles = new List<string>();
            foreach (var item in cluster)
                clustFiles.Add(dirName + Path.DirectorySeparatorChar + item);
            switch (measure)
            {
                case DistanceMeasures.HAMMING:
                    distRes = new JuryDistance(clustFiles, alignFile, true, distanceControl1.profileName);
                    break;
                case DistanceMeasures.MAXSUB:
                    {
                        distRes = new MaxSub(clustFiles, alignFile, distanceControl1.reference);
                    }
                    break;
                case DistanceMeasures.RMSD:
                    distRes = new Rmsd(clustFiles, alignFile, distanceControl1.reference, distanceControl1.CAtoms, distanceControl1.referenceProfile);
                    break;
            }
            distRes.InitMeasure();
            return distRes;
        }
Esempio n. 25
0
        private DistanceMeasure CreateMeasure(string processName, string dirName,DistanceMeasures measure,PDB.PDBMODE atoms,bool jury1d,string alignFileName,
                                              string profileName=null,string refJuryProfile=null)
        {
            DistanceMeasure dist=null;
            switch(measure)
            {
                case DistanceMeasures.HAMMING:
                    if (alignFileName != null)
                        dist = new JuryDistance(alignFileName, jury1d, profileName, refJuryProfile);
                    else
                        dist = new JuryDistance(dirName, alignFileName, jury1d, profileName, refJuryProfile);
                    break;
                case DistanceMeasures.COSINE:
                    if (alignFileName != null)
                        dist = new CosineDistance(alignFileName, jury1d, profileName, refJuryProfile);
                    else
                        dist = new CosineDistance(dirName, alignFileName, jury1d, profileName, refJuryProfile);
                    break;

                case DistanceMeasures.RMSD:
                    if (dirName == null)
                        throw new Exception("RMSD and MAXSUB measures cannot be used for aligned profiles!");
                    dist = new Rmsd(dirName, alignFileName, jury1d, atoms, refJuryProfile);
                    break;
                case DistanceMeasures.MAXSUB:
                    if (dirName == null)
                        throw new Exception("RMSD and MAXSUB measures cannot be used for aligned profiles!");
                    dist = new MaxSub(dirName, alignFileName, jury1d, refJuryProfile);
                    break;
                case DistanceMeasures.GDT_TS:
                    if (dirName == null)
                        throw new Exception("RMSD and MAXSUB measures cannot be used for aligned profiles!");
                    dist = new GDT_TS(dirName, alignFileName, jury1d, refJuryProfile);
                    break;



            }
            return dist;
        }
Esempio n. 26
0
        private void button2_Click(object sender, EventArgs e)
        {
            string[] aux;
            if (checkBox1.Checked)
            {
                if (jury1DSetup1.profileName == null || jury1DSetup1.profileName.Length == 0)
                {
                    MessageBox.Show("Profile name for 1djury must be specified!");
                    this.DialogResult = DialogResult.None;
                    return;
                }
                jury1D jury = new jury1D();
                jury.PrepareJury(structures, "", jury1DSetup1.profileName);
                List <string> prep = new List <string>();
                foreach (var item in structures)
                {
                    aux = item.Split(Path.DirectorySeparatorChar);
                    prep.Add(aux[aux.Length - 1]);
                }
                ClusterOutput oc = jury.JuryOptWeights(prep);

                for (int i = 0; i < selectBest1.bestNumber; i++)
                {
                    bestJuryStructures.Add(oc.juryLike[i].Key);
                }
            }
            this.DialogResult = DialogResult.OK;
            if (selectBest1.getFileName != null && File.Exists(selectBest1.getFileName))
            {
                DistanceMeasures measure = selectBest1.measure;

                structures.Add(selectBest1.getFileName);

                DistanceMeasure dist = null;
                switch (measure)
                {
                case DistanceMeasures.HAMMING:
                    dist = new JuryDistance(structures, "", false, selectBest1.hammingProfile);
                    break;

                case DistanceMeasures.MAXSUB:
                    dist = new MaxSub(structures, "", false);
                    break;

                case DistanceMeasures.RMSD:
                    dist = new Rmsd(structures, "", false, selectBest1.CAtoms);
                    break;
                }

                List <KeyValuePair <string, int> > distList = new List <KeyValuePair <string, int> >();
                aux = selectBest1.getFileName.Split(Path.DirectorySeparatorChar);
                dist.InitMeasure();
                string native = aux[aux.Length - 1];
                foreach (var item in structures)
                {
                    aux = item.Split(Path.DirectorySeparatorChar);
                    int val = dist.GetDistance(native, aux[aux.Length - 1]);
                    distList.Add(new KeyValuePair <string, int>(aux[aux.Length - 1], val));
                }

                distList.Sort((firstPair, nextPair) =>
                {
                    return(firstPair.Value.CompareTo(nextPair.Value));
                });

                for (int i = 0; i < selectBest1.bestNumber; i++)
                {
                    bestStructures.Add(distList[i].Key);
                }
            }
        }