File: IndexedNoAmbPackTest.java

package info (click to toggle)
biojava-live 1%3A1.7.1-8
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 55,160 kB
  • sloc: java: 180,820; xml: 6,908; sql: 510; makefile: 50
file content (45 lines) | stat: -rw-r--r-- 1,276 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package org.biojava.bio.symbol;

import java.util.Iterator;

import junit.framework.TestCase;

import org.biojava.bio.seq.ProteinTools;

/**
 * @author Matthew Pocock
 */
public class IndexedNoAmbPackTest
        extends TestCase
{
  public void testSymToIndexToSym()
          throws IllegalAlphabetException, IllegalSymbolException
  {
    FiniteAlphabet alpha = ProteinTools.getAlphabet();
    AlphabetIndex index = AlphabetManager.getAlphabetIndex(alpha);
    Packing packing = new IndexedNoAmbPack(index);

    for(Iterator i = alpha.iterator(); i.hasNext(); ) {
      Symbol sym = (Symbol) i.next();
      byte packed = packing.pack(sym);
      Symbol unpacked = packing.unpack(packed);

      assertEquals("Packing and unpacking round-trips", sym, unpacked);
    }
  }

  public void testIndexToSymToIndex()
          throws IllegalAlphabetException, IllegalSymbolException
  {
    FiniteAlphabet alpha = ProteinTools.getAlphabet();
    AlphabetIndex index = AlphabetManager.getAlphabetIndex(alpha);
    Packing packing = new IndexedNoAmbPack(index);

    for (byte i = 0; i < alpha.size(); i++) {
      Symbol unpacked = packing.unpack(i);
      byte repacked = packing.pack(unpacked);

      assertEquals("Unpacking and packing round-trips", i, repacked);
    }
  }
}