Example #1
0
        public static TwoAxisRealignment Create(string symmetry, string axisId1, string axisId2)
        {
            SymmetryBuilder    builder = SymmetryBuilderFactory.CreateFromSymmetryName(symmetry);
            TwoAxisRealignment result  = Create(builder, axisId1, axisId2);

            return(result);
        }
Example #2
0
        public static TwoAxisRealignment Create(string symmetry, int multiplicity1, int multiplicity2)
        {
            SymmetryBuilder    builder = SymmetryBuilderFactory.CreateFromSymmetryName(symmetry);
            string             axis1   = builder.GetUnits().First(axis => builder.GetMultiplicity(axis) == multiplicity1);
            string             axis2   = builder.GetUnits().First(axis => builder.GetMultiplicity(axis) == multiplicity2 && axis != axis1);
            TwoAxisRealignment result  = Create(symmetry, axis1, axis2);

            return(result);
        }
Example #3
0
        public SymdefPattern(string symmetry, string pattern, T item = null)
        {
            _symmetry = SymmetryBuilderFactory.CreateFromSymmetryName(symmetry);
            _symmetry.EnabledUnits = new string[] { pattern };

            OnCoordinateSystemsInitialized();

            if (item != null)
            {
                base.Add(item);
            }
        }
Example #4
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);
                    }
                }
            }
        }
Example #5
0
        static void Main(string[] args)
        {
            string[] skip = new string[]
            {
                // questionable C2 scaffolds, IMO - don't use them
                "ZC",
                "4pwwfrxC2",
                "bex2C2G2",
                "Di13",

                // questionable C3 scaffolds IMO or lacking free termini - don't use them
                "2L6HC3",
                "C3-1BH",
                "EXTN8",
                "1na0C3int2-xtal",
                "C3V"
            };

            foreach (string symmetry in new string[] { "T" })
            {
                string basedir = Directory.GetCurrentDirectory();
                foreach (string fileNameOligomer1 in Directory.EnumerateFiles(Path.Combine(basedir, @"Database\Scaffolds\Denovo\C3")))
                {
                    if (skip.Any(str => fileNameOligomer1.Contains(str)))
                    {
                        continue;
                    }

                    IStructure oligomer1 = PdbQuick.AssemblyFromFileOrCode(fileNameOligomer1);
                    foreach (string fileNameOligomer2 in Directory.EnumerateFiles(Path.Combine(basedir, @"Database\Scaffolds\Denovo\C2")))
                    {
                        if (skip.Any(str => fileNameOligomer2.Contains(str)))
                        {
                            continue;
                        }

                        IStructure oligomer2 = PdbQuick.AssemblyFromFileOrCode(fileNameOligomer2);
                        foreach (string fileNameStrut in Directory.EnumerateFiles(Path.Combine(basedir, @"Database\Scaffolds\Denovo\repeats\saxs_and_crystal")))
                        {
                            IStructure strut = PdbQuick.AssemblyFromFileOrCode(fileNameStrut);

                            string basenameC3    = (new FileInfo(fileNameOligomer1)).Name;
                            string basenameC2    = (new FileInfo(fileNameOligomer2)).Name;
                            string basenameStrut = (new FileInfo(fileNameStrut)).Name;
                            string outputBase    = String.Format("{0}32_{1}_{2}_{3}", symmetry, basenameC3, basenameStrut, basenameC2).Replace(".pdb", "");

                            Console.WriteLine("Trying {0} + {1} + {2}", basenameC3, basenameC2, basenameStrut);

                            SymmetryBuilder builder = SymmetryBuilderFactory.CreateFromSymmetryName(symmetry);
                            List <Model>    models  = SymmetricFusionGenerator.CnSnCn(oligomer1, oligomer2, new IStructure[] { strut },
                                                                                      new int[] { 0 }, new int[] { 0 }, new int[][] { new int[] { 0 } }, builder, "C3X", "C2", 5, 5, 5, 20);

                            for (int i = 0; i < models.Count; i++)
                            {
                                Model  model      = models[i];
                                string outputName = outputBase + "_" + i;
                                PdbQuick.Save(outputName + ".pdb", model.Structure);
                                foreach (KeyValuePair <string, Selection> kvp in model.Selections)
                                {
                                    string    selectionName = kvp.Key;
                                    Selection selection     = kvp.Value;

                                    if (model.AsymmetricUnit != null)
                                    {
                                        Resfile resfile = new Resfile();
                                        resfile.SetDesignOperation(model.AsymmetricUnit, selection, ResfileDesignOperation.NOTAA, new char[] { 'W', 'M', 'P', 'C' });

                                        if (resfile.DesignOperationsCount > 0)
                                        {
                                            string[] lines       = resfile.GetFileText();
                                            string   resfileName = String.Format("{0}_{1}_asu.resfile", outputName, selectionName);
                                            File.WriteAllLines(resfileName, lines);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }