コード例 #1
0
        private static ILoopsCollection CleanupLoops(ILoopsCollection LoopsCollection)
        {
            ILoopsCollection CleanedLoopsCollection = new ILoopsCollection();

            foreach (ILoop Loop in LoopsCollection.Loops)
            {
                var Count = (from p in CleanedLoopsCollection.Loops where p.ApexAtom == Loop.ApexAtom select p).Count();
                if (Count == 0)
                {
                    CleanedLoopsCollection.Add(Loop);
                }
            }
            return(CleanedLoopsCollection);
        }
コード例 #2
0
        public List <ILoopTrimer> FindTrimerLoops(ILoopsCollection LoopsCollection, ILoopCriteria LoopCriteria)
        {
            List <ILoopTrimer> LoopTrimers = new List <ILoopTrimer>();

            //Search for pairs if we specify
            if (LoopCriteria.SearchForTrimer)
            {
                foreach (ILoop LoopA in LoopsCollection.Loops)
                {
                    foreach (ILoop LoopB in LoopsCollection.Loops)
                    {
                        double InterPairDistanceAB = EuclideanDistance(LoopA.ApexAtom, LoopB.ApexAtom);
                        if (InterPairDistanceAB > LoopCriteria.LoopTrimerDistanceLowerLimit &&
                            InterPairDistanceAB < LoopCriteria.LoopTrimerDistanceUpperLimit)
                        {
                            foreach (ILoop LoopC in LoopsCollection.Loops)
                            {
                                double InterPairDistanceAC = EuclideanDistance(LoopA.ApexAtom, LoopC.ApexAtom);
                                double InterPairDistanceBC = EuclideanDistance(LoopB.ApexAtom, LoopC.ApexAtom);

                                if (InterPairDistanceAC > LoopCriteria.LoopTrimerDistanceLowerLimit &&
                                    InterPairDistanceAC < LoopCriteria.LoopTrimerDistanceUpperLimit &&
                                    InterPairDistanceBC > LoopCriteria.LoopTrimerDistanceLowerLimit &&
                                    InterPairDistanceBC < LoopCriteria.LoopTrimerDistanceUpperLimit)
                                {
                                    ILoopTrimer LoopTrimer = new ILoopTrimer();
                                    LoopTrimer.LoopA = LoopA;
                                    LoopTrimer.LoopB = LoopB;
                                    LoopTrimer.LoopC = LoopC;
                                    LoopTrimers.Add(LoopTrimer);
                                    Console.WriteLine("Added Trimer");
                                }
                            }
                        }
                    }
                }
            }

            return(LoopTrimers);
            //return CleanupLoopPairs(LoopPairs); //TODO -> Cleanup trimers
        }
コード例 #3
0
        public List<ILoopTrimer> FindTrimerLoops(ILoopsCollection LoopsCollection, ILoopCriteria LoopCriteria)
        {
            List<ILoopTrimer> LoopTrimers = new List<ILoopTrimer>();

            //Search for pairs if we specify
            if (LoopCriteria.SearchForTrimer) {
                foreach (ILoop LoopA in LoopsCollection.Loops) {
                    foreach (ILoop LoopB in LoopsCollection.Loops) {

                        double InterPairDistanceAB = EuclideanDistance(LoopA.ApexAtom, LoopB.ApexAtom);
                        if (InterPairDistanceAB > LoopCriteria.LoopTrimerDistanceLowerLimit &&
                            InterPairDistanceAB < LoopCriteria.LoopTrimerDistanceUpperLimit)
                        {

                            foreach (ILoop LoopC in LoopsCollection.Loops)
                            {
                                double InterPairDistanceAC = EuclideanDistance(LoopA.ApexAtom, LoopC.ApexAtom);
                                double InterPairDistanceBC = EuclideanDistance(LoopB.ApexAtom, LoopC.ApexAtom);

                                if (InterPairDistanceAC > LoopCriteria.LoopTrimerDistanceLowerLimit &&
                                    InterPairDistanceAC < LoopCriteria.LoopTrimerDistanceUpperLimit &&
                                    InterPairDistanceBC > LoopCriteria.LoopTrimerDistanceLowerLimit &&
                                    InterPairDistanceBC < LoopCriteria.LoopTrimerDistanceUpperLimit)
                                {
                                    ILoopTrimer LoopTrimer = new ILoopTrimer();
                                    LoopTrimer.LoopA = LoopA;
                                    LoopTrimer.LoopB = LoopB;
                                    LoopTrimer.LoopC = LoopC;
                                    LoopTrimers.Add(LoopTrimer);
                                    Console.WriteLine("Added Trimer");

                                }
                            }
                        }
                    }
                }
            }

            return (LoopTrimers);
            //return CleanupLoopPairs(LoopPairs); //TODO -> Cleanup trimers
        }
