Пример #1
0
        /// <summary>
        /// Detect all interfaces in a crystal
        /// built from XML coordinates file
        /// </summary>
        /// <param name="xmlFile"></param>
        /// <param name="paramFile"></param>
        public void FindInteractChains(string xmlFile, Dictionary <int, string> interfaceDefHash)
        {
            asymChainTreesHash.Clear();
            interfaceChainsList.Clear();
            string[] symOpStrings = GetSymOpStrings(interfaceDefHash);
            if (AppSettings.parameters == null)
            {
                AppSettings.LoadParameters();
            }

            pdbId = xmlFile.Substring(xmlFile.LastIndexOf("\\") + 1, 4);
            CrystalBuilder crystalBuilder = new CrystalBuilder("ALL");
            Dictionary <string, AtomInfo[]> interfaceChainHash = null;

            try
            {
                interfaceChainHash = crystalBuilder.BuildCrystal(xmlFile, symOpStrings);
            }
            catch (Exception ex)
            {
                throw new Exception("Building interface chains errors: " + xmlFile + ". " + ex.Message);
            }

            // for each chain in a cell including original and symmetric chains
            foreach (string chainAndSymOp in interfaceChainHash.Keys)
            {
                BVTree chainTree = new BVTree();
                chainTree.BuildBVTree(interfaceChainHash[chainAndSymOp], AppSettings.parameters.kDopsParam.bvTreeMethod, true);
                asymChainTreesHash.Add(chainAndSymOp, chainTree);
            }

            ChainContact chainContact  = null;
            List <int>   interfaceList = new List <int> (interfaceDefHash.Keys);

            interfaceList.Sort();
            foreach (int interfaceId in interfaceList)
            {
                string[] interfaceDefStrings = interfaceDefHash[interfaceId].ToString().Split(';');
                chainContact = new ChainContact(interfaceDefStrings[0], interfaceDefStrings[1]);
                BVTree           tree1       = (BVTree)asymChainTreesHash[interfaceDefStrings[0]];
                BVTree           tree2       = (BVTree)asymChainTreesHash[interfaceDefStrings[1]];
                ChainContactInfo contactInfo = chainContact.GetChainContactInfo(tree1, tree2);

                if (contactInfo == null)
                {
                    continue;
                }
                InterfaceChains interfaceChains = null;
                interfaceChains = new InterfaceChains(interfaceDefStrings[0], interfaceDefStrings[1],
                                                      tree1.Root.AtomList, tree2.Root.AtomList);
                interfaceChains.pdbId       = pdbId;
                interfaceChains.interfaceId = interfaceId;
                interfaceChains.seqDistHash = contactInfo.GetBbDistHash();
                //      interfaceChains.seqDistHash = contactInfo.cbetaContactHash;
                interfaceChains.seqContactHash = contactInfo.GetContactsHash();
                interfaceChainsList.Add(interfaceChains);
            }
        }
Пример #2
0
 public InterfaceChains(InterfaceChains extInterChains)
 {
     this.interfaceId       = extInterChains.interfaceId;
     this.firstSymOpString  = extInterChains.firstSymOpString;
     this.secondSymOpString = extInterChains.secondSymOpString;
     this.entityId1         = extInterChains.entityId1;
     this.entityId2         = extInterChains.entityId2;
     this.chain1            = (AtomInfo[])extInterChains.chain1.Clone();   // shaldow copy
     this.chain2            = (AtomInfo[])extInterChains.chain2.Clone();   // shaldow copy
     this.seqDistHash       = new Dictionary <string, double> (extInterChains.seqDistHash);
 }
Пример #3
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="extInterChains"></param>
 /// <param name="deepCopy"></param>
 public InterfaceChains(InterfaceChains extInterChains, bool deepCopy)
 {
     this.interfaceId       = extInterChains.interfaceId;
     this.firstSymOpString  = extInterChains.firstSymOpString;
     this.secondSymOpString = extInterChains.secondSymOpString;
     this.entityId1         = extInterChains.entityId1;
     this.entityId2         = extInterChains.entityId2;
     if (deepCopy)
     {
         DeepCopyChains(extInterChains.chain1, 1); // deep copy
         DeepCopyChains(extInterChains.chain2, 2);
         DeepCopySeqDistHash(extInterChains.seqDistHash);
     }
     else
     {
         this.chain1      = (AtomInfo[])extInterChains.chain1.Clone(); // shaldow copy
         this.chain2      = (AtomInfo[])extInterChains.chain2.Clone(); // shaldow copy
         this.seqDistHash = new Dictionary <string, double> (extInterChains.seqDistHash);
     }
 }
