Merge branch 'develop' into
authorgmungoc <g.m.carstairs@dundee.ac.uk>
Fri, 12 Feb 2016 14:11:34 +0000 (14:11 +0000)
committergmungoc <g.m.carstairs@dundee.ac.uk>
Fri, 12 Feb 2016 14:11:34 +0000 (14:11 +0000)
features/JAL-653_JAL-1766_htslib_refseqsupport

Conflicts:
resources/lang/Messages.properties
src/jalview/gui/FeatureColourChooser.java

1  2 
resources/lang/Messages.properties
src/jalview/gui/AlignFrame.java
src/jalview/gui/Desktop.java

@@@ -704,9 -704,7 +704,9 @@@ label.load_tree_for_sequence_set = Loa
  label.export_image = Export Image
  label.vamsas_store = VAMSAS store
  label.translate_cDNA = Translate as cDNA
 -label.linked_view_title = Linked cDNA and protein view
 +label.reverse = Reverse
 +label.reverse_complement = Reverse Complement
 +label.linked_view_title = Linked CDS and protein view
  label.align = Align
  label.extract_scores = Extract Scores
  label.get_cross_refs = Get Cross-References
@@@ -1145,7 -1143,7 +1145,7 @@@ status.finished_searching_for_sequences
  label.eps_file = EPS file
  label.png_image = PNG image
  status.saving_file = Saving {0}
- status.export_complete = Export complete.
+ status.export_complete = {0} Export completed.
  status.fetching_pdb = Fetching PDB {0}
  status.refreshing_news = Refreshing news
  status.importing_vamsas_session_from = Importing VAMSAS session from {0}
@@@ -1284,3 -1282,6 +1284,7 @@@ exception.pdb_server_unreachable = Jalv
  label.nw_mapping = Needleman & Wunsch Alignment
  label.sifts_mapping = SIFTs Mapping
  label.mapping_method = Sequence \u27f7 Structure mapping method
++label.mapping_method = Sequence \u27f7 Structure mapping method
+ status.waiting_for_user_to_select_output_file = Waiting for user to select {0} file.
+ status.cancelled_image_export_operation = Cancelled {0} export operation.
+ info.error_creating_file = Error creating {0} file.
@@@ -131,6 -131,7 +131,6 @@@ import java.util.Deque
  import java.util.Enumeration;
  import java.util.Hashtable;
  import java.util.List;
 -import java.util.Set;
  import java.util.Vector;
  
  import javax.swing.JCheckBoxMenuItem;
