Esempio n. 1
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);
        }
Esempio n. 2
0
        /// <summary>
        /// the sum of propabilities in an interface
        /// </summary>
        /// <param name="theInterface"></param>
        /// <param name="residuePairList"></param>
        /// <returns></returns>
        private double GetProbDistHash(InterfaceChains theInterface, string[] residuePairList,
                                       ref Dictionary <string, double> probDistHash, string method)
        {
            probDistHash = new Dictionary <string, double> ();
            double probSum = 0.0;
            double dist    = 0.0;
            double prob    = 0.0;

            foreach (string residuePair in residuePairList)
            {
                if (theInterface.seqDistHash.ContainsKey(residuePair))
                {
                    dist = (double)theInterface.seqDistHash[residuePair];
                }
                else
                {
                    dist = theInterface.CbetaDistForSeqIds(residuePair);
                }
                switch (method.ToUpper())
                {
                case "KLD":
                    prob = GetProbFromKld(dist);
                    break;

                case "GAUSS":
                    prob = GetProbFromGauss(dist);
                    break;

                default:
                    break;
                }
                if (prob > 1.0)
                {
                    prob = 1.0;
                }
                if (prob > 0.0)
                {
                    probDistHash.Add(residuePair, prob);
                    probSum += prob;
                }
            }
            NormalizeProbDistHash(ref probDistHash, probSum);
            return(probSum);
        }
Esempio n. 3
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)
        {
            List <string> residuePairList = new List <string> ();
            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);
                }
                else
                {
                    double dist = interface2.CbetaDistForSeqIds(seqIds);
                    // no data available
                    if (dist == -1)
                    {
                        continue;
                    }
                    residuePairList.Add(seqIds);
                }
            }
            // 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);
            }
            string[] residuePairs = new string [residuePairList.Count];
            residuePairList.CopyTo(residuePairs);
            return(residuePairs);
        }
Esempio n. 4
0
        /// <summary>
        /// only for identical sequences
        /// Q score for two interfaces with possible domain swapping
        /// We assume interface with domain swapping has larger surface area
        /// </summary>
        /// <param name="interfaceChain1">the interface with possible domain swapping, larger surface area</param>
        /// <param name="interfaceChain2">the interface with smaller surface area</param>
        /// <returns>Q</returns>
        public double ComputeQForDomainSwappingInterfaces(InterfaceChains interfaceChain1, InterfaceChains interfaceChain2,
                                                          string[] shiftSeqIdStrings)
        {
            if (!AreSameContactsInInterfaces(interfaceChain1, interfaceChain2))
            {
                return(-1.0);
            }
            double weightDistSum     = 0.0;
            double swapWeightDistSum = 0.0;
            double weightSum         = 0.0;
            double weight            = 0.0;
            double minDistanceDif    = 0;
            double distIntra         = 0.0;
            double dist1             = 0.0;
            double dist2             = 0.0;
            Dictionary <string, double> seqDistHash1 = interfaceChain1.seqDistHash;
            Dictionary <string, double> seqDistHash2 = new Dictionary <string, double>(interfaceChain2.seqDistHash);
            string reverseConKey = "";

            string[] seqIds = null;
            foreach (string conKey in seqDistHash1.Keys)
            {
                dist1         = seqDistHash1[conKey];
                seqIds        = conKey.ToString().Split('_');
                reverseConKey = seqIds[1] + "_" + seqIds[0];

                if (seqDistHash2.ContainsKey(conKey))
                {
                    dist2 = seqDistHash2[conKey];
                }
                // should get the distance from the whole proteins
                else
                {
                    dist2 = interfaceChain2.CbetaDistForSeqIds(conKey.ToString());
                    // no data available
                    if (dist2 == -1)
                    {
                        continue;
                    }
                }
                weight = GetProbFromGauss(Math.Min(dist1, dist2));
                /*			weightSum += weight;*/

                if (seqDistHash2.ContainsKey(conKey))
                {
                    weightSum     += weight;
                    weightDistSum += weight * Math.Exp(Math.Abs(dist1 - dist2) * -0.5);
                }
                else if (Array.BinarySearch(shiftSeqIdStrings, conKey) > -1 ||
                         Array.BinarySearch(shiftSeqIdStrings, reverseConKey) > -1)
                {
                    distIntra = GetIntraProtCbetaDistance(Convert.ToInt32(seqIds[0]),
                                                          Convert.ToInt32(seqIds[1]), interfaceChain2);
                    minDistanceDif     = GetMinDistanceDif(dist1, dist2, distIntra);
                    swapWeightDistSum += weight * Math.Exp(minDistanceDif * -0.5);
                }
                else
                {
                    weightSum     += weight;
                    weightDistSum += weight * Math.Exp(Math.Abs(dist1 - dist2) * -0.5);
                }
                // remove the matched one
                seqDistHash2.Remove(conKey);
            }
            // handle the remaining distances in disthash2
            // find corresponding distances from the whole proteins
            foreach (string seqIdPair in seqDistHash2.Keys)
            {
                dist2 = seqDistHash2[seqIdPair];

                dist1 = interfaceChain1.CbetaDistForSeqIds(seqIdPair.ToString());

                // no data available
                if (dist1 == -1)
                {
                    continue;
                }

                // dist2 must be the minimum since dist2 < cutoff and dist1 > cutoff
                weight         = GetProbFromGauss(dist2);
                weightSum     += weight;
                weightDistSum += weight * Math.Exp(Math.Abs(dist1 - dist2) * -0.5);
            }
            if (weightSum == 0)
            {
                return(-1.0);
            }
            if (swapWeightDistSum == 0)
            {
                return(-1.0);
            }
//			return (weightDistSum + swapWeightDistSum) / weightSum;
            return(weightDistSum / weightSum);
        }
Esempio n. 5
0
        /// <summary>
        /// Q Score for two interfaces
        /// based on residue pairs with minimum distance
        /// </summary>
        /// <param name="interfaceChain1"></param>
        /// <param name="interfaceChain2"></param>
        /// <returns></returns>
        public double WeightQFunc(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 weight = GetProbFromGauss(Math.Min(dist1, dist2));
                    weightSum     += weight;
                    weightDistSum += weight * Math.Exp(Math.Abs(dist1 - dist2) * -0.5);
                    // those remaining distances should find matching distance from
                    seqDistHash2.Remove(conKey);
                }
                // should get the distance from the whole proteins
                else
                {
                    double dist2 = interfaceChain2.CbetaDistForSeqIds(conKey.ToString());

                    // no data available
                    if (dist2 == -1)
                    {
                        continue;
                    }
                    // dist1 must be the minimum since dist1 < cutoff and dist2 > cutoff
                    double weight = GetProbFromGauss(dist1);
                    weightSum     += weight;
                    weightDistSum += weight * Math.Exp(Math.Abs(dist1 - dist2) * -0.5);
                }
            }
            // handle the remaining distances in disthash2
            // find corresponding distances from the whole proteins
            foreach (string seqIdPair in seqDistHash2.Keys)
            {
                double dist2 = seqDistHash2[seqIdPair];

                double dist1 = interfaceChain1.CbetaDistForSeqIds(seqIdPair.ToString());

                // no data available
                if (dist1 == -1)
                {
                    continue;
                }

                // dist2 must be the minimum since dist2 < cutoff and dist1 > cutoff
                double weight = GetProbFromGauss(dist2);
                weightSum     += weight;
                weightDistSum += weight * Math.Exp(Math.Abs(dist1 - dist2) * -0.5);
            }
            if (weightSum == 0)
            {
                return(-1.0);
            }
            return(weightDistSum / weightSum);
        }