Ejemplo n.º 1
0
        private StatClust Calc(ClusterOutput outp,bool flag)
        {
            List <string> five=new List<string>();
             List<string> listFiles = new List<string>();
            //if (outp == null || outp.clusters == null)
            //    return null;

            if(outp==null || outp.dirName==null)
                return null;
            string []aux=outp.dirName.Split(Path.DirectorySeparatorChar);
            string native=aux[aux.Length-1]+".pdb";

            string dirM = "";
            for (int i = 0; i < aux.Length - 1; i++)
                dirM += aux[i] + Path.DirectorySeparatorChar;
            native = dirM + native;
            if(!File.Exists(native))
                return null;

            five.Add(native);
           // jury1D jury = new jury1D(outp.dirName, "", "C:\\data\\dcd\\SS_SA9internal.profiles");
           // jury1D jury = new jury1D(outp.dirName, "", "C:\\data\\dcd\\SS3_SA9_jury_internal.profiles");
            //jury1D jury = new jury1D(outp.dirName, "", "C:\\data\\dcd\\SS8_SA3_jury_internal.profiles");
            jury1D jury;

            // jury1D jury = new jury1D(outp.dirName, "", "C:\\data\\dcd\\SS_Contact_jury_internal.profiles");
            if(outp.clusters!=null)
            {
                
                outp.clusters.Sort((a,b)=>b.Count.CompareTo(a.Count));
                int end = outp.clusters.Count;
                if (outp.clusters.Count > 5)
                    end = 5;
                
               

                for (int i = 0; i < end; i++)
                {
                     listFiles.Clear();
                    foreach (var item in outp.clusters[i])
                    {
                        listFiles.Add(outp.dirName + Path.DirectorySeparatorChar+item);

                    }
                    
                    //
                    //
                    //Sift sift = new Sift(listFiles);
                    //ClusterOutput oo = sift.Shape();
                    if (flag)
                    {
                        DistanceMeasure distRmsd = new Rmsd(listFiles, "", false, uQlustCore.PDB.PDBMODE.ONLY_CA);
                        distRmsd.InitMeasure();
                        string strName = distRmsd.GetReferenceStructure(outp.clusters[i]);

                        five.Add(outp.dirName + Path.DirectorySeparatorChar + strName);
                    }
                    else
                    {
                        jury = new jury1D();
                        jury.PrepareJury(listFiles, "", "Z:\\dcd\\SS3_SA9_jury_internal.profiles");
                        ClusterOutput oo = jury.JuryOptWeights(outp.clusters[i]);
                        if (oo == null)
                          continue;
                        five.Add(outp.dirName + Path.DirectorySeparatorChar + oo.juryLike[0].Key);

                    }
                    
                    //five.Add(outp.dirName + Path.DirectorySeparatorChar + outp.clusters[i][0]);
                }
                                                                               
            }
            if (outp.hNode != null)
            {
                int end;
                List<List<string>> cli=outp.hNode.GetClusters(10);
               
                cli.Sort((a, b) => b.Count.CompareTo(a.Count));

                outp.clusters = new List<List<string>>();
                end = cli.Count;
                if (cli.Count > 5)
                    end = 5;
                for (int i = 0; i < end; i++)
                {
                   // listFiles.Clear();
                    //foreach (var item in cli[i])
                    //{
                        //listFiles.Add(

                    //}

                    listFiles.Clear();
                    foreach (var item in cli[i])
                    {
                        listFiles.Add(outp.dirName + Path.DirectorySeparatorChar + item);

                    }

                    jury = new jury1D();
                    jury.PrepareJury(listFiles, "", "C:\\data\\dcd\\SS8_SA3_jury_internal.profiles");
                  
                    outp.clusters.Add(cli[0]);  //jury
                   
                    ClusterOutput oo = jury.JuryOptWeights(cli[i]);
                    if (oo == null)
                        continue;
                    five.Add(outp.dirName + Path.DirectorySeparatorChar + cli[i][0]);
                    //five.Add(outp.dirName + Path.DirectorySeparatorChar + strName);
                }

            }
            if (outp.juryLike != null)
            {
                int end = outp.juryLike.Count;
                if (outp.juryLike.Count > 5)
                    end = 5;

                for (int i = 0; i < end; i++)
                    five.Add(outp.dirName + Path.DirectorySeparatorChar + outp.juryLike[i].Key);                

            }
  //          DistanceMeasure dist;
 //           dist = new Rmsd(five, "", false, PDB.PDBMODE.ONLY_CA);
          //  dist = new MaxSub(five, "", false);

            Dictionary<string, double> cc = ReadScore(aux[aux.Length - 1]);


            if (cc == null)
                return null ;

           StatClust stCLust = new StatClust();
           string[] tt1 = native.Split(Path.DirectorySeparatorChar);
           stCLust.native = tt1[tt1.Length - 1];
           for (int i = 1; i < five.Count; i++)
           {
               
               string[] tt2 = five[i].Split(Path.DirectorySeparatorChar);
             //  double rmsd = dist.GetDistance(tt1[tt1.Length-1], tt2[tt2.Length-1]) /100.0;
               double rmsd=0;
               if (cc.ContainsKey(tt2[tt2.Length-1]))
                  rmsd = cc[tt2[tt2.Length - 1]];

               
               if (rmsd > stCLust.rmsd)
               {
                   if (outp.juryLike != null)
                       stCLust.size = outp.juryLike.Count;
                   else
                        stCLust.size = outp.clusters[i - 1].Count;
                   stCLust.rmsd = rmsd;
                   string[] dd = five[i].Split(Path.DirectorySeparatorChar);
                   stCLust.reference = dd[dd.Length-1];
               }

           }
           if (stCLust.rmsd < 1000)
           {
               avrSum += stCLust.rmsd;
               avrCount++;
           }
           if (outp.hNode != null)
           {
               outp.clusters.Clear();
               outp.clusters = null;
           }

           return stCLust;
        }
Ejemplo n.º 2
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);
                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);
                }
            }
        }
Ejemplo n.º 3
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;
        }
Ejemplo n.º 4
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;

        }
Ejemplo 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;
        }
Ejemplo n.º 6
0
        private void SaveAll()
        {
            DistanceMeasure dist=null;
            Settings set = new Settings();
            set.Load();

            string[] files;

            if (set.extension.Length > 0)
                files = Directory.GetFiles(directory, set.extension);
            else
                files = Directory.GetFiles(directory);

            List<string> fileList = new List<string>(2);
            StreamWriter r = new StreamWriter(saveFile);
            maxV = files.Length;
            foreach (var item in files)
            {
                fileList.Clear();
                fileList.Add(item);
                fileList.Add(markStructure);
                switch (distanceControl1.distDef)
                {

                    case DistanceMeasures.HAMMING:
                        dist = new JuryDistance(fileList, null, false, distanceControl1.profileName, distanceControl1.referenceProfile);
                        break;

                    case DistanceMeasures.RMSD:
                        dist = new Rmsd(fileList, null, false, distanceControl1.CAtoms, null);
                        break;
                    case DistanceMeasures.MAXSUB:
                        dist = new MaxSub(fileList, null, false, null);
                        break;
                    case DistanceMeasures.GDT_TS:
                        dist = new GDT_TS(fileList, null, false, null);
                        break;
                }


                dist.InitMeasure();
                try
                {


                        int val = dist.GetDistance(Path.GetFileName(fileList[1]), Path.GetFileName(fileList[0]));
                        currentV++;
                        if (val < int.MaxValue)
                            r.WriteLine(fileList[0] + " " + (double)val / 100);
                        else
                            r.WriteLine(fileList[0] + " NaN");


                }
                catch (Exception ex)
                {
                    exc = ex;
                }
            }
            r.Close();

            currentV = maxV;
        }