コード例 #1
0
        private void ParseLine(string line)
        {
            if (line.Length < 4)
            {
                return;
            }
            if (line.Substring(0, 4) == "ATOM" && line.IndexOf(" CA ") != -1)
            {
                string Record           = line.Substring(0, 6 - 0).Trim();
                string Id               = line.Substring(6, 11 - 6).Trim();
                string name             = line.Substring(12, 16 - 12).Trim();
                string residue          = line.Substring(17, 20 - 17).Trim();
                string chain            = line.Substring(21, 23 - 21).Trim();
                string residuenumber    = line.Substring(22, 26 - 22).Trim();
                string residueextension = line.Substring(26, 28 - 26).Trim();
                string xcoord           = line.Substring(30, 38 - 30).Trim();
                string ycoord           = line.Substring(38, 46 - 38).Trim();
                string zcoord           = line.Substring(46, 54 - 46).Trim();

                string[] PdbComponents = Regex.Split(line, @"[ \t]+");
                IResidue Residue       = new IResidue(Convert.ToInt32(Id),
                                                      name,
                                                      residue,
                                                      chain,
                                                      residuenumber + residueextension,
                                                      Convert.ToDouble(xcoord),
                                                      Convert.ToDouble(ycoord),
                                                      Convert.ToDouble(zcoord));

                //Add the atom to the list
                Atoms.Add(Residue);
            }
        }
コード例 #2
0
        private IResidue IsLoopSolventAccessible(List <IResidue> PdbResidues, List <IResidue> LoopResidues, ILoopCriteria LoopCriteria)
        {
            var PdbGuids = from p in PdbResidues
                           select p;

            var LoopGuids = from c in LoopResidues
                            select c;

            var PdbWithoutLoop = PdbGuids.Except(LoopGuids);

            //Grad the Apex atom from the loop segment
            double   MaxApexDistance = 0.0;
            double   ApexDistance    = 0.0;
            IResidue ApexResidue     = new IResidue();
            IResidue NTermResidue    = LoopResidues.First();
            IResidue CTermResidue    = LoopResidues.Last();

            double   TerminalDistance  = EuclideanDistance(NTermResidue, CTermResidue);
            IResidue PseudoTermResidue = new IResidue(0, "", "Virtual", "V", 0,
                                                      ((NTermResidue.X + CTermResidue.X) / 2),
                                                      ((NTermResidue.Y + CTermResidue.Y) / 2),
                                                      ((NTermResidue.Z + CTermResidue.Z) / 2));

            //Determine the Apex Residue
            foreach (IResidue Residue in LoopResidues)
            {
                ApexDistance = EuclideanDistance(PseudoTermResidue, Residue);
                if (ApexDistance > MaxApexDistance)
                {
                    MaxApexDistance = ApexDistance;
                    ApexResidue     = Residue;
                }
            }

            //Now calculate the distances between the Apex residue and all the other atoms in the PDB (minus the loop residues)
            foreach (IResidue Residue in PdbWithoutLoop)
            {
                if (EuclideanDistance(ApexResidue, Residue) < LoopCriteria.SolventExposedThreshold)
                {
                    //Not solvent accessible
                    return(null);
                }
            }
            return(ApexResidue);
        }
コード例 #3
0
 double EuclideanDistance(IResidue a, IResidue b)
 {
     return(Math.Sqrt(((a.X - b.X) * (a.X - b.X)) + ((a.Y - b.Y) * (a.Y - b.Y)) + ((a.Z - b.Z) * (a.Z - b.Z))));
 }
