Merge branch 'bug/JAL-3718_Getdown_does_not_autoupdate_correctly' into releases/Relea...
authorJim Procter <jprocter@issues.jalview.org>
Thu, 3 Sep 2020 08:07:42 +0000 (09:07 +0100)
committerJim Procter <jprocter@issues.jalview.org>
Thu, 3 Sep 2020 08:07:42 +0000 (09:07 +0100)
26 files changed:
help/help/help.jhm
help/help/helpTOC.xml
help/help/html/features/seqfetch.html
help/help/html/keys.html
help/help/html/logging.html
help/help/html/releases.html
src/jalview/api/FeatureRenderer.java
src/jalview/api/FeatureSettingsModelI.java
src/jalview/api/FeaturesDisplayedI.java
src/jalview/bin/Cache.java
src/jalview/ext/ensembl/EnsemblGene.java
src/jalview/ext/jmol/JalviewJmolBinding.java
src/jalview/gui/AlignFrame.java
src/jalview/gui/AlignViewport.java
src/jalview/gui/AppJmolBinding.java
src/jalview/gui/ChimeraViewFrame.java
src/jalview/gui/CutAndPasteTransfer.java
src/jalview/gui/SequenceFetcher.java
src/jalview/io/FileLoader.java
src/jalview/io/FileParse.java
src/jalview/io/PDBFeatureSettings.java
src/jalview/schemes/FeatureSettingsAdapter.java
src/jalview/viewmodel/seqfeatures/FeatureRendererModel.java
src/jalview/viewmodel/seqfeatures/FeaturesDisplayed.java
test/jalview/ext/ensembl/EnsemblGeneTest.java
test/jalview/io/FileIOTester.java

index 99d010d..7dbb76d 100755 (executable)
    
    <mapID target="importvcf" url="html/features/importvcf.html" />
    <mapID target="importvcf.attribs" url="html/features/importvcf.html#attribs" />
+   <mapID target="logging" url="html/logging.html" />
 </map>
index a0c7fe6..c5660fe 100755 (executable)
                        </tocitem>
                </tocitem>
                <tocitem text="Preferences" target="preferences" />
+    <tocitem text="The Java Console, Logging and Reporting Bugs" target="logging" />
                <tocitem text="Scripting with Groovy" target="groovy">
                        <tocitem text="Groovy Features Counter example" target="groovy.featurescounter"/>
                </tocitem>
index e726c49..4e9a75f 100755 (executable)
       &quot;OK&quot; to initiate the retrieval.</li>
   </ol>
 
-  <p>If you use the WSDBFetch sequence fetcher services (EMBL,
-    UniProt, PFAM, and RFAM) in work for publication, please cite:</p>
-  <p>
-    Pillai S., Silventoinen V., Kallio K., Senger M., Sobhany S., Tate
-    J., Velankar S., Golovin A., Henrick K., Rice P., Stoehr P., Lopez
-    R. <br> SOAP-based services provided by the European
-    Bioinformatics Institute.<br> Nucleic Acids Res. 33(1):W25-W28
-    (2005) <br> <br>
-  </p>
+  <p>If you use the Sequence Fetcher, please remember to cite the
+    corresponding services (linked to below):</p>
+  <ul>
+    <li>Ensembl - <a
+      href="https://github.com/Ensembl/ensembl-rest/wiki#citing">The
+        Ensembl REST API</a></li>
+    <li>EMBL/EMBLCDS - Provided by the <a
+      href="https://www.ebi.ac.uk/ena/browser/api/#/ENA_Browser_Data_API/getFlatFileUsingGET">European
+        Nucleotide Archive's ENA Data API</a><br />
+    <em>Note: Versions of Jalview prior to 2.11.1.1 employed the
+        XML endpoint of the ENA browser, which was retired in August
+        2020.</em></li>
+    <li>Uniprot - Free Text Search and Retrieval via the <a
+      href="https://www.uniprot.org/help/api">Uniprot REST API</a></li>
+    <li>PDB - Free Text Search via the <a
+      href="https://www.ebi.ac.uk/pdbe/api/doc/search.html">PDBe
+        REST API</a> and retrieval via <a
+      href="https://www.ebi.ac.uk/Tools/dbfetch/">WSDbFetch</a><br />
+      Pillai S., Silventoinen V., Kallio K., Senger M., Sobhany S., Tate
+      J., Velankar S., Golovin A., Henrick K., Rice P., Stoehr P., Lopez
+      R. <br> SOAP-based services provided by the European
+      Bioinformatics Institute.<br> Nucleic Acids Res.
+      33(1):W25-W28 (2005) <br> <br>
+    </li>
+  </ul>
 </body>
 </html>
