示例#1
0
        /// <summary>
        /// Initializes a new instance of the SimilarityMatrix class
        /// Constructs one of the standard similarity matrices.
        /// </summary>
        /// <param name="matrixId">
        /// Matrix to load, BLOSUM and PAM currently supported.
        /// The enum StandardSimilarityMatrices contains list of available matrices.
        /// </param>
        public SimilarityMatrix(StandardSimilarityMatrix matrixId)
        {
            // MoleculeType.Protein for BLOSUM and PAM series supported matrices
            MoleculeType moleculeType = MoleculeType.Protein;
            string       matrixText   = null;

            switch (matrixId)
            {
            case StandardSimilarityMatrix.Blosum45:
                matrixText = SimilarityMatrixResources.Blosum45;
                break;

            case StandardSimilarityMatrix.Blosum50:
                matrixText = SimilarityMatrixResources.Blosum50;
                break;

            case StandardSimilarityMatrix.Blosum62:
                matrixText = SimilarityMatrixResources.Blosum62;
                break;

            case StandardSimilarityMatrix.Blosum80:
                matrixText = SimilarityMatrixResources.Blosum80;
                break;

            case StandardSimilarityMatrix.Blosum90:
                matrixText = SimilarityMatrixResources.Blosum90;
                break;

            case StandardSimilarityMatrix.Pam250:
                matrixText = SimilarityMatrixResources.Pam250;
                break;

            case StandardSimilarityMatrix.Pam30:
                matrixText = SimilarityMatrixResources.Pam30;
                break;

            case StandardSimilarityMatrix.Pam70:
                matrixText = SimilarityMatrixResources.Pam70;
                break;

            case StandardSimilarityMatrix.AmbiguousDna:
                matrixText   = SimilarityMatrixResources.AmbiguousDna;
                moleculeType = MoleculeType.DNA;
                break;

            case StandardSimilarityMatrix.AmbiguousRna:
                matrixText   = SimilarityMatrixResources.AmbiguousRna;
                moleculeType = MoleculeType.RNA;
                break;

            case StandardSimilarityMatrix.DiagonalScoreMatrix:
                matrixText = SimilarityMatrixResources.DiagonalScoreMatrix;
                break;
            }

            using (TextReader reader = new StringReader(matrixText))
            {
                LoadFromStream(reader, moleculeType);
            }
        }
示例#2
0
        /// <summary>
        /// Initializes a new instance of the SimilarityMatrix class
        /// Constructs one of the standard similarity matrices.
        /// </summary>
        /// <param name="matrixId">
        /// Matrix to load, BLOSUM and PAM currently supported.
        /// The enum StandardSimilarityMatrices contains list of available matrices.
        /// </param>
        public SimilarityMatrix(StandardSimilarityMatrix matrixId)
        {
            // MoleculeType.Protein for BLOSUM and PAM series supported matrices
            IAlphabet moleculeType = Alphabets.Protein;
            string matrixText = null;

            switch (matrixId)
            {
                case StandardSimilarityMatrix.Blosum45:
                    matrixText = "Bio.SimilarityMatrices.Resources.BLOSUM45.txt";
                    break;
                case StandardSimilarityMatrix.Blosum50:
                    matrixText = "Bio.SimilarityMatrices.Resources.BLOSUM50.txt";
                    break;
                case StandardSimilarityMatrix.Blosum62:
                    matrixText = "Bio.SimilarityMatrices.Resources.BLOSUM62.txt";
                    break;
                case StandardSimilarityMatrix.Blosum80:
                    matrixText = "Bio.SimilarityMatrices.Resources.BLOSUM80.txt";
                    break;
                case StandardSimilarityMatrix.Blosum90:
                    matrixText = "Bio.SimilarityMatrices.Resources.BLOSUM90.txt";
                    break;
                case StandardSimilarityMatrix.Pam250:
                    matrixText = "Bio.SimilarityMatrices.Resources.PAM250.txt";
                    break;
                case StandardSimilarityMatrix.Pam30:
                    matrixText = "Bio.SimilarityMatrices.Resources.PAM30.txt";
                    break;
                case StandardSimilarityMatrix.Pam70:
                    matrixText = "Bio.SimilarityMatrices.Resources.PAM70.txt";
                    break;
                case StandardSimilarityMatrix.AmbiguousDna:
                    matrixText = "Bio.SimilarityMatrices.Resources.AmbiguousDNA.txt";
                    moleculeType = Alphabets.DNA;
                    break;
                case StandardSimilarityMatrix.AmbiguousRna:
                    matrixText = "Bio.SimilarityMatrices.Resources.AmbiguousRNA.txt";
                    moleculeType = Alphabets.RNA;
                    break;
                case StandardSimilarityMatrix.DiagonalScoreMatrix:
                    matrixText = "Bio.SimilarityMatrices.Resources.DiagonalScoreMatrix.txt";
                    break;
                case StandardSimilarityMatrix.EDnaFull:
                    matrixText = "Bio.SimilarityMatrices.Resources.EDNAFull.txt";
                    moleculeType = Alphabets.AmbiguousDNA;
                    break;
            }

            Stream stream = typeof(SimilarityMatrix).GetTypeInfo().Assembly.GetManifestResourceStream(matrixText);
            if (stream == null)
                throw new Exception("Could not locate SimilarityMatrix " + matrixText + " in resources.");

            using (TextReader reader = new StreamReader(stream))
            {
                LoadFromStream(reader, moleculeType);
            }
        }