コード例 #4
0
        private IResidue IsLoopVectorSolventAccessible(List <IResidue> PdbResidues, List <IResidue> LoopResidues, int VectorScale, ILoopCriteria LoopCriteria)
        {
            var PdbGuids = from p in PdbResidues
                           select p;

            var LoopGuids = from c in LoopResidues
                            select c;

            var PdbWithoutLoop = PdbGuids.Except(LoopGuids);


            IResidue[] LoopArray = LoopResidues.ToArray();
            IResidue   NTerm     = LoopArray[0];
            IResidue   NTermP1   = LoopArray[1]; //Might not use this...
            IResidue   NTermP2   = LoopArray[2];

            IResidue CTerm   = LoopArray[LoopArray.Count() - 1]; //Zero base
            IResidue CTermP1 = LoopArray[LoopArray.Count() - 2]; //Might not use this...
            IResidue CTermP2 = LoopArray[LoopArray.Count() - 3];

            //Average the positions of the N aand C sides of the loops
            IResidue P0Term = new IResidue(0, "Virtual", "VP0", "N", 0,
                                           (NTerm.X + CTerm.X) / 2,
                                           (NTerm.Y + CTerm.Y) / 2,
                                           (NTerm.Z + CTerm.Z) / 2);

            //Might not use this...
            IResidue P1Term = new IResidue(0, "Virtual", "VP1", "N", 0,
                                           (NTermP1.X + CTermP1.X) / 2,
                                           (NTermP1.Y + CTermP1.Y) / 2,
                                           (NTermP1.Z + CTermP1.Z) / 2);

            IResidue P2Term = new IResidue(0, "Virtual", "VP2", "N", 0,
                                           (NTermP2.X + CTermP2.X) / 2,
                                           (NTermP2.Y + CTermP2.Y) / 2,
                                           (NTermP2.Z + CTermP2.Z) / 2);

            //Calculate the unit vector (not using P1 for now)
            double unitX = P2Term.X - P0Term.X;
            double unitY = P2Term.Y - P0Term.Y;
            double unitZ = P2Term.Z - P0Term.Z;

            //Scaled PsuedoResidue out in the solvent
            IResidue SolventResidue = new IResidue(0, "Virtual", "Solvent", "N", 0,
                                                   (unitX * VectorScale) + P0Term.X,
                                                   (unitY * VectorScale) + P0Term.Y,
                                                   (unitZ * VectorScale) + P0Term.Z);



            //Now calculate the distances between the Apex residue and all the other atoms in the PDB (minus the loop residues)
            foreach (IResidue Residue in PdbWithoutLoop)
            {
                if (EuclideanDistance(SolventResidue, Residue) < LoopCriteria.SolventExposedThreshold)
                {
                    //Not solvent accessible
                    return(null);
                }
            }

            //Determine the Apex Residue
            IResidue ApexResidue     = new IResidue();
            double   MaxApexDistance = 0.0;
            double   ApexDistance    = 0.0;

            foreach (IResidue Residue in LoopResidues)
            {
                ApexDistance = EuclideanDistance(P0Term, Residue);
                if (ApexDistance > MaxApexDistance)
                {
                    MaxApexDistance = ApexDistance;
                    ApexResidue     = Residue;
                }
            }
            return(ApexResidue);
        }
コード例 #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
ファイル: IPdb.cs プロジェクト: brspurri/ScaffoldFinderV2
        private void ParseLine(string line)
        {
            if (line.Length < 4) { return; }
            if (line.Substring(0,4)=="ATOM" && line.IndexOf(" CA ")!=-1)
            {
                string Record = line.Substring(0, 6-0).Trim();
                string Id = line.Substring(6, 11 - 6).Trim();
                string name = line.Substring(12, 16 - 12).Trim();
                string residue = line.Substring(17, 20 - 17).Trim();
                string chain = line.Substring(21, 23 - 21).Trim();
                string residuenumber = line.Substring(22, 26 - 22).Trim();
                string residueextension = line.Substring(26, 28 - 26).Trim();
                string xcoord = line.Substring(30, 38 - 30).Trim();
                string ycoord = line.Substring(38, 46 - 38).Trim();
                string zcoord = line.Substring(46, 54 - 46).Trim();

                string[] PdbComponents = Regex.Split(line, @"[ \t]+");
                IResidue Residue = new IResidue(Convert.ToInt32(Id),
                    name,
                    residue,
                    chain,
                    residuenumber + residueextension,
                    Convert.ToDouble(xcoord),
                    Convert.ToDouble(ycoord),
                    Convert.ToDouble(zcoord));

                //Add the atom to the list
                Atoms.Add(Residue);
            }
        }
