Exemple #1
0
        public void SetSymmetry(SymmetryBuilder symmetry)
        {
            Trace.Assert(symmetry.EnabledUnits != null && symmetry.EnabledUnits.Length > 0);

            // Replace intermediate pattern-flow stages, but neither _in or _out, so as to maintain
            // connectivity with other objects
            CoordinateSystems = symmetry.EnabledUnits.SelectMany(unitId => symmetry.GetCoordinateSystems(unitId)).ToArray();
        }
Exemple #2
0
        static void RunJobAngleCXCX(object start)
        {
            JobStartParamsCXCX startParams = (JobStartParamsCXCX)start;
            int count = 0;

            // Get a bunch of fusions with the h**o-oligomer axes positioned such that after transformation by the symmetry definition's first coordinate system transformation,
            // the axes overlap the first and second repeating unit axes
            SymmetryBuilder  builder           = startParams.Symmetry;
            CoordinateSystem coordinateSystem1 = builder.GetPrincipalCoordinateSystem(startParams.UnitId1);
            CoordinateSystem coordinateSystem2 = builder.GetPrincipalCoordinateSystem(startParams.UnitId2);
            Line             principalAxis1    = Line.CreateFromPointAndDirection(coordinateSystem1.Translation, coordinateSystem1.UnitX); // The rosetta symdefs axes are along X of each transformed coordinate system, but something not requiring foreknowledge would be nice.
            Line             principalAxis2    = Line.CreateFromPointAndDirection(coordinateSystem2.Translation, coordinateSystem2.UnitX); // The rosetta symdefs axes are along X of each transformed coordinate system, but something not requiring foreknowledge would be nice.
            Quaternion       premultiply       = Quaternion.Inverse(coordinateSystem1.Transform.Rotation);

            principalAxis1.Direction = Vector3.Transform(principalAxis1.Direction, premultiply);
            principalAxis2.Direction = Vector3.Transform(principalAxis2.Direction, premultiply);
            principalAxis1.Point     = Vector3.Transform(principalAxis1.Point, premultiply);
            principalAxis2.Point     = Vector3.Transform(principalAxis2.Point, premultiply);
            TwoAxisRealignment      axisAlignmentUtility = TwoAxisRealignment.Create((float)startParams.AngleDegrees, principalAxis1, principalAxis2);
            List <FusionDesignInfo> fusions = Fuse.SymmetricFusionGenerator.CnCn(startParams.Cx1, startParams.Cx2, startParams.ChainCount1, startParams.ChainCount2, startParams.AngleDegrees, axisAlignmentUtility);

            int writtenOutCount = 0;

            foreach (FusionDesignInfo fusion in fusions)
            {
                // Create the pdb chains as per the symmetry builder and find whether any of these copies clashes
                bool         fullSystemClashes = false;
                List <Chain> outputChains      = new List <Chain>();

                if (builder is PxSymmetryBuilder)
                {
                    TwoAxisFusionDesignInfo twoAxisFusion = (TwoAxisFusionDesignInfo)fusion;
                    PxSymmetryBuilder       pxBuilder     = (PxSymmetryBuilder)builder;
                    pxBuilder.Scale = Line.GetDistance(twoAxisFusion.Axis1, twoAxisFusion.Axis2.Point) / Line.GetDistance(principalAxis1, principalAxis2.Point);
                    //pxBuilder.Scale = 2 * Line.GetDistance(twoAxisFusion.Axis2, twoAxisFusion.Axis1.Point);
                }

                CoordinateSystem[] coordinateSystems = builder.GetCoordinateSystems(startParams.UnitId1);
                for (int i = 0; i < coordinateSystems.Length; i++)
                {
                    outputChains.Add(new Chain(fusion.Peptide));
                    outputChains[i].Transform(coordinateSystems[i].Transform);


                    if (i > 0 && Clash.AnyContact(outputChains[0], outputChains[i], Clash.ContactType.MainchainMainchainClash))
                    {
                        fullSystemClashes = true;
                        break;
                    }
                }

#if DEBUG
                IChain[] originalChains = fusion.PdbOutputChains;
#endif
                fusion.PdbOutputChains = outputChains.ToArray();

                if (fullSystemClashes || writtenOutCount >= startParams.TopX)
                {
                    continue;
                }

                lock (lockFileIO)
                {
                    // Output files
                    string identifier = String.Format("CXCX_{0}_{1}_{2}_{3}", startParams.OutputPrefix, startParams.PdbCodeBundle1, startParams.PdbCodeBundle2, 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_CXCX.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);
#if DEBUG
                    PdbQuick.Save(identifier + "_2axis.pdb", originalChains);
#endif
                }
            }
            Console.WriteLine("Completed triplet [Bundle {0}]:[Bundle {1}], {2:F2} degrees, {3:F2}% ({4}/{5})", startParams.PdbCodeBundle1, startParams.PdbCodeBundle2, startParams.AngleDegrees, startParams.Counter.PercentComplete, startParams.Counter.Complete, startParams.Counter.Total);

            startParams.Counter.IncrementComplete();
            _threadCountSemaphore.Release();
        }
Exemple #3
0
 public override CoordinateSystem[] GetCoordinateSystems()
 {
     return(_symmetry.GetCoordinateSystems(_symmetry.EnabledUnits.First()));
 }