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);
                }
            }
        }
示例#2
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;
        }
示例#3
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;
        }
示例#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;

        }
示例#5
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;
        }