Example #1
0
        /// <summary>
        /// Add the ligands with the same author name
        /// </summary>
        /// <param name="pdbId"></param>
        /// <param name="interfaceInfoList"></param>
        /// <param name="type"></param>
        /// <param name="needAsaUpdated"></param>
        /// <param name="needSameAuthorLigands"></param>
        /// <returns></returns>
        public ProtInterface[] GenerateInterfaceFiles(string pdbId, string coordXmlFile, ProtInterfaceInfo[] interfaceInfoList,
                                                      string type, bool needSameAuthorLigands, string interfaceFileDir, DataTable asuTable, bool isAsuInterface)
        {
            string[] symOpStrings = GetSymOpStringsFromInterfaces(interfaceInfoList);

            // read data from crystal xml file
            EntryCrystal  thisEntryCrystal;
            XmlSerializer xmlSerializer = new XmlSerializer(typeof(EntryCrystal));
            FileStream    xmlFileStream = new FileStream(coordXmlFile, FileMode.Open);

            thisEntryCrystal = (EntryCrystal)xmlSerializer.Deserialize(xmlFileStream);
            xmlFileStream.Close();

            Dictionary <string, AtomInfo[]> entryChainsHash = BuildCrystalWithAllChains(thisEntryCrystal, symOpStrings);

            // protein asym id and its ligands with the same author name and the atoms for the ligands
            //    Hashtable asymIdLigandAtomInfoHash = GetEntryLigandAtomInfoHash(asuTable, thisEntryCrystal);
            Dictionary <string, string[]> asymLigandsHash = GetAsymChainLigandsHash(asuTable);

            int    i             = 0;
            string chain1        = "";
            string chain2        = "";
            string interfaceFile = "";

            ProtInterface[] interfaces      = new ProtInterface[interfaceInfoList.Length];
            string[]        symmetryStrings = new string[2];
            foreach (ProtInterfaceInfo interfaceInfo in interfaceInfoList)
            {
                chain1 = interfaceInfo.Chain1 + "_" + interfaceInfo.SymmetryString1;
                chain2 = interfaceInfo.Chain2 + "_" + interfaceInfo.SymmetryString2;
                if (!entryChainsHash.ContainsKey(chain1) || !entryChainsHash.ContainsKey(chain2))
                {
                    continue;
                }

                Dictionary <string, AtomInfo[]>[] ligandAtomInfoHashs = GetInterfaceLigandAtomInfoHashes(interfaceInfo, asymLigandsHash, entryChainsHash);

                interfaceInfo.Remark += FormatInterfaceAsa(interfaceInfo.ASA);
                symmetryStrings[0]    = interfaceInfo.SymmetryString1;
                symmetryStrings[1]    = interfaceInfo.SymmetryString2;
                interfaceInfo.Remark += FormatLigandsInfo(ligandAtomInfoHashs, symmetryStrings, asuTable);
                if (isAsuInterface)
                {
                    interfaceFile = Path.Combine(interfaceFileDir, pdbId + "_0" + interfaceInfo.InterfaceId.ToString() + ".cryst");
                }
                else
                {
                    interfaceFile = Path.Combine(interfaceFileDir, pdbId + "_" + interfaceInfo.InterfaceId.ToString() + ".cryst");
                }
                interfaceWriter.WriteInterfaceToFile(interfaceFile, entryChainsHash[chain1], entryChainsHash[chain2], interfaceInfo.Remark, type, ligandAtomInfoHashs);
                ParseHelper.ZipPdbFile(interfaceFile);

                interfaces[i] = new ProtInterface(interfaceInfo);
                interfaces[i].ResidueAtoms1 = GetSeqAtoms(entryChainsHash[chain1]);
                interfaces[i].ResidueAtoms2 = GetSeqAtoms(entryChainsHash[chain2]);
                i++;
            }
            return(interfaces);
        }
Example #2
0
        /// <summary>
        /// generate interface files from the input defintion
        /// </summary>
        /// <param name="pdbId"></param>
        /// <param name="interfaceInfoList"></param>
        /// <param name="type"></param>
        /// <param name="needAsaUpdated"></param>
        /// <returns></returns>
        public ProtInterface[] GenerateInterfaceFiles(string pdbId, ProtInterfaceInfo[] interfaceInfoList, string type, out bool needAsaUpdated)
        {
            string xmlFile      = Path.Combine(ProtCidSettings.dirSettings.coordXmlPath, pdbId + ".xml.gz");
            string coordXmlFile = AuxFuncLib.ParseHelper.UnZipFile(xmlFile, ProtCidSettings.tempDir);

            string[] symOpStrings = GetChainSymOpStringsFromInterfaces(interfaceInfoList);
            Dictionary <string, AtomInfo[]> buChainsHash = base.BuildCrystal(coordXmlFile, symOpStrings);

            File.Delete(coordXmlFile);

            needAsaUpdated = false;
            string[] asaChains = interfaceAsa.GetChainsWithoutAsa(interfaceInfoList, type);
            if (asaChains.Length > 0)
            {
                needAsaUpdated = true;
            }
            Dictionary <string, double> chainSaHash = interfaceAsa.GetChainsSurfaceAreaInBu(pdbId, buChainsHash, asaChains, type);
            //	Hashtable chainSaHash = GetChainsSurfaceAreaInBu (pdbId, buChainsHash, type);
            int    i      = 0;
            string chain1 = "";
            string chain2 = "";

            ProtInterface[] interfaces = new ProtInterface [interfaceInfoList.Length];
            foreach (ProtInterfaceInfo interfaceInfo in interfaceInfoList)
            {
                chain1 = interfaceInfo.Chain1 + "_" + interfaceInfo.SymmetryString1;
                chain2 = interfaceInfo.Chain2 + "_" + interfaceInfo.SymmetryString2;
                if (!buChainsHash.ContainsKey(chain1) || !buChainsHash.ContainsKey(chain2))
                {
                    continue;
                }

                if (interfaceInfo.ASA < 0)
                {
                    string interfaceComplexFile = interfaceWriter.WriteTempInterfaceToFile(pdbId, interfaceInfo.InterfaceId,
                                                                                           (AtomInfo[])buChainsHash[chain1], (AtomInfo[])buChainsHash[chain2], type);
                    double complexAsa = interfaceAsa.ComputeInterfaceSurfaceArea(interfaceComplexFile);

                    if (chainSaHash.ContainsKey(chain1) && chainSaHash.ContainsKey(chain2))
                    {
                        interfaceInfo.ASA = interfaceAsa.CalculateInterfaceBuriedSurfaceArea(
                            (double)chainSaHash[chain1], (double)chainSaHash[chain2], complexAsa);
                    }
                }
                interfaceInfo.Remark += FormatInterfaceAsa(interfaceInfo.ASA);

                string interfaceFile = interfaceWriter.WriteInterfaceToFile(pdbId, interfaceInfo.InterfaceId, buChainsHash[chain1], buChainsHash[chain2], interfaceInfo.Remark, type);
                ParseHelper.ZipPdbFile(interfaceFile);

                interfaces[i] = new ProtInterface(interfaceInfo);
                interfaces[i].ResidueAtoms1 = GetSeqAtoms(buChainsHash[chain1]);
                interfaces[i].ResidueAtoms2 = GetSeqAtoms(buChainsHash[chain2]);
                i++;
            }
            return(interfaces);
        }