import jalview.analysis.Conservation;
import jalview.commands.ChangeCaseCommand;
import jalview.commands.EditCommand;
+import jalview.commands.EditCommand.Action;
import jalview.datamodel.AlignmentAnnotation;
import jalview.datamodel.Annotation;
import jalview.datamodel.DBRefEntry;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
-import java.util.HashMap;
import java.util.Hashtable;
import java.util.LinkedHashMap;
import java.util.List;
JMenu outputMenu = new JMenu();
- JMenu showAnnotationsMenu = new JMenu();
+ JMenu seqShowAnnotationsMenu = new JMenu();
- JMenu hideAnnotationsMenu = new JMenu();
+ JMenu seqHideAnnotationsMenu = new JMenu();
- JMenuItem addReferenceAnnotations = new JMenuItem();
+ JMenuItem seqAddReferenceAnnotations = new JMenuItem();
+
+ JMenu groupShowAnnotationsMenu = new JMenu();
+
+ JMenu groupHideAnnotationsMenu = new JMenu();
+
+ JMenuItem groupAddReferenceAnnotations = new JMenuItem();
JMenuItem sequenceFeature = new JMenuItem();
/*
* Build menus for annotation types that may be shown or hidden, and for
- * 'reference annotations' that may be added to the alignment. The scope is
- * annotations for the current selection group (if there is one), else the
- * current sequence (if there is one), else not applicable (e.g. for popup
- * menu within the sequence).
+ * 'reference annotations' that may be added to the alignment. First for the
+ * currently selected sequence (if there is one):
*/
- final List<SequenceI> sequenceScope = getSequenceScope(seq);
- if (!sequenceScope.isEmpty())
- {
- buildAnnotationTypesMenus(sequenceScope);
- configureReferenceAnnotationsMenu(addReferenceAnnotations, sequenceScope);
- }
+ final List<SequenceI> selectedSequence = (seq == null ? Collections
+ .<SequenceI> emptyList() : Arrays.asList(seq));
+ buildAnnotationTypesMenus(seqShowAnnotationsMenu,
+ seqHideAnnotationsMenu, selectedSequence);
+ configureReferenceAnnotationsMenu(seqAddReferenceAnnotations,
+ selectedSequence);
+
+ /*
+ * And repeat for the current selection group (if there is one):
+ */
+ final List<SequenceI> selectedGroup = (ap.av.getSelectionGroup() == null ? Collections
+ .<SequenceI> emptyList() : ap.av.getSelectionGroup()
+ .getSequences());
+ buildAnnotationTypesMenus(groupShowAnnotationsMenu,
+ groupHideAnnotationsMenu, selectedGroup);
+ configureReferenceAnnotationsMenu(groupAddReferenceAnnotations,
+ selectedGroup);
try
{
{
AlignmentAnnotation[] aa = ap.av.getAlignment()
.getAlignmentAnnotation();
- for (int i = 0; i < aa.length; i++)
+ for (int i = 0; aa != null && i < aa.length; i++)
{
- if (aa[i].getRNAStruc() != null)
+ if (aa[i].isValidStruc() && aa[i].sequenceRef == null)
{
final String rnastruc = aa[i].getRNAStruc();
- final String structureLine = aa[i].label;
+ final String structureLine = aa[i].label + " (alignment)";
menuItem = new JMenuItem();
menuItem.setText(MessageManager.formatMessage(
"label.2d_rna_structure_line", new String[]
@Override
public void actionPerformed(ActionEvent e)
{
- // System.out.println("1:"+structureLine);
- System.out.println("1:sname" + seq.getName());
- System.out.println("2:seq" + seq);
-
- // System.out.println("3:"+seq.getSequenceAsString());
- System.out.println("3:strucseq" + rnastruc);
- // System.out.println("4:struc"+seq.getRNA());
- System.out.println("5:name" + seq.getName());
- System.out.println("6:ap" + ap);
+ // // System.out.println("1:"+structureLine);
+ // System.out.println("1:sname" + seq.getName());
+ // System.out.println("2:seq" + seq);
+ //
+ // // System.out.println("3:"+seq.getSequenceAsString());
+ // System.out.println("3:strucseq" + rnastruc);
+ // // System.out.println("4:struc"+seq.getRNA());
+ // System.out.println("5:name" + seq.getName());
+ // System.out.println("6:ap" + ap);
new AppVarna(structureLine, seq, seq.getSequenceAsString(),
rnastruc, seq.getName(), ap);
// new AppVarna(seq.getName(),seq,rnastruc,seq.getRNA(),
AlignmentAnnotation seqAnno[] = seq.getAnnotation();
for (int i = 0; i < seqAnno.length; i++)
{
- if (seqAnno[i].getRNAStruc() != null)
+ if (seqAnno[i].isValidStruc())
{
final String rnastruc = seqAnno[i].getRNAStruc();
}
/**
- * Add annotation types to a 'Show annotations' or 'Hide annotations' menu.
+ * Add annotation types to 'Show annotations' and/or 'Hide annotations' menus.
* "All" is added first, followed by a separator. Then add any annotation
- * types associated with the current selection.
+ * types associated with the current selection. Separate menus are built for
+ * the selected sequence group (if any), and the selected sequence.
* <p>
* Some annotation rows are always rendered together - these can be identified
* by a common graphGroup property > -1. Only one of each group will be marked
* <p>
* IUPredWS (Long), IUPredWS (Short)
*
- * @param forSequences
+ * @param seq
*/
- protected void buildAnnotationTypesMenus(List<SequenceI> forSequences)
+ protected void buildAnnotationTypesMenus(JMenu showMenu, JMenu hideMenu,
+ List<SequenceI> forSequences)
{
- showAnnotationsMenu.removeAll();
- hideAnnotationsMenu.removeAll();
+ showMenu.removeAll();
+ hideMenu.removeAll();
+
final List<String> all = Arrays.asList(ALL_ANNOTATIONS);
- addAnnotationTypeToShowHide(showAnnotationsMenu, forSequences, "", all,
- true, true);
- addAnnotationTypeToShowHide(hideAnnotationsMenu, forSequences, "", all,
- true, false);
- showAnnotationsMenu.addSeparator();
- hideAnnotationsMenu.addSeparator();
+ addAnnotationTypeToShowHide(showMenu, forSequences, "", all, true, true);
+ addAnnotationTypeToShowHide(hideMenu, forSequences, "", all, true,
+ false);
+ showMenu.addSeparator();
+ hideMenu.addSeparator();
final AlignmentAnnotation[] annotations = ap.getAlignment()
.getAlignmentAnnotation();
/*
* Find shown/hidden annotations types, distinguished by source (calcId),
- * and grouped by graphGroup.
+ * and grouped by graphGroup. Using LinkedHashMap means we will retrieve in
+ * the insertion order, which is the order of the annotations on the
+ * alignment.
*/
- Map<String, List<List<String>>> shownTypes = new HashMap<String, List<List<String>>>();
- Map<String, List<List<String>>> hiddenTypes = new HashMap<String, List<List<String>>>();
+ Map<String, List<List<String>>> shownTypes = new LinkedHashMap<String, List<List<String>>>();
+ Map<String, List<List<String>>> hiddenTypes = new LinkedHashMap<String, List<List<String>>>();
AlignmentAnnotationUtils.getShownHiddenTypes(shownTypes,
hiddenTypes,
AlignmentAnnotationUtils.asList(annotations),
{
for (List<String> type : hiddenTypes.get(calcId))
{
- addAnnotationTypeToShowHide(showAnnotationsMenu, forSequences,
+ addAnnotationTypeToShowHide(showMenu, forSequences,
calcId, type, false, true);
}
}
// grey out 'show annotations' if none are hidden
- showAnnotationsMenu.setEnabled(!hiddenTypes.isEmpty());
+ showMenu.setEnabled(!hiddenTypes.isEmpty());
for (String calcId : shownTypes.keySet())
{
for (List<String> type : shownTypes.get(calcId))
{
- addAnnotationTypeToShowHide(hideAnnotationsMenu, forSequences,
+ addAnnotationTypeToShowHide(hideMenu, forSequences,
calcId, type, false, false);
}
}
// grey out 'hide annotations' if none are shown
- hideAnnotationsMenu.setEnabled(!shownTypes.isEmpty());
+ hideMenu.setEnabled(!shownTypes.isEmpty());
}
/**
});
outputMenu.setText(MessageManager.getString("label.out_to_textbox")
+ "...");
- showAnnotationsMenu.setText(MessageManager
+ seqShowAnnotationsMenu.setText(MessageManager
.getString("label.show_annotations"));
- hideAnnotationsMenu.setText(MessageManager
+ seqHideAnnotationsMenu.setText(MessageManager
+ .getString("label.hide_annotations"));
+ groupShowAnnotationsMenu.setText(MessageManager
+ .getString("label.show_annotations"));
+ groupHideAnnotationsMenu.setText(MessageManager
.getString("label.hide_annotations"));
sequenceFeature.setText(MessageManager
.getString("label.create_sequence_feature"));
// groupMenu.add(chooseAnnotations);
/*
- * Add show/hide annotations to either Selection menu (if a selection group
- * in force), else to the Sequence menu.
+ * Add show/hide annotations to the Sequence menu, and to the Selection menu
+ * (if a selection group is in force).
*/
- SequenceGroup sg = this.ap.av.getSelectionGroup();
- if (sg != null && sg.getSize() > 0)
- {
- groupMenu.add(showAnnotationsMenu);
- groupMenu.add(hideAnnotationsMenu);
- groupMenu.add(addReferenceAnnotations);
- }
- else
- {
- sequenceMenu.add(showAnnotationsMenu);
- sequenceMenu.add(hideAnnotationsMenu);
- sequenceMenu.add(addReferenceAnnotations);
- }
+ sequenceMenu.add(seqShowAnnotationsMenu);
+ sequenceMenu.add(seqHideAnnotationsMenu);
+ sequenceMenu.add(seqAddReferenceAnnotations);
+ groupMenu.add(groupShowAnnotationsMenu);
+ groupMenu.add(groupHideAnnotationsMenu);
+ groupMenu.add(groupAddReferenceAnnotations);
groupMenu.add(editMenu);
groupMenu.add(outputMenu);
groupMenu.add(sequenceFeature);
* Add annotations at the top of the annotation, in the same order as their
* related sequences.
*/
- int insertPosition = 0;
for (SequenceI seq : candidates.keySet())
{
for (AlignmentAnnotation ann : candidates.get(seq))
// adjust for gaps
copyAnn.adjustForAlignment();
// add to the alignment and set visible
- this.ap.getAlignment().addAnnotation(copyAnn, insertPosition++);
+ this.ap.getAlignment().addAnnotation(copyAnn);
copyAnn.visible = true;
}
}
true,
true,
false,
- (ap.seqPanel.seqCanvas.fr != null) ? ap.seqPanel.seqCanvas.fr.minmax
+ (ap.getSeqPanel().seqCanvas.fr != null) ? ap.getSeqPanel().seqCanvas.fr.minmax
: null);
contents.append("</p>");
}
String choice = chooser.getSelectedFile().getPath();
jalview.bin.Cache.setProperty("LAST_DIRECTORY", choice);
new AssociatePdbFileWithSeq().associatePdbWithSeq(choice,
- jalview.io.AppletFormatAdapter.FILE, sequence, true);
+ jalview.io.AppletFormatAdapter.FILE, sequence, true,
+ Desktop.instance);
}
}
System.arraycopy(features, 0, tfeatures, 0, rsize);
features = tfeatures;
seqs = rseqs;
- if (ap.seqPanel.seqCanvas.getFeatureRenderer().amendFeatures(seqs,
+ if (ap.getSeqPanel().seqCanvas.getFeatureRenderer().amendFeatures(seqs,
features, true, ap))
{
ap.alignFrame.setShowSeqFeatures(true);
{
EditCommand editCommand = new EditCommand(
MessageManager.getString("label.edit_sequences"),
- EditCommand.REPLACE, dialog.getName().replace(' ',
+ Action.REPLACE, dialog.getName().replace(' ',
ap.av.getGapCharacter()),
sg.getSequencesAsArray(ap.av.getHiddenRepSequences()),
sg.getStartRes(), sg.getEndRes() + 1, ap.av.getAlignment());