コード例 #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
        /// <summary>
        /// Detect all interfaces in a crystal
        /// built from XML coordinates file
        /// </summary>
        /// <param name="xmlFile"></param>
        /// <param name="paramFile"></param>
        public int FindInteractChains(string xmlFile)
        {
            interChainId = 0;
            asymChainTreesHash.Clear();
            interfaceChainsList.Clear();
            pdbId = xmlFile.Substring(xmlFile.LastIndexOf("\\") + 1, 4);
            CrystalBuilder crystalBuilder = new CrystalBuilder(AppSettings.parameters.contactParams.atomType);
            Dictionary <string, AtomInfo[]> unitCellChainsHash = null;

            int[] maxSteps = null;
            // build crystal based on all symmetry operations
            try
            {
                maxSteps = crystalBuilder.BuildCrystal(xmlFile, ref unitCellChainsHash);
                if (unitCellChainsHash == null)
                {
                    throw new Exception("Cannot build unit cell.");
                }
                // if there are too many chains in a unit cell
                // only compute the interfaces between original ASU chains
                // and other chains
                if (unitCellChainsHash.Count > unitCellSize)
                {
                    //	throw new Exception ("Unit cell too large. Skip processing " + pdbId + ".");
                    // if there are too many chains in the unit cell,
                    // only check the interfaces within the unit cell.
                    for (int i = 0; i < maxSteps.Length; i++)
                    {
                        maxSteps[i] = 0;
                    }
                }
                // if there are too many chains, only use chains in the asymmetric unit
                if (unitCellChainsHash.Count >= maxUnitCellSize)
                {
                    Dictionary <string, AtomInfo[]> asuChainHash = GetAsymUnitHash(unitCellChainsHash);
                    unitCellChainsHash = asuChainHash;
                    // if it is still too big due to Non-symmetry operators,
                    // only use chains in the original asu in the PDB file, may not be the real Asu
                    if (asuChainHash.Count >= unitCellSize)
                    {
                        Dictionary <string, AtomInfo[]> origAsuChainHash = GetOrigAsymUnitHash(asuChainHash);
                        unitCellChainsHash = origAsuChainHash;
                    }
                }
            }
            catch (Exception ex)
            {
                throw new Exception("Building Crystal Errors: " + xmlFile + " " + ex.Message);
            }

            /*
             * build BVTree for original asymmetric chains +
             * their chains after applied symmetry operations
             * without translations
             */
            try
            {
                // for each chain in a cell including original and symmetric chains
                foreach (string chainAndSymOp in unitCellChainsHash.Keys)
                {
                    BVTree chainTree = new BVTree();
                    chainTree.BuildBVTree(unitCellChainsHash[chainAndSymOp], AppSettings.parameters.kDopsParam.bvTreeMethod, true);
                    asymChainTreesHash.Add(chainAndSymOp, chainTree);
                }
            }
            catch (Exception ex)
            {
                throw new Exception("Building Bounding Volumn Tree Errors: " + xmlFile + ". " + ex.Message);
            }

            /*
             * the critical step for the computation time
             * check all pairs of chains including translated chains
             * return a list of atompairs if exists
             */
            cryst1            = crystalBuilder.Crystal1;
            fract2CartnMatrix = crystalBuilder.fract2cartnMatrix;

            List <string> chainAndSymOps        = new List <string> (asymChainTreesHash.Keys);
            List <string> orderedChainAndSymOps = SortChainsInUnitCell(chainAndSymOps);

            // check interactions between 2 different chains and their translated chains
            // chainAndSymOps: chainId_symmetry operator_full symmetry operations
            // e.g. A_1_545
            try
            {
                ComputeUniqueInterfacesFromCryst(orderedChainAndSymOps, maxSteps);
            }
            catch (Exception ex)
            {
                /*	ProtCidSettings.progressInfo.progStrQueue.Enqueue
                 *              ("Retrieving unique interfaces of " + pdbId + " errors: " + ex.Message);*/
                throw new Exception("Retrieving unique interfaces of " + pdbId + " errors: " + ex.Message);
            }
            return(unitCellChainsHash.Count);
        }
コード例 #3
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);
            }
        }