code: public static <S extends Sequence<S>> Alignment<S> rightTrimAlignment(Alignment<S> alignment,
                                                                           AlignmentScoring<S> scoring) {
          if (scoring instanceof LinearGapAlignmentScoring)
              return rightTrimAlignment(alignment, (LinearGapAlignmentScoring<S>) scoring);
          else if (scoring instanceof AffineGapAlignmentScoring)
              return rightTrimAlignment(alignment, (AffineGapAlignmentScoring<S>) scoring);
          else
              throw new IllegalArgumentException("Unknown scoring type");
      }
docs: Try increase total alignment score by partially (or fully) trimming it from right side. If score can't be
  increased the same alignment will be returned.
  
  @param alignment input alignment
  @param scoring   scoring
  @return resulting alignment