@@@ -827,8 -828,6 +827,8 @@@ public class AlignFrame extends GAlignF
    public void setGUINucleotide(boolean nucleotide)
    {
      showTranslation.setVisible(nucleotide);
 +    showReverse.setVisible(nucleotide);
 +    showReverseComplement.setVisible(nucleotide);
      conservationMenuItem.setEnabled(!nucleotide);
      modifyConservation.setEnabled(!nucleotide);
      showGroupConservation.setEnabled(!nucleotide);
    @Override
    public void bioJSMenuItem_actionPerformed(ActionEvent e)
    {
-     BioJsHTMLOutput bjs = new BioJsHTMLOutput(alignPanel);
+     BioJsHTMLOutput bjs = new BioJsHTMLOutput(alignPanel, this);
      bjs.exportJalviewAlignmentAsBioJsHtmlFile();
    }
  
            return;
          }
  
 -        format = new IdentifyFile().Identify(str, "Paste");
 +        format = new IdentifyFile().identify(str, "Paste");
  
        } catch (OutOfMemoryError er)
        {
              // TODO 1: no mappings are set up for EMBL product
              // TODO 2: if they were, should add them to protein alignment, not
              // dna
 -            Set<AlignedCodonFrame> cf = prods.getCodonFrames();
 +            List<AlignedCodonFrame> cf = prods.getCodonFrames();
              for (AlignedCodonFrame acf : cf)
              {
                al.addCodonFrame(acf);
              }
 -            AlignFrame naf = new AlignFrame(al, DEFAULT_WIDTH,
 +            AlignFrame newFrame = new AlignFrame(al, DEFAULT_WIDTH,
                      DEFAULT_HEIGHT);
 -            String newtitle = "" + ((dna) ? "Proteins" : "Nucleotides")
 -                    + " for " + ((isRegSel) ? "selected region of " : "")
 +            String newtitle = "" + (dna ? "Proteins" : "Nucleotides")
 +                    + " for " + (isRegSel ? "selected region of " : "")
                      + getTitle();
 -            naf.setTitle(newtitle);
 +            newFrame.setTitle(newtitle);
  
 -            // temporary flag until SplitFrame is released
              boolean asSplitFrame = Cache.getDefault(
                      Preferences.ENABLE_SPLIT_FRAME, true);
              if (asSplitFrame)
                        .getSequenceSelection();
                if (dna)
                {
 -                copyAlignment = AlignmentUtils.makeExonAlignment(
 +                copyAlignment = AlignmentUtils.makeCdsAlignment(
                          sequenceSelection, cf);
                  al.getCodonFrames().clear();
                  al.getCodonFrames().addAll(cf);
                        AlignFrame.DEFAULT_WIDTH, AlignFrame.DEFAULT_HEIGHT);
                copyThis.setTitle(AlignFrame.this.getTitle());
                // SplitFrame with dna above, protein below
 -              SplitFrame sf = new SplitFrame(dna ? copyThis : naf,
 -                      dna ? naf : copyThis);
 -              naf.setVisible(true);
 +              boolean showSequenceFeatures = viewport
 +                      .isShowSequenceFeatures();
 +              newFrame.setShowSeqFeatures(showSequenceFeatures);
 +              copyThis.setShowSeqFeatures(showSequenceFeatures);
 +              FeatureRenderer myFeatureStyling = alignPanel.getSeqPanel().seqCanvas
 +                      .getFeatureRenderer();
 +              /*
 +               * copy feature rendering settings to split frame
 +               */
 +              newFrame.alignPanel.getSeqPanel().seqCanvas
 +                      .getFeatureRenderer().transferSettings(
 +                              myFeatureStyling);
 +              copyThis.alignPanel.getSeqPanel().seqCanvas
 +                      .getFeatureRenderer().transferSettings(
 +                              myFeatureStyling);
 +              SplitFrame sf = new SplitFrame(dna ? copyThis : newFrame,
 +                      dna ? newFrame : copyThis);
 +              newFrame.setVisible(true);
                copyThis.setVisible(true);
                String linkedTitle = MessageManager
                        .getString("label.linked_view_title");
              }
              else
              {
 -              Desktop.addInternalFrame(naf, newtitle, DEFAULT_WIDTH,
 +              Desktop.addInternalFrame(newFrame, newtitle, DEFAULT_WIDTH,
                        DEFAULT_HEIGHT);
              }
            }
                String type = null;
                try
                {
 -                type = new IdentifyFile().Identify(file, protocol);
 +                type = new IdentifyFile().identify(file, protocol);
                } catch (Exception ex)
                {
                  type = null;
  
    /**
     * Attempt to load a "dropped" file or URL string: First by testing whether
 -   * it's and Annotation file, then a JNet file, and finally a features file. If
 +   * it's an Annotation file, then a JNet file, and finally a features file. If
     * all are false then the user may have dropped an alignment file onto this
     * AlignFrame.
     * 
      {
        if (protocol == null)
        {
 -        protocol = jalview.io.FormatAdapter.checkProtocol(file);
 +        protocol = FormatAdapter.checkProtocol(file);
        }
        // if the file isn't identified, or not positively identified as some
        // other filetype (PFAM is default unidentified alignment file type) then
            // try to parse it as a features file
            if (format == null)
            {
 -            format = new IdentifyFile().Identify(file, protocol);
 +            format = new IdentifyFile().identify(file, protocol);
            }
            if (format.equalsIgnoreCase("JnetFile"))
            {
              viewport.setColumnSelection(cs);
              isAnnotation = true;
            }
 -          else
 +          else if (IdentifyFile.FeaturesFile.equals(format))
            {
 -            /*
 -             * if (format.equalsIgnoreCase("PDB")) {
 -             * 
 -             * String pdbfn = ""; // try to match up filename with sequence id
 -             * try { if (protocol == jalview.io.FormatAdapter.FILE) { File fl =
 -             * new File(file); pdbfn = fl.getName(); } else if (protocol ==
 -             * jalview.io.FormatAdapter.URL) { URL url = new URL(file); pdbfn =
 -             * url.getFile(); } } catch (Exception e) { } ; if (assocSeq ==
 -             * null) { SequenceIdMatcher idm = new SequenceIdMatcher(viewport
 -             * .getAlignment().getSequencesArray()); if (pdbfn.length() > 0) {
 -             * // attempt to find a match in the alignment SequenceI mtch =
 -             * idm.findIdMatch(pdbfn); int l = 0, c = pdbfn.indexOf("."); while
 -             * (mtch == null && c != -1) { while ((c = pdbfn.indexOf(".", l)) >
 -             * l) { l = c; } if (l > -1) { pdbfn = pdbfn.substring(0, l); } mtch
 -             * = idm.findIdMatch(pdbfn); } if (mtch != null) { // try and
 -             * associate // prompt ? PDBEntry pe = new AssociatePdbFileWithSeq()
 -             * .associatePdbWithSeq(file, protocol, mtch, true); if (pe != null)
 -             * { System.err.println("Associated file : " + file + " with " +
 -             * mtch.getDisplayId(true)); alignPanel.paintAlignment(true); } } //
 -             * TODO: maybe need to load as normal otherwise return; } }
 -             */
 -            // try to parse it as a features file
 -            boolean isGroupsFile = parseFeaturesFile(file, protocol);
 -            // if it wasn't a features file then we just treat it as a general
 -            // alignment file to load into the current view.
 -            if (!isGroupsFile)
 +            if (parseFeaturesFile(file, protocol))
              {
 -              new FileLoader().LoadFile(viewport, file, protocol, format);
 +              alignPanel.paintAlignment(true);
              }
 +          }
              else
              {
 -              alignPanel.paintAlignment(true);
 +              new FileLoader().LoadFile(viewport, file, protocol, format);
              }
 -          }
          }
        }
        if (isAnnotation)
        } catch (Exception x)
        {
        }
 -      ;
        new OOMWarning(
                "loading data "
                        + (protocol != null ? (protocol.equals(FormatAdapter.PASTE) ? "from clipboard."
    {
      // TODO no longer a menu action - refactor as required
      final AlignmentI alignment = getViewport().getAlignment();
 -    Set<AlignedCodonFrame> mappings = alignment.getCodonFrames();
 +    List<AlignedCodonFrame> mappings = alignment.getCodonFrames();
      if (mappings == null)
      {
        return;
        sf.setComplementVisible(this, show);
      }
    }
 +
 +  /**
 +   * Generate the reverse (optionally complemented) of the selected sequences,
 +   * and add them to the alignment
 +   */
 +  @Override
 +  protected void showReverse_actionPerformed(boolean complement)
 +  {
 +    AlignmentI al = null;
 +    try
 +    {
 +      Dna dna = new Dna(viewport, viewport.getViewAsVisibleContigs(true));
 +
 +      al = dna.reverseCdna(complement);
 +      viewport.addAlignment(al, "");
 +    } catch (Exception ex)
 +    {
 +      System.err.println(ex.getMessage());
 +      return;
 +    }
 +  }
  }
  
  class PrintThread extends Thread
@@@ -189,6 -189,7 +189,7 @@@ public class Desktop extends jalview.jb
        this.delegate = delegate;
      }
  
+     @Override
      public void activateFrame(JInternalFrame f)
      {
        try
        }
      }
  
