error.dbrefsource_implementation_exception =DBRefSource Implementation Exception
error.implementation_error_dbinstance_must_implement_interface = Implmentation Error - getDbInstances must be given a class that implements jalview.ws.seqfetcher.DbSourceProxy (was given{0})
error.implementation_error_must_init_dbsources =Implementation error. Must initialise dbSources
-label.view_controller_toggled_marked = {0} {1} columns {2} containing features of type {3} across {4} sequence(s)
+label.view_controller_toggled_marked = {0} {1} columns containing features of type {2} across {3} sequence(s)
label.toggled = Toggled
label.marked = Marked
label.not = not
error.dbrefsource_implementation_exception = Excepción de implementación DBRefSource
error.implementation_error_dbinstance_must_implement_interface = Error de Implementación- getDbInstances debe recibir una clase que implemente jalview.ws.seqfetcher.DbSourceProxy (recibió {0})
error.implementation_error_must_init_dbsources =Error de implementación. Debe inicializar dbSources
-label.view_controller_toggled_marked = {0} {1} columnas {2} conteniendo características del tipo {3} en {4} secuencia(s)
+label.view_controller_toggled_marked = {0} {1} columnas conteniendo características del tipo {2} en {3} secuencia(s)
label.toggled = Invertida
label.marked = Marcada
label.not = no
* @return true if operation affected state
*/
boolean markColumnsContainingFeatures(boolean invert,
- boolean extendCurrent, boolean clearColumns, String featureType);
+ boolean extendCurrent, boolean toggle, String featureType);
/**
* sort the alignment or current selection by average score over the given set
ColumnSelection cs = viewport.getColumnSelection();
if (bs.cardinality() > 0 || invert)
{
+ boolean changed = false;
if (cs == null)
{
cs = new ColumnSelection();
{
if (!extendCurrent)
{
+ changed = !cs.isEmpty();
cs.clear();
}
}
{
if (ibs < 0 || i < ibs)
{
+ changed = true;
if (toggle && cs.contains(i))
{
cs.removeElement(i++);
for (int i = bs.nextSetBit(alStart); i >= alStart; i = bs
.nextSetBit(i + 1))
{
+ changed = true;
if (toggle && cs.contains(i))
{
cs.removeElement(i);
}
}
}
- viewport.setColumnSelection(cs);
- alignPanel.paintAlignment(true);
- avcg.setStatus(MessageManager.formatMessage(
- "label.view_controller_toggled_marked",
- new String[] {
- (toggle ? MessageManager.getString("label.toggled")
- : MessageManager.getString("label.marked")),
- (invert ? (Integer.valueOf((alw - alStart)
- - bs.cardinality()).toString()) : (Integer
- .valueOf(bs.cardinality()).toString())),
- featureType, Integer.valueOf(nseq).toString() }));
- return true;
+ if (changed)
+ {
+ viewport.setColumnSelection(cs);
+ alignPanel.paintAlignment(true);
+ avcg.setStatus(MessageManager.formatMessage(
+ "label.view_controller_toggled_marked",
+ new String[] {
+ (toggle ? MessageManager.getString("label.toggled")
+ : MessageManager.getString("label.marked")),
+ (invert ? (Integer.valueOf((alw - alStart)
+ - bs.cardinality()).toString()) : (Integer
+ .valueOf(bs.cardinality()).toString())),
+ featureType, Integer.valueOf(nseq).toString() }));
+ return true;
+ }
}
else
{
cs.clear();
alignPanel.paintAlignment(true);
}
- return false;
}
+ return false;
}
@Override
import jalview.io.JnetAnnotationMaker;
import jalview.io.NewickFile;
import jalview.io.TCoffeeScoreFile;
+import jalview.io.gff.SequenceOntologyI;
import jalview.jbgui.GAlignFrame;
import jalview.schemes.Blosum62ColourScheme;
import jalview.schemes.BuriedColourScheme;
AlignFrame newFrame = new AlignFrame(al, DEFAULT_WIDTH,
DEFAULT_HEIGHT);
+ if (Cache.getDefault("HIDE_INTRONS", true))
+ {
+ newFrame.hideFeatureColumns(SequenceOntologyI.EXON, false);
+ }
String newtitle = String.format("%s %s %s",
MessageManager.getString(dna ? "label.proteins"
: "label.nucleotides"), MessageManager
System.err.println("Can't run Groovy script as console not found");
}
}
+
+ /**
+ * Hides columns containing (or not containing) a specified feature, provided
+ * that would not leave all columns hidden
+ *
+ * @param featureType
+ * @param columnsContaining
+ * @return
+ */
+ public boolean hideFeatureColumns(String featureType,
+ boolean columnsContaining)
+ {
+ boolean notForHiding = avc.markColumnsContainingFeatures(
+ columnsContaining, false, false, featureType);
+ if (notForHiding)
+ {
+ if (avc.markColumnsContainingFeatures(!columnsContaining, false,
+ false, featureType))
+ {
+ getViewport().hideSelectedColumns();
+ return true;
+ }
+ }
+ return false;
+ }
}
class PrintThread extends Thread
}
if (Cache.getDefault("HIDE_INTRONS", true))
{
- hideIntronsIfPresent(af);
+ af.hideFeatureColumns(SequenceOntologyI.EXON, false);
}
Desktop.addInternalFrame(af, title, AlignFrame.DEFAULT_WIDTH,
return al;
}
- /**
- * Hide columns not containing 'exon' features, provided there are exon
- * features on the alignment
- *
- * @param af
- */
- public void hideIntronsIfPresent(AlignFrame af)
- {
- boolean hasExons = af.avc.markColumnsContainingFeatures(false, false,
- false,
- SequenceOntologyI.EXON);
- if (hasExons)
- {
- af.avc.markColumnsContainingFeatures(true, false, true,
- SequenceOntologyI.EXON);
- af.getViewport().hideSelectedColumns();
- }
- }
-
void showErrorMessage(final String error)
{
resetDialog();
--- /dev/null
+package jalview.gui;
+
+import static org.testng.AssertJUnit.assertEquals;
+import static org.testng.AssertJUnit.assertFalse;
+import static org.testng.AssertJUnit.assertTrue;
+
+import jalview.datamodel.Alignment;
+import jalview.datamodel.AlignmentI;
+import jalview.datamodel.Sequence;
+import jalview.datamodel.SequenceFeature;
+import jalview.datamodel.SequenceI;
+
+import java.util.List;
+
+import org.testng.annotations.Test;
+
+public class AlignFrameTest
+{
+
+ @Test
+ public void testHideFeatureColumns()
+ {
+ SequenceI seq1 = new Sequence("Seq1", "ABCDEFGHIJ");
+ SequenceI seq2 = new Sequence("Seq2", "ABCDEFGHIJ");
+ seq1.addSequenceFeature(new SequenceFeature("Metal", "", 1, 5,
+ Float.NaN, null));
+ seq2.addSequenceFeature(new SequenceFeature("Metal", "", 6, 10,
+ Float.NaN, null));
+ seq1.addSequenceFeature(new SequenceFeature("Turn", "", 2, 4,
+ Float.NaN, null));
+ seq2.addSequenceFeature(new SequenceFeature("Turn", "", 7, 9,
+ Float.NaN, null));
+ AlignmentI al = new Alignment(new SequenceI[] { seq1, seq2 });
+ AlignFrame af = new AlignFrame(al, al.getWidth(), al.getHeight());
+
+ /*
+ * hiding a feature not present does nothing
+ */
+ assertFalse(af.hideFeatureColumns("exon", true));
+ assertTrue(af.getViewport().getColumnSelection().isEmpty());
+ assertTrue(af.getViewport().getColumnSelection().getHiddenColumns()
+ .isEmpty());
+ assertFalse(af.hideFeatureColumns("exon", false));
+ assertTrue(af.getViewport().getColumnSelection().isEmpty());
+ assertTrue(af.getViewport().getColumnSelection().getHiddenColumns()
+ .isEmpty());
+
+ /*
+ * hiding a feature in all columns does nothing
+ */
+ assertFalse(af.hideFeatureColumns("Metal", true));
+ assertTrue(af.getViewport().getColumnSelection().isEmpty());
+ List<int[]> hidden = af.getViewport().getColumnSelection()
+ .getHiddenColumns();
+ assertTrue(hidden.isEmpty());
+
+ /*
+ * hide a feature present in some columns
+ * sequence positions [2-4], [7-9] are column positions
+ * [1-3], [6-8] base zero
+ */
+ assertTrue(af.hideFeatureColumns("Turn", true));
+ hidden = af.getViewport().getColumnSelection()
+ .getHiddenColumns();
+ assertEquals(2, hidden.size());
+ assertEquals(1, hidden.get(0)[0]);
+ assertEquals(3, hidden.get(0)[1]);
+ assertEquals(6, hidden.get(1)[0]);
+ assertEquals(8, hidden.get(1)[1]);
+ }
+}