+
+ 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
+ pdbentry.getProperty().put("protocol", protocol);
+ toaddpdb.addPDBId(pdbentry);
+ }
+ }
+ return true;
+ }
+
+ public void newStructureView(JalviewLite applet, PDBEntry pdb, SequenceI[] seqs,
+ String[] chains, String protocol)
+ {
+ 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.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);
+ }