Пример #1
0
 public void testOverlapCigarConsistencyRev() {
   final byte[] read =
       DnaUtils.encodeString(
           DnaUtils.reverseComplement(
               "TAGGCGGGTTGCCAA TTAACTTGTA      GTCCTTGACA".replaceAll(" ", "")));
   final byte[] tmpl =
       DnaUtils.encodeString("TAGGG   TGGCCAA TTAACTTGTAGTGTGCGTCCTTGACA".replaceAll(" ", ""));
   final int[] actions = ActionsHelper.build("==========NNNNNN===============X====BBBX====", 0, 3);
   final AlignmentResult ar = new AlignmentResult(read, actions, tmpl);
   ar.setIdentifyingInfo(false, true);
   // System.out.println("cigar:" + ar.getCigarString(1, true) + " readString:" + ar.readString());
   final SAMRecord samrec = new SAMRecord(null);
   samrec.setCigarString(ar.getCigarString(true, false));
   samrec.setReadString(DnaUtils.reverseComplement(ar.readString()));
   samrec.setAttribute(SamUtils.ATTRIBUTE_NUM_MISMATCHES, 2);
   samrec.setAlignmentStart(1);
   samrec.setFlags(179);
   final NgsParams params =
       new NgsParamsBuilder()
           .gapOpenPenalty(EditDistanceFactory.DEFAULT_GAP_OPEN_PENALTY)
           .gapExtendPenalty(EditDistanceFactory.DEFAULT_GAP_EXTEND_PENALTY)
           .substitutionPenalty(EditDistanceFactory.DEFAULT_SUBSTITUTION_PENALTY)
           .unknownsPenalty(0)
           .create();
   try (MemoryPrintStream mps = new MemoryPrintStream()) {
     final SamValidator sv =
         new SamValidator(
             mps.printStream(), mps.printStream(), true, false, false, false, params, false);
     assertEquals(
         2 * EditDistanceFactory.DEFAULT_SUBSTITUTION_PENALTY,
         sv.isAtExpectedRef(tmpl, samrec, null));
   }
 }
Пример #2
0
  public void testCgTripleInsertRev() {
    final String read =
        "                           tagacaaatg        ttacaagaccacaggaggggaa".replaceAll(" ", "");
    final String temp =
        DnaUtils.reverseComplement(
            "tagacaaatgtgactggattacaag ccacaggagggggaaa".replaceAll(" ", ""));

    final String actions = "==========NNNNNNND=======I============X=";
    final AlignmentResult alignment2 =
        new AlignmentResult(
            DnaUtils.encodeString(read),
            ActionsHelper.build(actions, 2, 0),
            DnaUtils.encodeString(temp));

    alignment2.setIdentifyingInfo(false, true);
    alignment2.setRemainingOutput(-2, 1);

    assertEquals(0, alignment2.getScore());
    assertFalse(alignment2.isFirst());
    assertEquals(2, alignment2.getStart());
    assertEquals(-2, alignment2.getReadId());
    assertEquals(1, alignment2.getReferenceId());
    assertEquals(actions, alignment2.getActionsString());
    assertEquals(30, alignment2.getMatchCount());
    assertEquals(1, alignment2.getDeletionsFromReadCount());
    //    assertEquals(1, alignment2.getSubstitutionsCount());
    assertTrue(alignment2.isReverse());
    //    assertEquals(3, alignment2.mismatches());
    assertEquals("TAGACAAATGTTACAAGACCACAGGAGGGGAA", alignment2.readString());

    final String cigar2 = alignment2.getCigarString(true, false);
    assertEquals("1=1X12=1I7=1D7N10=", cigar2);
  }