From: tcofoegbu Date: Mon, 5 Jun 2017 11:15:40 +0000 (+0100) Subject: Merge branch 'spikes/phyre' into features/JAL-2136_phyre2_integration X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=6849cc1cb983a45b4b8fd840f5ffc7d31ca80f33;hp=4bf0e53de60bc7473aeb79de1029d665d40882c1;p=jalview.git Merge branch 'spikes/phyre' into features/JAL-2136_phyre2_integration --- diff --git a/examples/appletParameters.html b/examples/appletParameters.html index 7959c3a..04cc235 100644 --- a/examples/appletParameters.html +++ b/examples/appletParameters.html @@ -159,6 +159,11 @@ the applet can be interacted with via its Default is true. + showOccupancy + true or false + Default is true. + + sortBy Id , Pairwise Identity, or Length Sorts the alignment on startup diff --git a/help/html/features/preferences.html b/help/html/features/preferences.html index da045ba..6e8d3e4 100755 --- a/help/html/features/preferences.html +++ b/help/html/features/preferences.html @@ -89,10 +89,11 @@

Show Annotations - If this is selected the new window will display an annotation panel below the sequences. This annotation - panel may have several rows describing the whole alignment. The 3 - standard annotations Conservation, Quality and Consensus - for the alignment may be shown or hidden by default using the - checkboxes below. + panel may have several rows describing the whole alignment. The 4 + standard annotations Conservation, Quality, + Occupancy and Consensus for the alignment may + be shown or hidden by default using the checkboxes adjacent and + below.

Show group: Conservation and Consensus controls the display diff --git a/resources/lang/Messages.properties b/resources/lang/Messages.properties index 04bfb30..7bf0474 100644 --- a/resources/lang/Messages.properties +++ b/resources/lang/Messages.properties @@ -3,7 +3,7 @@ action.reset_services = Reset Services action.merge_results = Merge Results action.load_scheme = Load scheme action.save_scheme = Save scheme -label.scheme_changed = Changes to scheme {0} have not been saved.

Save changes, or continue without saving to make a new colour scheme. +label.scheme_changed = Changes to scheme ''{0}'' have not been saved.

Save changes, or continue without saving to make a new colour scheme. label.save_changes = Save Changes label.dont_save_changes = Don't Save action.save_image = Save Image @@ -68,6 +68,7 @@ action.user_defined = User Defined... action.by_conservation = By Conservation action.wrap = Wrap action.show_gaps = Show Gaps +action.show_occupancy = Show Occupancy action.show_hidden_markers = Show Hidden Markers action.find = Find action.undefine_groups = Undefine Groups @@ -181,6 +182,7 @@ label.score_model_conservation = Physicochemical property conservation label.score_model_enhconservation = Physicochemical property conservation label.status_bar = Status bar label.out_to_textbox = Output to Textbox +label.occupancy = Occupancy # delete Clustal - use FileFormat name instead label.clustal = Clustal # label.colourScheme_ as in JalviewColourScheme @@ -908,6 +910,7 @@ label.webservice_job_title_on = {0} using {1} on {2} label.updating_vamsas_session = Updating vamsas session label.loading_file = Loading File: {0} label.edit_params = Edit {0} +label.as_percentage = As Percentage error.not_implemented = Not implemented error.no_such_method_as_clone1_for = No such method as clone1 for {0} error.null_from_clone1 = Null from clone1! @@ -1296,10 +1299,7 @@ label.edit_sequence_url_link = Edit sequence URL link warn.name_cannot_be_duplicate = User-defined URL names must be unique and cannot be MIRIAM ids label.invalid_name = Invalid Name ! label.output_seq_details = Output Sequence Details to list all database references -<<<<<<< HEAD label.phyre2_model_prediction = 3D Protein Model prediction with Phyre2 label.run_phyre2_prediction = Run Phyre2 Prediction status.obtaining_mapping_with_phyre2_template_alignment = Obtaining mapping with Phyre2 Template alignment -======= label.urllinks = Links ->>>>>>> develop diff --git a/resources/lang/Messages_es.properties b/resources/lang/Messages_es.properties index a878ab7..bdd61fe 100644 --- a/resources/lang/Messages_es.properties +++ b/resources/lang/Messages_es.properties @@ -3,6 +3,9 @@ action.reset_services = Reiniciar servicios action.merge_results = Unificar resultados action.load_scheme = Cargar esquema action.save_scheme = Guardar esquema +label.scheme_changed = Cambios en el esquema ''{0}'' no se han guardado.

