Ejemplo n.º 1
0
 static MD()
 {
     matrices.Add("MD40", SubstitutionMatrix.Create("MD40", MatrixData.MD40, Routines.aminoAcidCodes));
     matrices.Add("MD120", SubstitutionMatrix.Create("MD120", MatrixData.MD120, Routines.aminoAcidCodes));
     matrices.Add("MD250", SubstitutionMatrix.Create("MD250", MatrixData.MD250, Routines.aminoAcidCodes));
     matrices.Add("MD350", SubstitutionMatrix.Create("MD350", MatrixData.MD350, Routines.aminoAcidCodes));
 }
Ejemplo n.º 2
0
        //public static SubstitutionMatrix Create(string name, List<List<double>> matrixInfo, char[] residueCodes)
        //// matrixInfo is a list of lists, with each sub-list containing a line from the substituion matrix
        //// file, which is stored as the bottom-left triangle of the symmetrical matrix.
        //{
        //    int maxResidues = residueCodes.Length;
        //    bool useNegativeMatrix = false;

        //    Dictionary<char, Dictionary<char, double>> matrix = new Dictionary<char, Dictionary<char, double>>(residueCodes.Length + 2);
        //    Dictionary<char, double> oldGapRow = new Dictionary<char, double>(residueCodes.Length + 2);
        //    Dictionary<char, double> newGapRow = new Dictionary<char, double>(residueCodes.Length + 2);

        //    for (int i = 0; i < maxResidues; i++)
        //    {
        //        int limit = matrixInfo[i].Count;
        //        Dictionary<char, double> row = new Dictionary<char, double>(residueCodes.Length + 2);
        //        for (int j = 0; j < limit; j++)
        //        {
        //            row.Add(residueCodes[j], matrixInfo[i][j] * 100);
        //        }
        //        for (int j = limit; j < maxResidues; j++)
        //        {
        //            row.Add(residueCodes[j], matrixInfo[j][i] * 100);
        //        }
        //        row.Add(Routines.oldGap, gapResidueValue);
        //        row.Add(Routines.newGap, gapResidueValue);

        //        matrix.Add(residueCodes[i], row);

        //        oldGapRow.Add(residueCodes[i], gapResidueValue);
        //        newGapRow.Add(residueCodes[i], gapResidueValue);
        //    }

        //    oldGapRow.Add(Routines.oldGap, gapGapValue);
        //    oldGapRow.Add(Routines.newGap, gapGapValue);
        //    newGapRow.Add(Routines.oldGap, gapGapValue);
        //    newGapRow.Add(Routines.newGap, gapGapValue);

        //    matrix.Add(Routines.oldGap, oldGapRow);
        //    matrix.Add(Routines.newGap, newGapRow);

        //    SubstitutionMatrix subMatrix = new SubstitutionMatrix(name, matrix, residueCodes);

        //    subMatrix.CalculateMatrixAverageScore();

        //    if (!useNegativeMatrix)
        //    {
        //        subMatrix.MakePositive();
        //    }



        //    return subMatrix;
        //}

        public static SubstitutionMatrix Create(string name, double[] matrixInfo, char[] residueCodes)
        // matrixInfo is a single array containing the bottom-left triangle of the symmetrical matrix.
        {
            int  maxResidues       = residueCodes.Length;
            bool useNegativeMatrix = false;

            Dictionary <char, Dictionary <char, double> > matrix = new Dictionary <char, Dictionary <char, double> >(residueCodes.Length + 2);
            Dictionary <char, double> oldGapRow = new Dictionary <char, double>(residueCodes.Length + 2);
            Dictionary <char, double> newGapRow = new Dictionary <char, double>(residueCodes.Length + 2);

            int rowStart = 0;

            for (int i = 0; i < maxResidues; i++) // rows
            {
                Dictionary <char, double> row = new Dictionary <char, double>(residueCodes.Length + 2);
                for (int j = 0; j <= i; j++) // Populate the row
                {
                    row.Add(residueCodes[j], matrixInfo[rowStart + j] * 100);
                }
                matrix.Add(residueCodes[i], row);

                for (int j = 0; j < i; j++) // Populate the column too
                {
                    matrix[residueCodes[j]].Add(residueCodes[i], matrixInfo[rowStart + i]);
                }

                rowStart += i + 1;

                oldGapRow.Add(residueCodes[i], gapResidueValue);
                newGapRow.Add(residueCodes[i], gapResidueValue);
            }

            foreach (KeyValuePair <char, Dictionary <char, double> > row in matrix) // Add gap columns
            {
                row.Value.Add(Routines.oldGap, gapResidueValue);
                row.Value.Add(Routines.newGap, gapResidueValue);
            }

            oldGapRow.Add(Routines.oldGap, gapGapValue);
            oldGapRow.Add(Routines.newGap, gapGapValue);
            newGapRow.Add(Routines.oldGap, gapGapValue);
            newGapRow.Add(Routines.newGap, gapGapValue);

            matrix.Add(Routines.oldGap, oldGapRow);
            matrix.Add(Routines.newGap, newGapRow);

            SubstitutionMatrix subMatrix = new SubstitutionMatrix(name, matrix, residueCodes);

            subMatrix.CalculateMatrixAverageScore();

            if (!useNegativeMatrix)
            {
                subMatrix.MakePositive();
            }

            return(subMatrix);
        }