コード例 #7
0
        private IResidue IsLoopVectorSolventAccessible(List<IResidue> PdbResidues, List<IResidue> LoopResidues, int VectorScale, ILoopCriteria LoopCriteria)
        {
            var PdbGuids = from p in PdbResidues
                           select p;

            var LoopGuids = from c in LoopResidues
                            select c;

            var PdbWithoutLoop = PdbGuids.Except(LoopGuids);

            IResidue[] LoopArray = LoopResidues.ToArray();
            IResidue NTerm = LoopArray[0];
            IResidue NTermP1 = LoopArray[1];    //Might not use this...
            IResidue NTermP2 = LoopArray[2];

            IResidue CTerm = LoopArray[LoopArray.Count()- 1]; //Zero base
            IResidue CTermP1 = LoopArray[LoopArray.Count() - 2]; //Might not use this...
            IResidue CTermP2 = LoopArray[LoopArray.Count() - 3];

            //Average the positions of the N aand C sides of the loops
            IResidue P0Term = new IResidue(0, "Virtual", "VP0", "N", 0,
                (NTerm.X + CTerm.X) / 2,
                (NTerm.Y + CTerm.Y) / 2,
                (NTerm.Z + CTerm.Z) / 2);

            //Might not use this...
            IResidue P1Term = new IResidue(0, "Virtual", "VP1", "N", 0,
                (NTermP1.X + CTermP1.X) / 2,
                (NTermP1.Y + CTermP1.Y) / 2,
                (NTermP1.Z + CTermP1.Z) / 2);

            IResidue P2Term = new IResidue(0, "Virtual", "VP2", "N", 0,
                (NTermP2.X + CTermP2.X) / 2,
                (NTermP2.Y + CTermP2.Y) / 2,
                (NTermP2.Z + CTermP2.Z) / 2);

            //Calculate the unit vector (not using P1 for now)
            double unitX = P2Term.X - P0Term.X;
            double unitY = P2Term.Y - P0Term.Y;
            double unitZ = P2Term.Z - P0Term.Z;

            //Scaled PsuedoResidue out in the solvent
            IResidue SolventResidue = new IResidue(0, "Virtual", "Solvent", "N", 0,
                (unitX * VectorScale) + P0Term.X,
                (unitY * VectorScale) + P0Term.Y,
                (unitZ * VectorScale) + P0Term.Z);

            //Now calculate the distances between the Apex residue and all the other atoms in the PDB (minus the loop residues)
            foreach (IResidue Residue in PdbWithoutLoop)
            {
                if (EuclideanDistance(SolventResidue, Residue) < LoopCriteria.SolventExposedThreshold)
                {
                    //Not solvent accessible
                    return null;
                }
            }

            //Determine the Apex Residue
            IResidue ApexResidue = new IResidue();
            double MaxApexDistance = 0.0;
            double ApexDistance = 0.0;
            foreach (IResidue Residue in LoopResidues)
            {
                ApexDistance = EuclideanDistance(P0Term, Residue);
                if (ApexDistance > MaxApexDistance)
                {
                    MaxApexDistance = ApexDistance;
                    ApexResidue = Residue;
                }
            }
            return ApexResidue;
        }
コード例 #8
0
        private IResidue IsLoopSolventAccessible(List<IResidue> PdbResidues, List<IResidue> LoopResidues, ILoopCriteria LoopCriteria)
        {
            var PdbGuids = from p in PdbResidues
                select p;

            var LoopGuids = from c in LoopResidues
                select c;

            var PdbWithoutLoop = PdbGuids.Except(LoopGuids);

            //Grad the Apex atom from the loop segment
            double MaxApexDistance = 0.0;
            double ApexDistance = 0.0;
            IResidue ApexResidue = new IResidue();
            IResidue NTermResidue = LoopResidues.First();
            IResidue CTermResidue = LoopResidues.Last();

            double TerminalDistance = EuclideanDistance(NTermResidue, CTermResidue);
            IResidue PseudoTermResidue = new IResidue(0, "", "Virtual", "V", 0,
                ((NTermResidue.X + CTermResidue.X) / 2),
                ((NTermResidue.Y+CTermResidue.Y) / 2),
                ((NTermResidue.Z+CTermResidue.Z) / 2));

            //Determine the Apex Residue
            foreach (IResidue Residue in LoopResidues) {
                ApexDistance = EuclideanDistance(PseudoTermResidue, Residue);
                if (ApexDistance > MaxApexDistance) {
                    MaxApexDistance = ApexDistance;
                    ApexResidue = Residue;
                }
            }

            //Now calculate the distances between the Apex residue and all the other atoms in the PDB (minus the loop residues)
            foreach (IResidue Residue in PdbWithoutLoop) {
                if (EuclideanDistance(ApexResidue, Residue) < LoopCriteria.SolventExposedThreshold) {
                    //Not solvent accessible
                    return null;
                }
            }
                return ApexResidue;
        }
コード例 #9
0
 double EuclideanDistance(IResidue a, IResidue b)
 {
     return Math.Sqrt(((a.X - b.X) * (a.X - b.X)) + ((a.Y - b.Y) * (a.Y - b.Y)) + ((a.Z - b.Z) * (a.Z - b.Z)));
 }