Esempio n. 1
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. 2
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. 3
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. 4
0
        static void StartJobsAsymmetricPair(AsymmetricFusionFlags options)
        {
            List <string>        files1        = GetPdbFiles("./", options.PeptideRegex1).ToList();
            List <string>        files2        = GetPdbFiles("./", options.PeptideRegex2).ToList();
            ThreadSafeJobCounter sharedCounter = new ThreadSafeJobCounter();

            sharedCounter.Total = files1.Count * files2.Count;

            Console.WriteLine("\nUsing the following files for unit 1:");
            files1.ForEach(file => Console.WriteLine(file));

            Console.WriteLine("\nUsing the following files for unit 2:");
            files2.ForEach(file => Console.WriteLine(file));

            // Parse n-peptide and offset it to positive Z
            foreach (string file1 in files1)
            {
                string pdbCode1 = PdbQuick.CodeFromFilePath(file1);
                IChain peptide1 = PdbQuick.ChainFromFileOrCode(file1);
                peptide1.Translate(-Rmsd.GetBackboneCentroid(peptide1));

                // Parse c-peptide and offset it to positive Z
                foreach (string file2 in files2)
                {
                    string pdbCode2 = PdbQuick.CodeFromFilePath(file2);
                    IChain peptide2 = PdbQuick.ChainFromFileOrCode(file2);
                    peptide2.Translate(-Rmsd.GetBackboneCentroid(peptide2));

                    if (peptide1 == null || peptide2 == null)
                    {
                        Console.WriteLine("Pdb parsing failed for one of [{0}, {1}]", file1, file2);
                        continue;
                    }

                    JobStartParamsAsymmetricPair startParams = new JobStartParamsAsymmetricPair();
                    startParams.OutputPrefix = "PAIR";
                    startParams.PdbCodeN     = pdbCode1;
                    startParams.PdbCodeC     = pdbCode2;
                    startParams.PeptideN     = peptide1;
                    startParams.PeptideC     = peptide2;
                    startParams.RangeN       = options.Range1 != null ? (Range)options.Range1 : new Range(0, peptide1.Count - 1);
                    startParams.RangeC       = options.Range2 != null ? (Range)options.Range2 : new Range(0, peptide2.Count - 1);
                    startParams.TopX         = options.TopX;
                    startParams.Counter      = sharedCounter; // Shared counter across queued jobs
                    Debug.Assert(startParams.Validate(), "JobStartParamsAsymmetricPair validation failure");

                    _threadCountSemaphore.WaitOne();
                    sharedCounter.IncrementQueued();

                    Console.WriteLine("Queuing triplet [Bundle {0}]:[Bundle {1}], {2:F2} % ({3}/{4})", pdbCode1, pdbCode2, startParams.Counter.PercentQueued, startParams.Counter.Queued, startParams.Counter.Total);

                    Thread thread = new Thread(new ParameterizedThreadStart(RunJobAsymmetricPair));
                    thread.Start(startParams);
                }
            }
        }
