Exemplo n.º 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="chain1"></param>
        /// <param name="chain2"></param>
        /// <param name="modelType">local, or global</param>
        /// <returns></returns>
        public StructAlignOutput AlignTwoChains(ChainAtoms chain1, ChainAtoms chain2, string modelType)
        {
            AtomInfo[]        calphaAtoms1 = chain1.CalphaAtoms();
            AtomInfo[]        calphaAtoms2 = chain2.CalphaAtoms();
            StructAlignOutput alignOutput  = AlignTwoSetsAtoms(calphaAtoms1, calphaAtoms2, modelType);

            return(alignOutput);
        }
Exemplo n.º 2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="chain1"></param>
        /// <param name="chain2"></param>
        public StructAlignOutput AlignTwoSetsAtoms(AtomInfo[] atoms1, AtomInfo[] atoms2, string modelType)
        {
            Coordinate[] coords1 = GetCoordinates(atoms1);
            Coordinate[] coords2 = GetCoordinates(atoms2);

            StructAlignOutput alignOutput = AlignTwoSetsCoordinates(coords1, coords2, modelType);

            if (alignOutput != null)
            {
                int startPos = -1;
                int endPos   = -1;
                alignOutput.alignment1 = ChangeOutputAlignmentToResidues(atoms1, alignOutput.alignment1, out startPos, out endPos);
                alignOutput.startPos1  = startPos;
                alignOutput.endPos1    = endPos;
                alignOutput.alignment2 = ChangeOutputAlignmentToResidues(atoms2, alignOutput.alignment2, out startPos, out endPos);
                alignOutput.startPos2  = startPos;
                alignOutput.endPos2    = endPos;
            }

            return(alignOutput);
        }
Exemplo n.º 3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="chain1"></param>
        /// <param name="chain2"></param>
        public StructAlignOutput AlignTwoSetsCoordinates(Coordinate[] coords1, Coordinate[] coords2, string modelType)
        {
            double bestScore = -1;
            int    endI      = -1;
            int    endJ      = -1;

            double[,] distanceMatrix = CreateDistanceMatrix(coords1, coords2);
            List <int> indexListI = new List <int>();
            List <int> indexListJ = new List <int>();

            // the dp matrix is one more than for both lists of the coords
            if (modelType == "local")
            {
                double[,] dpMatrix = CreateLocalMatrix(coords1.Length, coords2.Length, distanceMatrix, out bestScore, out endI, out endJ);
                AlignLocal(dpMatrix, endI, endJ, distanceMatrix, ref indexListI, ref indexListJ);
            }
            else
            {
                double[,] dpMatrix = CreateGlobalMatrix(coords1.Length, coords2.Length, distanceMatrix, out bestScore, out endI, out endJ);
                AlignGlobal(dpMatrix, endI, endJ, distanceMatrix, ref indexListI, ref indexListJ);
            }
            if (indexListI.Count == 0 || indexListJ.Count == 0)  // no local alignment
            {
                return(null);
            }

            int[] indexesI = new int[indexListI.Count];
            indexListI.CopyTo(indexesI);
            int[] indexesJ = new int[indexListJ.Count];
            indexListJ.CopyTo(indexesJ);

            StructAlignOutput alignOutput = new StructAlignOutput();

            alignOutput.startPos1  = indexesI[0];
            alignOutput.endPos1    = indexesI[indexesI.Length - 1];
            alignOutput.startPos2  = indexesJ[0];
            alignOutput.endPos2    = indexesJ[indexesJ.Length - 1];
            alignOutput.alignScore = bestScore;
            alignOutput.rmsd       = 0;
            string            alignment1      = "";
            string            alignment2      = "";
            int               coordI          = 0;
            int               coordJ          = 0;
            List <Coordinate> rmsdCoordsList1 = new List <Coordinate> ();
            List <Coordinate> rmsdCoordsList2 = new List <Coordinate> ();

            for (int i = 0; i < indexesI.Length; i++)
            {
                if (indexesI[i] > -1)
                {
                    coordI      = indexesI[i] - 1;
                    alignment1 += (coordI.ToString() + ",");
                }
                else
                {
                    alignment1 += "-,";
                }
                if (indexesJ[i] > -1)
                {
                    coordJ      = indexesJ[i] - 1;
                    alignment2 += (coordJ.ToString() + ",");
                }
                else
                {
                    alignment2 += "-,";
                }

                if (indexesI[i] > -1 && indexesJ[i] > -1)
                {
                    rmsdCoordsList1.Add(coords1[coordI]);
                    rmsdCoordsList2.Add(coords2[coordJ]);
                }
            }
            double rmsd = rmsdCalculator.CalculateRmsd(rmsdCoordsList1.ToArray(), rmsdCoordsList2.ToArray());

            alignOutput.rmsd       = rmsd;
            alignOutput.alignment1 = alignment1.TrimEnd(',');
            alignOutput.alignment2 = alignment2.TrimEnd(',');
            return(alignOutput);
        }