コード例 #4
0
        public List <ILoopPair> FindMatchedLoops(ILoopsCollection LoopsCollection, ILoopCriteria LoopCriteria)
        {
            List <ILoopPair> LoopPairs = new List <ILoopPair>();

            //Search for pairs if we specify
            if (LoopCriteria.SearchForLoopPairs)
            {
                foreach (ILoop LoopA in LoopsCollection.Loops)
                {
                    foreach (ILoop LoopB in LoopsCollection.Loops)
                    {
                        double InterPairDistance = EuclideanDistance(LoopA.ApexAtom, LoopB.ApexAtom);

                        if (InterPairDistance == 0)
                        {
                            //Same loop
                            continue;
                        }

                        double N0Distance = EuclideanDistance(LoopA.NTermAtom, LoopB.NTermAtom);
                        double N1Distance = EuclideanDistance(LoopA.NTermAtomP1, LoopB.NTermAtomP1);
                        double N2Distance = EuclideanDistance(LoopA.NTermAtomP2, LoopB.NTermAtomP2);

                        double C0Distance = EuclideanDistance(LoopA.CTermAtom, LoopB.CTermAtom);
                        double C1Distance = EuclideanDistance(LoopA.CTermAtomP1, LoopB.CTermAtomP1);
                        double C2Distance = EuclideanDistance(LoopA.CTermAtomP2, LoopB.CTermAtomP2);

                        //Old
                        //if (InterPairDistance > LoopCriteria.LoopPairDistanceLowerLimit &&
                        //   InterPairDistance < LoopCriteria.LoopPairDistanceUpperLimit) {

                        //New
                        if (N0Distance < LoopCriteria.NNP0DistanceUpper && N0Distance > LoopCriteria.NNP0DistanceLower &&
                            N1Distance < LoopCriteria.NNP1DistanceUpper && N1Distance > LoopCriteria.NNP1DistanceLower &&
                            N2Distance < LoopCriteria.NNP2DistanceUpper && N2Distance > LoopCriteria.NNP2DistanceLower &&
                            C0Distance < LoopCriteria.CCP0DistanceUpper && C0Distance > LoopCriteria.CCP0DistanceLower &&
                            C1Distance < LoopCriteria.CCP1DistanceUpper && C1Distance > LoopCriteria.CCP1DistanceLower &&
                            C2Distance < LoopCriteria.CCP2DistanceUpper && C2Distance > LoopCriteria.CCP2DistanceLower)
                        {
                            Vector3D vector1 = new Vector3D(1, 0, 0);
                            Vector3D vector2 = new Vector3D(0, 0, 1);
                            double   crossProduct3D;



                            // crossProduct is equal to 50
                            crossProduct3D = Vector3D.AngleBetween(LoopA.UnitVector, LoopB.UnitVector);



                            if (LoopCriteria.RequireLoopsOnSameChain)
                            {
                                if (crossProduct3D > LoopCriteria.LoopOrientationAngleLower &&
                                    crossProduct3D < LoopCriteria.LoopOrientationAngleUpper)
                                {
                                    if (LoopA.Chain == LoopB.Chain)
                                    {
                                        ILoopPair LoopPair = new ILoopPair();
                                        LoopPair.LoopA = LoopA;
                                        LoopPair.LoopB = LoopB;
                                        LoopPairs.Add(LoopPair);
                                    }
                                }
                            }
                        }
                    }
                }
            }

            //return (LoopPairs);
            return(CleanupLoopPairs(LoopPairs));
        }