Esempio n. 5
0
        public static IEnumerable <FusionDesignInfo> GetSplices(IChain nPeptide, Range nAllowedSpliceRange, IChain cPeptide, Range cAllowedSpliceRange, int topX = DefaultTopX)
        {
            List <FusionDesignInfo> splices = new List <FusionDesignInfo>();
            int   minAlignmentLength        = 8;
            float maxRmsd = 0.25f;

            // Find all alignments and remove those that are not between the desired ranges
            // If this becomes a bottleneck, could specify allowed alignment ranges
            List <SequenceAlignment> alignments = Fusion.GetAlignmentsPreservingFullSsBlocks(nPeptide, cPeptide, SS.Helix, minAlignmentLength, maxRmsd);

            alignments.RemoveAll(a => !(nAllowedSpliceRange.Start <= a.Range1.Start && a.Range1.End <= nAllowedSpliceRange.End));
            alignments.RemoveAll(a => !(cAllowedSpliceRange.Start <= a.Range2.Start && a.Range2.End <= cAllowedSpliceRange.End));

            foreach (SequenceAlignment alignment in alignments)
            {
                Matrix alignmentTransform = Rmsd.GetRmsdTransformForResidues(nPeptide, alignment.Range1.Start, alignment.Range1.End, cPeptide, alignment.Range2.Start, alignment.Range2.End);
                IChain copy1 = new Chain(nPeptide);
                IChain copy2 = new Chain(cPeptide);
                copy1.Transform(alignmentTransform);
                IChain[] clashCheckPeptides = new IChain[] { copy1, copy2 };
                if (Clash.GetInterSetBackboneClashes(clashCheckPeptides, new int[] { 0, alignment.Range2.End + 1 }, new int[] { alignment.Range1.Start - 1, copy2.Count - 1 }))
                {
                    continue;
                }

                // Create the spliced peptide
                IChain splicedPeptide = Fusion.GetChain(
                    new IChain[] { copy1, copy2 },
                    new SequenceAlignment[] { alignment },
                    new IEnumerable <int>[] { new int[] { }, new int[] { } });

                // Save it
                FusionDesignInfo spliceInfo     = new FusionDesignInfo();
                Range[]          originalRanges = null;
                Range[]          finalRanges    = null;
                Fusion.GetIdentityRanges(clashCheckPeptides, new SequenceAlignment[] { alignment }, out originalRanges, out finalRanges);
                spliceInfo.Peptide            = splicedPeptide;
                spliceInfo.OriginalChains     = new IChain[] { nPeptide, cPeptide };
                spliceInfo.PdbOutputChains    = new IChain[] { splicedPeptide, copy1, copy2 };
                spliceInfo.ImmutablePositions = new int[] { };
                spliceInfo.IdentityRanges     = finalRanges;
                spliceInfo.OriginalRanges     = originalRanges;

                splices.Add(spliceInfo);
                splices.Sort((a, b) => b.Score.CompareTo(a.Score));
                if (splices.Count > topX)
                {
                    splices.RemoveAt(topX);
                }
            }

            return(splices);
        }
Esempio n. 6
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. 7
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;

            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);
        }
