Font font = new Font("Helvetica", Font.PLAIN, 10);\r
jalview.gui.SequenceRenderer sr;\r
jalview.gui.FeatureRenderer fr;\r
+ jalview.gui.SeqCanvas seqcanvas;\r
+ Sequence sequence;\r
+ final StringBuffer mappingDetails = new StringBuffer();\r
\r
- public PDBCanvas()\r
+ public PDBCanvas(jalview.gui.SeqCanvas seqcanvas, Sequence seq)\r
{\r
+ this.seqcanvas = seqcanvas;\r
+ this.sequence = seq;\r
+ sr = seqcanvas.getSequenceRenderer();\r
+ fr = seqcanvas.getFeatureRenderer();\r
\r
+ seqcanvas.setPDBViewer(this);\r
}\r
\r
- public void setPDBFile(PDBfile pdb, Sequence sequence,\r
- jalview.gui.SequenceRenderer sr,\r
- jalview.gui.FeatureRenderer fr)\r
+ public void setPDBFile(PDBfile pdb)\r
{\r
-\r
-\r
this.sr = sr;\r
this.fr = fr;\r
int max = -10;\r
int seqstart = 0;\r
int seqend = 0;\r
\r
- for (int i = 0; i < pdb.chains.size(); i++) {\r
+ for (int i = 0; i < pdb.chains.size(); i++)\r
+ {\r
+\r
+ mappingDetails.append("\n\nPDB Sequence is :\nSequence = " + ((PDBChain) pdb.chains.elementAt(i)).sequence.getSequence());\r
+ mappingDetails.append("\nNo of residues = " + ((PDBChain) pdb.chains.elementAt(i)).residues.size()+"\n\n");\r
+\r
// Now lets compare the sequences to get\r
// the start and end points.\r
// Align the sequence to the pdb\r
((PDBChain) pdb.chains.elementAt(i)).sequence, "pep");\r
as.calcScoreMatrix();\r
as.traceAlignment();\r
- as.printAlignment();\r
-\r
+ PrintStream ps = new PrintStream(System.out)\r
+ {\r
+ public void print(String x) {\r
+ mappingDetails.append(x);\r
+ }\r
+ public void println()\r
+ {\r
+ mappingDetails.append("\n");\r
+ }\r
+ };\r
+\r
+ as.printAlignment(ps);\r
\r
if (as.maxscore > max) {\r
max = as.maxscore;\r
seqend = as.seq1end + sequence.getEnd()-1;\r
}\r
\r
- System.out.println("PDB start/end " + pdbstart + " " + pdbend);\r
- System.out.println("SEQ start/end "+ seqstart + " " + seqend);\r
+ mappingDetails.append("\nPDB start/end " + pdbstart + " " + pdbend);\r
+ mappingDetails.append("\nSEQ start/end "+ seqstart + " " + seqend);\r
}\r
\r
((PDBChain) pdb.chains.elementAt(maxchain)).pdbstart = pdbstart;\r
\r
scale = findScale();\r
\r
- System.out.println("Scale factor = " + scale);\r
\r
updateSeqColours();\r
ToolTipManager.sharedInstance().registerComponent(this);\r
}\r
}\r
}\r
-\r
+ /*\r
System.out.println("xmax " + max[0] + " min " + min[0]);\r
System.out.println("ymax " + max[1] + " min " + min[1]);\r
- System.out.println("zmax " + max[2] + " min " + min[2]);\r
+ System.out.println("zmax " + max[2] + " min " + min[2]);*/\r
\r
width[0] = (float) Math.abs(max[0] - min[0]);\r
width[1] = (float) Math.abs(max[1] - min[1]);\r
maxwidth = width[2];\r
}\r
\r
- System.out.println("Maxwidth = " + maxwidth);\r
+ // System.out.println("Maxwidth = " + maxwidth);\r
}\r
\r
public float findScale() {\r
\r
public void paintComponent(Graphics g) {\r
\r
+ super.paintComponent(g);\r
+\r
if(pdb==null)\r
{\r
g.setColor(Color.black);\r
g.setFont(new Font("Verdana", Font.BOLD, 14));\r
g.drawString("Retrieving PDB data....", 20, getHeight()/2);\r
-\r
return;\r
}\r
\r
\r
public void updateSeqColours()\r
{\r
- if(bysequence)\r
+ if(bysequence && pdb!=null)\r
{\r
for (int ii = 0; ii < pdb.chains.size(); ii++)\r
{\r
\r
public void keyPressed(KeyEvent evt) {\r
int key = evt.getKeyChar();\r
- System.out.println(key);\r
if (evt.getKeyCode() == KeyEvent.VK_UP)\r
{\r
scale = (float) (scale * 1.1);\r
\r
myAtom fatom = findAtom(e.getX(), e.getY());\r
\r
+ if(foundchain!=-1)\r
+ {\r
+ PDBChain chain = (PDBChain) pdb.chains.elementAt(foundchain);\r
+ int pos = chain.seqstart +\r
+ (fatom.resNumber - chain.pdbstart - chain.offset)+1;\r
+\r
+ int index = seqcanvas.getViewport().getAlignment().findIndex(sequence);\r
+\r
+ seqcanvas.highlightSearchResults(new int[]{index, pos, pos});\r
+ }\r
+ else\r
+ seqcanvas.highlightSearchResults(null);\r
+\r
if (fatom != null) {\r
this.setToolTipText(fatom.resNumber+" "+ fatom.resName);\r
} else {\r
}\r
}\r
\r
+ int foundchain = -1;\r
public myAtom findAtom(int x, int y) {\r
myAtom fatom = null;\r
\r
- int foundchain = -1;\r
+ foundchain = -1;\r
\r
for (int ii = 0; ii < pdb.chains.size(); ii++) {\r
PDBChain chain = (PDBChain) pdb.chains.elementAt(ii);\r
{\r
fatom = tmpBond.at1;\r
foundchain = ii;\r
+ break;\r
}\r
}\r
}\r
if (fatom != null) //)&& chain.ds != null)\r
{\r
chain = (PDBChain) pdb.chains.elementAt(foundchain);\r
-\r
- // SMJS TODO\r
- // int tmp = chain.ds.seqstart + fatom.resNumber - chain.offset;\r
- // int pos = chain.ds.findIndex(tmp);\r
- // System.out.println("Found seq " + chain.ds.name + " " + tmp + " " + pos);\r
}\r
}\r
\r
return fatom;\r
}\r
-\r
- public void update(Graphics g) {\r
- paint(g);\r
- }\r
}\r
{\r
PDBEntry pdb;\r
Sequence sequence;\r
- SeqCanvas seqcanvas;\r
PDBCanvas pdbcanvas;\r
\r
\r
{\r
pdb = entry;\r
sequence = seq;\r
- this.seqcanvas = seqcanvas;\r
-\r
\r
try\r
{\r
ex.printStackTrace();\r
}\r
\r
- pdbcanvas = new PDBCanvas();\r
+ pdbcanvas = new PDBCanvas(seqcanvas, seq);\r
+\r
setContentPane(pdbcanvas);\r
Desktop.addInternalFrame(this,\r
sequence.getName() + ":" + pdb.getId()\r
\r
PDBfile pdbfile = new PDBfile(result);\r
\r
- pdbcanvas.setPDBFile(pdbfile,\r
- sequence,\r
- seqcanvas.getSequenceRenderer(),\r
- seqcanvas.getFeatureRenderer());\r
+ pdbcanvas.setPDBFile(pdbfile);\r
\r
- seqcanvas.setPDBViewer(pdbcanvas);\r
}\r
catch (Exception ex)\r
{\r
{\r
public void keyPressed(KeyEvent evt)\r
{\r
- System.out.println("key press");\r
pdbcanvas.keyPressed(evt);\r
}\r
});\r
}\r
});\r
mapping.setText("View Mapping");\r
+ mapping.addActionListener(new ActionListener()\r
+ {\r
+ public void actionPerformed(ActionEvent e)\r
+ {\r
+ mapping_actionPerformed(e);\r
+ }\r
+ });\r
wire.setText("Wireframe");\r
wire.addActionListener(new ActionListener()\r
{\r
\r
public void charge_actionPerformed(ActionEvent e)\r
{\r
+ clearButtonGroup();\r
pdbcanvas.pdb.setChargeColours();\r
pdbcanvas.redrawneeded=true;\r
pdbcanvas.repaint();\r
\r
public void hydro_actionPerformed(ActionEvent e)\r
{\r
+ clearButtonGroup();\r
pdbcanvas.pdb.setHydrophobicityColours();\r
pdbcanvas.redrawneeded=true;\r
pdbcanvas.repaint();\r
\r
public void chain_actionPerformed(ActionEvent e)\r
{\r
+ clearButtonGroup();\r
pdbcanvas.pdb.setChainColours();\r
pdbcanvas.redrawneeded=true;\r
pdbcanvas.repaint();\r
\r
public void seqButton_actionPerformed(ActionEvent e)\r
{\r
+ clearButtonGroup();\r
pdbcanvas.bysequence = seqButton.isSelected();\r
pdbcanvas.updateSeqColours();\r
}\r
\r
void clearButtonGroup()\r
{\r
- charge.setSelected(false);\r
- hydro.setSelected(false);\r
- chain.setSelected(false);\r
- seqButton.setSelected(false);\r
+ pdbcanvas.bysequence = false;\r
+ pdbcanvas.bymolecule = false;\r
+ }\r
+\r
+ public void mapping_actionPerformed(ActionEvent e)\r
+ {\r
+ jalview.gui.CutAndPasteTransfer cap = new jalview.gui.CutAndPasteTransfer();\r
+ Desktop.addInternalFrame(cap, "PDB - Sequence Mapping", 500, 600);\r
+ cap.setText(pdbcanvas.mappingDetails.toString());\r
}\r
}\r