コード例 #5
0
        public ILoopsCollection Search(IPdb Pdb)
        {
            ILoopsCollection LoopsCollection = new ILoopsCollection();
            ILoopCriteria    LoopCriteria    = new ILoopCriteria(true);

            //Try some LINQ on this beast
            var Chains = (from p in Pdb.Atoms select p.Chain).Distinct();

            foreach (string ChainName in Chains)
            {
                //Get all the atoms in the chain
                var        Chain        = (from p in Pdb.Atoms where p.Chain == ChainName select p);
                IResidue[] AtomsInChain = Chain.ToArray();

                //Set the chain length if it is not explicitly set (full length here)
                if (LoopCriteria.Start == -1)
                {
                    LoopCriteria.Start = 0;
                }
                if (LoopCriteria.End == -1)
                {
                    LoopCriteria.End = AtomsInChain.Count();
                }

                //Search for the loops
                if (LoopCriteria.Length > AtomsInChain.Count())
                {
                    continue;
                }
                for (int i = LoopCriteria.Start; i < LoopCriteria.End - LoopCriteria.Length - 1; i++)
                {
                    //Check for the terminal distances
                    double eDistance = EuclideanDistance(AtomsInChain[i], AtomsInChain[i + LoopCriteria.Length]);
                    if (eDistance < LoopCriteria.TerminiDistanceThreshold)
                    {
                        //Passes the Distance Test

                        //Check for the solvent accessible regions
                        if (LoopCriteria.SolventAccessible)
                        {
                            List <IResidue> LoopResidues = new List <IResidue>();
                            for (int j = i; j < i + LoopCriteria.Length; j++)
                            {
                                LoopResidues.Add(AtomsInChain[j]);
                            }
                            IResidue ApexResidue = IsLoopVectorSolventAccessible(Pdb.Atoms, LoopResidues, 4, LoopCriteria);
                            //IResidue ApexResidue = IsLoopSolventAccessible(Pdb.Atoms, LoopResidues, LoopCriteria);
                            if (ApexResidue != null)
                            {
                                //Passes the solvent test, add it to the loop collection
                                ILoop Loop = new ILoop();
                                Loop.NTermAtom   = AtomsInChain[i];
                                Loop.NTermAtomP1 = AtomsInChain[i + 1];
                                Loop.NTermAtomP2 = AtomsInChain[i + 2];
                                Loop.CTermAtom   = AtomsInChain[i + LoopCriteria.Length];
                                Loop.CTermAtomP1 = AtomsInChain[i + LoopCriteria.Length - 1];
                                Loop.CTermAtomP2 = AtomsInChain[i + LoopCriteria.Length - 2];
                                Loop.LoopLength  = LoopCriteria.Length;
                                Loop.PdbCode     = Pdb.PdbCode;
                                Loop.Chain       = ChainName;
                                Loop.ApexAtom    = ApexResidue;


                                Loop.UnitVector = new Vector3D(((Loop.NTermAtomP2.X + Loop.CTermAtomP2.X) / 2) - ((Loop.NTermAtom.X + Loop.CTermAtom.X) / 2),
                                                               ((Loop.NTermAtomP2.Y + Loop.CTermAtomP2.Y) / 2) - ((Loop.NTermAtom.Y + Loop.CTermAtom.Y) / 2),
                                                               ((Loop.NTermAtomP2.X + Loop.CTermAtomP2.X) / 2) - ((Loop.NTermAtom.X + Loop.CTermAtom.X) / 2));

                                //Ensure Beta-Loop-Beta
                                if (EuclideanDistance(Loop.NTermAtom, Loop.CTermAtom) < LoopCriteria.TerminiDistanceThreshold &&
                                    EuclideanDistance(Loop.NTermAtomP1, Loop.CTermAtomP1) < LoopCriteria.TerminiDistanceThreshold &&
                                    EuclideanDistance(Loop.NTermAtomP2, Loop.CTermAtomP2) < LoopCriteria.TerminiDistanceThreshold)
                                {
                                    LoopsCollection.Add(Loop);
                                }
                            }
                        }
                    }
                }
                LoopCriteria.End   = -1;
                LoopCriteria.Start = -1;
            }

            //Cleanup
            LoopCriteria = null;

            //Return
            return(CleanupLoops(LoopsCollection));
        }