Esempio n. 8
0
        static void StartJobsAngleCXRCX(CxrcxFusionFlags options)
        {
            SymmetryBuilder symmetry = SymmetryBuilderFactory.CreateFromSymmetryName(options.Architecture);

            List <string>        filesOligomer1 = GetPdbFiles(Directory.GetCurrentDirectory(), options.OligomerRegex1).ToList();
            List <string>        filesOligomer2 = GetPdbFiles(Directory.GetCurrentDirectory(), options.OligomerRegex2).ToList();
            List <string>        filesRepeat    = GetPdbFiles(Directory.GetCurrentDirectory(), options.RepeatRegex).ToList();
            ThreadSafeJobCounter sharedCounter  = new ThreadSafeJobCounter();

            sharedCounter.Total = filesOligomer1.Count * filesOligomer2.Count * filesRepeat.Count;

            Console.WriteLine("Using the following spacer repeat proteins:");
            filesRepeat.ForEach(file => Console.WriteLine(file));

            Console.WriteLine("\nUsing the following files for h**o-oligomer 1:");
            filesOligomer1.ForEach(file => Console.WriteLine(file));

            Console.WriteLine("\nUsing the following files for h**o-oligomer 2:");
            filesOligomer2.ForEach(file => Console.WriteLine(file));

            float angleDegrees = (float)VectorMath.GetAngleDegrees(symmetry.GetPrincipalCoordinateSystem(options.UnitId1).UnitX, Vector3.Zero, symmetry.GetPrincipalCoordinateSystem(options.UnitId2).UnitX);

            Console.WriteLine("Angle for {0}:{1}:{2} calculated to: {3:F4}", options.Architecture, options.UnitId1, options.UnitId2, angleDegrees);

            // Parse oligomer 1 and offset it to positive Z
            foreach (string fileOligomer1 in filesOligomer1)
            {
                string pdbCodeOligomer1 = PdbQuick.CodeFromFilePath(fileOligomer1);
                IChain peptide1         = PdbQuick.ChainFromFileOrCode(fileOligomer1);

                if (peptide1 == null)
                {
                    Console.WriteLine("Pdb parsing failed for {0}", fileOligomer1);
                    continue;
                }

                peptide1.Translate(new Vector3(0, 0, 20 - Rmsd.GetBackboneCentroid(peptide1).Z));

                // Parse oligomer 2 and offset it to positive Z
                foreach (string fileOligomer2 in filesOligomer2)
                {
                    string pdbCodeOligomer2 = PdbQuick.CodeFromFilePath(fileOligomer2);
                    IChain peptide2         = PdbQuick.ChainFromFileOrCode(fileOligomer2);

                    if (peptide2 == null)
                    {
                        Console.WriteLine("Pdb parsing failed for {0}", fileOligomer2);
                        continue;
                    }

                    peptide2.Translate(new Vector3(0, 0, 20 - Rmsd.GetBackboneCentroid(peptide2).Z));

                    // Parse the repeat and offset it to positive Z
                    foreach (string fileRepeat in filesRepeat)
                    {
                        IChain repeat        = PdbQuick.ChainFromFileOrCode(fileRepeat);
                        string pdbCodeRepeat = PdbQuick.CodeFromFilePath(fileRepeat);

                        if (repeat == null)
                        {
                            Console.WriteLine("Pdb parsing failed for {0}", repeat);
                            continue;
                        }

                        repeat.Translate(new Vector3(0, 0, 20 - Rmsd.GetBackboneCentroid(repeat).Z));

                        JobStartParamsCXRCX startParams = new JobStartParamsCXRCX();
                        // things taken directly from user options
                        startParams.OutputPrefix = options.Architecture + "-" + options.UnitId1 + "-" + options.UnitId2;
                        startParams.UnitId1      = options.UnitId1;
                        startParams.UnitId2      = options.UnitId2;
                        startParams.ChainCount1  = options.Oligomerization1;
                        startParams.ChainCount2  = options.Oligomerization2;
                        startParams.TopX         = options.TopX;
                        // everything else:
                        startParams.Symmetry       = SymmetryBuilderFactory.CreateFromSymmetryName(options.Architecture);
                        startParams.PdbCodeBundle1 = pdbCodeOligomer1;
                        startParams.PdbCodeBundle2 = pdbCodeOligomer2;
                        startParams.PdbCodeRepeat  = pdbCodeRepeat;
                        startParams.Cx1            = peptide1;
                        startParams.Cx2            = peptide2;
                        startParams.Repeat         = repeat;
                        startParams.AngleDegrees   = angleDegrees;
                        startParams.Counter        = sharedCounter; // Shared counter across queued jobs
                        Debug.Assert(startParams.Validate(), "JobStartParamsCXRCX validation failure");

                        // Wait for free threads
                        _threadCountSemaphore.WaitOne();
                        sharedCounter.IncrementQueued();

                        // Start the job
                        Thread thread = new Thread(new ParameterizedThreadStart(RunJobAngleCXRCX));
                        thread.Start(startParams);
                        Console.WriteLine("Queuing triplet [Bundle {0}]:[Repeat {1}]:[Bundle {2}], {3:F2} degrees, {4:F2} % ({5}/{6})", pdbCodeOligomer1, pdbCodeRepeat, pdbCodeOligomer2, angleDegrees, startParams.Counter.PercentQueued, startParams.Counter.Queued, startParams.Counter.Total);
                    }
                }
            }
        }
Esempio n. 9
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;
        }
Esempio n. 10
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);
                }
            }
        }
Esempio n. 11
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);
        }