JAL-2668 fix broken factory method for colour scheme
[jalview.git] / src / jalview / gui / AlignViewport.java
index 14b7af0..b490a4b 100644 (file)
@@ -22,7 +22,6 @@ package jalview.gui;
 
 import jalview.analysis.AlignmentUtils;
 import jalview.analysis.AnnotationSorter.SequenceAnnotationOrder;
-import jalview.analysis.TreeModel;
 import jalview.api.AlignViewportI;
 import jalview.api.AlignmentViewPanel;
 import jalview.api.FeatureColourI;
@@ -76,8 +75,6 @@ public class AlignViewport extends AlignmentViewport
 {
   Font font;
 
-  TreeModel currentTree = null;
-
   boolean cursorMode = false;
 
   boolean antiAlias = false;
@@ -284,6 +281,9 @@ public class AlignViewport extends AlignmentViewport
       showOccupancy = Cache.getDefault(Preferences.SHOW_OCCUPANCY, true);
     }
     initAutoAnnotation();
+    initInformation();
+
+
     String colourProperty = alignment.isNucleotide()
             ? Preferences.DEFAULT_COLOUR_NUC
             : Preferences.DEFAULT_COLOUR_PROT;
@@ -448,27 +448,6 @@ public class AlignViewport extends AlignmentViewport
   }
 
   /**
-   * DOCUMENT ME!
-   * 
-   * @param tree
-   *          DOCUMENT ME!
-   */
-  public void setCurrentTree(TreeModel tree)
-  {
-    currentTree = tree;
-  }
-
-  /**
-   * DOCUMENT ME!
-   * 
-   * @return DOCUMENT ME!
-   */
-  public TreeModel getCurrentTree()
-  {
-    return currentTree;
-  }
-
-  /**
    * returns the visible column regions of the alignment
    * 
    * @param selectedRegionOnly
@@ -606,17 +585,75 @@ public class AlignViewport extends AlignmentViewport
             .getStructureSelectionManager(Desktop.instance);
   }
 
+  /**
+   * 
+   * @param pdbEntries
+   * @return an array of SequenceI arrays, one for each PDBEntry, listing which
+   *         sequences in the alignment hold a reference to it
+   */
+  public SequenceI[][] collateForPDB(PDBEntry[] pdbEntries)
+  {
+    List<SequenceI[]> seqvectors = new ArrayList<>();
+    for (PDBEntry pdb : pdbEntries)
+    {
+      List<SequenceI> choosenSeqs = new ArrayList<>();
+      for (SequenceI sq : alignment.getSequences())
+      {
+        Vector<PDBEntry> pdbRefEntries = sq.getDatasetSequence()
+                .getAllPDBEntries();
+        if (pdbRefEntries == null)
+        {
+          continue;
+        }
+        for (PDBEntry pdbRefEntry : pdbRefEntries)
+        {
+          if (pdbRefEntry.getId().equals(pdb.getId()))
+          {
+            if (pdbRefEntry.getChainCode() != null
+                    && pdb.getChainCode() != null)
+            {
+              if (pdbRefEntry.getChainCode().equalsIgnoreCase(
+                      pdb.getChainCode()) && !choosenSeqs.contains(sq))
+              {
+                choosenSeqs.add(sq);
+                continue;
+              }
+            }
+            else
+            {
+              if (!choosenSeqs.contains(sq))
+              {
+                choosenSeqs.add(sq);
+                continue;
+              }
+            }
+
+          }
+        }
+      }
+      seqvectors
+              .add(choosenSeqs.toArray(new SequenceI[choosenSeqs.size()]));
+    }
+    return seqvectors.toArray(new SequenceI[seqvectors.size()][]);
+  }
+
   @Override
   public boolean isNormaliseSequenceLogo()
   {
     return normaliseSequenceLogo;
   }
 
+
   public void setNormaliseSequenceLogo(boolean state)
   {
     normaliseSequenceLogo = state;
   }
 
+  public void setNormaliseHMMSequenceLogo(boolean state)
+  {
+    normaliseHMMSequenceLogo = state;
+  }
+
   /**
    * 
    * @return true if alignment characters should be displayed
@@ -627,7 +664,7 @@ public class AlignViewport extends AlignmentViewport
     return validCharWidth;
   }
 
-  private Hashtable<String, AutoCalcSetting> calcIdParams = new Hashtable<String, AutoCalcSetting>();
+  private Hashtable<String, AutoCalcSetting> calcIdParams = new Hashtable<>();
 
   public AutoCalcSetting getCalcIdSettingsFor(String calcId)
   {
@@ -1059,4 +1096,10 @@ public class AlignViewport extends AlignmentViewport
     fr.setTransparency(featureSettings.getTransparency());
   }
 
+  @Override
+  public boolean isNormaliseHMMSequenceLogo()
+  {
+    return normaliseHMMSequenceLogo;
+  }
+
 }