+     @Override
      public void beginDraggingFrame(JComponent f)
      {
        delegate.beginDraggingFrame(f);
      }
  
+     @Override
      public void beginResizingFrame(JComponent f, int direction)
      {
        delegate.beginResizingFrame(f, direction);
      }
  
+     @Override
      public void closeFrame(JInternalFrame f)
      {
        delegate.closeFrame(f);
      }
  
+     @Override
      public void deactivateFrame(JInternalFrame f)
      {
        delegate.deactivateFrame(f);
      }
  
+     @Override
      public void deiconifyFrame(JInternalFrame f)
      {
        delegate.deiconifyFrame(f);
      }
  
+     @Override
      public void dragFrame(JComponent f, int newX, int newY)
      {
        if (newY < 0)
        delegate.dragFrame(f, newX, newY);
      }
  
+     @Override
      public void endDraggingFrame(JComponent f)
      {
        delegate.endDraggingFrame(f);
      }
  
+     @Override
      public void endResizingFrame(JComponent f)
      {
        delegate.endResizingFrame(f);
      }
  
+     @Override
      public void iconifyFrame(JInternalFrame f)
      {
        delegate.iconifyFrame(f);
      }
  
+     @Override
      public void maximizeFrame(JInternalFrame f)
      {
        delegate.maximizeFrame(f);
      }
  