index 5f24a83..0faa1d5 100755 (executable)
       <td>Redo the last sequence edit undone.</td>
     </tr>
     <tr>
-      <td><strong>Up Arrow</strong></td>
-      <td>Both</td>
-      <td>Moves selected sequence(s) up the alignment.<br />In
-        Cursor mode press Alt key to move selection or sequence under
-        cursor.
-      </td>
-    </tr>
-    <tr>
-      <td><strong>Down Arrow</strong></td>
-      <td>Both</td>
-      <td>Moves selected sequence(s) down the alignment.<br />In
-        Cursor mode press Alt key to move selection or sequence under
-        cursor.
-      </td>
-    </tr>
-    <tr>
-      <td><strong>Left Arrow</strong></td>
-      <td>Normal</td>
-      <td>Slides selected sequence(s) left. Press Alt key to slide
-        in cursor mode</td>
-    </tr>
-    <tr>
-      <td><strong>Right Arrow</strong></td>
-      <td>Normal</td>
-      <td>Slides selected sequence(s) right. Press Alt key to slide
-        in cursor mode</td>
-    </tr>
-    <tr>
       <td><strong>Cursor Keys<br> (Arrow Keys)
       </strong></td>
       <td>Cursor</td>
       </td>
     </tr>
     <tr>
+      <td><strong>Cursor Keys<br> (Arrow Keys)
+      </strong></td>
+      <td>Normal<br />
+      <em>(+Alt in Cursor)</em></td>
+      <td>Moves selected sequence(s) up, down, left, or right
+        according to the direction pressed.<br>
+      <br>
+      <em>Alt+Arrow key to move selection or sequence under cursor
+          in cursor mode.</em>
+      </td>
+    </tr>
+    <tr>
       <td><strong>Page Up</strong></td>
       <td>Both</td>
       <td>Scroll up the alignment view</td>
index 2993370..c1bb89b 100644 (file)
  * The Jalview Authors are detailed in the 'AUTHORS' file.
  -->
 <head>
-<title>Logging and Reporting Bugs</title>
+<title>The Java Console, Logging and Reporting Bugs</title>
 </head>
 <body>
   <h2>
     <center>
-      <strong>Logging and Reporting Bugs</strong>
+      <strong>The Java Console, Logging and Reporting Bugs</strong>
     </center>
   </h2>
   
@@ -42,7 +42,7 @@
   <p>
   However, it is possible that some early logging information from when Jalview is initially launched, is not shown in the Java Console:
   <br/>
-  If you are using a version of Jalview installed from one of our install4j installers, then Jalview's initial launch logging can be found in
+  If you are using a standard desktop version of Jalview installed from one of our install4j installers, then Jalview's initial launch logging can be found in
   <pre>JALVIEW_APP_DIR/launcher.log</pre>
   where <em>JALVIEW_APP_DIR</em> is the directory that Jalview's application was installed into.
   <br/>
     <li>In Linux and other Unix OSes this is <em>~/opt/jalview</em> by default</li>
   </ul>
   <br/>
-  Whereas if you are using the Jalview executable jar file (also used by bioconda installations) then a minimised launcher will output logging information to STDOUT and STDERR.
+  Whereas if you are using the Jalview executable jar file (also used by bioconda installations) then the default run class (<em>jalview.bin.Launcher</em> -- a minimised launcher that will set memory and linux dpi settings before re-launching <em>jalview.bin.Jalview</em>), will output logging information to STDOUT and STDERR.
   </p>
   
   <h3><a name="java_console">Java Console and Log Level</a></h3>
