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); }
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; }
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)); }
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); }