Ejemplo n.º 3
0
 static PAM()
 {
     matrices.Add("PAM20", SubstitutionMatrix.Create("PAM20", MatrixData.PAM20, Routines.aminoAcidCodes));
     matrices.Add("PAM60", SubstitutionMatrix.Create("PAM60", MatrixData.PAM60, Routines.aminoAcidCodes));
     matrices.Add("PAM120", SubstitutionMatrix.Create("PAM120", MatrixData.PAM120, Routines.aminoAcidCodes));
     matrices.Add("PAM160", SubstitutionMatrix.Create("PAM160", MatrixData.PAM160, Routines.aminoAcidCodes));
     matrices.Add("PAM250", SubstitutionMatrix.Create("PAM250", MatrixData.PAM250, Routines.aminoAcidCodes));
     matrices.Add("PAM350", SubstitutionMatrix.Create("PAM350", MatrixData.PAM350, Routines.aminoAcidCodes));
 }
Ejemplo n.º 4
0
 static Gonnet()
 {
     matrices.Add("Gonnet40", SubstitutionMatrix.Create("Gonnet40", MatrixData.Gonnet40, Routines.aminoAcidCodes));
     matrices.Add("Gonnet80", SubstitutionMatrix.Create("Gonnet80", MatrixData.Gonnet80, Routines.aminoAcidCodes));
     matrices.Add("Gonnet120", SubstitutionMatrix.Create("Gonnet120", MatrixData.Gonnet120, Routines.aminoAcidCodes));
     matrices.Add("Gonnet160", SubstitutionMatrix.Create("Gonnet160", MatrixData.Gonnet160, Routines.aminoAcidCodes));
     matrices.Add("Gonnet250", SubstitutionMatrix.Create("Gonnet250", MatrixData.Gonnet250, Routines.aminoAcidCodes));
     matrices.Add("Gonnet300", SubstitutionMatrix.Create("Gonnet300", MatrixData.Gonnet300, Routines.aminoAcidCodes));
     matrices.Add("Gonnet350", SubstitutionMatrix.Create("Gonnet350", MatrixData.Gonnet350, Routines.aminoAcidCodes));
 }
Ejemplo n.º 5
0
 static BLOSUM()
 {
     matrices.Add("BLOSUM30", SubstitutionMatrix.Create("BLOSUM30", MatrixData.BLOSUM30, Routines.aminoAcidCodes));
     matrices.Add("BLOSUM35", SubstitutionMatrix.Create("BLOSUM35", MatrixData.BLOSUM35, Routines.aminoAcidCodes));
     matrices.Add("BLOSUM40", SubstitutionMatrix.Create("BLOSUM40", MatrixData.BLOSUM40, Routines.aminoAcidCodes));
     matrices.Add("BLOSUM45", SubstitutionMatrix.Create("BLOSUM45", MatrixData.BLOSUM45, Routines.aminoAcidCodes));
     matrices.Add("BLOSUM50", SubstitutionMatrix.Create("BLOSUM50", MatrixData.BLOSUM50, Routines.aminoAcidCodes));
     matrices.Add("BLOSUM55", SubstitutionMatrix.Create("BLOSUM55", MatrixData.BLOSUM55, Routines.aminoAcidCodes));
     matrices.Add("BLOSUM62", SubstitutionMatrix.Create("BLOSUM62", MatrixData.BLOSUM62, Routines.aminoAcidCodes));
     matrices.Add("BLOSUM62x2", SubstitutionMatrix.Create("BLOSUM62x2", MatrixData.BLOSUM62x2, Routines.aminoAcidCodes));
     matrices.Add("BLOSUM65", SubstitutionMatrix.Create("BLOSUM65", MatrixData.BLOSUM65, Routines.aminoAcidCodes));
     matrices.Add("BLOSUM70", SubstitutionMatrix.Create("BLOSUM70", MatrixData.BLOSUM70, Routines.aminoAcidCodes));
     matrices.Add("BLOSUM75", SubstitutionMatrix.Create("BLOSUM75", MatrixData.BLOSUM75, Routines.aminoAcidCodes));
     matrices.Add("BLOSUM80", SubstitutionMatrix.Create("BLOSUM80", MatrixData.BLOSUM80, Routines.aminoAcidCodes));
     matrices.Add("BLOSUM90", SubstitutionMatrix.Create("BLOSUM90", MatrixData.BLOSUM90, Routines.aminoAcidCodes));
 }
Ejemplo n.º 6
0
 static IUB() // Also referred to as SW_GAP in Clustal code
 {
     matrix = SubstitutionMatrix.Create("IUB", MatrixData.IUB, Routines.nucleotideCodes);
 }
Ejemplo n.º 7
0
 static AminoAcidIdentity()
 {
     matrix = SubstitutionMatrix.Create("Identity", MatrixData.AminoAcidIdentity, Routines.aminoAcidCodes);
 }
Ejemplo n.º 8
0
 static NucleotideIdentity()  // Also referred to as ClustalVDNA in Clustal code, or ClustalW (1.6)
 {
     matrix = SubstitutionMatrix.Create("Identity", MatrixData.NucleotideIdentity, Routines.nucleotideCodes);
 }