コード例 #6
0
ファイル: Program.cs プロジェクト: brspurri/ScaffoldFinderV2
        static void Main(string[] args)
        {
            #region Argument Parameters

            string OutputFilename;
            string PdbDirectory = @"C:\PDB\Monomer";
            string PdbMultimerDirectory = @"C:\Archives\Biounits";
            string PdbFile = @"C:\PDB\Monomer\pdb1rcv.ent.gz";
            bool useMultimeric = false;

            #endregion

            ILoopCriteria LoopCriteria = new ILoopCriteria();

            Arguments CommandLine = new Arguments(args);
            if (CommandLine["directory"] != null) {
                PdbDirectory = CommandLine["directory"];
            }

            if (CommandLine["multimeric"] != null) {
                useMultimeric = true;
            }

            if (CommandLine["searchfortrimer"] != null)
            {
                LoopCriteria.SearchForTrimer = true;
                LoopCriteria.SearchForLoopPairs = false;
            }

            if (CommandLine["file"] != null) {
                PdbFile = CommandLine["file"];
            }

            if (CommandLine["match"] != null) {
                LoopCriteria.SearchForLoopPairs = true;
                if (CommandLine["lower"] != null) {
                    LoopCriteria.LoopPairDistanceLowerLimit = Convert.ToDouble(CommandLine["lower"]);
                }
                if (CommandLine["upper"] != null) {
                    LoopCriteria.LoopPairDistanceUpperLimit = Convert.ToDouble(CommandLine["upper"]);
                }
            }
            else {
                LoopCriteria.SearchForLoopPairs = false;
            }

            if (CommandLine["out"] != null) {
                OutputFilename = CommandLine["out"];
            }
            else {
                OutputFilename = "ScaffoldFinderLog_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".txt";
            }

            string LogFilename = @"c:\Archives\Output\" + OutputFilename;
            FileStream LogStream = File.Open(LogFilename,
                                    FileMode.CreateNew,
                                    FileAccess.Write);
            StreamWriter LogFile = new StreamWriter(LogStream, Encoding.UTF8);

            //Write the lof file header
            if (LoopCriteria.SearchForLoopPairs) {
                LogFile.WriteLine("PDB,ChainA,NTermLoopA,CTermLoopA,Length,ChainB,NTermLoopB,CTermLoopB,LengthB,Size");
            }
            else if (LoopCriteria.SearchForTrimer)
            {
                LogFile.WriteLine("PDB,ChainA,NTermLoopA,CTermLoopA,Length,ChainB,NTermLoopB,CTermLoopB,LengthB,ChainC,NTermLoopC,CTermLoopC,LengthC");
            }
            else
            {
                LogFile.WriteLine("PDB,Chain,NTerm,CTerm,Length");
            }

            //Loop through the directory to get the PDBs
            DirectoryInfo Directory;
            if (useMultimeric) {
                Directory = new DirectoryInfo(PdbMultimerDirectory);

            }
            else {
                Directory = new DirectoryInfo(PdbDirectory);
            }

            int FileCounter = 0;
            int FileTotals = Directory.GetFiles().Count();
            foreach (FileInfo file in Directory.GetFiles())
            {
                FileCounter++;
                if (FileCounter % 500 == 0) {
                    Console.WriteLine("[" + FileCounter + "/" + FileTotals + "]: " + file.FullName);
                }
                //Console.SetCursorPosition(0, Console.CursorTop);

                //Console.WriteLine("Filename: " + file.Name + "  Size: " + file.Length);
                if (file.Length > 500000)
                {
                    continue;
                }
                IPdb Pdb = new IPdb(file.FullName, useMultimeric);
                ILoopsCollection LoopsCollection = new ILoopsCollection();
                if (Pdb.Atoms.Count() != 0) { // Implies Nucleic Acid
                    FindLoops findLoops = new FindLoops();
                    LoopsCollection = findLoops.Search(Pdb);
                    //LoopsCollection = FindLoops.Search(Pdb);
                    findLoops = null;

                }
                else {
                    continue;
                }

                //Search for three loops that match the trimer constraints
                if(LoopCriteria.SearchForTrimer) {
                    FindLoops findLoops = new FindLoops();
                    List<ILoopTrimer> LoopTrimer = findLoops.FindTrimerLoops(LoopsCollection, LoopCriteria);

                    foreach (ILoopTrimer Loops in LoopTrimer)
                    {
                        LogFile.WriteLine(Loops.LoopA.PdbCode + "," +
                                          Loops.LoopA.Chain + "," +
                                          Loops.LoopA.NTermAtom.ResidueNumber + Loops.LoopA.NTermAtom.ResidueExtension + "," +
                                          Loops.LoopA.CTermAtom.ResidueNumber + Loops.LoopA.CTermAtom.ResidueExtension + "," +
                                          Loops.LoopA.LoopLength + "," +
                                          Loops.LoopB.Chain + "," +
                                          Loops.LoopB.NTermAtom.ResidueNumber + Loops.LoopB.NTermAtom.ResidueExtension + "," +
                                          Loops.LoopB.CTermAtom.ResidueNumber + Loops.LoopB.CTermAtom.ResidueExtension + "," +
                                          Loops.LoopB.LoopLength + "," +
                                          Loops.LoopC.Chain + "," +
                                          Loops.LoopC.NTermAtom.ResidueNumber + Loops.LoopC.NTermAtom.ResidueExtension + "," +
                                          Loops.LoopC.CTermAtom.ResidueNumber + Loops.LoopC.CTermAtom.ResidueExtension + "," +
                                          Loops.LoopC.LoopLength);
                    }

                    LoopTrimer = null;
                    findLoops = null;
                }

                else if (LoopCriteria.SearchForLoopPairs) {
                    FindLoops findLoops = new FindLoops();
                    List<ILoopPair> LoopPairs = findLoops.FindMatchedLoops(LoopsCollection, LoopCriteria);
                    foreach (ILoopPair LoopPair in LoopPairs)
                    {
                        Console.WriteLine("Found: " + LoopPair.LoopA.PdbCode);
                        LogFile.WriteLine(LoopPair.LoopA.PdbCode + "," +
                                          LoopPair.LoopA.Chain + "," +
                                          LoopPair.LoopA.NTermAtom.ResidueNumber + LoopPair.LoopA.NTermAtom.ResidueExtension + "," +
                                          LoopPair.LoopA.CTermAtom.ResidueNumber + LoopPair.LoopA.CTermAtom.ResidueExtension + "," +
                                          LoopPair.LoopA.LoopLength + "," +
                                          LoopPair.LoopB.Chain + "," +
                                          LoopPair.LoopB.NTermAtom.ResidueNumber + LoopPair.LoopB.NTermAtom.ResidueExtension + "," +
                                          LoopPair.LoopB.CTermAtom.ResidueNumber + LoopPair.LoopB.CTermAtom.ResidueExtension + "," +
                                          LoopPair.LoopB.LoopLength + "," +
                                          Pdb.Atoms.Count()) ;
                    }
                    LoopPairs = null;
                    findLoops = null;

                }

                else
                {

                    foreach (ILoop Loop in LoopsCollection.Loops)
                    {

                        LogFile.WriteLine(Loop.PdbCode + "," +
                                          Loop.Chain + "," +
                                          Loop.NTermAtom.ResidueNumber + Loop.NTermAtom.ResidueExtension + "," +
                                          Loop.CTermAtom.ResidueNumber + Loop.CTermAtom.ResidueExtension + "," +
                                          Loop.LoopLength);

                    }
                    //Cleanup

                }
            }

            LogFile.Close();
            LogStream.Close();

               // Console.ReadLine();
        }
