public static bool Run(string[] args) { switch (args.FirstOrDefault()) { case CxrcxFusionFlags.BaseFlag: { CxrcxFusionFlags options = new CxrcxFusionFlags(); if (options.ParseArgs(args)) { StartJobsAngleCXRCX(options); } else { return(false); } } break; case CxcxFusionFlags.BaseFlag: { CxcxFusionFlags options = new CxcxFusionFlags(); if (options.ParseArgs(args)) { StartJobsAngleCXCX(options); } else { return(false); } } break; case AsymmetricFusionFlags.BaseFlag: { AsymmetricFusionFlags options = new AsymmetricFusionFlags(); if (options.ParseArgs(args)) { StartJobsAsymmetricPair(options); } else { return(false); } } break; default: return(false); } return(true); }
static void StartJobsAngleCXCX(CxcxFusionFlags 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(); ThreadSafeJobCounter sharedCounter = new ThreadSafeJobCounter(); sharedCounter.Total = filesOligomer1.Count * filesOligomer2.Count; 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 pdbCode1 = PdbQuick.CodeFromFilePath(fileOligomer1); IChain peptide1 = PdbQuick.ChainFromFileOrCode(fileOligomer1); 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 pdbCode2 = PdbQuick.CodeFromFilePath(fileOligomer2); IChain peptide2 = PdbQuick.ChainFromFileOrCode(fileOligomer2); peptide2.Translate(new Vector3(0, 0, 20 - Rmsd.GetBackboneCentroid(peptide2).Z)); if (peptide1 == null || peptide2 == null) { Console.WriteLine("Pdb parsing failed for one of [{0}, {1}]", fileOligomer1, fileOligomer2); continue; } JobStartParamsCXCX startParams = new JobStartParamsCXCX(); // 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 = pdbCode1; startParams.PdbCodeBundle2 = pdbCode2; startParams.Cx1 = peptide1; startParams.Cx2 = peptide2; startParams.AngleDegrees = angleDegrees; startParams.Counter = sharedCounter; // Shared counter across queued jobs Debug.Assert(startParams.Validate(), "JobStartParamsCXRCX validation failure"); _threadCountSemaphore.WaitOne(); sharedCounter.IncrementQueued(); Thread thread = new Thread(new ParameterizedThreadStart(RunJobAngleCXCX)); thread.Start(startParams); Console.WriteLine("Queuing triplet [Bundle {0}]:[Bundle {1}], {2:F2} degrees, {3:F2} % ({4}/{5})", pdbCode1, pdbCode2, angleDegrees, startParams.Counter.PercentQueued, startParams.Counter.Queued, startParams.Counter.Total); } } }