0)
cmd.setLength(cmd.length() - 4);
- viewer.evalStringQuiet("select *;restrict "
- +cmd+";cartoon;center "+cmd);
+ viewer.evalStringQuiet("select *;restrict " + cmd + ";cartoon;center "
+ + cmd);
}
void closeViewer()
@@ -284,24 +305,42 @@ public synchronized void addSequence(SequenceI [] seq)
viewer.setJmolStatusListener(null);
viewer = null;
- //We'll need to find out what other
+ // We'll need to find out what other
// listeners need to be shut down in Jmol
- StructureSelectionManager
- .getStructureSelectionManager()
- .removeStructureViewerListener(this, pdbentry.getFile());
+ StructureSelectionManager.getStructureSelectionManager()
+ .removeStructureViewerListener(this, pdbentry.getFile());
}
public void run()
{
try
{
- EBIFetchClient ebi = new EBIFetchClient();
- String query = "pdb:" + pdbentry.getId();
- pdbentry.setFile(ebi.fetchDataAsFile(query, "default", "raw")
- .getAbsolutePath());
- initJmol("load "+pdbentry.getFile());
- }
- catch (Exception ex)
+ // TODO: replace with reference fetching/transfer code (validate PDBentry
+ // as a DBRef?)
+ jalview.ws.dbsources.Pdb pdbclient = new jalview.ws.dbsources.Pdb();
+ AlignmentI pdbseq;
+ if ((pdbseq = pdbclient.getSequenceRecords(pdbentry.getId())) != null)
+ {
+ // just transfer the file name from the first seuqence's first PDBEntry
+ pdbentry.setFile(((PDBEntry) pdbseq.getSequenceAt(0).getPDBId()
+ .elementAt(0)).getFile());
+ initJmol("load " + pdbentry.getFile());
+ }
+ else
+ {
+ JOptionPane
+ .showInternalMessageDialog(
+ Desktop.desktop,
+ pdbentry.getId()
+ + " could not be retrieved. Please try downloading the file manually.",
+ "Couldn't load file", JOptionPane.ERROR_MESSAGE);
+
+ }
+ } catch (OutOfMemoryError oomerror)
+ {
+ new OOMWarning("Retrieving PDB id " + pdbentry.getId() + " from MSD",
+ oomerror);
+ } catch (Exception ex)
{
ex.printStackTrace();
}
@@ -309,9 +348,8 @@ public synchronized void addSequence(SequenceI [] seq)
public void pdbFile_actionPerformed(ActionEvent actionEvent)
{
- JalviewFileChooser chooser = new JalviewFileChooser(
- jalview.bin.Cache.getProperty(
- "LAST_DIRECTORY"));
+ JalviewFileChooser chooser = new JalviewFileChooser(jalview.bin.Cache
+ .getProperty("LAST_DIRECTORY"));
chooser.setFileView(new JalviewFileView());
chooser.setDialogTitle("Save PDB File");
@@ -323,23 +361,21 @@ public synchronized void addSequence(SequenceI [] seq)
{
try
{
- BufferedReader in = new BufferedReader(new FileReader(pdbentry.getFile()));
+ BufferedReader in = new BufferedReader(new FileReader(pdbentry
+ .getFile()));
File outFile = chooser.getSelectedFile();
PrintWriter out = new PrintWriter(new FileOutputStream(outFile));
String data;
- while ( (data = in.readLine()) != null)
+ while ((data = in.readLine()) != null)
{
- if (
- ! (data.indexOf("") > -1 || data.indexOf("
") > -1)
- )
+ if (!(data.indexOf("") > -1 || data.indexOf("
") > -1))
{
out.println(data);
}
}
out.close();
- }
- catch (Exception ex)
+ } catch (Exception ex)
{
ex.printStackTrace();
}
@@ -349,18 +385,17 @@ public synchronized void addSequence(SequenceI [] seq)
public void viewMapping_actionPerformed(ActionEvent actionEvent)
{
jalview.gui.CutAndPasteTransfer cap = new jalview.gui.CutAndPasteTransfer();
- jalview.gui.Desktop.addInternalFrame(cap, "PDB - Sequence Mapping", 550,
- 600);
- cap.setText(
- StructureSelectionManager.getStructureSelectionManager().printMapping(
- pdbentry.getFile())
- );
+ jalview.gui.Desktop.addInternalFrame(cap, "PDB - Sequence Mapping",
+ 550, 600);
+ cap.setText(StructureSelectionManager.getStructureSelectionManager()
+ .printMapping(pdbentry.getFile()));
}
/**
* DOCUMENT ME!
- *
- * @param e DOCUMENT ME!
+ *
+ * @param e
+ * DOCUMENT ME!
*/
public void eps_actionPerformed(ActionEvent e)
{
@@ -369,8 +404,9 @@ public synchronized void addSequence(SequenceI [] seq)
/**
* DOCUMENT ME!
- *
- * @param e DOCUMENT ME!
+ *
+ * @param e
+ * DOCUMENT ME!
*/
public void png_actionPerformed(ActionEvent e)
{
@@ -386,33 +422,27 @@ public synchronized void addSequence(SequenceI [] seq)
if (type == jalview.util.ImageMaker.PNG)
{
- im = new jalview.util.ImageMaker(this,
- jalview.util.ImageMaker.PNG,
- "Make PNG image from view",
- width, height,
- null, null);
+ im = new jalview.util.ImageMaker(this, jalview.util.ImageMaker.PNG,
+ "Make PNG image from view", width, height, null, null);
}
else
{
- im = new jalview.util.ImageMaker(this,
- jalview.util.ImageMaker.EPS,
- "Make EPS file from view",
- width, height,
- null, this.getTitle());
+ im = new jalview.util.ImageMaker(this, jalview.util.ImageMaker.EPS,
+ "Make EPS file from view", width, height, null, this
+ .getTitle());
}
if (im.getGraphics() != null)
{
Rectangle rect = new Rectangle(width, height);
- viewer.renderScreenImage(im.getGraphics(),
- rect.getSize(), rect);
+ viewer.renderScreenImage(im.getGraphics(), rect.getSize(), rect);
im.writeImage();
}
}
-
public void seqColour_actionPerformed(ActionEvent actionEvent)
{
+ lastCommand = null;
colourBySequence = seqColour.isSelected();
colourBySequence(ap.alignFrame.alignPanel);
}
@@ -429,7 +459,7 @@ public synchronized void addSequence(SequenceI [] seq)
colourBySequence = false;
seqColour.setSelected(false);
viewer.evalStringQuiet("select *;color white;select ASP,GLU;color red;"
- +"select LYS,ARG;color blue;select CYS;color yellow");
+ + "select LYS,ARG;color blue;select CYS;color yellow");
}
public void zappoColour_actionPerformed(ActionEvent actionEvent)
@@ -472,7 +502,7 @@ public synchronized void addSequence(SequenceI [] seq)
colourBySequence = false;
seqColour.setSelected(false);
- if(cs==null)
+ if (cs == null)
return;
String res;
@@ -481,19 +511,17 @@ public synchronized void addSequence(SequenceI [] seq)
Enumeration en = ResidueProperties.aa3Hash.keys();
StringBuffer command = new StringBuffer("select *;color white;");
- while(en.hasMoreElements())
+ while (en.hasMoreElements())
{
res = en.nextElement().toString();
index = ((Integer) ResidueProperties.aa3Hash.get(res)).intValue();
- if(index>20)
+ if (index > 20)
continue;
col = cs.findColour(ResidueProperties.aa[index].charAt(0));
- command.append("select "+res+";color["
- + col.getRed() + ","
- + col.getGreen() + ","
- + col.getBlue() + "];");
+ command.append("select " + res + ";color[" + col.getRed() + ","
+ + col.getGreen() + "," + col.getBlue() + "];");
}
viewer.evalStringQuiet(command.toString());
@@ -507,40 +535,38 @@ public synchronized void addSequence(SequenceI [] seq)
public void backGround_actionPerformed(ActionEvent actionEvent)
{
java.awt.Color col = JColorChooser.showDialog(this,
- "Select Background Colour",
- null);
+ "Select Background Colour", null);
if (col != null)
{
- viewer.evalStringQuiet("background ["
- + col.getRed() + ","
- + col.getGreen() + ","
- + col.getBlue() + "];");
+ viewer.evalStringQuiet("background [" + col.getRed() + ","
+ + col.getGreen() + "," + col.getBlue() + "];");
}
}
-
public void jmolHelp_actionPerformed(ActionEvent actionEvent)
{
- try{
- jalview.util.BrowserLauncher.openURL(
- "http://jmol.sourceforge.net/docs/JmolUserGuide/");
- }catch(Exception ex){}
- }
-
+ try
+ {
+ jalview.util.BrowserLauncher
+ .openURL("http://jmol.sourceforge.net/docs/JmolUserGuide/");
+ } catch (Exception ex)
+ {
+ }
+ }
- //////////////////////////////////
- ///StructureListener
+ // ////////////////////////////////
+ // /StructureListener
public String getPdbFile()
{
return pdbentry.getFile();
}
- Pattern pattern = Pattern.compile(
- "\\[(.*)\\]([0-9]+)(:[a-zA-Z]*)?\\.([a-zA-Z]+)(/[0-9]*)?"
- );
+ Pattern pattern = Pattern
+ .compile("\\[(.*)\\]([0-9]+)(:[a-zA-Z]*)?\\.([a-zA-Z]+)(/[0-9]*)?");
String lastMessage;
+
public void mouseOverStructure(int atomIndex, String strInfo)
{
Matcher matcher = pattern.matcher(strInfo);
@@ -564,10 +590,13 @@ public synchronized void addSequence(SequenceI [] seq)
}
StringBuffer resetLastRes = new StringBuffer();
+
StringBuffer eval = new StringBuffer();
- public void highlightAtom(int atomIndex, int pdbResNum, String chain, String pdbfile)
+ public void highlightAtom(int atomIndex, int pdbResNum, String chain,
+ String pdbfile)
{
+ // TODO: rna: remove CA dependency in select string
if (!pdbfile.equals(pdbentry.getFile()))
return;
@@ -582,26 +611,27 @@ public synchronized void addSequence(SequenceI [] seq)
resetLastRes.setLength(0);
resetLastRes.append("select " + pdbResNum);
+ eval.append(":");
+ resetLastRes.append(":");
if (!chain.equals(" "))
{
- eval.append(":" + chain);
- resetLastRes.append(":" + chain);
+ eval.append(chain);
+ resetLastRes.append(chain);
}
- eval.append(";color gold;wireframe 100");
+ eval.append(";wireframe 100;" + eval.toString() + " and not hetero;"); // ".*;");
- Color col = new Color(viewer.getAtomArgb(atomIndex));
-
- resetLastRes.append(";color["
- + col.getRed() + ","
- + col.getGreen() + ","
- + col.getBlue() + "];wireframe 0");
+ resetLastRes.append(";wireframe 0;" + resetLastRes.toString()
+ // + ".*;spacefill 0;");
+ + " and not hetero;spacefill 0;");
+ eval.append("spacefill 200;select none");
+ // System.out.println("jmol:\n"+eval+"\n");
viewer.evalStringQuiet(eval.toString());
-
}
- public Color getColour(int atomIndex, int pdbResNum, String chain, String pdbfile)
+ public Color getColour(int atomIndex, int pdbResNum, String chain,
+ String pdbfile)
{
if (!pdbfile.equals(pdbentry.getFile()))
return null;
@@ -611,27 +641,27 @@ public synchronized void addSequence(SequenceI [] seq)
public void updateColours(Object source)
{
- colourBySequence( (AlignmentPanel) source);
+ colourBySequence((AlignmentPanel) source);
}
-
-//End StructureListener
-////////////////////////////
+ // End StructureListener
+ // //////////////////////////
String lastCommand;
- FeatureRenderer fr=null;
+
+ FeatureRenderer fr = null;
+
public void colourBySequence(AlignmentPanel sourceap)
{
this.ap = sourceap;
- if(!colourBySequence || ap.alignFrame.getCurrentView()!=ap.av)
+ if (!colourBySequence || ap.alignFrame.getCurrentView() != ap.av)
return;
StructureMapping[] mapping = ssm.getMapping(pdbentry.getFile());
if (mapping.length < 1)
- return;
-
+ return;
SequenceRenderer sr = new SequenceRenderer(ap.av);
@@ -651,37 +681,37 @@ public synchronized void addSequence(SequenceI [] seq)
StringBuffer command = new StringBuffer();
int lastPos = -1;
- for (int s = 0; s < sequence.length; s++)
+ for (int sp, s = 0; s < sequence.length; s++)
{
for (int m = 0; m < mapping.length; m++)
{
- System.out.println(mapping[m].getSequence().getName()+" "+sequence[s].getName()+" "
- +((mapping[m].getSequence() == sequence[s])
- +" "+(ap.av.alignment.findIndex(sequence[s]))));
-
- if (mapping[m].getSequence() == sequence[s]
- && ap.av.alignment.findIndex(sequence[s])>-1)
+ if (mapping[m].getSequence() == sequence[s]
+ && (sp = ap.av.alignment.findIndex(sequence[s])) > -1)
{
- for (int r = 0; r < sequence[s].getLength(); r++)
+ SequenceI asp = ap.av.alignment.getSequenceAt(sp);
+ for (int r = 0; r < asp.getLength(); r++)
{
- int pos = mapping[m].getPDBResNum(
- sequence[s].findPosition(r));
+ // No mapping to gaps in sequence.
+ if (jalview.util.Comparison.isGap(asp.getCharAt(r)))
+ {
+ continue;
+ }
+ int pos = mapping[m].getPDBResNum(asp.findPosition(r));
- if (pos < 1 || pos==lastPos)
+ if (pos < 1 || pos == lastPos)
continue;
lastPos = pos;
- Color col = sr.getResidueBoxColour(sequence[s], r);
+ Color col = sr.getResidueBoxColour(asp, r);
if (showFeatures)
- col = fr.findFeatureColour(col, sequence[s], r);
+ col = fr.findFeatureColour(col, asp, r);
- if (command.toString().endsWith(":" + mapping[m].getChain()+
- ";color["
- + col.getRed() + ","
- + col.getGreen() + ","
- + col.getBlue() + "]"))
+ if (command.toString().endsWith(
+ ":" + mapping[m].getChain() + ";color[" + col.getRed()
+ + "," + col.getGreen() + "," + col.getBlue()
+ + "]"))
{
command = condenseCommand(command, pos);
continue;
@@ -694,10 +724,8 @@ public synchronized void addSequence(SequenceI [] seq)
command.append(":" + mapping[m].getChain());
}
- command.append(";color["
- + col.getRed() + ","
- + col.getGreen() + ","
- + col.getBlue() + "]");
+ command.append(";color[" + col.getRed() + "," + col.getGreen()
+ + "," + col.getBlue() + "]");
}
break;
@@ -714,7 +742,8 @@ public synchronized void addSequence(SequenceI [] seq)
StringBuffer condenseCommand(StringBuffer command, int pos)
{
- StringBuffer sb = new StringBuffer(command.substring(0, command.lastIndexOf("select")+7));
+ StringBuffer sb = new StringBuffer(command.substring(0, command
+ .lastIndexOf("select") + 7));
command.delete(0, sb.length());
@@ -722,25 +751,25 @@ public synchronized void addSequence(SequenceI [] seq)
if (command.indexOf("-") > -1)
{
- start = command.substring(0,command.indexOf("-"));
+ start = command.substring(0, command.indexOf("-"));
}
else
{
start = command.substring(0, command.indexOf(":"));
}
- sb.append(start+"-"+pos+command.substring(command.indexOf(":")));
+ sb.append(start + "-" + pos + command.substring(command.indexOf(":")));
return sb;
}
- /////////////////////////////////
- //JmolStatusListener
+ // ///////////////////////////////
+ // JmolStatusListener
public String eval(String strEval)
{
- // System.out.println(strEval);
- //"# 'eval' is implemented only for the applet.";
+ // System.out.println(strEval);
+ // "# 'eval' is implemented only for the applet.";
return null;
}
@@ -749,15 +778,10 @@ public synchronized void addSequence(SequenceI [] seq)
System.out.println("JMOL CREATE IMAGE");
}
- public void setCallbackFunction(String callbackType,
- String callbackFunction)
- {}
-
public void notifyFileLoaded(String fullPathName, String fileName,
- String modelName, Object clientFile,
- String errorMsg)
+ String modelName, String errorMsg, int modelParts)
{
- if(errorMsg!=null)
+ if (errorMsg != null)
{
fileLoadingError = errorMsg;
repaint();
@@ -768,28 +792,30 @@ public synchronized void addSequence(SequenceI [] seq)
if (fileName != null)
{
-
- //FILE LOADED OK
+ // TODO: do some checking using the modelPts number of parts against our own estimate of the number of chains
+ // FILE LOADED OK
ssm = StructureSelectionManager.getStructureSelectionManager();
- MCview.PDBfile pdbFile = ssm.setMapping(sequence,chains,pdbentry.getFile(), AppletFormatAdapter.FILE);
+ MCview.PDBfile pdbFile = ssm.setMapping(sequence, chains, pdbentry
+ .getFile(), AppletFormatAdapter.FILE);
ssm.addStructureViewerListener(this);
Vector chains = new Vector();
- for(int i=0; i