-  
-  
+  <p>
+  The Java Console is opened by selecting <strong>Tools &rarr; Show Java Console</strong>.  This option is saved across Jalview sessions so you can start Jalview with the Java Console already open by previously quitting Jalview with the Java Console already opened.  Selecting <em>Show Java Console</em> in the <em>Tools</em> menu a second time will deselect the option and close the window.  Closing the window in your system's usual way will also deselect the option in the <em>Tools</em> menu.
+  </p>
+  <p>
+  The Java Console's text display always shows information about your system and Jalview installation setup, which is followed by messages output from some of the processes that your Jalview session has performed since opening the console.
+  </p>
+  <p>
+  You can control the detail of what appears as output by selecting a <em>Log level</em> using the drop-down list at the bottom left of the console.  There are several levels of logging that you can choose from: in decreasing levels of verbosity they are: TRACE, DEBUG, INFO, WARN.  By default the level initially chosen is INFO.
+  </p>
+  <p>
+  <strong>Note! If you change the log level in the Java Console, this change will only persist for as long as the console is open.  Once you close the console the log level will revert back to what it had been when you opened the console (usually INFO).</strong>
+  </p>
+  <p>
+  You can change the default log level by editing the Jalview preferenecs file, <em>.jalview_properties</em>, found in your home directory (on Windows: %HOMEPATH%, or the folder above 'My Documents'; on macOS: ~ or /Users/<em>username</em>; on linux/unix: ~ or /home/<em>username</em>), and setting the property <em>logs.Jalview.level</em> to the log level you prefer, e.g.
+  <pre>
+  logs.Jalview.level=DEBUG
+  </pre>
+  You can also set the property
+  <pre>
+  logs.Axis.level=DEBUG
+  </pre>
+  to get debug information for Jalview's JPred service. The Axis log level cannot be set from within the Java Console.
+  </p>
+  <p>
+  You can set the <em>logs.jalview.level</em> property to a log level not usually presented in the Java Console (though restricted to log levels used by Apache Log4j -- see <a href="https://logging.apache.org/log4j/2.x/manual/customloglevels.html">Log4j Custom Log Levels</a> for details of the standard log levels available).  Jalview does not currently define any custom log levels.  If you do set the property with a log level that is normally not visible in the Java Console this should be respected and visibly selected when you open the console.
+  </p>
+  <p>
+  The <em>Clear</em> button at the bottom of the console will clear all logging messages except for the initial system information which is rewritten to the console.
+  </p>
+  <p>
+  The <em>Copy to clipboard</em> button at the bottom right of the console will copy all of the text in the console to your system clipboard, ready to paste into another application (e.g. email composer or issue tracker).
+  </p>
+
   <h3>Reporting Bugs</h3>
 
+  <p>
+  If you come across a problem in Jalview where something is not working as described, or how you think it should, you should first check the <a href="https://www.jalview.org/faq">Jalview FAQ</a> to see if this is a known problem and if there is a suggested workaround.
+  </p>
+  <p>
+  If there is no FAQ answer covering your problem then you can submit a bug report on the <a href="https://issues.jalview.org/">Jalview Issue Tracker</a>.  It is good practice to search the issue tracker first to see if the issue has already been reported.  If an issue already exists please continue to add your own comments to the issue which may well help narrow down the problem, if not then you can create an account and submit a new bug report: 
+  </p>
+  <p>
+  Make sure that you set Project to <em>Jalview (JAL)</em>, and Issue Type to <em>Bug</em> or <em>New Feature</em> or <em>Improvement</em> appropriately.<br/>
+  Give a one line summary of the issue in the <em>Summary</em>.
+  <br/>
+  In the <em>Environment</em> text box you can describe the system you are using.  This is usually most easily done by opening the Java Console, clicking the <em>Clear</em> button, and then immediately on the <em>Copy to clipboard</em> button, and then pasting the clipboard into the text box.
+  </p>
+  <p>
+  You can then give more detailed information about how to recreate the problem in the <em>Description</em> text box.  If you want to attach any screenshots or example alignment files that demonstrate the problem then you can drag them to the Create Issue dialog in your browser, or use the <em>Attachment</em> browse facility to locate them on your computer.
+  </p>
+
+  <p>
+  To help the Jalview team with diagnosing a particular issue, it is really helpful if you can also add more detailed logs output whilst re-creating the problem.  To do this, open the Java Console, click the <em>Clear</em> button and select TRACE in the <em>Log level</em> drop down list.
+  <br/>
+  Whilst leaving the console open, perform the task in Jalview that re-creates the problem.
+  <br/>
+  Then you can copy the debug information in the Java Console by clicking on the <em>Copy to clipboard</em> button and then paste that into the Description, or a Comment of your issue.
+  </p>
+
+  <p>For other queries or comments about Jalview, remember you can contact the Jalview team using email via the <a href="https://www.jalview.org/mailman/listinfo/jalview-discuss">Jalview discussion list</a> or on Twitter <a href="https://twitter.com/Jalview/">@Jalview</a>!
+  </p>
 
 </body>
 </html>