コード例 #7
0
        static void Main(string[] args)
        {
            #region Argument Parameters

            string OutputFilename;
            string PdbDirectory         = @"C:\PDB\Monomer";
            string PdbMultimerDirectory = @"C:\Archives\Biounits";
            string PdbFile       = @"C:\PDB\Monomer\pdb1rcv.ent.gz";
            bool   useMultimeric = false;

            #endregion

            ILoopCriteria LoopCriteria = new ILoopCriteria();

            Arguments CommandLine = new Arguments(args);
            if (CommandLine["directory"] != null)
            {
                PdbDirectory = CommandLine["directory"];
            }

            if (CommandLine["multimeric"] != null)
            {
                useMultimeric = true;
            }

            if (CommandLine["searchfortrimer"] != null)
            {
                LoopCriteria.SearchForTrimer    = true;
                LoopCriteria.SearchForLoopPairs = false;
            }

            if (CommandLine["file"] != null)
            {
                PdbFile = CommandLine["file"];
            }

            if (CommandLine["match"] != null)
            {
                LoopCriteria.SearchForLoopPairs = true;
                if (CommandLine["lower"] != null)
                {
                    LoopCriteria.LoopPairDistanceLowerLimit = Convert.ToDouble(CommandLine["lower"]);
                }
                if (CommandLine["upper"] != null)
                {
                    LoopCriteria.LoopPairDistanceUpperLimit = Convert.ToDouble(CommandLine["upper"]);
                }
            }
            else
            {
                LoopCriteria.SearchForLoopPairs = false;
            }

            if (CommandLine["out"] != null)
            {
                OutputFilename = CommandLine["out"];
            }
            else
            {
                OutputFilename = "ScaffoldFinderLog_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".txt";
            }



            string     LogFilename = @"c:\Archives\Output\" + OutputFilename;
            FileStream LogStream   = File.Open(LogFilename,
                                               FileMode.CreateNew,
                                               FileAccess.Write);
            StreamWriter LogFile = new StreamWriter(LogStream, Encoding.UTF8);


            //Write the lof file header
            if (LoopCriteria.SearchForLoopPairs)
            {
                LogFile.WriteLine("PDB,ChainA,NTermLoopA,CTermLoopA,Length,ChainB,NTermLoopB,CTermLoopB,LengthB,Size");
            }
            else if (LoopCriteria.SearchForTrimer)
            {
                LogFile.WriteLine("PDB,ChainA,NTermLoopA,CTermLoopA,Length,ChainB,NTermLoopB,CTermLoopB,LengthB,ChainC,NTermLoopC,CTermLoopC,LengthC");
            }
            else
            {
                LogFile.WriteLine("PDB,Chain,NTerm,CTerm,Length");
            }


            //Loop through the directory to get the PDBs
            DirectoryInfo Directory;
            if (useMultimeric)
            {
                Directory = new DirectoryInfo(PdbMultimerDirectory);
            }
            else
            {
                Directory = new DirectoryInfo(PdbDirectory);
            }

            int FileCounter = 0;
            int FileTotals  = Directory.GetFiles().Count();
            foreach (FileInfo file in Directory.GetFiles())
            {
                FileCounter++;
                if (FileCounter % 500 == 0)
                {
                    Console.WriteLine("[" + FileCounter + "/" + FileTotals + "]: " + file.FullName);
                }
                //Console.SetCursorPosition(0, Console.CursorTop);

                //Console.WriteLine("Filename: " + file.Name + "  Size: " + file.Length);
                if (file.Length > 500000)
                {
                    continue;
                }
                IPdb             Pdb             = new IPdb(file.FullName, useMultimeric);
                ILoopsCollection LoopsCollection = new ILoopsCollection();
                if (Pdb.Atoms.Count() != 0)   // Implies Nucleic Acid
                {
                    FindLoops findLoops = new FindLoops();
                    LoopsCollection = findLoops.Search(Pdb);
                    //LoopsCollection = FindLoops.Search(Pdb);
                    findLoops = null;
                }
                else
                {
                    continue;
                }

                //Search for three loops that match the trimer constraints
                if (LoopCriteria.SearchForTrimer)
                {
                    FindLoops          findLoops  = new FindLoops();
                    List <ILoopTrimer> LoopTrimer = findLoops.FindTrimerLoops(LoopsCollection, LoopCriteria);

                    foreach (ILoopTrimer Loops in LoopTrimer)
                    {
                        LogFile.WriteLine(Loops.LoopA.PdbCode + "," +
                                          Loops.LoopA.Chain + "," +
                                          Loops.LoopA.NTermAtom.ResidueNumber + Loops.LoopA.NTermAtom.ResidueExtension + "," +
                                          Loops.LoopA.CTermAtom.ResidueNumber + Loops.LoopA.CTermAtom.ResidueExtension + "," +
                                          Loops.LoopA.LoopLength + "," +
                                          Loops.LoopB.Chain + "," +
                                          Loops.LoopB.NTermAtom.ResidueNumber + Loops.LoopB.NTermAtom.ResidueExtension + "," +
                                          Loops.LoopB.CTermAtom.ResidueNumber + Loops.LoopB.CTermAtom.ResidueExtension + "," +
                                          Loops.LoopB.LoopLength + "," +
                                          Loops.LoopC.Chain + "," +
                                          Loops.LoopC.NTermAtom.ResidueNumber + Loops.LoopC.NTermAtom.ResidueExtension + "," +
                                          Loops.LoopC.CTermAtom.ResidueNumber + Loops.LoopC.CTermAtom.ResidueExtension + "," +
                                          Loops.LoopC.LoopLength);
                    }

                    LoopTrimer = null;
                    findLoops  = null;
                }

                else if (LoopCriteria.SearchForLoopPairs)
                {
                    FindLoops        findLoops = new FindLoops();
                    List <ILoopPair> LoopPairs = findLoops.FindMatchedLoops(LoopsCollection, LoopCriteria);
                    foreach (ILoopPair LoopPair in LoopPairs)
                    {
                        Console.WriteLine("Found: " + LoopPair.LoopA.PdbCode);
                        LogFile.WriteLine(LoopPair.LoopA.PdbCode + "," +
                                          LoopPair.LoopA.Chain + "," +
                                          LoopPair.LoopA.NTermAtom.ResidueNumber + LoopPair.LoopA.NTermAtom.ResidueExtension + "," +
                                          LoopPair.LoopA.CTermAtom.ResidueNumber + LoopPair.LoopA.CTermAtom.ResidueExtension + "," +
                                          LoopPair.LoopA.LoopLength + "," +
                                          LoopPair.LoopB.Chain + "," +
                                          LoopPair.LoopB.NTermAtom.ResidueNumber + LoopPair.LoopB.NTermAtom.ResidueExtension + "," +
                                          LoopPair.LoopB.CTermAtom.ResidueNumber + LoopPair.LoopB.CTermAtom.ResidueExtension + "," +
                                          LoopPair.LoopB.LoopLength + "," +
                                          Pdb.Atoms.Count());
                    }
                    LoopPairs = null;
                    findLoops = null;
                }

                else
                {
                    foreach (ILoop Loop in LoopsCollection.Loops)
                    {
                        LogFile.WriteLine(Loop.PdbCode + "," +
                                          Loop.Chain + "," +
                                          Loop.NTermAtom.ResidueNumber + Loop.NTermAtom.ResidueExtension + "," +
                                          Loop.CTermAtom.ResidueNumber + Loop.CTermAtom.ResidueExtension + "," +
                                          Loop.LoopLength);
                    }
                    //Cleanup
                }
            }

            LogFile.Close();
            LogStream.Close();


            // Console.ReadLine();
        }