Guardar cambios, o continuar sin guardar para hacer un nuevo esquema. +label.save_changes = Guardar cambios +label.dont_save_changes = No guardar action.save_image = Guardar imagen action.paste = Pegar action.show_html_source = Mostrar código HTML @@ -1140,6 +1143,9 @@ action.annotations=Anotaciones label.nuc_alignment_colour=Color del Alineamiento Nucleotídico label.copy_format_from=Copiar formato de label.chimera=Chimera +label.create_chimera_attributes = Escribir características de Jalview +label.create_chimera_attributes_tip = Establecer atributos en Chimera para características visibles +label.attributes_set = {0} valores de atributos establecidos en Chimera label.open_split_window=Abrir ventana dividida label.open_split_window?=¿Quieres abrir ventana dividida, con cDNA y proteína vinculadas? status.searching_for_pdb_structures=Buscando Estructuras PDB @@ -1178,9 +1184,14 @@ label.hide_insertions=Ocultar Inserciones info.change_threshold_mode_to_enable=Cambiar Modo de Umbral para Habilitar label.separate_multiple_query_values=Introducir uno o mas {0}s separados por punto y coma ";" label.let_chimera_manage_structure_colours=Deja que Chimera maneje colores de estructuras +label.fetch_chimera_attributes = Buscar atributos desde Chimera +label.fetch_chimera_attributes_tip = Copiar atributo de Chimera a característica de Jalview label.view_rna_structure=Estructura 2D VARNA label.scale_protein_to_cdna_tip=Hacer a los residuos de proteínas de la misma anchura que los codones en ventanas divididas label.colour_with_chimera=Colorear con Chimera +label.superpose_structures = Superponer estructuras +error.superposition_failed = Superposición fallido: {0} +label.insufficient_residues = Residuos alineados ({0}) insuficentes para superponer label.show_pdbstruct_dialog=Datos de Estructura 3D... label.hide_all=Ocultar todos label.invert=Invertir diff --git a/src/jalview/analysis/AAFrequency.java b/src/jalview/analysis/AAFrequency.java index ee16f94..3636b5e 100755 --- a/src/jalview/analysis/AAFrequency.java +++ b/src/jalview/analysis/AAFrequency.java @@ -20,10 +20,6 @@ */ package jalview.analysis; -import java.util.Arrays; -import java.util.Hashtable; -import java.util.List; - import jalview.datamodel.AlignedCodonFrame; import jalview.datamodel.AlignmentAnnotation; import jalview.datamodel.AlignmentI; @@ -41,6 +37,11 @@ import jalview.util.Format; import jalview.util.MappingUtils; import jalview.util.QuickSort; +import java.awt.Color; +import java.util.Arrays; +import java.util.Hashtable; +import java.util.List; + /** * Takes in a vector or array of sequences and column start and column end and * returns a new Hashtable[] of size maxSeqLength, if Hashtable not supplied. @@ -315,6 +316,7 @@ public class AAFrequency // always set ranges again gaprow.graphMax = nseq; gaprow.graphMin = 0; + double scale = 0.8/nseq; for (int i = startCol; i < endCol; i++) { ProfileI profile = profiles.get(i); @@ -330,11 +332,11 @@ public class AAFrequency final int gapped = profile.getNonGapped(); - String description = String.valueOf(gapped); + String description = ""; gaprow.annotations[i] = new Annotation(description, description, - '\0', - gapped); + '\0', gapped, jalview.util.ColorUtils.bleachColour( + Color.DARK_GRAY, (float) scale * gapped)); } } diff --git a/src/jalview/appletgui/AlignViewport.java b/src/jalview/appletgui/AlignViewport.java index 065c503..e50cc09 100644 --- a/src/jalview/appletgui/AlignViewport.java +++ b/src/jalview/appletgui/AlignViewport.java @@ -149,6 +149,9 @@ public class AlignViewport extends AlignmentViewport implements showConsensus = applet.getDefaultParameter("showConsensus", showConsensus); + showOccupancy = applet.getDefaultParameter("showOccupancy", + showOccupancy); + setShowUnconserved(applet.getDefaultParameter("showUnconserved", getShowUnconserved())); diff --git a/src/jalview/appletgui/AnnotationColumnChooser.java b/src/jalview/appletgui/AnnotationColumnChooser.java index a8dff62..bbd01f6 100644 --- a/src/jalview/appletgui/AnnotationColumnChooser.java +++ b/src/jalview/appletgui/AnnotationColumnChooser.java @@ -204,6 +204,7 @@ public class AnnotationColumnChooser extends AnnotationRowFilter implements thresholdValue.setEnabled(false); thresholdValue.setColumns(7); + thresholdValue.setCaretPosition(0); ok.addActionListener(this); cancel.addActionListener(this); @@ -219,6 +220,9 @@ public class AnnotationColumnChooser extends AnnotationRowFilter implements // thresholdPanel.setFont(JvSwingUtils.getLabelFont()); // thresholdPanel.setLayout(new MigLayout("", "[left][right]", "[][]")); + percentThreshold.setLabel("As percentage"); + percentThreshold.addItemListener(this); + actionPanel.setBackground(Color.white); // actionPanel.setFont(JvSwingUtils.getLabelFont()); @@ -239,6 +243,7 @@ public class AnnotationColumnChooser extends AnnotationRowFilter implements ngStructureFilterPanel = new StructureFilterPanel(this); thresholdPanel.setTitle("Threshold Filter"); + thresholdPanel.add(percentThreshold); thresholdPanel.add(getThreshold()); thresholdPanel.add(slider); thresholdPanel.add(thresholdValue); @@ -425,7 +430,7 @@ public class AnnotationColumnChooser extends AnnotationRowFilter implements slider.setMinimum((int) (getCurrentAnnotation().graphMin * 1000)); slider.setMaximum((int) (getCurrentAnnotation().graphMax * 1000)); slider.setValue((int) (getCurrentAnnotation().threshold.value * 1000)); - thresholdValue.setText(getCurrentAnnotation().threshold.value + ""); + setThresholdValueText(); // slider.setMajorTickSpacing((int) (range / 10f)); slider.setEnabled(true); thresholdValue.setEnabled(true); @@ -574,6 +579,14 @@ public class AnnotationColumnChooser extends AnnotationRowFilter implements { threshold_actionPerformed(null); } + else if (e.getSource() == percentThreshold) + { + if (!adjusting) + { + percentageValue_actionPerformed(); + } + + } } public void selectedAnnotationChanged() diff --git a/src/jalview/appletgui/AnnotationRowFilter.java b/src/jalview/appletgui/AnnotationRowFilter.java index 8d67d71..6ea0fed 100644 --- a/src/jalview/appletgui/AnnotationRowFilter.java +++ b/src/jalview/appletgui/AnnotationRowFilter.java @@ -31,7 +31,6 @@ import java.awt.Panel; import java.awt.Scrollbar; import java.awt.TextField; import java.awt.event.ActionEvent; -import java.util.Vector; @SuppressWarnings("serial") public abstract class AnnotationRowFilter extends Panel @@ -60,6 +59,8 @@ public abstract class AnnotationRowFilter extends Panel protected Scrollbar slider = new Scrollbar(Scrollbar.HORIZONTAL); + protected Checkbox percentThreshold = new Checkbox(); + protected TextField thresholdValue = new TextField(20); protected Frame frame; @@ -132,18 +133,49 @@ public abstract class AnnotationRowFilter extends Panel updateView(); } + protected void setThresholdValueText() + { + adjusting = true; + if (percentThreshold.getState()) + { + double scl = slider.getMaximum() - slider.getMinimum(); + scl = (slider.getValue() - slider.getMinimum()) / scl; + thresholdValue.setText(100 * scl + ""); + } + else + { + thresholdValue.setText((slider.getValue() / 1000f) + ""); + } + thresholdValue.setCaretPosition(0); + adjusting = false; + } + public void thresholdValue_actionPerformed(ActionEvent e) { try { float f = Float.parseFloat(thresholdValue.getText()); - slider.setValue((int) (f * 1000)); + if (percentThreshold.getState()) + { + slider.setValue(slider.getMinimum() + + ((int) ((f / 100f) * (slider.getMaximum() - slider + .getMinimum())))); + } + else + { + slider.setValue((int) (f * 1000)); + } updateView(); } catch (NumberFormatException ex) { } } + protected void percentageValue_actionPerformed() + { + setThresholdValueText(); + } + protected void populateThresholdComboBox(Choice threshold) { threshold.addItem(MessageManager diff --git a/src/jalview/appletgui/SeqCanvas.java b/src/jalview/appletgui/SeqCanvas.java index ed8a46d..89df11f 100755 --- a/src/jalview/appletgui/SeqCanvas.java +++ b/src/jalview/appletgui/SeqCanvas.java @@ -501,7 +501,7 @@ public class SeqCanvas extends Panel g.setClip(0, 0, cWidth * avcharWidth, canvasHeight); } - drawPanel(g, startRes, endx, 0, al.getHeight(), ypos); + drawPanel(g, startRes, endx, 0, al.getHeight() - 1, ypos); g.setClip(null); if (av.isShowAnnotation()) @@ -580,7 +580,7 @@ public class SeqCanvas extends Panel g1.setColor(Color.blue); g1.drawLine((blockEnd - blockStart + 1) * avcharWidth - 1, 0 + offset, (blockEnd - blockStart + 1) * avcharWidth - - 1, (endSeq - startSeq) * avcharHeight + - 1, (endSeq - startSeq + 1) * avcharHeight + offset); } diff --git a/src/jalview/datamodel/Alignment.java b/src/jalview/datamodel/Alignment.java index 2dafc0c..8371036 100755 --- a/src/jalview/datamodel/Alignment.java +++ b/src/jalview/datamodel/Alignment.java @@ -1635,10 +1635,6 @@ public class Alignment implements AlignmentI return aa; } - /** - * Returns an iterable collection of any annotations that match on given - * sequence ref, calcId and label (ignoring null values). - */ @Override public Iterable findAnnotations(SequenceI seq, String calcId, String label) @@ -1646,9 +1642,11 @@ public class Alignment implements AlignmentI ArrayList aa = new ArrayList(); for (AlignmentAnnotation ann : getAlignmentAnnotation()) { - if (ann.getCalcId() != null && ann.getCalcId().equals(calcId) - && ann.sequenceRef != null && ann.sequenceRef == seq - && ann.label != null && ann.label.equals(label)) + if ((calcId == null || (ann.getCalcId() != null && ann.getCalcId() + .equals(calcId))) + && (seq == null || (ann.sequenceRef != null && ann.sequenceRef == seq)) + && (label == null || (ann.label != null && ann.label + .equals(label)))) { aa.add(ann); } diff --git a/src/jalview/datamodel/AnnotatedCollectionI.java b/src/jalview/datamodel/AnnotatedCollectionI.java index 3f6c515..2963fd5 100644 --- a/src/jalview/datamodel/AnnotatedCollectionI.java +++ b/src/jalview/datamodel/AnnotatedCollectionI.java @@ -40,6 +40,17 @@ public interface AnnotatedCollectionI extends SequenceCollectionI */ Iterable findAnnotation(String calcId); + /** + * Returns an iterable collection of any annotations that match on given + * sequence ref, calcId and label (ignoring null values). + * + * @param seq + * null or reference sequence to select annotation for + * @param calcId + * null or the calcId to select annotation for + * @param label + * null or the label to select annotation for + */ Iterable findAnnotations(SequenceI seq, String calcId, String label); diff --git a/src/jalview/datamodel/SequenceGroup.java b/src/jalview/datamodel/SequenceGroup.java index 1246d23..76ad093 100755 --- a/src/jalview/datamodel/SequenceGroup.java +++ b/src/jalview/datamodel/SequenceGroup.java @@ -1289,12 +1289,6 @@ public class SequenceGroup implements AnnotatedCollectionI return aa; } - /** - * Returns a list of annotations that match the specified sequenceRef, calcId - * and label, ignoring null values. - * - * @return list of AlignmentAnnotation objects - */ @Override public Iterable findAnnotations(SequenceI seq, String calcId, String label) @@ -1302,9 +1296,11 @@ public class SequenceGroup implements AnnotatedCollectionI ArrayList aa = new ArrayList(); for (AlignmentAnnotation ann : getAlignmentAnnotation()) { - if (ann.getCalcId() != null && ann.getCalcId().equals(calcId) - && ann.sequenceRef != null && ann.sequenceRef == seq - && ann.label != null && ann.label.equals(label)) + if ((calcId == null || (ann.getCalcId() != null && ann.getCalcId() + .equals(calcId))) + && (seq == null || (ann.sequenceRef != null && ann.sequenceRef == seq)) + && (label == null || (ann.label != null && ann.label + .equals(label)))) { aa.add(ann); } diff --git a/src/jalview/ext/rbvi/chimera/JalviewChimeraBinding.java b/src/jalview/ext/rbvi/chimera/JalviewChimeraBinding.java index ecf93d3..daf6131 100644 --- a/src/jalview/ext/rbvi/chimera/JalviewChimeraBinding.java +++ b/src/jalview/ext/rbvi/chimera/JalviewChimeraBinding.java @@ -172,8 +172,6 @@ public abstract class JalviewChimeraBinding extends AAStructureBindingModel if (getSsm() != null) { getSsm().addStructureViewerListener(this); - // ssm.addSelectionListener(this); - refreshGUI(); } return true; } catch (Exception q) diff --git a/src/jalview/fts/service/uniprot/UniProtFTSRestClient.java b/src/jalview/fts/service/uniprot/UniProtFTSRestClient.java index 27bfca8..a23df4c 100644 --- a/src/jalview/fts/service/uniprot/UniProtFTSRestClient.java +++ b/src/jalview/fts/service/uniprot/UniProtFTSRestClient.java @@ -157,14 +157,14 @@ public class UniProtFTSRestClient extends FTSRestClient if (foundDataRow != null && foundDataRow.length > 0) { result = new ArrayList(); - String titleRow = getDataColumnsFieldsAsTabDelimitedString(uniprotRestRequest - .getWantedFields()); - // System.out.println(">>>>Title row : " + titleRow); + boolean firstRow = true; for (String dataRow : foundDataRow) { - if (dataRow.equalsIgnoreCase(titleRow)) + // The first data row is usually the header data. This should be + // filtered out from the rest of the data See: JAL-2485 + if (firstRow) { - // System.out.println(">>>>>>>>>> matched!!!"); + firstRow = false; continue; } // System.out.println(dataRow); diff --git a/src/jalview/gui/AlignViewport.java b/src/jalview/gui/AlignViewport.java index 602e3a1..26a7a3a 100644 --- a/src/jalview/gui/AlignViewport.java +++ b/src/jalview/gui/AlignViewport.java @@ -279,6 +279,8 @@ public class AlignViewport extends AlignmentViewport implements false); showGroupConsensus = Cache.getDefault("SHOW_GROUP_CONSENSUS", false); showConsensus = Cache.getDefault("SHOW_IDENTITY", true); + + showOccupancy = Cache.getDefault(Preferences.SHOW_OCCUPANCY, true); } initAutoAnnotation(); String colourProperty = alignment.isNucleotide() ? Preferences.DEFAULT_COLOUR_NUC diff --git a/src/jalview/gui/AnnotationColumnChooser.java b/src/jalview/gui/AnnotationColumnChooser.java index 637eb30..c321e59 100644 --- a/src/jalview/gui/AnnotationColumnChooser.java +++ b/src/jalview/gui/AnnotationColumnChooser.java @@ -151,6 +151,9 @@ public class AnnotationColumnChooser extends AnnotationRowFilter implements thresholdPanel.setFont(JvSwingUtils.getLabelFont()); thresholdPanel.setLayout(new MigLayout("", "[left][right]", "[][]")); + percentThreshold.setBackground(Color.white); + percentThreshold.setFont(JvSwingUtils.getLabelFont()); + JPanel actionPanel = new JPanel(); actionPanel.setBackground(Color.white); actionPanel.setFont(JvSwingUtils.getLabelFont()); @@ -174,8 +177,9 @@ public class AnnotationColumnChooser extends AnnotationRowFilter implements ngStructureFilterPanel = new StructureFilterPanel(this); thresholdPanel.add(getThreshold()); - thresholdPanel.add(thresholdValue, "wrap"); - thresholdPanel.add(slider, "grow, span, wrap"); + thresholdPanel.add(percentThreshold, "wrap"); + thresholdPanel.add(slider, "grow"); + thresholdPanel.add(thresholdValue, "span, wrap"); actionPanel.add(ok); actionPanel.add(cancel); @@ -282,12 +286,14 @@ public class AnnotationColumnChooser extends AnnotationRowFilter implements slider.setEnabled(true); thresholdValue.setEnabled(true); + percentThreshold.setEnabled(true); if (selectedThresholdItem == AnnotationColourGradient.NO_THRESHOLD) { slider.setEnabled(false); thresholdValue.setEnabled(false); thresholdValue.setText(""); + percentThreshold.setEnabled(false); // build filter params } else if (selectedThresholdItem != AnnotationColourGradient.NO_THRESHOLD) @@ -308,7 +314,18 @@ public class AnnotationColumnChooser extends AnnotationRowFilter implements slider.setMinimum((int) (getCurrentAnnotation().graphMin * 1000)); slider.setMaximum((int) (getCurrentAnnotation().graphMax * 1000)); slider.setValue((int) (getCurrentAnnotation().threshold.value * 1000)); - thresholdValue.setText(getCurrentAnnotation().threshold.value + ""); + + if (percentThreshold.isSelected()) + { + thresholdValue + .setText("" + + ((getCurrentAnnotation().threshold.value - getCurrentAnnotation().graphMin) * 100f / (getCurrentAnnotation().graphMax - getCurrentAnnotation().graphMin))); + } + else + { + thresholdValue.setText(getCurrentAnnotation().threshold.value + ""); + } + slider.setMajorTickSpacing((int) (range / 10f)); slider.setEnabled(true); thresholdValue.setEnabled(true); @@ -392,6 +409,7 @@ public class AnnotationColumnChooser extends AnnotationRowFilter implements ap.paintAlignment(true); } + public ColumnSelection getOldColumnSelection() { return oldColumnSelection; diff --git a/src/jalview/gui/AnnotationRowFilter.java b/src/jalview/gui/AnnotationRowFilter.java index c2bf41b..1035a6c 100644 --- a/src/jalview/gui/AnnotationRowFilter.java +++ b/src/jalview/gui/AnnotationRowFilter.java @@ -62,6 +62,8 @@ public abstract class AnnotationRowFilter extends JPanel protected JCheckBox seqAssociated = new JCheckBox(); + protected JCheckBox percentThreshold = new JCheckBox(); + protected JSlider slider = new JSlider(); protected JTextField thresholdValue = new JTextField(20); @@ -120,13 +122,27 @@ public abstract class AnnotationRowFilter extends JPanel { if (!adjusting) { - thresholdValue.setText((slider.getValue() / 1000f) + ""); + setThresholdValueText(); valueChanged(!sliderDragging); } } }); } + protected void setThresholdValueText() + { + adjusting = true; + if (percentThreshold.isSelected()) + { + thresholdValue.setText("" + (slider.getValue() - slider.getMinimum()) + * 100f / (slider.getMaximum() - slider.getMinimum())); + } + else + { + thresholdValue.setText((slider.getValue() / 1000f) + ""); + } + adjusting = false; + } protected void addSliderMouseListeners() { @@ -275,13 +291,27 @@ public abstract class AnnotationRowFilter extends JPanel try { float f = Float.parseFloat(thresholdValue.getText()); - slider.setValue((int) (f * 1000)); + if (percentThreshold.isEnabled()) + { + slider.setValue(slider.getMinimum() + + ((int) ((f / 100f) * (slider.getMaximum() - slider + .getMinimum())))); + } + else + { + slider.setValue((int) (f * 1000)); + } updateView(); } catch (NumberFormatException ex) { } } + protected void percentageValue_actionPerformed() + { + setThresholdValueText(); + } + protected void thresholdIsMin_actionPerformed() { updateView(); @@ -439,6 +469,18 @@ public abstract class AnnotationRowFilter extends JPanel } }); + percentThreshold.setText(MessageManager.getString("label.as_percentage")); + percentThreshold.addActionListener(new ActionListener() + { + @Override + public void actionPerformed(ActionEvent e) + { + if (!adjusting) + { + percentageValue_actionPerformed(); + } + } + }); slider.setPaintLabels(false); slider.setPaintTicks(true); slider.setBackground(Color.white); diff --git a/src/jalview/gui/Preferences.java b/src/jalview/gui/Preferences.java index cf80a6d..cccdd2e 100755 --- a/src/jalview/gui/Preferences.java +++ b/src/jalview/gui/Preferences.java @@ -107,6 +107,8 @@ public class Preferences extends GPreferences public static final String SHOW_AUTOCALC_ABOVE = "SHOW_AUTOCALC_ABOVE"; + public static final String SHOW_OCCUPANCY = "SHOW_OCCUPANCY"; + private static final int MIN_FONT_SIZE = 1; private static final int MAX_FONT_SIZE = 30; @@ -210,6 +212,7 @@ public class Preferences extends GPreferences openoverv.setSelected(Cache.getDefault("SHOW_OVERVIEW", false)); showUnconserved .setSelected(Cache.getDefault("SHOW_UNCONSERVED", false)); + showOccupancy.setSelected(Cache.getDefault(SHOW_OCCUPANCY, false)); showGroupConsensus.setSelected(Cache.getDefault("SHOW_GROUP_CONSENSUS", false)); showGroupConservation.setSelected(Cache.getDefault( @@ -572,6 +575,8 @@ public class Preferences extends GPreferences Boolean.toString(idItalics.isSelected())); Cache.applicationProperties.setProperty("SHOW_UNCONSERVED", Boolean.toString(showUnconserved.isSelected())); + Cache.applicationProperties.setProperty(SHOW_OCCUPANCY, + Boolean.toString(showOccupancy.isSelected())); Cache.applicationProperties.setProperty("SHOW_GROUP_CONSENSUS", Boolean.toString(showGroupConsensus.isSelected())); Cache.applicationProperties.setProperty("SHOW_GROUP_CONSERVATION", @@ -851,6 +856,7 @@ public class Preferences extends GPreferences conservation.setEnabled(annotations.isSelected()); quality.setEnabled(annotations.isSelected()); identity.setEnabled(annotations.isSelected()); + showOccupancy.setEnabled(annotations.isSelected()); showGroupConsensus.setEnabled(annotations.isSelected()); showGroupConservation.setEnabled(annotations.isSelected()); showConsensHistogram.setEnabled(annotations.isSelected() diff --git a/src/jalview/gui/SeqCanvas.java b/src/jalview/gui/SeqCanvas.java index 4557819..64e5fdc 100755 --- a/src/jalview/gui/SeqCanvas.java +++ b/src/jalview/gui/SeqCanvas.java @@ -588,7 +588,7 @@ public class SeqCanvas extends JComponent (int) clip.getBounds().getHeight()); } - drawPanel(g, startRes, endx, 0, al.getHeight(), ypos); + drawPanel(g, startRes, endx, 0, al.getHeight() - 1, ypos); if (av.isShowAnnotation()) { @@ -683,7 +683,7 @@ public class SeqCanvas extends JComponent g1.drawLine((blockEnd - blockStart + 1) * charWidth - 1, 0 + offset, (blockEnd - blockStart + 1) * charWidth - 1, - (endSeq - startSeq) * charHeight + offset); + (endSeq - startSeq + 1) * charHeight + offset); } g1.translate(-screenY * charWidth, 0); diff --git a/src/jalview/io/JSONFile.java b/src/jalview/io/JSONFile.java index 053a65e..583bbc0 100644 --- a/src/jalview/io/JSONFile.java +++ b/src/jalview/io/JSONFile.java @@ -767,7 +767,8 @@ public class JSONFile extends AlignFile implements ComplexAlignFile } } } - globalColourScheme = viewport.getGlobalColourScheme().getSchemeName(); + globalColourScheme = (viewport.getGlobalColourScheme() == null) ? ResidueColourScheme.NONE + : viewport.getGlobalColourScheme().getSchemeName(); setDisplayedFeatures(viewport.getFeaturesDisplayed()); showSeqFeatures = viewport.isShowSequenceFeatures(); diff --git a/src/jalview/jbgui/GPreferences.java b/src/jalview/jbgui/GPreferences.java index dda06b4..1ad95dd 100755 --- a/src/jalview/jbgui/GPreferences.java +++ b/src/jalview/jbgui/GPreferences.java @@ -101,6 +101,8 @@ public class GPreferences extends JPanel protected JComboBox fontNameCB = new JComboBox(); + protected JCheckBox showOccupancy = new JCheckBox(); + protected JCheckBox showUnconserved = new JCheckBox(); protected JCheckBox idItalics = new JCheckBox(); @@ -1174,6 +1176,13 @@ public class GPreferences extends JPanel identity.setHorizontalTextPosition(SwingConstants.LEFT); identity.setSelected(true); identity.setText(MessageManager.getString("label.consensus")); + showOccupancy.setFont(LABEL_FONT); + showOccupancy.setEnabled(false); + showOccupancy.setHorizontalAlignment(SwingConstants.RIGHT); + showOccupancy.setHorizontalTextPosition(SwingConstants.LEFT); + showOccupancy.setSelected(true); + showOccupancy.setText(MessageManager.getString("label.occupancy")); + JLabel showGroupbits = new JLabel(); showGroupbits.setFont(LABEL_FONT); showGroupbits.setHorizontalAlignment(SwingConstants.RIGHT); @@ -1228,10 +1237,10 @@ public class GPreferences extends JPanel .getString("label.database_references")); annotations.setFont(LABEL_FONT); annotations.setHorizontalAlignment(SwingConstants.RIGHT); - annotations.setHorizontalTextPosition(SwingConstants.LEADING); + annotations.setHorizontalTextPosition(SwingConstants.LEFT); annotations.setSelected(true); annotations.setText(MessageManager.getString("label.show_annotations")); - annotations.setBounds(new Rectangle(169, 12, 200, 23)); + // annotations.setBounds(new Rectangle(169, 12, 200, 23)); annotations.addActionListener(new ActionListener() { @Override @@ -1358,11 +1367,13 @@ public class GPreferences extends JPanel sortAutocalc.setBounds(new Rectangle(290, 285, 165, 21)); JPanel annsettingsPanel = new JPanel(); - annsettingsPanel.setBounds(new Rectangle(173, 34, 320, 75)); + annsettingsPanel.setBounds(new Rectangle(173, 13, 320, 96)); annsettingsPanel.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0)); annsettingsPanel.setBorder(new EtchedBorder()); visualTab.add(annsettingsPanel); Border jb = new EmptyBorder(1, 1, 4, 5); + annotations.setBorder(jb); + showOccupancy.setBorder(jb); quality.setBorder(jb); conservation.setBorder(jb); identity.setBorder(jb); @@ -1374,17 +1385,26 @@ public class GPreferences extends JPanel showConsensLogo.setBorder(jb); JPanel autoAnnotSettings = new JPanel(); - autoAnnotSettings.setLayout(new GridLayout(3, 3)); annsettingsPanel.add(autoAnnotSettings); + autoAnnotSettings.setLayout(new GridLayout(0, 2)); + autoAnnotSettings.add(annotations); autoAnnotSettings.add(quality); + // second row of autoannotation box + autoAnnotSettings = new JPanel(); + annsettingsPanel.add(autoAnnotSettings); + + autoAnnotSettings.setLayout(new GridLayout(0, 3)); autoAnnotSettings.add(conservation); autoAnnotSettings.add(identity); + autoAnnotSettings.add(showOccupancy); autoAnnotSettings.add(showGroupbits); autoAnnotSettings.add(showGroupConservation); autoAnnotSettings.add(showGroupConsensus); autoAnnotSettings.add(showConsensbits); autoAnnotSettings.add(showConsensHistogram); autoAnnotSettings.add(showConsensLogo); + + JPanel tooltipSettings = new JPanel(); tooltipSettings.setBorder(new TitledBorder(MessageManager @@ -1433,7 +1453,6 @@ public class GPreferences extends JPanel jPanel2.add(sortAnnLabel); jPanel2.add(startupCheckbox); visualTab.add(jPanel2); - visualTab.add(annotations); visualTab.add(startupFileTextfield); visualTab.add(sortby); visualTab.add(sortAnnBy); diff --git a/src/jalview/viewmodel/AlignmentViewport.java b/src/jalview/viewmodel/AlignmentViewport.java index 47dceec..0015299 100644 --- a/src/jalview/viewmodel/AlignmentViewport.java +++ b/src/jalview/viewmodel/AlignmentViewport.java @@ -823,7 +823,7 @@ public abstract class AlignmentViewport implements AlignViewportI, public void updateConsensus(final AlignmentViewPanel ap) { // see note in mantis : issue number 8585 - if ((consensus == null || gapcounts == null) || !autoCalculateConsensus) + if (consensus == null || !autoCalculateConsensus) { return; } @@ -1284,6 +1284,8 @@ public abstract class AlignmentViewport implements AlignViewportI, protected boolean showConsensus = true; + protected boolean showOccupancy = true; + private Map sequenceColours = new HashMap(); protected SequenceAnnotationOrder sortAnnotationsBy = null; @@ -1893,11 +1895,7 @@ public abstract class AlignmentViewport implements AlignViewportI, consensus = new AlignmentAnnotation("Consensus", "PID", new Annotation[1], 0f, 100f, AlignmentAnnotation.BAR_GRAPH); initConsensus(consensus); - gapcounts = new AlignmentAnnotation("Occupancy", - "Number of aligned positions", - new Annotation[1], 0f, alignment.getHeight(), - AlignmentAnnotation.BAR_GRAPH); - initGapCounts(gapcounts); + initGapCounts(); initComplementConsensus(); } @@ -1954,15 +1952,19 @@ public abstract class AlignmentViewport implements AlignViewportI, // these should be extracted from the view model - style and settings for // derived annotation - private void initGapCounts(AlignmentAnnotation counts) + private void initGapCounts() { - counts.hasText = false; - counts.autoCalculated = true; - counts.graph = AlignmentAnnotation.BAR_GRAPH; - - if (showConsensus) + if (showOccupancy) { - alignment.addAnnotation(counts); + gapcounts = new AlignmentAnnotation("Occupancy", + "Number of aligned positions", new Annotation[1], 0f, + alignment.getHeight(), AlignmentAnnotation.BAR_GRAPH); + gapcounts.hasText = true; + gapcounts.autoCalculated = true; + gapcounts.scaleColLabel = true; + gapcounts.graph = AlignmentAnnotation.BAR_GRAPH; + + alignment.addAnnotation(gapcounts); } } diff --git a/src/jalview/ws/sifts/SiftsClient.java b/src/jalview/ws/sifts/SiftsClient.java index 30ac0ae..7b26214 100644 --- a/src/jalview/ws/sifts/SiftsClient.java +++ b/src/jalview/ws/sifts/SiftsClient.java @@ -604,8 +604,12 @@ public class SiftsClient extends StructureMappingClient implements .getDbResNum()); } catch (NumberFormatException nfe) { - resNum = (pdbRefDb == null) ? Integer.valueOf(residue - .getDbResNum()) : Integer.valueOf(pdbRefDb + if (pdbRefDb == null || pdbRefDb.getDbResNum().equals("null")) + { + resNum = UNASSIGNED; + continue; + } + resNum = Integer.valueOf(pdbRefDb .getDbResNum().split("[a-zA-Z]")[0]); continue; } diff --git a/test/jalview/datamodel/AlignmentTest.java b/test/jalview/datamodel/AlignmentTest.java index c5d09c1..660a69c 100644 --- a/test/jalview/datamodel/AlignmentTest.java +++ b/test/jalview/datamodel/AlignmentTest.java @@ -620,6 +620,67 @@ public class AlignmentTest assertFalse(iter.hasNext()); } + /** + * Test method that returns annotations that match on reference sequence, + * label, or calcId. + */ + @Test(groups = { "Functional" }) + public void testFindAnnotations_bySeqLabelandorCalcId() + { + // TODO: finish testFindAnnotations_bySeqLabelandorCalcId test + /* Note - this is an incomplete test - need to check null or + * non-null [ matches, not matches ] behaviour for each of the three + * parameters..*/ + + // search for a single, unique calcId with wildcards on other params + Iterable anns = al.findAnnotations(null, + "CalcIdForD.melanogaster.2", null); + Iterator iter = anns.iterator(); + assertTrue(iter.hasNext()); + AlignmentAnnotation ann = iter.next(); + assertEquals("D.melanogaster.2", ann.sequenceRef.getName()); + assertFalse(iter.hasNext()); + + // save reference to test sequence reference parameter + SequenceI rseq = ann.sequenceRef; + + // search for annotation associated with a single sequence + anns = al.findAnnotations(rseq, null, null); + iter = anns.iterator(); + assertTrue(iter.hasNext()); + ann = iter.next(); + assertEquals("D.melanogaster.2", ann.sequenceRef.getName()); + assertFalse(iter.hasNext()); + + // search for annotation with a non-existant calcId + anns = al.findAnnotations(null, "CalcIdForD.melanogaster.?", null); + iter = anns.iterator(); + assertFalse(iter.hasNext()); + + // search for annotation with a particular label - expect three + anns = al.findAnnotations(null, null, "secondary structure"); + iter = anns.iterator(); + assertTrue(iter.hasNext()); + iter.next(); + assertTrue(iter.hasNext()); + iter.next(); + assertTrue(iter.hasNext()); + iter.next(); + // third found.. so + assertFalse(iter.hasNext()); + + // null on all parameters == find all annotations + anns = al.findAnnotations(null, null, null); + iter = anns.iterator(); + int n = al.getAlignmentAnnotation().length; + while (iter.hasNext()) + { + n--; + iter.next(); + } + assertTrue("Found " + n + " fewer annotations from search.", n == 0); + } + @Test(groups = { "Functional" }) public void testDeleteAllAnnotations_includingAutocalculated() { diff --git a/test/jalview/gui/AlignViewportTest.java b/test/jalview/gui/AlignViewportTest.java index 06df70a..e6c16b7 100644 --- a/test/jalview/gui/AlignViewportTest.java +++ b/test/jalview/gui/AlignViewportTest.java @@ -50,6 +50,7 @@ import jalview.util.MapList; import java.util.ArrayList; import java.util.List; +import org.testng.Assert; import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; @@ -327,6 +328,8 @@ public class AlignViewportTest Boolean.TRUE.toString()); Cache.applicationProperties.setProperty("SHOW_CONSERVATION", Boolean.FALSE.toString()); + Cache.applicationProperties.setProperty("SHOW_OCCUPANCY", + Boolean.FALSE.toString()); Cache.applicationProperties.setProperty("SHOW_IDENTITY", Boolean.FALSE.toString()); AlignFrame af = new FileLoader().LoadFileWaitTillLoaded( @@ -404,4 +407,40 @@ public class AlignViewportTest av.setSelectionGroup(sg2); assertSame(sg2.getContext(), sg1); // unchanged } + /** + * Verify that setting/clearing SHOW_OCCUPANCY preference adds or omits occupancy row from viewport + */ + @Test(groups = { "Functional" }) + public void testShowOrDontShowOccupancy() + { + // disable occupancy + jalview.bin.Cache.setProperty("SHOW_OCCUPANCY", Boolean.FALSE.toString()); + AlignFrame af = new FileLoader().LoadFileWaitTillLoaded( + "examples/uniref50.fa", DataSourceType.FILE); + AlignViewport av = af.getViewport(); + Assert.assertNull(av.getAlignmentGapAnnotation(), "Preference did not disable occupancy row."); + int c = 0; + for (AlignmentAnnotation aa : av.getAlignment().findAnnotations(null, + null, "Occupancy")) + { + c++; + } + Assert.assertEquals(c, 0, "Expected zero occupancy rows."); + + // enable occupancy + jalview.bin.Cache.setProperty("SHOW_OCCUPANCY", Boolean.TRUE.toString()); + af = new FileLoader().LoadFileWaitTillLoaded( + "examples/uniref50.fa", DataSourceType.FILE); + av = af.getViewport(); + Assert.assertNotNull(av.getAlignmentGapAnnotation(), "Preference did not enable occupancy row."); + c = 0; + for (AlignmentAnnotation aa : av.getAlignment().findAnnotations(null, + null, av.getAlignmentGapAnnotation().label)) + { + c++; + } + ; + Assert.assertEquals(c, 1, "Expected to find one occupancy row."); + + } } diff --git a/test/jalview/gui/StructureChooserTest.java b/test/jalview/gui/StructureChooserTest.java index b7eef0f..c04353f 100644 --- a/test/jalview/gui/StructureChooserTest.java +++ b/test/jalview/gui/StructureChooserTest.java @@ -136,7 +136,7 @@ public class StructureChooserTest assertEquals("Cached PDB Entries", filterOpt.getName()); } - @Test(groups = { "Functional" }) + @Test(groups = { "Network" }) public void fetchStructuresInfoTest() { SequenceI[] selectedSeqs = new SequenceI[] { seq }; diff --git a/test/jalview/io/JSONFileTest.java b/test/jalview/io/JSONFileTest.java index a8611cc..4e4abe9 100644 --- a/test/jalview/io/JSONFileTest.java +++ b/test/jalview/io/JSONFileTest.java @@ -36,6 +36,7 @@ import jalview.gui.AlignFrame; import jalview.gui.JvOptionPane; import jalview.json.binding.biojson.v1.ColourSchemeMapper; import jalview.schemes.ColourSchemeI; +import jalview.schemes.ResidueColourScheme; import java.io.IOException; import java.util.ArrayList; @@ -90,6 +91,8 @@ public class JSONFileTest private JSONFile jf; + private AlignExportSettingI exportSettings; + @BeforeTest(alwaysRun = true) public void setup() throws Exception { @@ -193,7 +196,7 @@ public class JSONFileTest TEST_ANOT_HEIGHT = expectedAnnots.size(); TEST_CS_HEIGHT = expectedColSel.getHiddenColumns().size(); - AlignExportSettingI exportSettings = new AlignExportSettingI() + exportSettings = new AlignExportSettingI() { @Override public boolean isExportHiddenSequences() @@ -338,6 +341,50 @@ public class JSONFileTest } @Test(groups = { "Functional" }) + /** + * Test for bug JAL-2489, NPE when exporting BioJSON with global colour scheme set as 'None' + */ + public void testBioJSONRoundTripWithGlobalColourSchemeSetAsNone() + { + AppletFormatAdapter formatAdapter = new AppletFormatAdapter(); + + Alignment _alignment; + try + { + // load example BioJSON file + _alignment = (Alignment) formatAdapter.readFile(TEST_JSON_FILE, + DataSourceType.FILE, FileFormat.Json); + JSONFile bioJsonFile = (JSONFile) formatAdapter.getAlignFile(); + AlignFrame alignFrame = new AlignFrame(_alignment, + bioJsonFile.getHiddenSequences(), + bioJsonFile.getColumnSelection(), AlignFrame.DEFAULT_WIDTH, + AlignFrame.DEFAULT_HEIGHT); + // Change colour scheme to 'None' and perform round trip + ColourSchemeI cs = ColourSchemeMapper.getJalviewColourScheme( + ResidueColourScheme.NONE, _alignment); + alignFrame.changeColour(cs); + alignFrame.getViewport().setFeaturesDisplayed( + bioJsonFile.getDisplayedFeatures()); + formatAdapter = new AppletFormatAdapter(alignFrame.alignPanel, + exportSettings); + // export BioJSON string + String jsonOutput = formatAdapter.formatSequences(FileFormat.Json, + alignFrame.alignPanel.getAlignment(), false); + // read back Alignment from BioJSON string + formatAdapter = new AppletFormatAdapter(); + formatAdapter.readFile(jsonOutput, DataSourceType.PASTE, + FileFormat.Json); + // assert 'None' colour scheme is retained after round trip + JSONFile _bioJsonFile = (JSONFile) formatAdapter.getAlignFile(); + Assert.assertEquals(_bioJsonFile.getGlobalColourScheme(), + ResidueColourScheme.NONE); + } catch (IOException e) + { + e.printStackTrace(); + } + } + + @Test(groups = { "Functional" }) public void isShowSeqFeaturesSet() { Assert.assertTrue(testJsonFile.isShowSeqFeatures(), diff --git a/test/jalview/io/testProps.jvprops b/test/jalview/io/testProps.jvprops index 95da22e..8ede59c 100644 --- a/test/jalview/io/testProps.jvprops +++ b/test/jalview/io/testProps.jvprops @@ -31,6 +31,7 @@ JAVA_CONSOLE_SCREEN_HEIGHT=162 PIR_MODELLER=false GAP_SYMBOL=- SHOW_QUALITY=true +SHOW_OCCUPANCY=true SHOW_GROUP_CONSERVATION=false SHOW_JWS2_SERVICES=true SHOW_NPFEATS_TOOLTIP=true diff --git a/test/jalview/ws/jws2/ParameterUtilsTest.java b/test/jalview/ws/jws2/ParameterUtilsTest.java index e859cb0..c0aa2ee 100644 --- a/test/jalview/ws/jws2/ParameterUtilsTest.java +++ b/test/jalview/ws/jws2/ParameterUtilsTest.java @@ -74,7 +74,7 @@ public class ParameterUtilsTest disc = JalviewJabawsTestUtils.getJabawsDiscoverer(); } - @Test(groups = { "Functional" }) + @Test(groups = { "Network" }) public void testWriteParameterSet() throws WrongParameterException { for (Jws2Instance service : disc.getServices())