index c2bdd57..6b40e9e 100755 (executable)
@@ -174,6 +174,14 @@ li:before {
             specifying output format when exporting an alignment via the
             command line
           </li>
+          <li>
+            <!-- JAL-3667 -->Windows 10: For a minority of users, if
+            backups are not enabled, Jalview sometimes fails to
+            overwrite an existing file and raises a warning dialog. (in
+            2.11.0, and 2.11.1.0, the workaround is to try to save the
+            file again, and if that fails, delete the original file and
+            save in place.)
+          </li>
         </ul> <em>Developing Jalview</em>
         <ul>
           <li>
@@ -189,21 +197,18 @@ li:before {
             tooltips. (Also affects v2.11.1.0)
           </li>
           <li>
-            <!-- JAL-3667 -->Windows 10: For a minority of users, if
-            backups are not enabled, Jalview sometimes fails to
-            overwrite an existing file and raises a warning dialog.
-            Workaround is to try to save the file again, and if that
-            fails, delete the original file and save in place.
-          </li>
-          <li>
             <!-- JAL-3702 -->Drag and drop of alignment file onto
-            alignment window not working correctly when in a HiDPI
-            scaled mode in Linux
+            alignment window when in a HiDPI scaled mode in Linux only
+            works for the top left quadrant of the alignment window
           </li>
           <li>
             <!-- JAL-3701 -->Stale build data in jalview standalone jar
             builds (only affects 2.11.1.1 branch)
           </li>
+          <li>
+            <!-- JAL-3127 -->Sequence ID colourscheme not re-applied
+            when alignment view restored from project (since Jalview 2.11.0)
+          </li>
         </ul>
       </td>
     </tr>
index 8aa2858..fff3b38 100644 (file)
@@ -297,4 +297,11 @@ public interface FeatureRenderer
    * @return
    */
   MappedFeatures findComplementFeaturesAtResidue(SequenceI sequence, int pos);
+
+  /**
+   * Sends a message to let any registered parties know that something about
+   * feature rendering has changed
+   */
+  void notifyFeaturesChanged();
+
 }
index c0fc523..c8a835a 100644 (file)
@@ -35,7 +35,8 @@ public interface FeatureSettingsModelI extends Comparator<String>
   // interface, simplifying instantiating classes
 
   /**
-   * Answers true if the specified feature type is displayed
+   * Answers true if the specified feature type is to be displayed, false if no
+   * preference
    * 
    * @param type
    * @return
@@ -43,6 +44,15 @@ public interface FeatureSettingsModelI extends Comparator<String>
   boolean isFeatureDisplayed(String type);
 
   /**
+   * Answers true if the specified feature type is to be hidden, false if no
+   * preference
+   * 
+   * @param type
+   * @return
+   */
+  boolean isFeatureHidden(String type);
+
+  /**
    * Answers true if the specified feature group is displayed
    * 
    * @param group
index e69785f..9387e3f 100644 (file)
@@ -39,6 +39,8 @@ public interface FeaturesDisplayedI
 
   void setVisible(String featureType);
 
+  void setHidden(String featureType);
+
   /**
    * Sets all the specified feature types to visible. Visibility of other
    * feature types is not changed.
index 6e44b0c..ba28717 100755 (executable)
@@ -315,6 +315,9 @@ public class Cache
       // lcastor = Logger.getLogger("org.exolab.castor.xml.Marshaller");
       // lcastor.setLevel(Level.toLevel(Cache.getDefault("logs.Castor.Level",
       // Level.INFO.toString())));
+      // we shouldn't need to do this
+      org.apache.log4j.Logger.getRootLogger().setLevel(org.apache.log4j.Level.INFO); 
+
       jalview.bin.Cache.log.setLevel(Level.toLevel(Cache
               .getDefault("logs.Jalview.level", Level.INFO.toString())));
       // laxis.addAppender(ap);
index 9c7ce63..461226b 100644 (file)
@@ -629,10 +629,10 @@ public class EnsemblGene extends EnsemblSeqProxy
       SequenceOntologyI so = SequenceOntologyFactory.getInstance();
 
       @Override
-      public boolean isFeatureDisplayed(String type)
+      public boolean isFeatureHidden(String type)
       {
-        return (so.isA(type, SequenceOntologyI.EXON)
-                || so.isA(type, SequenceOntologyI.SEQUENCE_VARIANT));
+        return (!so.isA(type, SequenceOntologyI.EXON)
+                && !so.isA(type, SequenceOntologyI.SEQUENCE_VARIANT));
       }
 
       @Override
index 1ceabd1..b2224ab 100644 (file)
@@ -22,11 +22,13 @@ package jalview.ext.jmol;
 
 import jalview.api.AlignmentViewPanel;
 import jalview.api.FeatureRenderer;
+import jalview.api.FeatureSettingsModelI;
 import jalview.api.SequenceRenderer;
 import jalview.datamodel.AlignmentI;
 import jalview.datamodel.HiddenColumns;
 import jalview.datamodel.PDBEntry;
 import jalview.datamodel.SequenceI;
+import jalview.gui.AppJmol;
 import jalview.gui.IProgressIndicator;
 import jalview.io.DataSourceType;
 import jalview.io.StructureFile;
@@ -37,6 +39,7 @@ import jalview.structure.StructureMappingcommandSet;
 import jalview.structure.StructureSelectionManager;
 import jalview.structures.models.AAStructureBindingModel;
 import jalview.util.MessageManager;
+import jalview.ws.dbsources.Pdb;
 
 import java.awt.Color;
 import java.awt.Container;
@@ -1190,7 +1193,9 @@ public abstract class JalviewJmolBinding extends AAStructureBindingModel
       FeatureRenderer fr = getFeatureRenderer(null);
       if (fr != null)
       {
-        fr.featuresAdded();
+        FeatureSettingsModelI colours = new Pdb().getFeatureColourScheme();
+        ((AppJmol) getViewer()).getAlignmentPanel().av
+                .applyFeaturesStyle(colours);
       }
       refreshGUI();
       loadNotifiesHandled++;
index 5e16397..4be7d0e 100644 (file)
@@ -1749,10 +1749,10 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
   }
 
   /**
-   * DOCUMENT ME!
+   * Calls AlignmentI.moveSelectedSequencesByOne with current sequence selection or the sequence under cursor in keyboard mode 
    * 
    * @param up
-   *          DOCUMENT ME!
+   *          or down (if !up)
    */
   public void moveSelectedSequences(boolean up)
   {
@@ -1760,8 +1760,23 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
 
     if (sg == null)
     {
-      return;
+      if (viewport.cursorMode) 
+      {
+        sg = new SequenceGroup();
+        sg.addSequence(viewport.getAlignment()
+                .getSequenceAt(alignPanel.getSeqPanel().seqCanvas.cursorY),false);
+      } else {
+        return;
+      }
+    }
+    
+    if (sg.getSize() < 1)
+    {
+        return;
     }
+    
+    // TODO: JAL-3733 - add an event to the undo buffer for this !
+    
     viewport.getAlignment().moveSelectedSequencesByOne(sg,
             viewport.getHiddenRepSequences(), up);
     alignPanel.paintAlignment(true, false);
index ba7aad4..8e12ff5 100644 (file)
@@ -992,8 +992,8 @@ public class AlignViewport extends AlignmentViewport
     
     FeatureRenderer fr = getAlignPanel().getSeqPanel().seqCanvas
             .getFeatureRenderer();
-    List<String> origRenderOrder = new ArrayList(),
-            origGroups = new ArrayList();
+    List<String> origRenderOrder = new ArrayList<>();
+    List<String> origGroups = new ArrayList<>();
     // preserve original render order - allows differentiation between user configured colours and autogenerated ones
     origRenderOrder.addAll(fr.getRenderOrder());
     origGroups.addAll(fr.getFeatureGroups());
@@ -1004,7 +1004,7 @@ public class AlignViewport extends AlignmentViewport
     if (!mergeOnly)
     {
       // only clear displayed features if we are mergeing
-      displayed.clear();
+      // displayed.clear();
     }
     // TODO this clears displayed.featuresRegistered - do we care?
     //
@@ -1036,6 +1036,10 @@ public class AlignViewport extends AlignmentViewport
         {
           displayed.setVisible(type);
         }
+        else if (featureSettings.isFeatureHidden(type))
+        {
+          displayed.setHidden(type);
+        }
       }
     }
 
