Beispiel #1
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);
                }
            }
        }
Beispiel #2
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);
                    }
                }
            }
        }