示例#3
0
        /// <summary>
        /// Initializes a new instance of the SimilarityMatrix class
        /// Constructs one of the standard similarity matrices.
        /// </summary>
        /// <param name="matrixId">
        /// Matrix to load, BLOSUM and PAM currently supported.
        /// The enum StandardSimilarityMatrices contains list of available matrices.
        /// </param>
        public SimilarityMatrix(StandardSimilarityMatrix matrixId)
        {
            // MoleculeType.Protein for BLOSUM and PAM series supported matrices
            IAlphabet moleculeType = Alphabets.Protein;
            string    matrixText   = null;

            switch (matrixId)
            {
            case StandardSimilarityMatrix.Blosum45:
                matrixText = "Bio.SimilarityMatrices.Resources.BLOSUM45.txt";
                break;

            case StandardSimilarityMatrix.Blosum50:
                matrixText = "Bio.SimilarityMatrices.Resources.BLOSUM50.txt";
                break;

            case StandardSimilarityMatrix.Blosum62:
                matrixText = "Bio.SimilarityMatrices.Resources.BLOSUM62.txt";
                break;

            case StandardSimilarityMatrix.Blosum80:
                matrixText = "Bio.SimilarityMatrices.Resources.BLOSUM80.txt";
                break;

            case StandardSimilarityMatrix.Blosum90:
                matrixText = "Bio.SimilarityMatrices.Resources.BLOSUM90.txt";
                break;

            case StandardSimilarityMatrix.Pam250:
                matrixText = "Bio.SimilarityMatrices.Resources.PAM250.txt";
                break;

            case StandardSimilarityMatrix.Pam30:
                matrixText = "Bio.SimilarityMatrices.Resources.PAM30.txt";
                break;

            case StandardSimilarityMatrix.Pam70:
                matrixText = "Bio.SimilarityMatrices.Resources.PAM70.txt";
                break;

            case StandardSimilarityMatrix.Pam1:
                matrixText = "Bio.SimilarityMatrices.Resources.PAM1.txt";
                break;

            case StandardSimilarityMatrix.Conservative:
                matrixText = "Bio.SimilarityMatrices.Resources.Conservative.txt";
                break;

            case StandardSimilarityMatrix.radical:
                matrixText = "Bio.SimilarityMatrices.Resources.radical.txt";
                break;

            case StandardSimilarityMatrix.Conservative_Only_By_Side:
                matrixText = "Bio.SimilarityMatrices.Resources.Conservative_Only_By_Side.txt";
                break;

            case StandardSimilarityMatrix.radical_Only_By_Side:
                matrixText = "Bio.SimilarityMatrices.Resources.radical_Only_By_Side.txt";
                break;

            case StandardSimilarityMatrix.AmbiguousDna:
                matrixText   = "Bio.SimilarityMatrices.Resources.AmbiguousDNA.txt";
                moleculeType = Alphabets.DNA;
                break;

            case StandardSimilarityMatrix.AmbiguousRna:
                matrixText   = "Bio.SimilarityMatrices.Resources.AmbiguousRNA.txt";
                moleculeType = Alphabets.RNA;
                break;

            case StandardSimilarityMatrix.DiagonalScoreMatrix:
                matrixText = "Bio.SimilarityMatrices.Resources.DiagonalScoreMatrix.txt";
                break;

            case StandardSimilarityMatrix.EDnaFull:
                matrixText   = "Bio.SimilarityMatrices.Resources.EDNAFull.txt";
                moleculeType = Alphabets.AmbiguousDNA;
                break;

            case StandardSimilarityMatrix.Silent:
                matrixText = "Bio.SimilarityMatrices.Resources.Silent.txt";
                break;
            }
            Assembly H = typeof(SimilarityMatrix).GetTypeInfo().Assembly;

            H.GetManifestResourceStream(matrixText);
            Stream stream = typeof(SimilarityMatrix).GetTypeInfo().Assembly.GetManifestResourceStream(matrixText);

            if (stream == null)
            {
                throw new Exception("Could not locate SimilarityMatrix " + matrixText + " in resources.");
            }

            using (TextReader reader = new StreamReader(stream))
            {
                LoadFromStream(reader, moleculeType);
            }
        }