コード例 #8
0
 private static ILoopsCollection CleanupLoops(ILoopsCollection LoopsCollection)
 {
     ILoopsCollection CleanedLoopsCollection = new ILoopsCollection();
     foreach (ILoop Loop in LoopsCollection.Loops) {
         var Count = (from p in CleanedLoopsCollection.Loops where p.ApexAtom == Loop.ApexAtom select p).Count();
         if (Count == 0) {
             CleanedLoopsCollection.Add(Loop);
         }
     }
     return CleanedLoopsCollection;
 }
コード例 #9
0
        public ILoopsCollection Search(IPdb Pdb)
        {
            ILoopsCollection LoopsCollection = new ILoopsCollection();
            ILoopCriteria LoopCriteria = new ILoopCriteria(true);

            //Try some LINQ on this beast
            var Chains = (from p in Pdb.Atoms select p.Chain).Distinct();

            foreach (string ChainName in Chains)
            {
                //Get all the atoms in the chain
                var Chain = (from p in Pdb.Atoms where p.Chain == ChainName select p);
                IResidue[] AtomsInChain = Chain.ToArray();

                //Set the chain length if it is not explicitly set (full length here)
                if(LoopCriteria.Start == -1) { LoopCriteria.Start = 0; }
                if(LoopCriteria.End == -1) { LoopCriteria.End = AtomsInChain.Count(); }

                //Search for the loops
                if (LoopCriteria.Length > AtomsInChain.Count()) { continue; }
                for (int i = LoopCriteria.Start; i < LoopCriteria.End - LoopCriteria.Length-1; i++)
                {
                    //Check for the terminal distances
                    double eDistance = EuclideanDistance(AtomsInChain[i], AtomsInChain[i + LoopCriteria.Length]);
                    if (eDistance < LoopCriteria.TerminiDistanceThreshold) {
                        //Passes the Distance Test

                        //Check for the solvent accessible regions
                        if (LoopCriteria.SolventAccessible) {
                            List<IResidue> LoopResidues = new List<IResidue>();
                            for (int j = i; j < i + LoopCriteria.Length; j++) { LoopResidues.Add(AtomsInChain[j]); }
                            IResidue ApexResidue = IsLoopVectorSolventAccessible(Pdb.Atoms, LoopResidues, 4, LoopCriteria);
                            //IResidue ApexResidue = IsLoopSolventAccessible(Pdb.Atoms, LoopResidues, LoopCriteria);
                            if (ApexResidue!=null) {
                                //Passes the solvent test, add it to the loop collection
                                ILoop Loop = new ILoop();
                                Loop.NTermAtom = AtomsInChain[i];
                                Loop.NTermAtomP1 = AtomsInChain[i + 1];
                                Loop.NTermAtomP2 = AtomsInChain[i + 2];
                                Loop.CTermAtom = AtomsInChain[i + LoopCriteria.Length];
                                Loop.CTermAtomP1 = AtomsInChain[i + LoopCriteria.Length - 1];
                                Loop.CTermAtomP2 = AtomsInChain[i + LoopCriteria.Length - 2];
                                Loop.LoopLength = LoopCriteria.Length;
                                Loop.PdbCode = Pdb.PdbCode;
                                Loop.Chain = ChainName;
                                Loop.ApexAtom = ApexResidue;

                                Loop.UnitVector = new Vector3D(((Loop.NTermAtomP2.X + Loop.CTermAtomP2.X) / 2) - ((Loop.NTermAtom.X + Loop.CTermAtom.X) / 2),
                                    ((Loop.NTermAtomP2.Y + Loop.CTermAtomP2.Y) / 2) - ((Loop.NTermAtom.Y + Loop.CTermAtom.Y) / 2),
                                    ((Loop.NTermAtomP2.X + Loop.CTermAtomP2.X) / 2) - ((Loop.NTermAtom.X + Loop.CTermAtom.X) / 2));

                                //Ensure Beta-Loop-Beta
                                if (EuclideanDistance(Loop.NTermAtom, Loop.CTermAtom) < LoopCriteria.TerminiDistanceThreshold &&
                                    EuclideanDistance(Loop.NTermAtomP1, Loop.CTermAtomP1) < LoopCriteria.TerminiDistanceThreshold &&
                                    EuclideanDistance(Loop.NTermAtomP2, Loop.CTermAtomP2) < LoopCriteria.TerminiDistanceThreshold)
                                {
                                    LoopsCollection.Add(Loop);
                                }
                            }
                        }
                    }

                }
                LoopCriteria.End = -1;
                LoopCriteria.Start = -1;

            }

            //Cleanup
            LoopCriteria = null;

            //Return
            return CleanupLoops(LoopsCollection);
        }
