- if (sequence == null || pdbentry == null || sequence.length < 1
- || pdbentry.length < 1)
- {
- return ("Jalview Jmol Window");
- }
- StringBuffer title = new StringBuffer(sequence[0].getName() + ":"
- + pdbentry[0].getId());
-
- if (pdbentry[0].getProperty() != null)
- {
- if (pdbentry[0].getProperty().get("method") != null)
- {
- title.append(" Method: ");
- title.append(pdbentry[0].getProperty().get("method"));
- }
- if (pdbentry[0].getProperty().get("chains") != null)
- {
- title.append(" Chain:");
- title.append(pdbentry[0].getProperty().get("chains"));
- }
- }
- return title.toString();
- }
-
- /**
- * prepare the view for a given set of models/chains. chainList contains
- * strings of the form 'pdbfilename:Chaincode'
- *
- * @param chainList
- * list of chains to make visible
- */
- public void centerViewer(Vector chainList)
- {
- StringBuffer cmd = new StringBuffer();
- String lbl;
- int mlength, p;
- for (int i = 0, iSize = chainList.size(); i < iSize; i++)
- {
- mlength = 0;
- lbl = (String) chainList.elementAt(i);
- do
- {
- p = mlength;
- mlength = lbl.indexOf(":", p);
- } while (p < mlength && mlength < (lbl.length() - 2));
- cmd.append(":" + lbl.substring(mlength + 1) + " /"
- + getModelNum(lbl.substring(0, mlength)) + " or ");
- }
- if (cmd.length() > 0)
- cmd.setLength(cmd.length() - 4);
- evalStateCommand("select *;restrict " + cmd + ";cartoon;center " + cmd);
- }
-
- public void closeViewer()
- {
- viewer.setModeMouse(org.jmol.viewer.JmolConstants.MOUSE_NONE);
- // remove listeners for all structures in viewer
- StructureSelectionManager.getStructureSelectionManager()
- .removeStructureViewerListener(this, this.getPdbFile());
- // and shut down jmol
- viewer.evalStringQuiet("zap");
- viewer.setJmolStatusListener(null);
- lastCommand = null;
- viewer = null;
- }
-
- public void colourByChain()
- {
- colourBySequence = false;
- evalStateCommand("select *;color chain");
- }
-
- public void colourByCharge()
- {
- colourBySequence = false;
- evalStateCommand("select *;color white;select ASP,GLU;color red;"
- + "select LYS,ARG;color blue;select CYS;color yellow");
- }
-
- /**
- * superpose the structures associated with sequences in the alignment
- * according to their corresponding positions.
- */
- public void superposeStructures(AlignmentI alignment)
- {
- String[] files = getPdbFile();
-
- StringBuffer command = new StringBuffer();
- boolean matched[] = new boolean[alignment.getWidth()];
- String commonpositions[][] = new String[files.length][alignment
- .getWidth()];
- for (int pdbfnum = 0; pdbfnum < files.length; pdbfnum++)
- {
- StructureMapping[] mapping = ssm.getMapping(files[pdbfnum]);
-
- if (mapping == null || mapping.length < 1)
- continue;
-
- int lastPos = -1;
- for (int s = 0; s < sequence.length; s++)
- {
- for (int sp, m = 0; m < mapping.length; m++)
- {
- if (mapping[m].getSequence() == sequence[s]
- && (sp = alignment.findIndex(sequence[s])) > -1)
- {
- SequenceI asp = alignment.getSequenceAt(sp);
- for (int r = 0; r < asp.getLength(); r++)
- {
- // no mapping to gaps in sequence
- if (jalview.util.Comparison.isGap(asp.getCharAt(r)))
- {
- matched[r] = false; // exclude from common set
- continue;
- }
- int pos = mapping[m].getPDBResNum(asp.findPosition(r));
-
- if (pos < 1 || pos == lastPos)
- continue;
-
- lastPos = pos;
-
- commonpositions[m][r] = (mapping[m].getChain() != " " ? ":"
- + mapping[m].getChain() : "")
- + "/" + (pdbfnum + 1) + ".1";
- }
- break;
- }
- }
- }
- }
- command.append("select ");
- // form the matched pair selection strings
- String sep = "";
- for (int r = 0; r < matched.length; r++)
- {
- if (matched[r])
- {
- command.append(sep);
- command.append("(");
- for (int s = 0; s < commonpositions.length; s++)
- {
- if (s > 0)
- {
- command.append(" | ");
- }
- command.append(commonpositions[s][r]);
- }
- command.append(")");
- sep = " | ";
- }
- }
- evalStateCommand(command.toString());