Exemplo n.º 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="interface2"></param>
        /// <param name="alignRow"></param>
        public void SuperposeInterfaces(InterfaceChains interface2, DataTable alignInfoTable)
        {
            AtomInfo[] chain1     = interface2.chain1;
            string     asymChain1 = interface2.firstSymOpString.Substring(0, interface2.firstSymOpString.IndexOf("_"));
            DataRow    alignRow   = GetAlignRow(alignInfoTable, asymChain1);

            SuperposeChain(chain1, alignRow);

            AtomInfo[] chain2     = interface2.chain2;
            string     asymChain2 = interface2.secondSymOpString.Substring(0, interface2.secondSymOpString.IndexOf("_"));

            if (asymChain1 != asymChain2)
            {
                DataRow alignRow2 = GetAlignRow(alignInfoTable, asymChain2);
                SuperposeChain(chain2, alignRow2);
                interface2.seqDistHash =
                    SuperposeInterface(interface2.seqDistHash, alignRow, alignRow2);
            }
            else
            {
                SuperposeChain(chain2, alignRow);
                interface2.seqDistHash =
                    SuperposeInterface(interface2.seqDistHash, alignRow);
            }
            interface2.ResetSeqResidueHash();
        }
Exemplo n.º 2
0
        /// <summary>
        /// Q Score for two interfaces, only based on residue pairs
        /// with Calpha or Cbeta distance less than some cutoff
        /// </summary>
        /// <param name="interfaceChain1"></param>
        /// <param name="interfaceChain2"></param>
        /// <returns></returns>
        public double ComputeInterfacesQscore_Max(InterfaceChains interfaceChain1, InterfaceChains interfaceChain2)
        {
            // must handle missing coordinates
            // the order of sequence id may not be exactly same
            double weightDistSum = 0.0;
            double weightSum     = 0.0;
            Dictionary <string, double> seqDistHash1 = interfaceChain1.seqDistHash;
            Dictionary <string, double> seqDistHash2 = new Dictionary <string, double>(interfaceChain2.seqDistHash);

            foreach (string conKey in seqDistHash1.Keys)
            {
                double dist1 = seqDistHash1[conKey];

                if (seqDistHash2.ContainsKey(conKey))
                {
                    double dist2 = seqDistHash2[conKey];

                    double weightTemp = Math.Pow((Math.Max(dist1, dist2) / AppSettings.parameters.contactParams.cutoffResidueDist), 2);
                    double weight     = Math.Pow(1 - weightTemp, 2);
                    weightSum     += weight;
                    weightDistSum += weight * Math.Exp(Math.Abs(dist1 - dist2) * -1);
                }
            }
            if (weightSum == 0)
            {
                return(-1.0);
            }

            return(weightDistSum / weightSum);
        }
Exemplo n.º 3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="srcDir"></param>
        /// <param name="pdbId"></param>
        /// <param name="interfaceIds"></param>
        /// <param name="type"></param>
        /// <returns></returns>
        public InterfaceChains[] GetInterfacesFromFiles(string srcDir, string pdbId, int[] interfaceIds, string type)
        {
            List <InterfaceChains> interfaceList = new List <InterfaceChains> ();

            if (Directory.Exists(srcDir))
            {
                foreach (int interfaceId in interfaceIds)
                {
                    string   searchMode     = pdbId + "_" + interfaceId.ToString() + "." + type + ".gz";
                    string[] interfaceFiles = Directory.GetFiles(srcDir, searchMode);
                    if (interfaceFiles.Length > 0)
                    {
                        InterfaceChains crystInterface = new InterfaceChains();
                        crystInterface.pdbId = pdbId;
                        string interfaceFile = ParseHelper.UnZipFile(interfaceFiles[0], ProtCidSettings.tempDir);
                        ReadInterfaceFromFile(interfaceFile, ref crystInterface, "ALL");
                        File.Delete(interfaceFile);

                        if (crystInterface.GetInterfaceResidueDist())
                        {
                            interfaceList.Add(crystInterface);
                        }
                    }
                }
            }
            return(interfaceList.ToArray());
        }
Exemplo n.º 4
0
        /// <summary>
        /// get the cryst interfaces from the cryst interface files
        /// </summary>
        /// <param name="pdbId"></param>
        /// <param name="pqsBuId"></param>
        public InterfaceChains[] GetInterfacesFromFiles(string pdbId, string type)
        {
            string searchMode = pdbId + "*." + type + ".gz";
            string filePath   = ProtCidSettings.dirSettings.interfaceFilePath +
                                "\\" + type + "\\" + pdbId.Substring(1, 2);
            List <InterfaceChains> interfaceList = new List <InterfaceChains>();

            if (Directory.Exists(filePath))
            {
                string[] interfaceFiles = Directory.GetFiles(filePath, searchMode);

                for (int i = 0; i < interfaceFiles.Length; i++)
                {
                    InterfaceChains crystInterface = new InterfaceChains();
                    string          interfaceFile  = ParseHelper.UnZipFile(interfaceFiles[i], ProtCidSettings.tempDir);
                    ReadInterfaceFromFile(interfaceFile, ref crystInterface, "ALL");
                    File.Delete(interfaceFile);
                    if (crystInterface.GetInterfaceResidueDist())
                    {
                        interfaceList.Add(crystInterface);
                    }
                }
            }
            return(interfaceList.ToArray());
        }
