*/
package jalview.gui;
-import jalview.analysis.AlignSeq;
-import jalview.datamodel.AlignmentAnnotation;
-import jalview.datamodel.ColumnSelection;
-import jalview.datamodel.RnaViewerModel;
-import jalview.datamodel.SequenceGroup;
-import jalview.datamodel.SequenceI;
-import jalview.ext.varna.RnaModel;
-import jalview.structure.SecondaryStructureListener;
-import jalview.structure.SelectionListener;
-import jalview.structure.SelectionSource;
-import jalview.structure.StructureSelectionManager;
-import jalview.structure.VamsasSource;
-import jalview.util.Comparison;
-import jalview.util.MessageManager;
-import jalview.util.ShiftList;
-
import java.awt.BorderLayout;
import java.awt.Color;
import java.util.Collection;
import fr.orsay.lri.varna.models.annotations.HighlightRegionAnnotation;
import fr.orsay.lri.varna.models.rna.ModeleBase;
import fr.orsay.lri.varna.models.rna.RNA;
+import jalview.analysis.AlignSeq;
+import jalview.datamodel.AlignmentAnnotation;
+import jalview.datamodel.ColumnSelection;
+import jalview.datamodel.HiddenColumns;
+import jalview.datamodel.RnaViewerModel;
+import jalview.datamodel.SequenceGroup;
+import jalview.datamodel.SequenceI;
+import jalview.ext.varna.RnaModel;
+import jalview.structure.SecondaryStructureListener;
+import jalview.structure.SelectionListener;
+import jalview.structure.SelectionSource;
+import jalview.structure.StructureSelectionManager;
+import jalview.structure.VamsasSource;
+import jalview.util.Comparison;
+import jalview.util.MessageManager;
+import jalview.util.ShiftList;
-public class AppVarna extends JInternalFrame implements SelectionListener,
- SecondaryStructureListener, InterfaceVARNASelectionListener,
- VamsasSource
+public class AppVarna extends JInternalFrame
+ implements SelectionListener, SecondaryStructureListener,
+ InterfaceVARNASelectionListener, VamsasSource
{
private static final byte[] PAIRS = new byte[] { '(', ')', '[', ']', '{',
'}', '<', '>' };
}
}
+ /**
+ * highlight a region from start to end (inclusive) on rna
+ *
+ * @param rna
+ * @param start
+ * - first base pair index (from 0)
+ * @param end
+ * - last base pair index (from 0)
+ */
public void highlightRegion(RNA rna, int start, int end)
{
clearLastSelection();
{
this(ap);
- String sname = aa.sequenceRef == null ? "secondary structure (alignment)"
+ String sname = aa.sequenceRef == null
+ ? "secondary structure (alignment)"
: seq.getName() + " structure";
String theTitle = sname
- + (aa.sequenceRef == null ? " trimmed to " + seq.getName() : "");
+ + (aa.sequenceRef == null ? " trimmed to " + seq.getName()
+ : "");
theTitle = MessageManager.formatMessage("label.varna_params",
- new String[] { theTitle });
+ new String[]
+ { theTitle });
setTitle(theTitle);
String gappedTitle = sname + " (with gaps)";
addModel(gappedModel, gappedTitle);
String trimmedTitle = "trimmed " + sname;
- RnaModel trimmedModel = new RnaModel(trimmedTitle, aa, seq, null, false);
+ RnaModel trimmedModel = new RnaModel(trimmedTitle, aa, seq, null,
+ false);
addModel(trimmedModel, trimmedTitle);
vab.setSelectedIndex(0);
}
*/
protected AppVarna(AlignmentPanel ap)
{
+ this.setFrameIcon(null);
this.ap = ap;
this.viewId = System.currentTimeMillis() + "." + this.hashCode();
vab = new AppVarnaBinding();
RnaModel rnaModel = models.get(rna);
if (rnaModel.seq == sequence)
{
- int highlightPos = rnaModel.gapped ? index : position - 1;
+ int highlightPos = rnaModel.gapped ? index
+ : position - sequence.getStart();
mouseOverHighlighter.highlightRegion(rna, highlightPos, highlightPos);
vab.updateSelectedRNA(rna);
}
@Override
public void selection(SequenceGroup seqsel, ColumnSelection colsel,
- SelectionSource source)
+ HiddenColumns hidden, SelectionSource source)
{
if (source != ap.av)
{
{
return;
}
- if (seqsel != null && seqsel.getSize() > 0)
+
+ RnaModel rnaModel = models.get(rna);
+
+ if (seqsel != null && seqsel.getSize() > 0
+ && seqsel.contains(rnaModel.seq))
{
int start = seqsel.getStartRes(), end = seqsel.getEndRes();
- ShiftList shift = offsets.get(rna);
- if (shift != null)
+ if (rnaModel.gapped)
{
- start = shift.shift(start);
- end = shift.shift(end);
+ ShiftList shift = offsets.get(rna);
+ if (shift != null)
+ {
+ start = shift.shift(start);
+ end = shift.shift(end);
+ }
}
+ else
+ {
+ start = rnaModel.seq.findPosition(start) - rnaModel.seq.getStart();
+ end = rnaModel.seq.findPosition(end) - rnaModel.seq.getStart();
+ }
+
selectionHighlighter.highlightRegion(rna, start, end);
- selectionHighlighter.getLastHighlight().setOutlineColor(
- seqsel.getOutlineColour());
+ selectionHighlighter.getLastHighlight()
+ .setOutlineColor(seqsel.getOutlineColour());
// TODO - translate column markings to positions on structure if present.
vab.updateSelectedRNA(rna);
}
}
@Override
- public void onSelectionChanged(BaseList arg0, BaseList arg1, BaseList arg2)
+ public void onSelectionChanged(BaseList arg0, BaseList arg1,
+ BaseList arg2)
{
// TODO translate selected regions in VARNA to a selection on the
// alignpanel.
{
if (!model.ann.isValidStruc())
{
- throw new IllegalArgumentException("Invalid RNA structure annotation");
+ throw new IllegalArgumentException(
+ "Invalid RNA structure annotation");
}
/*
ShiftList offset = new ShiftList();
int ofstart = -1;
int sleng = seq.getLength();
- char[] seqChars = seq.getSequence();
for (int i = 0; i < sleng; i++)
{
- if (Comparison.isGap(seqChars[i]))
+ if (Comparison.isGap(seq.getCharAt(i)))
{
if (ofstart == -1)
{
{
if (!model.ann.isValidStruc())
{
- throw new IllegalArgumentException("Invalid RNA structure annotation");
+ throw new IllegalArgumentException(
+ "Invalid RNA structure annotation");
}
try