/// <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); } }
/// <summary> /// get the interface residues and corresponding distance /// </summary> public bool GetInterfaceResidueDist() { ChainContact chainContact = new ChainContact(this.firstSymOpString, this.secondSymOpString, AppSettings.parameters.contactParams.cutoffResidueDist, AppSettings.parameters.contactParams.numOfResidueContacts); ChainContactInfo interfaceInfo = chainContact.GetChainContactInfo(chain1, chain2); if (interfaceInfo == null) { return(false); } seqDistHash = interfaceInfo.GetBbDistHash(); seqContactHash = interfaceInfo.GetContactsHash(); return(true); }
/// <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); } }
/// <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); }
/// <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); }