Exemplo n.º 5
0
        /// <summary>
        /// compare two interfaces
        /// </summary>
        /// <param name="interChains"></param>
        /// <param name="interChainsList"></param>
        /// <returns></returns>
        public bool AreChainInterfacesSame(InterfaceChains interface1, InterfaceChains interface2)
        {
            // get q scores for the interaction chains: Q_weight
            float qScore = (float)qFunc.WeightQFunc(interface1, interface2);

            if (qScore >= AppSettings.parameters.simInteractParam.uniqueInterfaceCutoff)
            {
                return(true);
            }
            else
            {
                interface2.Reverse();
                qScore = (float)qFunc.WeightQFunc(interface1, interface2);
                if (qScore >= AppSettings.parameters.simInteractParam.uniqueInterfaceCutoff)
                {
                    return(true);
                }
                else
                {
                    // reverse it back
                    interface2.Reverse();
                    return(false);
                }
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// check symmetry when two chains with same sequence
        /// </summary>
        /// <param name="chainInterface"></param>
        /// <returns></returns>
        public bool IsInterfaceSymmetry(InterfaceChains chainInterface)
        {
            if (chainInterface.entityId1 != chainInterface.entityId2)
            {
                return(false);
            }
            List <string> chainAContactList = new List <string>();
            List <string> chainBContactList = new List <string>();

            foreach (string seqPair in chainInterface.seqDistHash.Keys)
            {
                string[] seqIds = seqPair.Split('_');
                chainAContactList.Add(seqIds[0] + "_" + seqIds[1]);
                chainBContactList.Add(seqIds[1] + "_" + seqIds[0]);
            }

            int numOfCommonContacts = GetNumOfCommonContacts(chainAContactList, chainBContactList);
            int totalContacts       = chainInterface.seqDistHash.Count;

            int[] contacts = new int[2];
            contacts[0] = numOfCommonContacts;
            contacts[1] = totalContacts;

            double percent = (double)numOfCommonContacts / (double)totalContacts;

            if (percent < symmetryPercentCutoff)
            {
                return(false);
            }
            return(true);
        }
Exemplo n.º 7
0
        /// <summary>
        /// for h**o-dimer with sequence identity > 95%
        /// </summary>
        /// <param name="inInterface"></param>
        /// <returns></returns>
        public double CalculateInterfaceSymmetry(InterfaceChains inInterface, Dictionary <string, string> entityCrcDict, Dictionary <Tuple <string, string>, CrcSeqAlignInfo> crcPairAlignInfoDict)
        {
            bool            isReversed   = false;
            CrcSeqAlignInfo seqAlignInfo = GetEntitySequenceAlignInfo(inInterface.pdbId, inInterface.entityId1, inInterface.entityId2, entityCrcDict, crcPairAlignInfoDict, out isReversed);

            if (seqAlignInfo.identity < symSeqIdentityCutoff)
            {
                return(-1.0);
            }
            double jIndex = 0;

            if (inInterface.entityId1 == inInterface.entityId2)
            {
                jIndex = CalculateHomoInterfaceSymmetry(inInterface);
            }
            else
            {
                if (isReversed)
                {
                    seqAlignInfo.Reverse();
                }
                jIndex = CalculateHomoInterfaceSymmetry(inInterface, seqAlignInfo);
            }
            return(jIndex);
        }
Exemplo n.º 8
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="buInterfaceDefTable"></param>
        /// <param name="biolUnitHash"></param>
        /// <returns></returns>
        private InterfaceChains[] GetEntryBiolUnitInterfaces(DataTable buInterfaceDefTable, Dictionary <string, AtomInfo[]> biolUnitHash, string buType)
        {
            string chainSymOpString1 = "";
            string chainSymOpString2 = "";
            List <InterfaceChains> buInterfaceList = new List <InterfaceChains> ();

            foreach (DataRow interfaceDefRow in buInterfaceDefTable.Rows)
            {
                if (buType == "pqs") // use PQS chains
                {
                    chainSymOpString1 = interfaceDefRow["Chain1"].ToString().TrimEnd();
                    chainSymOpString2 = interfaceDefRow["Chain2"].ToString().TrimEnd();
                }
                else
                {
                    chainSymOpString1 = interfaceDefRow["Chain1"].ToString().TrimEnd() + "_" +
                                        interfaceDefRow["SymmetryString1"].ToString().TrimEnd();
                    chainSymOpString2 = interfaceDefRow["Chain2"].ToString().TrimEnd() + "_" +
                                        interfaceDefRow["SymmetryString2"].ToString().TrimEnd();
                }
                if (biolUnitHash.ContainsKey(chainSymOpString1) && biolUnitHash.ContainsKey(chainSymOpString2))
                {
                    InterfaceChains buInterface = new InterfaceChains();
                    buInterface.firstSymOpString  = chainSymOpString1;
                    buInterface.secondSymOpString = chainSymOpString2;
                    buInterface.interfaceId       = Convert.ToInt32(interfaceDefRow["InterfaceID"].ToString());
                    buInterface.pdbId             = interfaceDefRow["PdbID"].ToString();
                    buInterface.chain1            = (AtomInfo[])biolUnitHash[chainSymOpString1];
                    buInterface.chain2            = (AtomInfo[])biolUnitHash[chainSymOpString2];
                    buInterface.GetInterfaceResidueDist();
                    buInterfaceList.Add(buInterface);
                }
            }
            return(buInterfaceList.ToArray());
        }
Exemplo n.º 9
0
        /// <summary>
        /// reverse the residue sequence id after interface comparing
        /// </summary>
        /// <param name="interChains2"></param>
        /// <param name="alignInfoTable"></param>
        public void ReverseSupInterfaces(InterfaceChains interface2, DataTable alignInfoTable)
        {
            DataRow alignRow  = null;
            DataRow alignRow2 = null;

            AtomInfo[] chain1     = interface2.chain1;
            string     asymChain1 = interface2.firstSymOpString.Substring(0, interface2.firstSymOpString.IndexOf("_"));

            alignRow = GetAlignRow(alignInfoTable, asymChain1);
            ReverseSupChain(chain1, alignRow);

            AtomInfo[] chain2     = interface2.chain2;
            string     asymChain2 = interface2.secondSymOpString.Substring(0, interface2.secondSymOpString.IndexOf("_"));

            if (asymChain1 != asymChain2)
            {
                alignRow2 = GetAlignRow(alignInfoTable, asymChain2);
                ReverseSupChain(chain2, alignRow2);
                interface2.seqDistHash =
                    ReverseSupInterface(interface2.seqDistHash, alignRow, alignRow2);
            }
            else
            {
                ReverseSupChain(chain2, alignRow);
                interface2.seqDistHash =
                    ReverseSupInterface(interface2.seqDistHash, alignRow);
            }
            interface2.ClearSeqResidueHash();
        }
Exemplo n.º 10
0
        /// <summary>
        /// for h**o-dimer with sequence identity of two monomers > 95%
        /// </summary>
        /// <param name="inInterface">an interface with two homologous chains, with sequence identity >= 95%</param>
        /// <returns></returns>
        public double CalculateHomoInterfaceSymmetry(InterfaceChains inInterface, CrcSeqAlignInfo seqAlignInfo)
        {
            if (inInterface.seqDistHash == null)
            {
                inInterface.GetInterfaceResidueDist();
            }
            List <string>[] seqIdPairLists   = GetSeqIdPairLists(inInterface.seqDistHash, seqAlignInfo);
            List <string>   totalSeqPairList = new List <string>(seqIdPairLists[0]);
            List <string>   sameSeqPairList  = new List <string>();

            foreach (string seqPair in seqIdPairLists[0])
            {
                if (seqIdPairLists[1].Contains(seqPair))
                {
                    sameSeqPairList.Add(seqPair);
                }
            }
            foreach (string seqPair in seqIdPairLists[1])
            {
                if (!totalSeqPairList.Contains(seqPair))
                {
                    totalSeqPairList.Add(seqPair);
                }
            }
            double jIndex = (double)sameSeqPairList.Count / (double)totalSeqPairList.Count;

            return(jIndex);
        }
Exemplo n.º 11
0
        /// <summary>
        /// Q Score for two interfaces
        /// based on KLD distributions
        /// </summary>
        /// <param name="interfaceChain1"></param>
        /// <param name="interfaceChain2"></param>
        /// <returns></returns>
        public double KldQFunc(InterfaceChains interface1, InterfaceChains interface2)
        {
            /*		string[] commonResiduePairs = GetCommonResiduePairs (interface1, interface2);
             *              double propSum1 = GetPropSum (interface1);
             *              double propSum2 = GetPropSum (interface2);
             *              double propSum1InCommon = 0.0;
             *              double propSum2InCommon = 0.0;
             *              foreach (string residuePair in commonResiduePairs)
             *              {
             *                      string[] seqIds = residuePair.Split ('_');
             *                      double prop1 = GetNormProp ((double)interface1.seqDistHash[residuePair], propSum1);
             *                      double prop2 = GetNormProp ((double)interface2.seqDistHash[residuePair], propSum2);
             *                      propSum1InCommon += prop1 * Math.Log (prop1 / prop2);
             *                      propSum2InCommon += prop2 * Math.Log (prop2 / prop1);
             *              }
             *              double qScore = 1- (propSum1InCommon + propSum2InCommon);
             *              return qScore;
             */
            string[] allResiduePairs = GetAllResiduePairs(interface1, interface2);
            Dictionary <string, double> probHash1 = null;
            Dictionary <string, double> probHash2 = null;
            double propSum1 = GetProbDistHash(interface1, allResiduePairs, ref probHash1, "KLD");
            double propSum2 = GetProbDistHash(interface2, allResiduePairs, ref probHash2, "KLD");
            double qScore   = GetDistrSimScore(probHash1, probHash2);

            return(qScore);
        }
Exemplo n.º 12
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="chainInterface"></param>
 /// <param name="domainStart1"></param>
 /// <param name="domainEnd1"></param>
 /// <param name="domainStart2"></param>
 /// <param name="domainEnd2"></param>
 /// <returns></returns>
 public DomainInterface GetInterChainDomainInterface(InterfaceChains chainInterface,
                                                     int domainStart1, int domainEnd1, int domainStart2, int domainEnd2)
 {
     Range[] domainRanges1 = FormatDomainRange(domainStart1, domainEnd1);
     Range[] domainRanges2 = FormatDomainRange(domainStart2, domainEnd2);
     return(GetDomainInterface(chainInterface, domainRanges1, domainRanges2));
 }
Exemplo n.º 13
0
        /*
         * Function:
         * 1. constant function
         * y = 1 if x > 0 and x <= 5;
         * 2. Gaussian distribution function
         * y = (area / (sigma * sqrt(PI / 2))) * exp(-2 * ((x - mean) / sigma)^2) if x > 5
         * */
        /// <summary>
        /// Q Score from KLD
        /// </summary>
        /// <param name="interface1"></param>
        /// <param name="interface2"></param>
        /// <returns></returns>
        public double KLDQFunc_Gauss(InterfaceChains interface1, InterfaceChains interface2)
        {
            bool needReversed = false;

            //		string[] allResiduePairs = GetCommonResiduePairs (interface1, interface2, out needReversed);
            string[] allResiduePairs = GetAllResiduePairs(interface1, interface2, out needReversed);
            // no common residue pairs
            if (needReversed)
            {
                interface2.Reverse();
                allResiduePairs = GetAllResiduePairs(interface1, interface2);
            }

            Dictionary <string, double> probDistHash1 = null;
            Dictionary <string, double> probDistHash2 = null;
            double propSum1 = GetProbDistHash(interface1, allResiduePairs, ref probDistHash1, "GAUSS");
            double propSum2 = GetProbDistHash(interface2, allResiduePairs, ref probDistHash2, "GAUSS");

            double qScore = GetSimScoreForDistributions(probDistHash1, probDistHash2);

            // reverse back to original order
            if (needReversed)
            {
                interface2.Reverse();
            }
            return(qScore);
        }
Exemplo n.º 14
0
        /// <summary>
        /// get a list of common residue pairs from two interfaces
        /// </summary>
        /// <param name="interface1"></param>
        /// <param name="interface2"></param>
        /// <returns></returns>
        private string[] GetCommonResiduePairs(InterfaceChains interface1, InterfaceChains interface2, out bool needReversed)
        {
            needReversed = false;
            List <string> commonResiduePairList         = new List <string> ();
            List <string> reversedCommonResiduePairList = new List <string> ();

            foreach (string seqIds in interface1.seqDistHash.Keys)
            {
                if (interface2.seqDistHash.ContainsKey(seqIds))
                {
                    commonResiduePairList.Add(seqIds);
                }
                string[] seqIdFields       = seqIds.Split('_');
                string   reversedSeqString = seqIdFields[1] + "_" + seqIdFields[0];
                if (interface2.seqDistHash.ContainsKey(reversedSeqString))
                {
                    reversedCommonResiduePairList.Add(seqIds);
                }
            }
            if (reversedCommonResiduePairList.Count > commonResiduePairList.Count)
            {
                commonResiduePairList = reversedCommonResiduePairList;
                needReversed          = true;
            }
            string[] commonResiduePairs = new string [commonResiduePairList.Count];
            commonResiduePairList.CopyTo(commonResiduePairs);
            return(commonResiduePairs);
        }
Exemplo n.º 15
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="buInterface"></param>
 /// <param name="maxSeq1"></param>
 /// <param name="minSeq1"></param>
 /// <param name="maxSeq2"></param>
 /// <param name="minSeq2"></param>
 private void GetMaxMinContactSeqIDs(InterfaceChains buInterface, ref int maxSeq1, ref int minSeq1,
                                     ref int maxSeq2, ref int minSeq2)
 {
     maxSeq1 = -1;
     minSeq1 = 999999;
     maxSeq2 = -1;
     minSeq2 = 999999;
     foreach (string seqString in buInterface.seqContactHash.Keys)
     {
         string[] seqIds = seqString.Split('_');
         int      seqId1 = ParseHelper.ConvertSeqToInt(seqIds[0]);
         if (maxSeq1 < seqId1)
         {
             maxSeq1 = seqId1;
         }
         if (minSeq1 > seqId1)
         {
             minSeq1 = seqId1;
         }
         int seqId2 = ParseHelper.ConvertSeqToInt(seqIds[1]);
         if (maxSeq2 < seqId2)
         {
             maxSeq2 = seqId2;
         }
         if (minSeq2 > seqId2)
         {
             minSeq2 = seqId2;
         }
     }
 }
Exemplo n.º 16
0
        private double GetIntraProtCbetaDistance(int i, int j, InterfaceChains theInterface)
        {
            if (i == j)
            {
                return(0.0);
            }
            double dist = theInterface.GetIntraProtDistance(i, j);

            return(dist);
        }
Exemplo n.º 17
0
 public DomainInterface(InterfaceChains chainInterface)
 {
     this.interfaceId       = chainInterface.interfaceId;
     this.firstSymOpString  = chainInterface.firstSymOpString;
     this.secondSymOpString = chainInterface.secondSymOpString;
     this.entityId1         = chainInterface.entityId1;
     this.entityId2         = chainInterface.entityId2;
     this.chain1            = (AtomInfo[])chainInterface.chain1.Clone();
     this.chain2            = (AtomInfo[])chainInterface.chain2.Clone();
     this.seqDistHash       = new Dictionary <string, double> (chainInterface.seqDistHash);
 }
Exemplo n.º 18
0
        /// <summary>
        /// domain interaction of the interface
        /// </summary>
        /// <param name="chainInterface"></param>
        /// <param name="domainRange1"></param>
        /// <param name="domainRange2"></param>
        /// <returns></returns>
        public DomainInterface GetDomainInterface(InterfaceChains chainInterface, Range[] domainRanges1, Range[] domainRanges2)
        {
            DomainInterface domainInterface = new DomainInterface(chainInterface);

            domainInterface.chain1      = GetDomainAtoms(chainInterface.chain1, domainRanges1);
            domainInterface.chain2      = GetDomainAtoms(chainInterface.chain2, domainRanges2);
            domainInterface.seqDistHash =
                GetResDistHash(chainInterface.seqDistHash, domainRanges1, domainRanges2);

            return(domainInterface);
        }
Exemplo n.º 19
0
        /// <summary>
        /// the sum of probabilities for common contacts
        /// from the input interface
        /// </summary>
        /// <param name="interace1"></param>
        /// <param name="interface2"></param>
        /// <returns></returns>
        private double GetPropSumInCommon(InterfaceChains theInterface, string[] commonResiduePairs)
        {
            double propSum = 0.0;

            foreach (string seqIds in commonResiduePairs)
            {
                double expValue = ((double)theInterface.seqDistHash[seqIds] - zeroNormValue) / (2 * sigma1 * sigma1);
                propSum += Math.Exp((-1) * expValue);
            }
            return(propSum);
        }
Exemplo n.º 20
0
        /// <summary>
        /// the sum of probabilities in the interface
        /// </summary>
        /// <param name="interfaceChain"></param>
        /// <returns></returns>
        private double GetPropSum(InterfaceChains interfaceChain)
        {
            double propSum = 0.0;

            foreach (string seqIds in interfaceChain.seqDistHash.Keys)
            {
                double expValue = ((double)interfaceChain.seqDistHash[seqIds] - zeroNormValue) / (2 * sigma1 * sigma1);
                propSum += Math.Exp((-1) * expValue);
            }
            return(propSum);
        }
Exemplo n.º 21
0
        /// <summary>
        /// superpose interfaces based on psiblast alignment
        /// </summary>
        /// <param name="interChains2"></param>
        /// <param name="alignInfoTable"></param>
        public double SuperposeInterfaces(InterfaceChains interface1,
                                          InterfaceChains interface2, DataTable alignInfoTable, bool isReverse)
        {
            DataRow alignRow  = null;
            DataRow alignRow2 = null;
            double  identity  = 100.0;

            if (isReverse)
            {
                interface2.Reverse();
            }
            int entityId11 = interface1.entityId1;

            AtomInfo[] chain21    = interface2.chain1;
            int        entityId21 = interface2.entityId1;

            int entityId12 = interface1.entityId2;

            AtomInfo[] chain22    = interface2.chain2;
            int        entityId22 = interface2.entityId2;

            alignRow = GetAlignRow(alignInfoTable, entityId11, entityId21);
            if (alignRow != null)
            {
                identity = Convert.ToDouble(alignRow["Identity"].ToString());
                SuperposeChain(chain21, alignRow);
            }
            if (entityId21 == entityId22 && entityId11 == entityId12)
            {
                SuperposeChain(chain22, alignRow);
                interface2.seqDistHash =
                    SuperposeInterface(interface2.seqDistHash, alignRow);
            }
            else
            {
                alignRow2 = GetAlignRow(alignInfoTable, entityId12, entityId22);
                if (alignRow2 != null)
                {
                    if (identity > Convert.ToDouble(alignRow2["Identity"].ToString()))
                    {
                        identity = Convert.ToDouble(alignRow2["Identity"].ToString());
                    }
                    SuperposeChain(chain22, alignRow2);
                }
                interface2.seqDistHash =
                    SuperposeInterface(interface2.seqDistHash, alignRow, alignRow2);
            }
            // reset the hashtable for residue and its bb atoms.
            interface2.ResetSeqResidueHash();

            return(identity);
        }
Exemplo n.º 22
0
        /// <summary>
        /// get a list of common residue pairs from two interfaces
        /// </summary>
        /// <param name="interface1"></param>
        /// <param name="interface2"></param>
        /// <returns></returns>
        private string[] GetAllResiduePairs(InterfaceChains interface1, InterfaceChains interface2, out bool needReversed)
        {
            needReversed = false;
            List <string> residuePairList            = new List <string> ();
            int           commonResidueCount         = 0;
            int           reversedCommonResidueCount = 0;
            List <string> seqIdList2 = new List <string> (interface2.seqDistHash.Keys);

            foreach (string seqIds in interface1.seqDistHash.Keys)
            {
                if (seqIdList2.Contains(seqIds))
                {
                    residuePairList.Add(seqIds);
                    seqIdList2.Remove(seqIds);
                    commonResidueCount++;
                }
                else
                {
                    double dist = interface2.CbetaDistForSeqIds(seqIds);
                    // no data available
                    if (dist == -1)
                    {
                        continue;
                    }
                    residuePairList.Add(seqIds);
                }
                string[] seqFields = seqIds.Split('_');
                if (seqIdList2.Contains(seqFields[1] + "_" + seqFields[0]))
                {
                    reversedCommonResidueCount++;
                }
            }
            // for left contacts in interface2
            foreach (string seqIds in seqIdList2)
            {
                double dist = interface1.CbetaDistForSeqIds(seqIds);

                // no data available
                if (dist == -1)
                {
                    continue;
                }
                residuePairList.Add(seqIds);
            }
            if (reversedCommonResidueCount > commonResidueCount)
            {
                needReversed = true;
            }
            string[] residuePairs = new string [residuePairList.Count];
            residuePairList.CopyTo(residuePairs);
            return(residuePairs);
        }
Exemplo n.º 23
0
        /// <summary>
        /// for h**o-dimer with sequence identity > 95%
        /// </summary>
        /// <param name="inInterface"></param>
        /// <returns></returns>
        public double CalculateInterfaceSymmetry(InterfaceChains inInterface)
        {
            bool homoSeqs = AreSameSequence(inInterface.pdbId, inInterface.entityId1, inInterface.entityId2);

            if (!homoSeqs)
            {
                return(-1.0);
            }

            double jIndex = CalculateHomoInterfaceSymmetry(inInterface);

            return(jIndex);
        }
Exemplo n.º 24
0
        /// <summary>
        /// check if two interfaces are from same asymmetric chains
        /// For PQS interfaces
        /// </summary>
        /// <param name="interface1"></param>
        /// <param name="interface2"></param>
        /// <returns></returns>
        private bool AreAsymChainsSame(InterfaceChains interface1, InterfaceChains interface2, Dictionary <string, string> pqsAsymChainMatchHash)
        {
            // get asymmetric chains
            string asymChain11 = "";
            string asymChain12 = "";
            string asymChain21 = "";
            string asymChain22 = "";

            if (pqsAsymChainMatchHash.ContainsKey(interface1.firstSymOpString))
            {
                asymChain11 = pqsAsymChainMatchHash[interface1.firstSymOpString];
            }
            else
            {
                asymChain11 = interface1.firstSymOpString;
            }
            if (pqsAsymChainMatchHash.ContainsKey(interface1.secondSymOpString))
            {
                asymChain12 = pqsAsymChainMatchHash[interface1.secondSymOpString];
            }
            else
            {
                asymChain12 = interface1.secondSymOpString;
            }

            if (pqsAsymChainMatchHash.ContainsKey(interface2.firstSymOpString))
            {
                asymChain21 = pqsAsymChainMatchHash[interface2.firstSymOpString];
            }
            else
            {
                asymChain21 = interface2.firstSymOpString;
            }
            if (pqsAsymChainMatchHash.ContainsKey(interface2.secondSymOpString))
            {
                asymChain22 = pqsAsymChainMatchHash[interface2.secondSymOpString];
            }
            else
            {
                asymChain22 = interface2.secondSymOpString;
            }


            if ((asymChain11 == asymChain21 && asymChain12 == asymChain22) ||
                (asymChain11 == asymChain22 && asymChain12 == asymChain21))
            {
                return(true);
            }
            return(false);
        }
Exemplo n.º 25
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="domainRow"></param>
        /// <param name="pfamCode1"></param>
        /// <param name="pfamCode2"></param>
        /// <param name="chainInterfaces"></param>
        /// <returns></returns>
        private DomainInterface GetInterChainDomainInterface(DataRow domainInterfaceRow, string pfamCode1, string pfamCode2, InterfaceChains[] chainInterfaces)
        {
            string          pdbId             = domainInterfaceRow["PdbID"].ToString();
            DomainInterface domainInterface   = new DomainInterface();
            int             domainInterfaceId = Convert.ToInt32(domainInterfaceRow["DomainInterfaceID"].ToString());
            string          interfacePfam1    = "";
            string          interfacePfam2    = "";

            Range[] domainRanges1 = GetDomainRange(pdbId, Convert.ToInt64(domainInterfaceRow["DomainID1"].ToString()), out interfacePfam1);

            Range[] domainRanges2    = GetDomainRange(pdbId, Convert.ToInt64(domainInterfaceRow["DomainID2"].ToString()), out interfacePfam2);
            int     chainInterfaceId = Convert.ToInt32(domainInterfaceRow["InterfaceID"].ToString());

            if (chainInterfaceId > 0)  // inter-chain domain interface
            {
                InterfaceChains chainInterface = GetChainInterface(chainInterfaces, chainInterfaceId);
                if (chainInterface != null)
                {
                    domainInterface = GetDomainInterface(chainInterface, domainRanges1, domainRanges2);
                }
            }
            if (domainInterface != null)
            {
                /*      if (domainInterfaceRow["IsReversed"].ToString() == "1")
                 *    {
                 *        domainInterface.familyCode1 = pfamCode2;
                 *        domainInterface.familyCode2 = pfamCode1;
                 *    }
                 *    else
                 *    {
                 *        domainInterface.familyCode1 = pfamCode1;
                 *        domainInterface.familyCode2 = pfamCode2;
                 *    }*/
                domainInterface.domainInterfaceId = domainInterfaceId;
                domainInterface.pdbId             = pdbId;
                domainInterface.interfaceId       = chainInterfaceId;
                domainInterface.domainId1         = Convert.ToInt64(domainInterfaceRow["DomainID1"].ToString());
                domainInterface.domainId2         = Convert.ToInt64(domainInterfaceRow["DomainID2"].ToString());
                domainInterface.familyCode1       = interfacePfam1;
                domainInterface.familyCode2       = interfacePfam2;

                // if the domain interface chain order is different from the pfam ids defined for the relation
                // then reverse the interface chains
                if (interfacePfam1 == pfamCode2 && interfacePfam2 == pfamCode1)
                {
                    domainInterface.Reverse();
                }
            }
            return(domainInterface);
        }
Exemplo n.º 26
0
        /// <summary>
        /// get a list of common residue pairs from two interfaces
        /// </summary>
        /// <param name="interface1"></param>
        /// <param name="interface2"></param>
        /// <returns></returns>
        private string[] GetCommonResiduePairs(InterfaceChains interface1, InterfaceChains interface2)
        {
            List <string> commonResiduePairList = new List <string> ();

            foreach (string seqIds in interface1.seqDistHash.Keys)
            {
                if (interface2.seqDistHash.ContainsKey(seqIds))
                {
                    commonResiduePairList.Add(seqIds);
                }
            }
            string[] commonResiduePairs = new string [commonResiduePairList.Count];
            commonResiduePairList.CopyTo(commonResiduePairs);
            return(commonResiduePairs);
        }
Exemplo n.º 27
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="interfaceChains1"></param>
        /// <param name="interfaceChains2"></param>
        /// <param name="alignRow"></param>
        /// <returns></returns>
        public InterfacePairInfo CompareSupStructures(InterfaceChains interface1, InterfaceChains interface2, DataTable alignInfoTable)
        {
            InterfacePairInfo       interfacePairInfo = new InterfacePairInfo((InterfaceInfo)interface1, (InterfaceInfo)interface2);
            SuperpositionInterfaces supInterface      = new SuperpositionInterfaces();
            bool isReverse = false;

            double identity = supInterface.SuperposeInterfaces(interface1, interface2, alignInfoTable, isReverse);

            // Q score
            float qScore = (float)qFunc.WeightQFunc(interface1, interface2);

            // change the sequence number back.
            supInterface.ReverseSupInterfaces(interface1, interface2, alignInfoTable, isReverse);

            if (qScore >= AppSettings.parameters.simInteractParam.interfaceSimCutoff)
            {
                interfacePairInfo.qScore               = qScore;
                interfacePairInfo.identity             = identity;
                interfacePairInfo.isInterface2Reversed = false;
            }
            else
            {
                isReverse = true;
                double reversedIdentity = supInterface.SuperposeInterfaces(interface1, interface2, alignInfoTable, isReverse);
                if (reversedIdentity < AppSettings.parameters.simInteractParam.identityCutoff)
                {
                    reversedIdentity = AppSettings.parameters.simInteractParam.identityCutoff;
                }
                float reversedQScore = (float)qFunc.WeightQFunc(interface1, interface2);
                supInterface.ReverseSupInterfaces(interface1, interface2, alignInfoTable, isReverse);
                if (reversedQScore >= qScore)
                {
                    interfacePairInfo.qScore               = reversedQScore;
                    interfacePairInfo.identity             = reversedIdentity;
                    interfacePairInfo.isInterface2Reversed = true;
                }
                else
                {
                    // go back to the original chain order
                    //		interface2.Reverse ();
                    interfacePairInfo.qScore               = qScore;
                    interfacePairInfo.identity             = identity;
                    interfacePairInfo.isInterface2Reversed = false;
                }
            }

            return(interfacePairInfo);
        }
Exemplo n.º 28
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="buInterface"></param>
        /// <param name="domainStart1"></param>
        /// <param name="domainEnd1"></param>
        /// <param name="domainStart2"></param>
        /// <param name="domainEnd2"></param>
        /// <returns></returns>
        private bool AreDomainsInteracted(InterfaceChains buInterface, int domainStart1, int domainEnd1,
                                          int domainStart2, int domainEnd2)
        {
            int  numOfResidueContacts = 0;
            int  numOfAtomContacts    = 0;
            int  seqId1 = -1;
            int  seqId2 = -1;
            bool hasEnoughResiduePairs = false;
            bool hasContacts           = false;

            foreach (string seqString in buInterface.seqDistHash.Keys)
            {
                string[] seqIds = seqString.Split('_');
                seqId1 = ParseHelper.ConvertSeqToInt(seqIds[0]);
                seqId2 = ParseHelper.ConvertSeqToInt(seqIds[1]);
                if (seqId1 >= domainStart1 && seqId1 <= domainEnd1 &&
                    seqId2 >= domainStart2 && seqId2 <= domainEnd2)
                {
                    numOfResidueContacts++;
                    if (numOfResidueContacts >= AppSettings.parameters.contactParams.numOfResidueContacts)
                    {
                        hasEnoughResiduePairs = true;
                        break;
                    }
                }
            }
            foreach (string seqString in buInterface.seqContactHash.Keys)
            {
                string[] seqIds = seqString.Split('_');
                seqId1 = ParseHelper.ConvertSeqToInt(seqIds[0]);
                seqId2 = ParseHelper.ConvertSeqToInt(seqIds[1]);
                if (seqId1 >= domainStart1 && seqId1 <= domainEnd1 &&
                    seqId2 >= domainStart2 && seqId2 <= domainEnd2)
                {
                    numOfAtomContacts++;
                    hasContacts = true;
                    //      break;
                }
            }
            //    if (hasContacts && hasEnoughResiduePairs)
            if ((hasContacts && hasEnoughResiduePairs) ||
                numOfAtomContacts >= AppSettings.parameters.contactParams.domainNumOfAtomContacts)
            {
                return(true);
            }
            return(false);
        }
Exemplo n.º 29
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="domainInterfaceFile"></param>
        /// <returns></returns>
        public double CalculateDomainInterfaceSurfaceArea(string domainInterfaceFile, ref Dictionary <string, double> domainChainAsaHash)
        {
            FileInfo        fileInfo        = new FileInfo(domainInterfaceFile);
            InterfaceChains domainInterface = new InterfaceChains();
            string          remark          = interfaceReader.ReadInterfaceChainsFromFile(domainInterfaceFile, ref domainInterface);

            if (domainInterface.chain1.Length == 0 || domainInterface.chain2.Length == 0)
            {
                throw new Exception("no interface atoms.");
            }
            string[] domainChainStrings = interfaceReader.GetDomainChainStrings(remark);

            double chainASA = 0;
            double chainBSA = 0;

            if (domainChainAsaHash.ContainsKey(domainChainStrings[0]))
            {
                chainASA = (double)domainChainAsaHash[domainChainStrings[0]];
            }
            else
            {
                string domainChainAFile = domainInterfaceFile.Replace(".cryst", "A.cryst");
                interfaceWriter.WriterOneInterfaceChainToFile(domainChainAFile, domainInterface.chain1, "A");
                chainASA = interfaceAsa.ComputeInterfaceSurfaceArea(domainChainAFile);
                domainChainAsaHash.Add(domainChainStrings[0], chainASA);
            }
            if (domainChainAsaHash.ContainsKey(domainChainStrings[1]))
            {
                chainBSA = (double)domainChainAsaHash[domainChainStrings[1]];
            }
            else
            {
                string domainChainBFile = domainInterfaceFile.Replace(".cryst", "B.cryst");
                interfaceWriter.WriterOneInterfaceChainToFile(domainChainBFile, domainInterface.chain2, "B");
                chainBSA = interfaceAsa.ComputeInterfaceSurfaceArea(domainChainBFile);
                domainChainAsaHash.Add(domainChainStrings[1], chainBSA);
            }
            double interfaceSA = interfaceAsa.ComputeInterfaceSurfaceArea(domainInterfaceFile);

            double interfaceBSA = -1;

            if (chainASA > 0 && chainBSA > 0 && interfaceSA > 0)
            {
                interfaceBSA = (chainASA + chainBSA - interfaceSA) / 2;
            }
            return(interfaceBSA);
        }
Exemplo n.º 30
0
        /// <summary>
        /// domain interaction of the interface
        /// </summary>
        /// <param name="chainInterface"></param>
        /// <param name="domainRange1"></param>
        /// <param name="domainRange2"></param>
        /// <returns></returns>
        private DomainInterface GetDomainInterface(InterfaceChains chainInterface, string domainRangeString1, string domainRangeString2)
        {
            DomainInterface domainInterface = new DomainInterface(chainInterface);

            if (domainRangeString1 != "-" && domainRangeString2 != "-")
            {
                Range[] domainRanges1 = GetDomainRanges(domainRangeString1);
                domainInterface.chain1 = GetDomainAtoms(domainInterface.chain1, domainRanges1);

                Range[] domainRanges2 = GetDomainRanges(domainRangeString2);
                domainInterface.chain2 = GetDomainAtoms(domainInterface.chain2, domainRanges2);

                domainInterface.seqDistHash =
                    GetResDistHash(domainInterface.seqDistHash, domainRanges1, domainRanges2);
            }
            return(domainInterface);
        }