@@ -1064,6 +1068,8 @@ public class AlignViewport extends AlignmentViewport
       fr.orderFeatures(featureSettings);
     }
     fr.setTransparency(featureSettings.getTransparency());
+
+    fr.notifyFeaturesChanged();
   }
 
   public String getViewName()
index 724cec1..3432911 100644 (file)
@@ -208,11 +208,6 @@ public class AppJmolBinding extends JalviewJmolBinding
     AlignmentPanel ap = (alignment == null)
             ? appJmolWindow.getAlignmentPanel()
             : (AlignmentPanel) alignment;
-    if (ap.av.isShowSequenceFeatures())
-    {
-      return ap.av.getAlignPanel().getSeqPanel().seqCanvas.fr;
-    }
-
-    return null;
+    return ap.av.getAlignPanel().getFeatureRenderer();
   }
 }
index a7349b8..47bad81 100644 (file)
@@ -575,7 +575,8 @@ public class ChimeraViewFrame extends StructureViewerBase
 
       /*
        * ensure that any newly discovered features (e.g. RESNUM)
-       * are added to any open feature settings dialog
+       * are notified to the FeatureRenderer (and added to any 
+       * open feature settings dialog)
        */
       FeatureRenderer fr = getBinding().getFeatureRenderer(null);
       if (fr != null)
