+ **/
+ public boolean addPdbFile(String sequenceId, String pdbEntryString,
+ String pdbFile)
+ {
+ SequenceI toaddpdb = viewport.getAlignment().findName(sequenceId);
+ boolean needtoadd = false;
+ if (toaddpdb != null)
+ {
+ Vector pdbe = toaddpdb.getPDBId();
+ PDBEntry pdbentry = null;
+ if (pdbe != null && pdbe.size() > 0)
+ {
+ for (int pe = 0, peSize = pdbe.size(); pe < peSize; pe++)
+ {
+ pdbentry = (PDBEntry) pdbe.elementAt(pe);
+ if (!pdbentry.getId().equals(pdbEntryString)
+ && !pdbentry.getFile().equals(pdbFile))
+ {
+ pdbentry = null;
+ }
+ else
+ {
+ continue;
+ }
+ }
+ }
+ if (pdbentry == null)
+ {
+ pdbentry = new PDBEntry();
+ pdbentry.setId(pdbEntryString);
+ pdbentry.setFile(pdbFile);
+ needtoadd = true; // add this new entry to sequence.
+ }
+ // resolve data source
+ // TODO: this code should be a refactored to an io package
+ String protocol = AppletFormatAdapter.resolveProtocol(pdbFile, "PDB");
+ if (protocol == null)
+ {
+ return false;
+ }
+ if (needtoadd)
+ {
+ // make a note of the access mode and add
+ if (pdbentry.getProperty()==null)
+ {pdbentry.setProperty(new Hashtable());}
+ pdbentry.getProperty().put("protocol", protocol);
+ toaddpdb.addPDBId(pdbentry);
+ }
+ }
+ return true;
+ }
+ private Object[] cleanSeqChainArrays(SequenceI[] seqs, String[] chains)
+ {
+ if (seqs != null)
+ {
+ Vector sequences = new Vector();
+ for (int i = 0; i < seqs.length; i++)
+ {
+ if (seqs[i] != null)
+ {
+ sequences.addElement(new Object[] { seqs[i], (chains!=null) ? chains[i] : null});
+ }
+ }
+ seqs = new SequenceI[sequences.size()];
+ chains = new String[sequences.size()];
+ for (int i = 0, isize = sequences.size(); i < isize; i++)
+ {
+ Object[] oj = (Object[]) sequences.elementAt(i);
+
+ seqs[i] = (SequenceI) oj[0];
+ chains[i] = (String) oj[1];
+ }
+ }
+ return new Object[] { seqs, chains};
+
+ }
+ public void newStructureView(JalviewLite applet, PDBEntry pdb,
+ SequenceI[] seqs, String[] chains, String protocol)
+ {
+ // Scrub any null sequences from the array
+ Object[] sqch = cleanSeqChainArrays(seqs, chains);
+ seqs = (SequenceI[]) sqch[0];
+ chains = (String[]) sqch[1];
+ if (seqs == null || seqs.length == 0)
+ {
+ System.err
+ .println("JalviewLite.AlignFrame:newStructureView: No sequence to bind structure to.");
+ }
+ if (protocol == null || protocol.trim().length() == 0
+ || protocol.equals("null"))
+ {
+ protocol = (String) pdb.getProperty().get("protocol");
+ if (protocol == null)
+ {
+ System.err.println("Couldn't work out protocol to open structure: "
+ + pdb.getId());
+ return;
+ }
+ }
+ if (applet.isAlignPdbStructures() && applet.jmolAvailable)
+ {
+ // can only do alignments with Jmol
+ // find the last jmol window assigned to this alignment
+ jalview.appletgui.AppletJmol ajm = null, tajm;
+ Vector jmols = applet
+ .getAppletWindow(jalview.appletgui.AppletJmol.class);
+ for (int i = 0, iSize = jmols.size(); i < iSize; i++)
+ {
+ tajm = (jalview.appletgui.AppletJmol) jmols.elementAt(i);
+ if (tajm.ap.alignFrame == this)
+ {
+ ajm = tajm;
+ break;
+ }
+ }
+ if (ajm!=null)
+ {
+ System.err.println("Incremental adding and aligning structure to existing Jmol view not yet implemented.");
+ // try and add the pdb structure
+ // ajm.addS
+ ajm = null;
+ }
+ }
+ // otherwise, create a new window
+ if (applet.jmolAvailable)
+ {
+ new jalview.appletgui.AppletJmol(pdb, seqs, chains, alignPanel,
+ protocol);
+ applet.lastFrameX += 40;
+ applet.lastFrameY += 40;
+ }
+ else
+ {
+ new MCview.AppletPDBViewer(pdb, seqs, chains, alignPanel, protocol);
+ }
+
+ }
+
+ public void alignedStructureView(JalviewLite applet, PDBEntry[] pdb,
+ SequenceI[][] seqs, String[][] chains, String[] protocols)
+ {
+ // TODO Auto-generated method stub
+ System.err.println("Aligned Structure View: Not yet implemented.");
+ }