/**
  * Recompute the substring buffers, this needs to happen anytime the sequences are changed or the
  * block width changes...and results in a tiny speedup
  */
 private void recalcSubstrs() {
   substrs1.clear();
   substrs2.clear();
   for (int i = 0; i < Math.min(sequenceOne.length(), sequenceTwo.length()); i++) {
     substrs1.add(
         sequenceOne.toString().substring(i, Math.min(i + blockWidth, sequenceOne.length())));
     substrs2.add(
         sequenceTwo.toString().substring(i, Math.min(i + blockWidth, sequenceTwo.length())));
   }
 }
Exemple #2
0
 /**
  * Returns the amino acid that corresponds to the codon beginning at site i in this sequence
  *
  * @param sequence
  * @param site
  * @return
  */
 public AminoAcid translate(Sequence sequence, int site) {
   if (site >= (sequence.length() - 2)) {
     throw new IllegalArgumentException(
         "Cannot translate codon site #"
             + site
             + " because sequence is only "
             + sequence.length()
             + " sites long.");
   } else {
     AminoAcid aa = translate(sequence.toString().substring(site, site + 3));
     if (aa == null) {
       System.out.println(
           "Cannot translate codon :" + sequence.toString().substring(site, site + 3));
     }
     return aa;
   }
 }