@Test(expected = IllegalArgumentException.class)
 public void testConvertQualityNoop() {
   frag.setSequence(new Text("AGTAGTAGTAGTAGTAGTAGTAGTAGTAGT"));
   frag.setQuality(new Text("[[[[[[[[[[[[[[[[[[[[[[[[[[[[[["));
   SequencedFragment.convertQuality(
       frag.getQuality(),
       FormatConstants.BaseQualityEncoding.Sanger,
       FormatConstants.BaseQualityEncoding.Sanger);
 }
 @Test(expected = FormatException.class)
 public void testConvertQualitySangerUnderRange() {
   frag.setSequence(new Text("AGTAGTAGTAGTAGTAGTAGTAGTAGTAGT"));
   frag.setQuality(new Text("### ##########################"));
   SequencedFragment.convertQuality(
       frag.getQuality(),
       FormatConstants.BaseQualityEncoding.Sanger,
       FormatConstants.BaseQualityEncoding.Illumina);
 }
 @Test
 public void testVerifyQualityIlluminaOutOfRange() {
   frag.setSequence(new Text("AGTAGTAGTAGTAGTAGTAGTAGTAGTAGT"));
   frag.setQuality(new Text("zzz=zzzzzzzzzzzzzzzzzzzzzzzzzz"));
   assertEquals(
       3,
       SequencedFragment.verifyQuality(
           frag.getQuality(), FormatConstants.BaseQualityEncoding.Illumina));
 }
 @Test
 public void testVerifyQualitySangerOk() {
   frag.setSequence(new Text("AGTAGTAGTAGTAGTAGTAGTAGTAGTAGT"));
   frag.setQuality(new Text("##############################"));
   assertEquals(
       -1,
       SequencedFragment.verifyQuality(
           frag.getQuality(), FormatConstants.BaseQualityEncoding.Sanger));
 }
 @Test
 public void testConvertQualitySangerToIllumina() {
   frag.setSequence(new Text("AGTAGTAGTAGTAGTAGTAGTAGTAGTAGT"));
   frag.setQuality(new Text("[[[[[[[[[[[[[[[[[[[[[[[[[[[[[["));
   SequencedFragment.convertQuality(
       frag.getQuality(),
       FormatConstants.BaseQualityEncoding.Sanger,
       FormatConstants.BaseQualityEncoding.Illumina);
   assertEquals("zzzzzzzzzzzzzzzzzzzzzzzzzzzzzz", frag.getQuality().toString());
 }
  @Test
  public void testSerializationWithFields() throws IOException {
    frag.setSequence(new Text("AGTAGTAGTAGTAGTAGTAGTAGTAGTAGT"));
    frag.setQuality(new Text("BBBBBBBBBBBBBBBBBBBBBBBBBBBBBB"));

    frag.setInstrument("machine");
    frag.setLane(3);
    frag.setRead(1);
    frag.setIndexSequence("CAT");

    assertEquals(frag, cloneBySerialization(frag));
  }
  @Test
  public void testVerifyQualitySangerOutOfRange() {
    frag.setSequence(new Text("AGTAGTAGTAGTAGTAGTAGTAGTAGTAGT"));
    frag.setQuality(
        new Text("#############################" + Character.toString((char) 127))); // over range
    assertEquals(
        29,
        SequencedFragment.verifyQuality(
            frag.getQuality(), FormatConstants.BaseQualityEncoding.Sanger));

    frag.setQuality(new Text("##### ########################")); // under range
    assertEquals(
        5,
        SequencedFragment.verifyQuality(
            frag.getQuality(), FormatConstants.BaseQualityEncoding.Sanger));
  }
  @Test
  public void testToString() {
    String seq = "AGTAGTAGTAGTAGTAGTAGTAGTAGTAGT";
    String qual = "##############################";
    frag.setSequence(new Text(seq));
    frag.setQuality(new Text(qual));

    frag.setInstrument("machine");
    frag.setRunNumber(123);
    frag.setFlowcellId("flowcell");
    frag.setLane(3);
    frag.setTile(1001);
    frag.setXpos(1234);
    frag.setYpos(4321);
    frag.setIndexSequence("CAT");
    frag.setRead(1);

    assertEquals(
        "machine\t123\tflowcell\t3\t1001\t1234\t4321\tCAT\t1\t" + seq + "\t" + qual + "\t1",
        frag.toString());
  }
 @Test(expected = IllegalArgumentException.class)
 public void testNoNullSequence() {
   frag.setSequence(null);
 }
 @Test
 public void testSerializationWithSeq() throws IOException {
   frag.setSequence(new Text("AGTAGTAGTAGTAGTAGTAGTAGTAGTAGT"));
   frag.setQuality(new Text("##############################"));
   assertEquals(frag, cloneBySerialization(frag));
 }