Exemple #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);
                }
            }
        }
Exemple #2
0
        static void RunJobAsymmetricPair(object start)
        {
            JobStartParamsAsymmetricPair startParams = (JobStartParamsAsymmetricPair)start;

            int count = 0;
            IEnumerable <FusionDesignInfo> fusions = Fuse.Fusion2.GetSplices(startParams.PeptideN, startParams.RangeN, startParams.PeptideC, startParams.RangeC, (int)startParams.TopX);

            lock (lockFileIO)
            {
                foreach (FusionDesignInfo fusion in fusions)
                {
                    // Output files
                    string identifier = String.Format("PAIR_{0}_{1}_{2}_{3}", startParams.OutputPrefix, startParams.PdbCodeN, startParams.PdbCodeC, count++);

                    // -resfile
                    Resfile resfile = new Resfile();
                    fusion.DesignablePositions.ToList().ForEach(item => resfile.SetNotAminoAcids(0, item, "MW"));  // Set the designable residues, disallowing Met and Trp entirely
                    fusion.ImmutablePositions.ToList().ForEach(item => resfile.SetNativeRotamer(0, item));         // Set the immutable positions, overriding any designable ones if they conflict
                    File.AppendAllLines(identifier + ".resfile", resfile.GetFileText());

                    // -scores
                    File.AppendAllText("scores_CXR.txt", String.Format("{0} {1:F2}\n", identifier, fusion.Score));

                    // -forward folding fixed-backbone ranges
                    File.AppendAllText(identifier + ".fixed_ranges", String.Format("fixedbb_range1={0}-{1} fixedbb_range2={2}-{3}", 1, fusion.IdentityRanges[0].End + 1, fusion.IdentityRanges[1].Start + 1, fusion.Peptide.Count));

                    // -pdbs
                    PdbQuick.Save(identifier + "_monomer.pdb", new IChain[] { fusion.Peptide });
                    PdbQuick.Save(identifier + "_multichain.pdb", fusion.PdbOutputChains);
                }
            }
            Console.WriteLine("Completed triplet [N-term {0}]:[C-term {1}], {2:F2}% ({3}/{4})", startParams.PdbCodeN, startParams.PdbCodeC, (float)startParams.Counter.Complete / startParams.Counter.Total * 100, startParams.Counter.Complete, startParams.Counter.Total);

            startParams.Counter.IncrementComplete();
            _threadCountSemaphore.Release();
        }