Ejemplo n.º 1
0
  @Test
  public void assertEncodeSequence() {
    FastaInput in = new FastaInput();
    Sequence seq = null;
    long numSeqs = 0;

    Assert.assertTrue(in.open("A.fasta"));

    try {
      while ((seq = in.readNextSequence()) != null) {
        String sequence = seq.getSequence();
        int seqOldLen = sequence.length();
        byte[] comSequence = SequenceUtils.compressSequence(sequence);
        int seqNewLen = comSequence.length;
        System.out.print(seqOldLen + " : ");
        System.out.print(seqNewLen + " = " + ((double) seqNewLen / (double) seqOldLen));
        System.out.print(" -> ");

        String decomp = SequenceUtils.decompressSequence(comSequence);
        System.out.println(decomp.length());

        Assert.assertTrue(seq.getAttributes().size() > 0);
        Assert.assertTrue(seq.getChunks() != null);
        Assert.assertTrue(seq.getChunks().size() > 0);

        Assert.assertEquals(sequence, decomp.substring(0, seqOldLen));

        ++numSeqs;
      }
    } finally {
      in.close();
    }

    Assert.assertTrue(numSeqs == 6);
  }
Ejemplo n.º 2
0
  @Test
  public void testReadNextSequence() {

    FastaInput in = new FastaInput();
    Sequence seq = null;
    long numSeqs = 0;

    Assert.assertTrue(in.open("A.fasta"));

    try {
      while ((seq = in.readNextSequence()) != null) {
        // System.out.println(seq.getId());

        /*for(String key : seq.getAttributes().keySet()) {
        	System.out.println("key: " + key + ", value = " + seq.getAttributes().get(key));
        }*/

        Assert.assertTrue(seq.getAttributes().size() > 0);
        Assert.assertTrue(seq.getChunks() != null);
        Assert.assertTrue(seq.getChunks().size() > 0);

        ++numSeqs;
      }
    } finally {
      in.close();
    }

    Assert.assertTrue(numSeqs == 6);
  }