コード例 #10
0
        public List<ILoopPair> FindMatchedLoops(ILoopsCollection LoopsCollection, ILoopCriteria LoopCriteria)
        {
            List<ILoopPair> LoopPairs = new List<ILoopPair>();

            //Search for pairs if we specify
            if (LoopCriteria.SearchForLoopPairs)
            {
                foreach (ILoop LoopA in LoopsCollection.Loops)
                {
                    foreach (ILoop LoopB in LoopsCollection.Loops)
                    {
                        double InterPairDistance = EuclideanDistance(LoopA.ApexAtom, LoopB.ApexAtom);

                        if(InterPairDistance==0) {
                            //Same loop
                            continue;
                        }

                        double N0Distance = EuclideanDistance(LoopA.NTermAtom, LoopB.NTermAtom);
                        double N1Distance = EuclideanDistance(LoopA.NTermAtomP1, LoopB.NTermAtomP1);
                        double N2Distance = EuclideanDistance(LoopA.NTermAtomP2, LoopB.NTermAtomP2);

                        double C0Distance = EuclideanDistance(LoopA.CTermAtom, LoopB.CTermAtom);
                        double C1Distance = EuclideanDistance(LoopA.CTermAtomP1, LoopB.CTermAtomP1);
                        double C2Distance = EuclideanDistance(LoopA.CTermAtomP2, LoopB.CTermAtomP2);

                        //Old
                        //if (InterPairDistance > LoopCriteria.LoopPairDistanceLowerLimit &&
                        //   InterPairDistance < LoopCriteria.LoopPairDistanceUpperLimit) {

                        //New
                        if( N0Distance < LoopCriteria.NNP0DistanceUpper && N0Distance > LoopCriteria.NNP0DistanceLower &&
                            N1Distance < LoopCriteria.NNP1DistanceUpper && N1Distance > LoopCriteria.NNP1DistanceLower &&
                            N2Distance < LoopCriteria.NNP2DistanceUpper && N2Distance > LoopCriteria.NNP2DistanceLower &&
                            C0Distance < LoopCriteria.CCP0DistanceUpper && C0Distance > LoopCriteria.CCP0DistanceLower &&
                            C1Distance < LoopCriteria.CCP1DistanceUpper && C1Distance > LoopCriteria.CCP1DistanceLower &&
                            C2Distance < LoopCriteria.CCP2DistanceUpper && C2Distance > LoopCriteria.CCP2DistanceLower) {

                                Vector3D vector1 = new Vector3D(1, 0, 0);
                                Vector3D vector2 = new Vector3D(0, 0, 1);
                                double crossProduct3D;

                                // crossProduct is equal to 50
                                crossProduct3D = Vector3D.AngleBetween(LoopA.UnitVector, LoopB.UnitVector);

                               if (LoopCriteria.RequireLoopsOnSameChain)
                               {
                                   if (crossProduct3D > LoopCriteria.LoopOrientationAngleLower &&
                                       crossProduct3D < LoopCriteria.LoopOrientationAngleUpper)
                                   {
                                       if (LoopA.Chain == LoopB.Chain)
                                       {
                                           ILoopPair LoopPair = new ILoopPair();
                                           LoopPair.LoopA = LoopA;
                                           LoopPair.LoopB = LoopB;
                                           LoopPairs.Add(LoopPair);
                                       }
                                   }
                               }

                        }
                    }
                }
            }

            //return (LoopPairs);
            return CleanupLoopPairs(LoopPairs);
        }