index b3bff0d..279d89f 100644 (file)
@@ -272,11 +272,8 @@ public class CutAndPasteTransfer extends GCutAndPasteTransfer
        */
       if (viewport != null && viewport.getAlignment() != null)
       {
-        if (proxyColourScheme != null)
-        {
-          viewport.applyFeaturesStyle(proxyColourScheme);
-        }
         ((AlignViewport) viewport).addAlignment(al, title);
+        viewport.applyFeaturesStyle(proxyColourScheme);
       }
       else
       {
index 1c4e6a6..7451646 100755 (executable)
@@ -1023,10 +1023,7 @@ public class SequenceFetcher extends JPanel implements Runnable
           }
         }
 
-        if (preferredFeatureColours != null)
-        {
-          af.getViewport().applyFeaturesStyle(preferredFeatureColours);
-        }
+        af.getViewport().applyFeaturesStyle(preferredFeatureColours);
         if (Cache.getDefault("HIDE_INTRONS", true))
         {
           af.hideFeatureColumns(SequenceOntologyI.EXON, false);
index 3afbaad..20db946 100755 (executable)
@@ -391,12 +391,9 @@ public class FileLoader implements Runnable
                   .getFeatureColourScheme();
           if (viewport != null)
           {
-            if (proxyColourScheme != null)
-            {
-              viewport.applyFeaturesStyle(proxyColourScheme);
-            }
             // append to existing alignment
             viewport.addAlignment(al, title);
+            viewport.applyFeaturesStyle(proxyColourScheme);
           }
           else
           {
index f1d79fe..3013c0b 100755 (executable)
@@ -24,6 +24,7 @@ import jalview.api.AlignExportSettingI;
 import jalview.api.AlignViewportI;
 import jalview.api.AlignmentViewPanel;
 import jalview.api.FeatureSettingsModelI;
+import jalview.bin.Cache;
 import jalview.util.MessageManager;
 
 import java.io.BufferedInputStream;
@@ -201,18 +202,41 @@ public class FileParse
     }
     return error;
   }
-  
+
   /**
-   * Recognise the 2-byte magic header for gzip streams
+   * Recognise the 2-byte magic header indicating a gzipped stream
    * 
+   * see
    * https://recalll.co/ask/v/topic/java-How-to-check-if-InputStream-is-Gzipped/555aadd62bd27354438b90f6
    * 
-   * @param bytes - at least two bytes 
-   * @return 
+   * @param input
+   *          - input stream that supports mark and contains at least two bytes
+   * 
+   * @return false if mark not supported or no magic header found
+   *
+   * @throws IOException
    */
