@@ -0,0 +1,2370 @@
+/*%0A *                  BioJava development code%0A *%0A * This code may be freely distributed and modified under the%0A * terms of the GNU Lesser General Public Licence.  This should%0A * be distributed with the code.  If you do not have a copy,%0A * see:%0A *%0A *      http://www.gnu.org/copyleft/lesser.html%0A *%0A * Copyright for this code is held jointly by the individual%0A * authors.  These should be listed in @author doc comments.%0A *%0A * For more information on the BioJava project and its aims,%0A * or to join the biojava-l mailing list, visit the home page%0A * at:%0A *%0A *      http://www.biojava.org/%0A * %0A * Created on Aug 23, 2007%0A * %0A */%0A%0Apackage org.biojava.bio.alignment;%0A%0Aimport java.io.BufferedReader;%0Aimport java.io.IOException;%0Aimport java.io.InputStream;%0Aimport java.io.InputStreamReader;%0A%0Aimport org.biojava.bio.seq.io.SymbolTokenization;%0Aimport org.biojava.bio.symbol.Alphabet;%0Aimport org.biojava.bio.symbol.AlphabetManager;%0Aimport org.biojava.bio.symbol.FiniteAlphabet;%0Aimport org.biojava.bio.symbol.Symbol;%0A%0Aimport junit.framework.TestCase;%0A%0Apublic class SubstitutionMatrixTest extends TestCase %7B%0A%09%0A%09%0A%09%0A%09public void testParseSubstitutionMatrix()%7B%0A%09%09%0A%09%09InputStream inStream = this.getClass().getResourceAsStream(%22/files/blosum62.mat%22);%0A        assertNotNull(inStream);%0A        %0A%0A        try %7B%0A            FiniteAlphabet alphabet = (FiniteAlphabet) AlphabetManager.alphabetForName(%22PROTEIN-TERM%22);%0A            SymbolTokenization symtok = alphabet.getTokenization(%22token%22);%0A        %09String file = readMatrix(inStream);%0A        %09SubstitutionMatrix matrix = new SubstitutionMatrix(alphabet,file,%22blosum 62%22);%0A        %09//matrix.printMatrix();%0A        %09%0A        %09Symbol A = symtok.parseToken(%22A%22);%0A        %09Symbol W = symtok.parseToken(%22W%22);%0A        %09Symbol D = symtok.parseToken(%22D%22);%0A        %09 %0A        %09%09%0A        %09assertEquals(matrix.getValueAt(A, A), 4);%0A        %09assertEquals(matrix.getValueAt(W, D),-4);%0A        %7D catch (Exception e)%7B%0A        %09fail(e.getMessage());%0A        %7D%0A        %0A        %0A%09%7D%0A%0A%09%0A%09private String readMatrix(InputStream stream) throws IOException%7B%0A%09%09String newline = System.getProperty(%22line.separator%22);%0A%09%09BufferedReader reader = new BufferedReader(new InputStreamReader( stream));%0A%09%09StringBuffer file = new StringBuffer();%0A%09%09while (reader.ready())%7B%0A%09%09%09file.append(reader.readLine() );%0A%09%09%09file.append(newline);%0A%09%09%7D%0A%09%09%0A%09%09return file.toString();%0A%09%7D%0A%7D%0A

test parsing of subsitution matrices