Пример #4
0
        /// <summary>
        /// Detect all interfaces in a crystal
        /// built from XML coordinates file
        /// </summary>
        /// <param name="xmlFile"></param>
        /// <param name="paramFile"></param>
        public void FindInteractChains(string xmlFile, Dictionary <int, string> interfaceDefHash, Dictionary <int, string> interfaceEntityInfoHash, out bool interfaceExist)
        {
            interChainId = 0;
            interfaceChainsList.Clear();
            asymChainTreesHash.Clear();
            interfaceExist = true;
            string[] symOpStrings = GetSymOpStrings(interfaceDefHash);

            pdbId = xmlFile.Substring(xmlFile.LastIndexOf("\\") + 1, 4);
            CrystalBuilder crystalBuilder = new CrystalBuilder(AppSettings.parameters.contactParams.atomType);
            Dictionary <string, AtomInfo[]> interfaceChainHash = null;

            try
            {
                interfaceChainHash = crystalBuilder.BuildCrystal(xmlFile, symOpStrings);
            }
            catch (Exception ex)
            {
                throw new Exception("Building interface chains errors: " + xmlFile + "  " + ex.Message);
            }

            // for each chain in a cell including original and symmetric chains
            foreach (string chainAndSymOp in interfaceChainHash.Keys)
            {
                BVTree chainTree = new BVTree();
                chainTree.BuildBVTree(interfaceChainHash[chainAndSymOp], AppSettings.parameters.kDopsParam.bvTreeMethod, true);
                asymChainTreesHash.Add(chainAndSymOp, chainTree);
            }

            ChainContact chainContact = null;

            foreach (int interfaceId in interfaceDefHash.Keys)
            {
                string[] interfaceDefStrings = interfaceDefHash[interfaceId].ToString().Split(';');
                chainContact = new ChainContact(interfaceDefStrings[0], interfaceDefStrings[1]);
                BVTree tree1 = (BVTree)asymChainTreesHash[interfaceDefStrings[0]];
                BVTree tree2 = (BVTree)asymChainTreesHash[interfaceDefStrings[1]];
                if (tree1 == null || tree2 == null)
                {
                    continue;
                }
                ChainContactInfo contactInfo = chainContact.GetChainContactInfo(tree1, tree2);

                if (contactInfo == null)
                {
                    interfaceExist = false;
                    break;
                }
                string[]        entityStrings   = interfaceEntityInfoHash[interfaceId].Split('_');
                InterfaceChains interfaceChains = null;
                interfaceChains = new InterfaceChains(interfaceDefStrings[0], interfaceDefStrings[1], tree1.Root.CalphaCbetaAtoms(), tree2.Root.CalphaCbetaAtoms());
                //	interfaceChains = new InterfaceChains (symOpStrings[0], symOpStrings[1], tree1.Root.AtomList, tree2.Root.AtomList);
                interfaceChains.pdbId          = pdbId;
                interfaceChains.interfaceId    = interfaceId;
                interfaceChains.entityId1      = Convert.ToInt32(entityStrings[0]);
                interfaceChains.entityId2      = Convert.ToInt32(entityStrings[1]);
                interfaceChains.seqDistHash    = contactInfo.GetBbDistHash();
                interfaceChains.seqContactHash = contactInfo.GetContactsHash();
                interfaceChainsList.Add(interfaceChains);
            }
        }