-  private static boolean isGzipStream(byte[] bytes) {
-    int head = ((int) bytes[0] & 0xff) | ((bytes[1] << 8) & 0xff00);
-    return (GZIPInputStream.GZIP_MAGIC == head);
+  public static boolean isGzipStream(InputStream input) throws IOException
+  {
+    if (!input.markSupported())
+    {
+      Cache.log.error(
+              "FileParse.izGzipStream: input stream must support mark/reset");
+      return false;
+    }
+    input.mark(4);
+
+    // get first 2 bytes or return false
+    byte[] bytes = new byte[2];
+    int read = input.read(bytes);
+    input.reset();
+    if (read != bytes.length)
+    {
+      return false;
+    }
+
+    int header = (bytes[0] & 0xff) | ((bytes[1] << 8) & 0xff00);
+    return (GZIPInputStream.GZIP_MAGIC == header);
   }
 
   /**
@@ -226,16 +250,11 @@ public class FileParse
 
     // NB: stackoverflow https://stackoverflow.com/questions/4818468/how-to-check-if-inputstream-is-gzipped
     // could use a PushBackInputStream rather than a BufferedInputStream
-    
-    BufferedInputStream bufinput;
+        
     if (!input.markSupported()) {
-       bufinput= new BufferedInputStream(input,16);
-       input = bufinput;
+       input = new BufferedInputStream(input,16);
     }
-    input.mark(4);
-    byte[] bytes=input.readNBytes(2);
-    input.reset();
-    if (bytes.length==2 && isGzipStream(bytes)) {
+    if (isGzipStream(input)) {
       return getGzipReader(input);
     }
     // return a buffered reader for the stream.
index 0f2b0ac..ee82418 100644 (file)
@@ -36,10 +36,9 @@ public class PDBFeatureSettings extends FeatureSettingsAdapter
   private static final String FEATURE_RES_NUM = PDBChain.RESNUM_FEATURE;
 
   @Override
-  public boolean isFeatureDisplayed(String type)
+  public boolean isFeatureHidden(String type)
   {
-    return type.equalsIgnoreCase(FEATURE_INSERTION)
-            || type.equalsIgnoreCase(FEATURE_RES_NUM);
+    return type.equalsIgnoreCase(FEATURE_RES_NUM);
   }
 
   @Override
index b15e4cf..6e8554f 100644 (file)
@@ -36,6 +36,12 @@ public class FeatureSettingsAdapter implements FeatureSettingsModelI
   }
 
   @Override
+  public boolean isFeatureHidden(String type)
+  {
+    return false;
+  }
+
+  @Override
   public boolean isGroupDisplayed(String group)
   {
     return true;
index 426ec1f..b348766 100644 (file)
@@ -102,11 +102,11 @@ public abstract class FeatureRendererModel
 
   Map<String, Float> featureOrder = null;
 
-  protected PropertyChangeSupport changeSupport = new PropertyChangeSupport(
-          this);
-
   protected AlignViewportI av;
 
+  private PropertyChangeSupport changeSupport = new PropertyChangeSupport(
+          this);
+
   @Override
   public AlignViewportI getViewport()
   {
@@ -299,13 +299,19 @@ public abstract class FeatureRendererModel
       {
         firing = Boolean.TRUE;
         findAllFeatures(true); // add all new features as visible
-        changeSupport.firePropertyChange("changeSupport", null, null);
+        notifyFeaturesChanged();
         firing = Boolean.FALSE;
       }
     }
   }
 
   @Override
+  public void notifyFeaturesChanged()
+  {
+    changeSupport.firePropertyChange("changeSupport", null, null);
+  }
+
+  @Override
   public List<SequenceFeature> findFeaturesAtColumn(SequenceI sequence, int column)
   {
     /*
index f44a2d1..d7da519 100644 (file)
@@ -29,9 +29,9 @@ import java.util.Set;
 
 public class FeaturesDisplayed implements FeaturesDisplayedI
 {
-  private Set<String> featuresDisplayed = new HashSet<String>();
+  private Set<String> featuresDisplayed = new HashSet<>();
 
-  private Set<String> featuresRegistered = new HashSet<String>();
+  private Set<String> featuresRegistered = new HashSet<>();
 
   public FeaturesDisplayed(FeaturesDisplayedI featuresDisplayed2)
   {
@@ -93,6 +93,13 @@ public class FeaturesDisplayed implements FeaturesDisplayedI
   }
 
   @Override
+  public void setHidden(String featureType)
+  {
+    featuresDisplayed.remove(featureType);
+    featuresRegistered.add(featureType);
+  }
+
+  @Override
   public boolean isRegistered(String type)
   {
     return featuresRegistered.contains(type);
index 8b1e840..ef12ed4 100644 (file)
@@ -271,18 +271,24 @@ public class EnsemblGeneTest
 
   /**
    * Check behaviour of feature colour scheme for EnsemblGene sequences.
-   * Currently coded to display exon and sequence_variant (or sub-types) only,
-   * with sequence_variant in red above exon coloured by label.
+   * Currently coded to hide all except exon and sequence_variant (or sub-types)
+   * only, with sequence_variant in red above exon coloured by label.
    */
   @Test(groups = "Functional")
   public void testGetFeatureColourScheme()
   {
     FeatureSettingsModelI fc = new EnsemblGene().getFeatureColourScheme();
-    assertTrue(fc.isFeatureDisplayed("exon"));
-    assertTrue(fc.isFeatureDisplayed("coding_exon")); // subtype of exon
-    assertTrue(fc.isFeatureDisplayed("sequence_variant"));
-    assertTrue(fc.isFeatureDisplayed("feature_variant")); // subtype
-    assertFalse(fc.isFeatureDisplayed("transcript"));
+    assertFalse(fc.isFeatureDisplayed("exon"));
+    assertFalse(fc.isFeatureHidden("exon"));
+    assertFalse(fc.isFeatureDisplayed("coding_exon")); // subtype of exon
+    assertFalse(fc.isFeatureHidden("coding_exon")); // subtype of exon
+    assertFalse(fc.isFeatureDisplayed("sequence_variant"));
+    assertFalse(fc.isFeatureHidden("sequence_variant"));
+    assertFalse(fc.isFeatureDisplayed("feature_variant")); // subtype
+    assertFalse(fc.isFeatureHidden("feature_variant")); // subtype
+    assertTrue(fc.isFeatureHidden("transcript"));
+    assertTrue(fc.isFeatureHidden("CDS"));
+
     assertEquals(Color.RED, fc.getFeatureColour("sequence_variant")
             .getColour());
     assertEquals(Color.RED, fc.getFeatureColour("feature_variant")
index f6480a6..04d01b0 100644 (file)
  */
 package jalview.io;
 
-import jalview.gui.JvOptionPane;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertTrue;
 
+import java.io.BufferedInputStream;
 import java.io.File;
+import java.io.FileInputStream;
 import java.io.IOException;
+import java.io.InputStream;
 
 import org.testng.AssertJUnit;
 import org.testng.annotations.AfterClass;
 import org.testng.annotations.BeforeClass;
 import org.testng.annotations.Test;
 
+import jalview.bin.Cache;
+import jalview.gui.JvOptionPane;
+
 /**
  * @author jimp
  * 
@@ -50,6 +57,7 @@ public class FileIOTester
   @BeforeClass(alwaysRun = true)
   public static void setUpBeforeClass() throws Exception
   {
+    Cache.initLogger();
   }
 
   /**
@@ -88,8 +96,9 @@ public class FileIOTester
   public void testStarsInFasta1() throws IOException
   {
     String uri;
-    FileParse fp = new FileParse(uri = STARS_FA_FILE1.getAbsoluteFile()
-            .toString(), DataSourceType.FILE);
+    FileParse fp = new FileParse(
+            uri = STARS_FA_FILE1.getAbsoluteFile().toString(),
+            DataSourceType.FILE);
     assertValidFormat(FileFormat.Fasta, uri, fp);
   }
 
@@ -97,8 +106,9 @@ public class FileIOTester
   public void testStarsInFasta2() throws IOException
   {
     String uri;
-    FileParse fp = new FileParse(uri = STARS_FA_FILE2.getAbsoluteFile()
-            .toString(), DataSourceType.FILE);
+    FileParse fp = new FileParse(
+            uri = STARS_FA_FILE2.getAbsoluteFile().toString(),
+            DataSourceType.FILE);
     assertValidFormat(FileFormat.Fasta, uri, fp);
   }
 
@@ -106,8 +116,9 @@ public class FileIOTester
   public void testGzipIo() throws IOException
   {
     String uri;
-    FileParse fp = new FileParse(uri = ALIGN_FILE.getAbsoluteFile().toURI()
-            .toString(), DataSourceType.URL);
+    FileParse fp = new FileParse(
+            uri = ALIGN_FILE.getAbsoluteFile().toURI().toString(),
+            DataSourceType.URL);
     assertValidFormat(FileFormat.Fasta, uri, fp);
   }
 
@@ -115,17 +126,36 @@ public class FileIOTester
   public void testGziplocalFileIO() throws IOException
   {
     String filepath;
-    FileParse fp = new FileParse(filepath = ALIGN_FILE.getAbsoluteFile()
-            .toString(), DataSourceType.FILE);
+    FileParse fp = new FileParse(
+            filepath = ALIGN_FILE.getAbsoluteFile().toString(),
+            DataSourceType.FILE);
     assertValidFormat(FileFormat.Fasta, filepath, fp);
   }
 
   @Test(groups = { "Functional" })
+  public void testIsGzipInputStream() throws IOException
+  {
+    InputStream is = new FileInputStream(ALIGN_FILE);
+    
+    /*
+     * first try fails - FileInputStream does not support mark/reset
+     */
+    assertFalse(FileParse.isGzipStream(is));
+    
+    /*
+     * wrap in a BufferedInputStream and try again
+     */
+    is = new BufferedInputStream(is, 16);
+    assertTrue(FileParse.isGzipStream(is));
+  }
+
+  @Test(groups = { "Functional" })
   public void testNonGzipURLIO() throws IOException
   {
     String uri;
-    FileParse fp = new FileParse(uri = NOTGZALIGN_FILE.getAbsoluteFile()
-            .toURI().toString(), DataSourceType.URL);
+    FileParse fp = new FileParse(
+            uri = NOTGZALIGN_FILE.getAbsoluteFile().toURI().toString(),
+            DataSourceType.URL);
     assertValidFormat(FileFormat.Fasta, uri, fp);
   }
 
@@ -133,8 +163,9 @@ public class FileIOTester
   public void testNonGziplocalFileIO() throws IOException
   {
     String filepath;
-    FileParse fp = new FileParse(filepath = NOTGZALIGN_FILE
-            .getAbsoluteFile().toString(), DataSourceType.FILE);
+    FileParse fp = new FileParse(
+            filepath = NOTGZALIGN_FILE.getAbsoluteFile().toString(),
+            DataSourceType.FILE);
     assertValidFormat(FileFormat.Fasta, filepath, fp);
   }
 }