- return;
- }
- boolean iAmProtein = !getAlignment().isNucleotide();
- AlignmentI proteinAlignment = iAmProtein ? getAlignment()
- : codingComplement.getAlignment();
- if (proteinAlignment == null)
- {
- return;
- }
- final Set<AlignedCodonFrame> mappings = proteinAlignment
- .getCodonFrames();
-
- /*
- * Heuristic: find the first mapped sequence (if any) with a non-gapped
- * residue in the middle column of the visible region. Scroll the
- * complementary alignment to line up the corresponding residue.
- */
- int seqOffset = 0;
- SequenceI sequence = null;
- int middleColumn = getStartRes() + (getEndRes() - getStartRes()) / 2;
- final HiddenSequences hiddenSequences = getAlignment()
- .getHiddenSequences();
- for (int seqNo = getStartSeq(); seqNo < getEndSeq(); seqNo++, seqOffset++)
- {
- sequence = getAlignment().getSequenceAt(seqNo);
- if (hiddenSequences != null && hiddenSequences.isHidden(sequence))
- {
- continue;
- }
- if (Comparison.isGap(sequence.getCharAt(middleColumn)))
- {
- continue;
- }
- List<AlignedCodonFrame> seqMappings = MappingUtils
- .findMappingsForSequence(sequence, mappings);
- if (!seqMappings.isEmpty())
- {
- break;
- }
- }
-
- if (sequence == null)
- {
- /*
- * No ungapped mapped sequence in middle column - do nothing
- */
- return;
+ // TODO would like next line without cast but needs more refactoring...
+ final AlignmentPanel complementPanel = ((AlignViewport) getCodingComplement()).getAlignPanel();
+ complementPanel.setFollowingComplementScroll(true);
+ complementPanel.scrollToCentre(sr, seqOffset);