+     @Override
      public void minimizeFrame(JInternalFrame f)
      {
        delegate.minimizeFrame(f);
      }
  
+     @Override
      public void openFrame(JInternalFrame f)
      {
        delegate.openFrame(f);
        delegate.resizeFrame(f, newX, newY, newWidth, newHeight);
      }
  
+     @Override
      public void setBoundsForFrame(JComponent f, int newX, int newY,
              int newWidth, int newHeight)
      {
  
      this.addWindowListener(new WindowAdapter()
      {
+       @Override
        public void windowClosing(WindowEvent evt)
        {
          quit();
      MouseAdapter ma;
      this.addMouseListener(ma = new MouseAdapter()
      {
+       @Override
        public void mousePressed(MouseEvent evt)
        {
          if (SwingUtilities.isRightMouseButton(evt))
      // Spawn a thread that shows the splashscreen
      SwingUtilities.invokeLater(new Runnable()
      {
+       @Override
        public void run()
        {
          new SplashScreen();
      // takes to open it later on.
      new Thread(new Runnable()
      {
+       @Override
        public void run()
        {
          Cache.log.debug("Filechooser init thread started.");
          // reselected again.
          boolean refresh = true;
  
+         @Override
          public void menuCanceled(MenuEvent e)
          {
            refresh = true;
          }
  
+         @Override
          public void menuDeselected(MenuEvent e)
          {
            refresh = true;
          }
  
+         @Override
          public void menuSelected(MenuEvent e)
          {
            if (refresh)
              MessageManager.getString("label.paste_new_window"));
      item.addActionListener(new ActionListener()
      {
+       @Override
        public void actionPerformed(ActionEvent evt)
        {
          paste();
          String file = (String) contents
                  .getTransferData(DataFlavor.stringFlavor);
  
 -        String format = new IdentifyFile().Identify(file,
 +        String format = new IdentifyFile().identify(file,
                  FormatAdapter.PASTE);
  
          new FileLoader().LoadFile(file, FormatAdapter.PASTE, format);
      final JMenuItem menuItem = new JMenuItem(title);
      frame.addInternalFrameListener(new javax.swing.event.InternalFrameAdapter()
      {
+       @Override
        public void internalFrameActivated(
                javax.swing.event.InternalFrameEvent evt)
        {
  
        }
  
+       @Override
        public void internalFrameClosed(
                javax.swing.event.InternalFrameEvent evt)
        {
  
      menuItem.addActionListener(new ActionListener()
      {
+       @Override
        public void actionPerformed(ActionEvent e)
        {
          try
      }
    }
  
+   @Override
    public void lostOwnership(Clipboard clipboard, Transferable contents)
    {
      if (!internalCopy)
      internalCopy = false;
    }
  
+   @Override
    public void dragEnter(DropTargetDragEvent evt)
    {
    }
  
+   @Override
    public void dragExit(DropTargetEvent evt)
    {
    }
  
+   @Override
    public void dragOver(DropTargetDragEvent evt)
    {
    }
     * @param evt
     *          DOCUMENT ME!
     */
+   @Override
    public void drop(DropTargetDropEvent evt)
    {
      boolean success = true;
            }
            else
            {
 -            format = new IdentifyFile().Identify(file, protocol);
 +            format = new IdentifyFile().identify(file, protocol);
            }
  
            new FileLoader().LoadFile(file, protocol, format);
        }
        else
        {
 -        format = new IdentifyFile().Identify(choice, FormatAdapter.FILE);
 +        format = new IdentifyFile().identify(choice, FormatAdapter.FILE);
        }
  
        if (viewport != null)
      }
      else
      {
 -      String format = new IdentifyFile().Identify(url, FormatAdapter.URL);
 +      String format = new IdentifyFile().identify(url, FormatAdapter.URL);
  
        if (format.equals("URL NOT FOUND"))
        {
      // message.toString(), "About Jalview", JOptionPane.INFORMATION_MESSAGE);
      new Thread(new Runnable()
      {
+       @Override
        public void run()
        {
          new SplashScreen(true);
  
        new Thread(new Runnable()
        {
+         @Override
          public void run()
          {
            // TODO: refactor to Jalview desktop session controller action.
                selectedFile.getParent());
        new Thread(new Runnable()
        {
+         @Override
          public void run()
          {
            setProgressBar(
            sessit.addActionListener(new ActionListener()
            {
  
+             @Override
              public void actionPerformed(ActionEvent e)
              {
                if (dsktp.v_client == null)
                  Thread rthr = new Thread(new Runnable()
                  {
  
+                   @Override
                    public void run()
                    {
                      dsktp.v_client = new VamsasApplication(dsktp, mysesid);
        return showMemoryUsage;
      }
  
+     @Override
      public void run()
      {
        df = java.text.NumberFormat.getNumberInstance();
        groovyShell.setText(MessageManager.getString("label.groovy_console"));
        groovyShell.addActionListener(new ActionListener()
        {
+         @Override
          public void actionPerformed(ActionEvent e)
          {
            groovyShell_actionPerformed();
     * 
     * @see jalview.gui.IProgressIndicator#setProgressBar(java.lang.String, long)
     */
+   @Override
    public void setProgressBar(String message, long id)
    {
      if (progressBars == null)
     * @see jalview.gui.IProgressIndicator#registerHandler(long,
     * jalview.gui.IProgressIndicatorHandler)
     */
+   @Override
    public void registerHandler(final long id,
            final IProgressIndicatorHandler handler)
    {
        cancel.addActionListener(new ActionListener()
        {
  
+         @Override
          public void actionPerformed(ActionEvent e)
          {
            handler.cancelActivity(id);
              // only run if we aren't already displaying one of these.
              addDialogThread(serviceChangedDialog = new Runnable()
              {
+               @Override
                public void run()
                {
  
    {
      new Thread(new Runnable()
      {
+       @Override
        public void run()
        {
          try
    {
      dialogExecutor.submit(new Runnable()
      {
+       @Override
        public void run()
        {
          if (dialogPause)
      ImageMaker im = new jalview.util.ImageMaker(this, ImageMaker.TYPE.EPS,
              "View of Desktop", getWidth(), getHeight(), of = new File(
                      "Jalview_snapshot" + System.currentTimeMillis()
-                             + ".eps"), "View of desktop");
+                             + ".eps"), "View of desktop", null, 0, false);
      try
      {
        paintAll(im.getGraphics());