*/
package jalview.gui;
-import java.awt.Rectangle;
-import java.util.ArrayList;
-import java.util.List;
-
import jalview.api.structures.JalviewStructureDisplayI;
import jalview.bin.Cache;
import jalview.datamodel.PDBEntry;
import jalview.datamodel.StructureViewerModel;
import jalview.structure.StructureSelectionManager;
+import java.awt.Rectangle;
+import java.util.ArrayList;
+import java.util.List;
+
/**
* proxy for handling structure viewers.
*
* @return
*/
private JalviewStructureDisplayI onlyOnePdb(PDBEntry[] pdbs,
- SequenceI[][] seqsForPdbs,
- AlignmentPanel ap)
+ SequenceI[][] seqsForPdbs, AlignmentPanel ap)
{
List<SequenceI> seqs = new ArrayList<SequenceI>();
if (pdbs == null || pdbs.length == 0)
protected JalviewStructureDisplayI viewStructures(ViewerType viewerType,
PDBEntry[] pdbs, SequenceI[][] seqsForPdbs, AlignmentPanel ap)
{
+ PDBEntry[] pdbsForFile = getUniquePdbFiles(pdbs);
JalviewStructureDisplayI sview = null;
if (viewerType.equals(ViewerType.JMOL))
{
- sview = new AppJmol(ap, pdbs, ap.av.collateForPDB(pdbs));
+ sview = new AppJmol(ap, pdbsForFile, ap.av.collateForPDB(pdbsForFile));
}
else if (viewerType.equals(ViewerType.CHIMERA))
{
- sview = new ChimeraViewFrame(pdbs, ap.av.collateForPDB(pdbs), ap);
+ sview = new ChimeraViewFrame(pdbsForFile,
+ ap.av.collateForPDB(pdbsForFile), ap);
}
else
{
return sview;
}
+ /**
+ * Convert the array of PDBEntry into an array with no filename repeated
+ *
+ * @param pdbs
+ * @return
+ */
+ static PDBEntry[] getUniquePdbFiles(PDBEntry[] pdbs)
+ {
+ if (pdbs == null)
+ {
+ return null;
+ }
+ List<PDBEntry> uniques = new ArrayList<PDBEntry>();
+ List<String> filesSeen = new ArrayList<String>();
+ for (PDBEntry entry : pdbs)
+ {
+ String file = entry.getFile();
+ if (file == null)
+ {
+ uniques.add(entry);
+ }
+ else if (!filesSeen.contains(file))
+ {
+ uniques.add(entry);
+ filesSeen.add(file);
+ }
+ }
+ return uniques.toArray(new PDBEntry[uniques.size()]);
+ }
+
protected JalviewStructureDisplayI viewStructures(ViewerType viewerType,
PDBEntry pdb, SequenceI[] seqsForPdb, AlignmentPanel ap)
{
*/
public JalviewStructureDisplayI createView(ViewerType type,
String[] pdbf, String[] id, SequenceI[][] sq,
- AlignmentPanel alignPanel, StructureViewerModel viewerData, String fileloc,
- Rectangle rect, String vid)
+ AlignmentPanel alignPanel, StructureViewerModel viewerData,
+ String fileloc, Rectangle rect, String vid)
{
final boolean useinViewerSuperpos = viewerData.isAlignWithPanel();
final boolean usetoColourbyseq = viewerData.isColourWithAlignPanel();