Пример #5
0
        /// <summary>
        /// add the interactive chains if it is unique
        /// if it is not homomultimer, should consider the sequence alignment
        /// within an entry
        /// </summary>
        /// <param name="interChains"></param>
        private bool AddInterChainsToList(InterfaceChains interfaceChains)
        {
            bool hasSameInterface = false;
            int  interfaceIndex   = 0;

            foreach (InterfaceChains interfaceChainsInList in interfaceChainsList)
            {
                if (interfacesComp.AreInterfacesSame(interfaceChainsInList, interfaceChains))
                {
                    hasSameInterface = true;
                    break;
                }
                interfaceIndex++;
            }
            if (!hasSameInterface)
            {
                // assign a sequential number
                interChainId++;
                interfaceChains.pdbId       = pdbId;
                interfaceChains.interfaceId = interChainId;
                interfaceChainsList.Add(interfaceChains);

                return(true);
            }
            else
            {
                InterfaceChains interfaceInList = (InterfaceChains)interfaceChainsList[interfaceIndex];
                if ((!HasOriginalChain(interfaceInList.firstSymOpString) &&
                     !HasOriginalChain(interfaceInList.secondSymOpString))
                    &&
                    (HasOriginalChain(interfaceChains.firstSymOpString) ||
                     HasOriginalChain(interfaceChains.secondSymOpString)))
                {
                    interfaceChains.pdbId               = pdbId;
                    interfaceChains.interfaceId         = interfaceInList.interfaceId;
                    interfaceChainsList[interfaceIndex] = interfaceChains;
                    return(true);
                }
                else if (((HasOriginalChain(interfaceInList.firstSymOpString) &&
                           interfaceInList.secondSymOpString.IndexOf("555") < 0)
                          ||
                          (interfaceInList.firstSymOpString.IndexOf("555") < 0 &&
                           HasOriginalChain(interfaceInList.secondSymOpString)))
                         &&
                         ((HasOriginalChain(interfaceChains.firstSymOpString) &&
                           interfaceChains.secondSymOpString.IndexOf("555") > -1)
                          ||
                          (interfaceChains.firstSymOpString.IndexOf("555") > -1 &&
                           HasOriginalChain(interfaceChains.secondSymOpString))))
                {
                    interfaceChains.pdbId               = pdbId;
                    interfaceChains.interfaceId         = interfaceInList.interfaceId;
                    interfaceChainsList[interfaceIndex] = interfaceChains;
                    return(true);
                }
                else if ((interfaceInList.firstSymOpString.IndexOf("555") < 0 &&
                          interfaceInList.secondSymOpString.IndexOf("555") < 0)
                         &&
                         (interfaceChains.firstSymOpString.IndexOf("555") > -1 ||
                          interfaceChains.secondSymOpString.IndexOf("555") > -1))
                {
                    interfaceChains.pdbId               = pdbId;
                    interfaceChains.interfaceId         = interfaceInList.interfaceId;
                    interfaceChainsList[interfaceIndex] = interfaceChains;
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
        }
Пример #6
0
        /// <summary>
        /// check interaction a center chain with
        /// another translated chains
        /// </summary>
        /// <param name="chainASymOp">translated chain</param>
        /// <param name="chainBSymOp">center chain</param>
        /// <param name="treeA">translated tree</param>
        /// <param name="treeB">center tree</param>
        private bool DetectTwoChainContactWithTranslation(string translateChainSymOp, string centerChainSymOp,
                                                          BVTree translateTree, BVTree centerTree, bool skipOrig)
        {
            string transChainSymOp = "";
            int    origX           = -1;
            int    origY           = -1;
            int    origZ           = -1;
            string transVectString = translateChainSymOp.Substring(translateChainSymOp.LastIndexOf("_") + 1,
                                                                   translateChainSymOp.Length - translateChainSymOp.LastIndexOf("_") - 1);

            GetOrigPoint(transVectString, ref origX, ref origY, ref origZ);

            bool thisNewInterfaceExist = false;


            try
            {
                ChainContact chainContact = null;

                /* total number of BVTrees: (step * 2 + 1) ^ 3
                 * total comparison of BVTrees: (step * 2 + 1) - 1
                 * e.g. steps = 1; total comparisons: 26
                 * compare all neighbor unit cells with the original unit cell
                 */
                // comare center chain B with center chain A and all its translated chains
                foreach (int xA in xStepList)
                {
                    foreach (int yA in yStepList)
                    {
                        foreach (int zA in zStepList)
                        {
                            if (xA == 0 && yA == 0 && zA == 0 && skipOrig)
                            {
                                thisNewInterfaceExist = true;
                                continue;
                            }
                            // chain_symmetry operator number_translation vector
                            // e.g. A_1_556 (chain A, symmetry operator is 1, and translation vector (0, 0, 1))
                            transChainSymOp = GetTransSymOpString(translateChainSymOp, origX + xA, origY + yA, origZ + zA);
                            if (parsedPairList.Contains(centerChainSymOp + "_" + transChainSymOp))
                            {
                                continue;
                            }
                            else
                            {
                                parsedPairList.Add(centerChainSymOp + "_" + transChainSymOp);
                            }

                            double[] fractVectorA = new double [3] {
                                xA, yA, zA
                            };
                            double[] translateVectorA = ComputeTransVectInCartn(fractVectorA);
                            //	BVTree translatedTree = translateTree.UpdateBVTree (translateVectorA);

                            chainContact = new ChainContact(centerChainSymOp, transChainSymOp);
                            ChainContactInfo contactInfo = chainContact.GetChainContactInfo(centerTree, translateTree, translateVectorA);
                            if (contactInfo != null)
                            {
                                InterfaceChains interfaceChains = null;
                                Node            updateRoot      = new Node(translateTree.Root.CalphaCbetaAtoms());
                                updateRoot.UpdateLeafNode(translateVectorA);
                                interfaceChains = new InterfaceChains(centerChainSymOp, transChainSymOp,
                                                                      centerTree.Root.CalphaCbetaAtoms(), updateRoot.AtomList);
                                interfaceChains.seqDistHash    = contactInfo.GetBbDistHash();
                                interfaceChains.seqContactHash = contactInfo.GetContactsHash();
                                if (AddInterChainsToList(interfaceChains))
                                {
                                    thisNewInterfaceExist = true;
                                }
                            }
                        }
                    }
                }                // end of translated chain
            }
            catch (Exception ex)
            {
                throw new Exception(string.Format("Comparisons of rotated and translated chains ({0}, {1}) errors: {2}",
                                                  translateChainSymOp, centerChainSymOp, ex.Message));
            }
            return(thisNewInterfaceExist);
        }
Пример #7
0
        /// <summary>
        /// check interaction a center chain with
        /// its corresponding translated chains
        /// </summary>
        /// <param name="chainASymOp"></param>
        /// <param name="chainBSymOp"></param>
        /// <param name="treeA"></param>
        /// <param name="treeB"></param>
        private bool DetectChainContactWithTranslation(string chainASymOp, BVTree origTreeA)
        {
            string        transChainASymOp = "";
            List <string> parsedSymOpsList = new List <string> ();
            int           origX            = -1;
            int           origY            = -1;
            int           origZ            = -1;
            string        transVectString  = chainASymOp.Substring(chainASymOp.LastIndexOf("_") + 1,
                                                                   chainASymOp.Length - chainASymOp.LastIndexOf("_") - 1);

            GetOrigPoint(transVectString, ref origX, ref origY, ref origZ);

            bool thisNewInterfaceExist = false;

            /* total number of BVTrees: (step * 2 + 1) ^ 3
             * total comparison of BVTrees: (step * 2 + 1) - 1
             * e.g. steps = 1; total comparisons: 26
             * compare all neighbor unit cells with the original unit cell
             */
            // compare a center chain with all its corresponding translated chains
            foreach (int xA in xStepList)
            {
                foreach (int yA in yStepList)
                {
                    foreach (int zA in zStepList)
                    {
                        // skip check contacts with itself
                        // probably we need to check contacts within a chain also.
                        if (xA == 0 && yA == 0 && zA == 0)
                        {
                            thisNewInterfaceExist = true;
                            continue;
                        }

                        transChainASymOp = GetTransSymOpString(chainASymOp, origX + xA, origY + yA, origZ + zA);
                        if (parsedPairList.Contains(chainASymOp + "_" + transChainASymOp))
                        {
                            continue;
                        }
                        else
                        {
                            parsedPairList.Add(chainASymOp + "_" + transChainASymOp);
                        }

                        double[] fractVectorA = new double [3] {
                            xA, yA, zA
                        };
                        double[] translateVectorA = ComputeTransVectInCartn(fractVectorA);

                        // get the BVtree for the translated chain
                        //	BVTree treeA = origTreeA.UpdateBVTree (translateVectorA);

                        ChainContact     chainContact = new ChainContact(chainASymOp, transChainASymOp);
                        ChainContactInfo contactInfo  = chainContact.GetChainContactInfo(origTreeA, origTreeA, translateVectorA);
                        if (contactInfo != null)
                        {
                            InterfaceChains interfaceChains = null;
                            Node            updateRoot      = new Node(origTreeA.Root.CalphaCbetaAtoms());
                            updateRoot.UpdateLeafNode(translateVectorA);
                            interfaceChains = new InterfaceChains(chainASymOp, transChainASymOp,
                                                                  origTreeA.Root.CalphaCbetaAtoms(), updateRoot.AtomList);
                            interfaceChains.seqDistHash    = contactInfo.GetBbDistHash();
                            interfaceChains.seqContactHash = contactInfo.GetContactsHash();
                            if (AddInterChainsToList(interfaceChains))
                            {
                                thisNewInterfaceExist = true;
                            }
                        }
                    }
                }
            }
            return(thisNewInterfaceExist);
        }