if (stretchGroup == null)
{
- stretchGroup = av.getAlignment().findGroup(sequence);
- if (stretchGroup != null && res > stretchGroup.getStartRes()
- && res < stretchGroup.getEndRes())
- {
- av.setSelectionGroup(stretchGroup);
- }
- else
- {
- stretchGroup = null;
- }
+ stretchGroup = av.getAlignment().findGroup(sequence, res);
+ av.setSelectionGroup(stretchGroup);
}
- else if (!stretchGroup.getSequences(null).contains(sequence)
+ if (stretchGroup == null
+ || !stretchGroup.getSequences(null).contains(sequence)
|| stretchGroup.getStartRes() > res
|| stretchGroup.getEndRes() < res)
{
* @see jalview.datamodel.AlignmentI#findGroup(jalview.datamodel.SequenceI)
*/
@Override
- public SequenceGroup findGroup(SequenceI s)
+ public SequenceGroup findGroup(SequenceI seq, int position)
{
synchronized (groups)
{
- for (int i = 0; i < this.groups.size(); i++)
+ for (SequenceGroup sg : groups)
{
- SequenceGroup sg = groups.get(i);
-
- if (sg.getSequences(null).contains(s))
+ if (sg.getSequences(null).contains(seq))
{
- return sg;
+ if (position >= sg.getStartRes() && position <= sg.getEndRes())
+ {
+ return sg;
+ }
}
}
}
int findIndex(SequenceI s);
/**
- * Finds group that given sequence is part of.
+ * Returns the first group (in the order in which groups were added) that
+ * includes the given sequence and aligned position (base 0), or null if none
+ * found
*
- * @param s
- * Sequence in alignment.
+ * @param seq
+ * @param position
*
- * @return First group found for sequence. WARNING : Sequences may be members
- * of several groups. This method is incomplete.
+ * @return
*/
- SequenceGroup findGroup(SequenceI s);
+ SequenceGroup findGroup(SequenceI seq, int position);
/**
* Finds all groups that a given sequence is part of.
import java.util.ArrayList;
import java.util.List;
-import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;
import javax.swing.ToolTipManager;
if (stretchGroup == null)
{
- stretchGroup = av.getAlignment().findGroup(sequence);
-
- if ((stretchGroup != null) && (res > stretchGroup.getStartRes())
- && (res < stretchGroup.getEndRes()))
- {
- av.setSelectionGroup(stretchGroup);
- }
- else
- {
- stretchGroup = null;
- }
+ stretchGroup = av.getAlignment().findGroup(sequence, res);
+ av.setSelectionGroup(stretchGroup);
}
- else if (!stretchGroup.getSequences(null).contains(sequence)
+ if (stretchGroup == null
+ || !stretchGroup.getSequences(null).contains(sequence)
|| (stretchGroup.getStartRes() > res)
|| (stretchGroup.getEndRes() < res))
{