/*
-* Jalview - A Sequence Alignment Editor and Viewer
-* Copyright (C) 2006 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle
-*
-* This program is free software; you can redistribute it and/or
-* modify it under the terms of the GNU General Public License
-* as published by the Free Software Foundation; either version 2
-* of the License, or (at your option) any later version.
-*
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with this program; if not, write to the Free Software
-* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
-*/
+ * Jalview - A Sequence Alignment Editor and Viewer
+ * Copyright (C) 2007 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+ */
package MCview;
-import jalview.analysis.AlignSeq;
-
-import jalview.datamodel.*;
+import java.io.*;
+import java.util.*;
// JBPNote TODO: This class is quite noisy - needs proper log.info/log.debug
import java.awt.*;
import java.awt.event.*;
-import java.io.*;
-
-import java.util.*;
-
-
+import jalview.analysis.*;
+import jalview.datamodel.*;
-public class AppletPDBCanvas extends Panel implements MouseListener, MouseMotionListener
+public class AppletPDBCanvas
+ extends Panel implements MouseListener, MouseMotionListener
{
- MCMatrix idmat = new MCMatrix(3, 3);
- MCMatrix objmat = new MCMatrix(3, 3);
- boolean redrawneeded = true;
- int omx = 0;
- int mx = 0;
- int omy = 0;
- int my = 0;
- public PDBfile pdb;
- int bsize;
- Image img;
- Graphics ig;
- Dimension prefsize;
- float[] centre = new float[3];
- float[] width = new float[3];
- float maxwidth;
- float scale;
- String inStr;
- String inType;
- boolean bysequence = true;
- boolean depthcue = true;
- boolean wire = false;
- boolean bymolecule = false;
- boolean zbuffer = true;
- boolean dragging;
- int xstart;
- int xend;
- int ystart;
- int yend;
- int xmid;
- int ymid;
- Font font = new Font("Helvetica", Font.PLAIN, 10);
- jalview.appletgui.SeqCanvas seqcanvas;
- public Sequence sequence;
- final StringBuffer mappingDetails = new StringBuffer();
- String appletToolTip = null;
- int toolx, tooly;
- PDBChain mainchain;
- Vector highlightRes;
- boolean pdbAction = false;
- Bond highlightBond1, highlightBond2;
- boolean errorLoading = false;
- boolean seqColoursReady = false;
- jalview.appletgui.FeatureRenderer fr;
-
- public AppletPDBCanvas(jalview.appletgui.SeqCanvas seqcanvas, Sequence seq)
- {
- this.seqcanvas = seqcanvas;
- this.sequence = seq;
-
- seqcanvas.setPDBCanvas(this);
- addKeyListener(new KeyAdapter()
- {
-
- public void keyPressed(KeyEvent evt)
- {
- doKeyPressed(evt);
- }
- });
- }
+ MCMatrix idmat = new MCMatrix(3, 3);
+ MCMatrix objmat = new MCMatrix(3, 3);
+ boolean redrawneeded = true;
+ int omx = 0;
+ int mx = 0;
+ int omy = 0;
+ int my = 0;
+ public PDBfile pdb;
+ int bsize;
+ Image img;
+ Graphics ig;
+ Dimension prefsize;
+ float[] centre = new float[3];
+ float[] width = new float[3];
+ float maxwidth;
+ float scale;
+ String inStr;
+ String inType;
+ boolean bysequence = true;
+ boolean depthcue = true;
+ boolean wire = false;
+ boolean bymolecule = false;
+ boolean zbuffer = true;
+ boolean dragging;
+ int xstart;
+ int xend;
+ int ystart;
+ int yend;
+ int xmid;
+ int ymid;
+ Font font = new Font("Helvetica", Font.PLAIN, 10);
+ jalview.appletgui.SeqCanvas seqcanvas;
+ public Sequence sequence;
+ final StringBuffer mappingDetails = new StringBuffer();
+ String appletToolTip = null;
+ int toolx, tooly;
+ PDBChain mainchain;
+ Vector highlightRes;
+ boolean pdbAction = false;
+ Bond highlightBond1, highlightBond2;
+ boolean errorLoading = false;
+ boolean seqColoursReady = false;
+ jalview.appletgui.FeatureRenderer fr;
+
+ public AppletPDBCanvas(jalview.appletgui.SeqCanvas seqcanvas, Sequence seq)
+ {
+ this.seqcanvas = seqcanvas;
+ this.sequence = seq;
+
+ seqcanvas.setPDBCanvas(this);
+ addKeyListener(new KeyAdapter()
+ {
+ public void keyPressed(KeyEvent evt)
+ {
+ doKeyPressed(evt);
+ }
+ });
+ }
public void setPDBFile(PDBfile pdb)
- {
- int max = -10;
- int maxchain = -1;
- int pdbstart = 0;
- int pdbend = 0;
- int seqstart = 0;
- int seqend = 0;
- AlignSeq maxAlignseq = null;;
-
- for (int i = 0; i < pdb.chains.size(); i++)
- {
-
- mappingDetails.append("\n\nPDB Sequence is :\nSequence = " + ((PDBChain) pdb.chains.elementAt(i)).sequence.getSequenceAsString());
- mappingDetails.append("\nNo of residues = " + ((PDBChain) pdb.chains.elementAt(i)).residues.size()+"\n\n");
-
- // Now lets compare the sequences to get
- // the start and end points.
- // Align the sequence to the pdb
- AlignSeq as = new AlignSeq(sequence,
- ((PDBChain) pdb.chains.elementAt(i)).sequence, "pep");
- as.calcScoreMatrix();
- as.traceAlignment();
- PrintStream ps = new PrintStream(System.out)
- {
- public void print(String x) {
- mappingDetails.append(x);
- }
- public void println()
- {
- mappingDetails.append("\n");
- }
- };
-
- as.printAlignment(ps);
-
- if (as.maxscore > max) {
- max = as.maxscore;
- maxchain = i;
-
- pdbstart = as.seq2start;
- pdbend = as.seq2end;
- seqstart = as.seq1start + sequence.getStart()-1;
- seqend = as.seq1end + sequence.getEnd()-1;
- maxAlignseq = as;
- }
+ {
+ int max = -10;
+ int maxchain = -1;
+ int pdbstart = 0;
+ int pdbend = 0;
+ int seqstart = 0;
+ int seqend = 0;
+ AlignSeq maxAlignseq = null; ;
+
+ for (int i = 0; i < pdb.chains.size(); i++)
+ {
- mappingDetails.append("\nPDB start/end " + pdbstart + " " + pdbend);
- mappingDetails.append("\nSEQ start/end "+ seqstart + " " + seqend);
+ mappingDetails.append("\n\nPDB Sequence is :\nSequence = " +
+ ( (PDBChain) pdb.chains.elementAt(i)).sequence.
+ getSequenceAsString());
+ mappingDetails.append("\nNo of residues = " +
+ ( (PDBChain) pdb.chains.elementAt(i)).residues.size() +
+ "\n\n");
+
+ // Now lets compare the sequences to get
+ // the start and end points.
+ // Align the sequence to the pdb
+ AlignSeq as = new AlignSeq(sequence,
+ ( (PDBChain) pdb.chains.elementAt(i)).sequence,
+ "pep");
+ as.calcScoreMatrix();
+ as.traceAlignment();
+ PrintStream ps = new PrintStream(System.out)
+ {
+ public void print(String x)
+ {
+ mappingDetails.append(x);
}
- mainchain = (PDBChain) pdb.chains.elementAt(maxchain);
-
- mainchain.pdbstart = pdbstart;
- mainchain.pdbend = pdbend;
- mainchain.seqstart = seqstart;
- mainchain.seqend = seqend;
- mainchain.isVisible = true;
- mainchain.makeExactMapping(maxAlignseq, sequence);
- mainchain.transferRESNUMFeatures(sequence, null);
- this.pdb = pdb;
- this.prefsize = new Dimension(getSize().width, getSize().height);
-
- //Initialize the matrices to identity
- for (int i = 0; i < 3; i++) {
- for (int j = 0; j < 3; j++) {
- if (i != j) {
- idmat.addElement(i, j, 0);
- objmat.addElement(i, j, 0);
- } else {
- idmat.addElement(i, j, 1);
- objmat.addElement(i, j, 1);
- }
- }
+ public void println()
+ {
+ mappingDetails.append("\n");
}
+ };
- addMouseMotionListener(this);
- addMouseListener(this);
+ as.printAlignment(ps);
+ if (as.maxscore > max)
+ {
+ max = as.maxscore;
+ maxchain = i;
+
+ pdbstart = as.seq2start;
+ pdbend = as.seq2end;
+ seqstart = as.seq1start + sequence.getStart() - 1;
+ seqend = as.seq1end + sequence.getEnd() - 1;
+ maxAlignseq = as;
+ }
- findCentre();
- findWidth();
-
- setupBonds();
-
- scale = findScale();
+ mappingDetails.append("\nPDB start/end " + pdbstart + " " + pdbend);
+ mappingDetails.append("\nSEQ start/end " + seqstart + " " + seqend);
}
+ mainchain = (PDBChain) pdb.chains.elementAt(maxchain);
- Vector visiblebonds;
- void setupBonds()
- {
- seqColoursReady = false;
- // Sort the bonds by z coord
- visiblebonds = new Vector();
+ mainchain.pdbstart = pdbstart;
+ mainchain.pdbend = pdbend;
+ mainchain.seqstart = seqstart;
+ mainchain.seqend = seqend;
+ mainchain.isVisible = true;
+ mainchain.makeExactMapping(maxAlignseq, sequence);
+ mainchain.transferRESNUMFeatures(sequence, null);
+ this.pdb = pdb;
+ this.prefsize = new Dimension(getSize().width, getSize().height);
- for (int ii = 0; ii < pdb.chains.size(); ii++)
+ //Initialize the matrices to identity
+ for (int i = 0; i < 3; i++)
+ {
+ for (int j = 0; j < 3; j++)
{
- if ( ( (PDBChain) pdb.chains.elementAt(ii)).isVisible)
+ if (i != j)
{
- Vector tmp = ( (PDBChain) pdb.chains.elementAt(ii)).bonds;
-
- for (int i = 0; i < tmp.size(); i++)
- {
- visiblebonds.addElement(tmp.elementAt(i));
- }
+ idmat.addElement(i, j, 0);
+ objmat.addElement(i, j, 0);
+ }
+ else
+ {
+ idmat.addElement(i, j, 1);
+ objmat.addElement(i, j, 1);
}
}
- updateSeqColours();
- seqColoursReady = true;
- redrawneeded = true;
- repaint();
}
+ addMouseMotionListener(this);
+ addMouseListener(this);
- public void findWidth() {
- float[] max = new float[3];
- float[] min = new float[3];
-
- max[0] = (float) -1e30;
- max[1] = (float) -1e30;
- max[2] = (float) -1e30;
-
- min[0] = (float) 1e30;
- min[1] = (float) 1e30;
- min[2] = (float) 1e30;
+ findCentre();
+ findWidth();
- for (int ii = 0; ii < pdb.chains.size(); ii++) {
- if (((PDBChain) pdb.chains.elementAt(ii)).isVisible) {
- Vector bonds = ((PDBChain) pdb.chains.elementAt(ii)).bonds;
+ setupBonds();
- for (int i = 0; i < bonds.size(); i++) {
- Bond tmp = (Bond) bonds.elementAt(i);
+ scale = findScale();
+ }
- if (tmp.start[0] >= max[0]) {
- max[0] = tmp.start[0];
- }
+ Vector visiblebonds;
+ void setupBonds()
+ {
+ seqColoursReady = false;
+ // Sort the bonds by z coord
+ visiblebonds = new Vector();
- if (tmp.start[1] >= max[1]) {
- max[1] = tmp.start[1];
- }
+ for (int ii = 0; ii < pdb.chains.size(); ii++)
+ {
+ if ( ( (PDBChain) pdb.chains.elementAt(ii)).isVisible)
+ {
+ Vector tmp = ( (PDBChain) pdb.chains.elementAt(ii)).bonds;
- if (tmp.start[2] >= max[2]) {
- max[2] = tmp.start[2];
- }
+ for (int i = 0; i < tmp.size(); i++)
+ {
+ visiblebonds.addElement(tmp.elementAt(i));
+ }
+ }
+ }
+ updateSeqColours();
+ seqColoursReady = true;
+ redrawneeded = true;
+ repaint();
+ }
+
+ public void findWidth()
+ {
+ float[] max = new float[3];
+ float[] min = new float[3];
+
+ max[0] = (float) - 1e30;
+ max[1] = (float) - 1e30;
+ max[2] = (float) - 1e30;
+
+ min[0] = (float) 1e30;
+ min[1] = (float) 1e30;
+ min[2] = (float) 1e30;
+
+ for (int ii = 0; ii < pdb.chains.size(); ii++)
+ {
+ if ( ( (PDBChain) pdb.chains.elementAt(ii)).isVisible)
+ {
+ Vector bonds = ( (PDBChain) pdb.chains.elementAt(ii)).bonds;
- if (tmp.start[0] <= min[0]) {
- min[0] = tmp.start[0];
- }
+ for (int i = 0; i < bonds.size(); i++)
+ {
+ Bond tmp = (Bond) bonds.elementAt(i);
- if (tmp.start[1] <= min[1]) {
- min[1] = tmp.start[1];
- }
+ if (tmp.start[0] >= max[0])
+ {
+ max[0] = tmp.start[0];
+ }
- if (tmp.start[2] <= min[2]) {
- min[2] = tmp.start[2];
- }
+ if (tmp.start[1] >= max[1])
+ {
+ max[1] = tmp.start[1];
+ }
- if (tmp.end[0] >= max[0]) {
- max[0] = tmp.end[0];
- }
+ if (tmp.start[2] >= max[2])
+ {
+ max[2] = tmp.start[2];
+ }
- if (tmp.end[1] >= max[1]) {
- max[1] = tmp.end[1];
- }
+ if (tmp.start[0] <= min[0])
+ {
+ min[0] = tmp.start[0];
+ }
- if (tmp.end[2] >= max[2]) {
- max[2] = tmp.end[2];
- }
+ if (tmp.start[1] <= min[1])
+ {
+ min[1] = tmp.start[1];
+ }
- if (tmp.end[0] <= min[0]) {
- min[0] = tmp.end[0];
- }
+ if (tmp.start[2] <= min[2])
+ {
+ min[2] = tmp.start[2];
+ }
- if (tmp.end[1] <= min[1]) {
- min[1] = tmp.end[1];
- }
+ if (tmp.end[0] >= max[0])
+ {
+ max[0] = tmp.end[0];
+ }
- if (tmp.end[2] <= min[2]) {
- min[2] = tmp.end[2];
- }
- }
- }
- }
+ if (tmp.end[1] >= max[1])
+ {
+ max[1] = tmp.end[1];
+ }
- width[0] = (float) Math.abs(max[0] - min[0]);
- width[1] = (float) Math.abs(max[1] - min[1]);
- width[2] = (float) Math.abs(max[2] - min[2]);
+ if (tmp.end[2] >= max[2])
+ {
+ max[2] = tmp.end[2];
+ }
- maxwidth = width[0];
+ if (tmp.end[0] <= min[0])
+ {
+ min[0] = tmp.end[0];
+ }
- if (width[1] > width[0]) {
- maxwidth = width[1];
- }
+ if (tmp.end[1] <= min[1])
+ {
+ min[1] = tmp.end[1];
+ }
- if (width[2] > width[1]) {
- maxwidth = width[2];
+ if (tmp.end[2] <= min[2])
+ {
+ min[2] = tmp.end[2];
+ }
}
-
- // System.out.println("Maxwidth = " + maxwidth);
+ }
}
- public float findScale() {
- int dim;
- int width;
- int height;
-
- if (getSize().width != 0) {
- width = getSize().width;
- height = getSize().height;
- } else {
- width = prefsize.width;
- height = prefsize.height;
- }
+ width[0] = (float) Math.abs(max[0] - min[0]);
+ width[1] = (float) Math.abs(max[1] - min[1]);
+ width[2] = (float) Math.abs(max[2] - min[2]);
- if (width < height) {
- dim = width;
- } else {
- dim = height;
- }
+ maxwidth = width[0];
- return (float) (dim / (1.5d * maxwidth));
+ if (width[1] > width[0])
+ {
+ maxwidth = width[1];
}
- public void findCentre() {
- float xtot = 0;
- float ytot = 0;
- float ztot = 0;
-
- int bsize = 0;
-
- //Find centre coordinate
- for (int ii = 0; ii < pdb.chains.size(); ii++) {
- if (((PDBChain) pdb.chains.elementAt(ii)).isVisible) {
- Vector bonds = ((PDBChain) pdb.chains.elementAt(ii)).bonds;
-
- bsize += bonds.size();
-
- for (int i = 0; i < bonds.size(); i++) {
- xtot = xtot + ((Bond) bonds.elementAt(i)).start[0] +
- ((Bond) bonds.elementAt(i)).end[0];
+ if (width[2] > width[1])
+ {
+ maxwidth = width[2];
+ }
- ytot = ytot + ((Bond) bonds.elementAt(i)).start[1] +
- ((Bond) bonds.elementAt(i)).end[1];
+ // System.out.println("Maxwidth = " + maxwidth);
+ }
- ztot = ztot + ((Bond) bonds.elementAt(i)).start[2] +
- ((Bond) bonds.elementAt(i)).end[2];
- }
- }
- }
+ public float findScale()
+ {
+ int dim;
+ int width;
+ int height;
- centre[0] = xtot / (2 * (float) bsize);
- centre[1] = ytot / (2 * (float) bsize);
- centre[2] = ztot / (2 * (float) bsize);
+ if (getSize().width != 0)
+ {
+ width = getSize().width;
+ height = getSize().height;
+ }
+ else
+ {
+ width = prefsize.width;
+ height = prefsize.height;
}
- public void paint(Graphics g)
+ if (width < height)
{
+ dim = width;
+ }
+ else
+ {
+ dim = height;
+ }
- if(errorLoading)
- {
- g.setColor(Color.white);
- g.fillRect(0,0,getSize().width, getSize().height);
- g.setColor(Color.black);
- g.setFont(new Font("Verdana", Font.BOLD, 14));
- g.drawString("Error loading PDB data!!", 50, getSize().height/2);
- return;
- }
+ return (float) (dim / (1.5d * maxwidth));
+ }
- if( !seqColoursReady )
- {
- g.setColor(Color.black);
- g.setFont(new Font("Verdana", Font.BOLD, 14));
- g.drawString("Fetching PDB data...", 50, getSize().height/2);
- return;
- }
+ public void findCentre()
+ {
+ float xtot = 0;
+ float ytot = 0;
+ float ztot = 0;
+ int bsize = 0;
+ //Find centre coordinate
+ for (int ii = 0; ii < pdb.chains.size(); ii++)
+ {
+ if ( ( (PDBChain) pdb.chains.elementAt(ii)).isVisible)
+ {
+ Vector bonds = ( (PDBChain) pdb.chains.elementAt(ii)).bonds;
- //Only create the image at the beginning -
- //this saves much memory usage
- if ((img == null) || (prefsize.width != getSize().width) ||
- (prefsize.height != getSize().height)) {
+ bsize += bonds.size();
- try{ prefsize.width = getSize().width;
- prefsize.height = getSize().height;
+ for (int i = 0; i < bonds.size(); i++)
+ {
+ xtot = xtot + ( (Bond) bonds.elementAt(i)).start[0] +
+ ( (Bond) bonds.elementAt(i)).end[0];
- scale = findScale();
- img = createImage(prefsize.width, prefsize.height);
- ig = img.getGraphics();
+ ytot = ytot + ( (Bond) bonds.elementAt(i)).start[1] +
+ ( (Bond) bonds.elementAt(i)).end[1];
- redrawneeded = true;
- }catch(Exception ex)
- {
- ex.printStackTrace();
- }
+ ztot = ztot + ( (Bond) bonds.elementAt(i)).start[2] +
+ ( (Bond) bonds.elementAt(i)).end[2];
}
+ }
+ }
+ centre[0] = xtot / (2 * (float) bsize);
+ centre[1] = ytot / (2 * (float) bsize);
+ centre[2] = ztot / (2 * (float) bsize);
+ }
- if (redrawneeded)
- {
- drawAll(ig, prefsize.width, prefsize.height);
- redrawneeded = false;
- }
- if(appletToolTip!=null)
- {
- ig.setColor(Color.red);
- ig.drawString(appletToolTip, toolx, tooly);
- }
-
- g.drawImage(img, 0, 0, this);
+ public void paint(Graphics g)
+ {
- pdbAction = false;
+ if (errorLoading)
+ {
+ g.setColor(Color.white);
+ g.fillRect(0, 0, getSize().width, getSize().height);
+ g.setColor(Color.black);
+ g.setFont(new Font("Verdana", Font.BOLD, 14));
+ g.drawString("Error loading PDB data!!", 50, getSize().height / 2);
+ return;
}
- public void drawAll(Graphics g, int width, int height)
+ if (!seqColoursReady)
{
- ig.setColor(Color.black);
- ig.fillRect(0, 0, width, height);
- drawScene(ig);
- drawLabels(ig);
+ g.setColor(Color.black);
+ g.setFont(new Font("Verdana", Font.BOLD, 14));
+ g.drawString("Fetching PDB data...", 50, getSize().height / 2);
+ return;
}
- void setColours(jalview.schemes.ColourSchemeI cs)
- {
- bysequence = false;
- pdb.setColours(cs);
- redrawneeded = true;
- repaint();
- }
- public void updateSeqColours()
+ //Only create the image at the beginning -
+ //this saves much memory usage
+ if ( (img == null) || (prefsize.width != getSize().width) ||
+ (prefsize.height != getSize().height))
{
- if (pdbAction)
+
+ try
{
- return;
- }
+ prefsize.width = getSize().width;
+ prefsize.height = getSize().height;
+
+ scale = findScale();
+ img = createImage(prefsize.width, prefsize.height);
+ ig = img.getGraphics();
- if(bysequence && pdb!=null)
+ redrawneeded = true;
+ }
+ catch (Exception ex)
{
- for (int ii = 0; ii < pdb.chains.size(); ii++)
- {
- colourBySequence((PDBChain) pdb.chains.elementAt(ii));
- }
+ ex.printStackTrace();
}
-
- redrawneeded=true;
- repaint();
}
+ if (redrawneeded)
+ {
+ drawAll(ig, prefsize.width, prefsize.height);
+ redrawneeded = false;
+ }
+ if (appletToolTip != null)
+ {
+ ig.setColor(Color.red);
+ ig.drawString(appletToolTip, toolx, tooly);
+ }
- int findTrueIndex(int pos)
+ g.drawImage(img, 0, 0, this);
+
+ pdbAction = false;
+ }
+
+ public void drawAll(Graphics g, int width, int height)
+ {
+ ig.setColor(Color.black);
+ ig.fillRect(0, 0, width, height);
+ drawScene(ig);
+ drawLabels(ig);
+ }
+
+ void setColours(jalview.schemes.ColourSchemeI cs)
+ {
+ bysequence = false;
+ pdb.setColours(cs);
+ redrawneeded = true;
+ repaint();
+ }
+
+ public void updateSeqColours()
+ {
+ if (pdbAction)
{
- // returns the alignment position for a residue
- int j = sequence.getStart();
- int i = 0;
+ return;
+ }
- while ( (i < sequence.getLength()) && (j <= sequence.getEnd()) && (j <= pos+1))
+ if (bysequence && pdb != null)
+ {
+ for (int ii = 0; ii < pdb.chains.size(); ii++)
{
- if (!jalview.util.Comparison.isGap(sequence.getCharAt(i)))
- {
- j++;
- }
-
- i++;
+ colourBySequence( (PDBChain) pdb.chains.elementAt(ii));
}
+ }
- if(i>1)
- i--;
+ redrawneeded = true;
+ repaint();
+ }
- if ( (j == sequence.getEnd()) && (j < pos))
- {
- return sequence.getEnd() + 1;
- }
- else
+ int findTrueIndex(int pos)
+ {
+ // returns the alignment position for a residue
+ int j = sequence.getStart();
+ int i = 0;
+
+ while ( (i < sequence.getLength()) && (j <= sequence.getEnd()) &&
+ (j <= pos + 1))
+ {
+ if (!jalview.util.Comparison.isGap(sequence.getCharAt(i)))
{
- return i;
+ j++;
}
+
+ i++;
}
+ if (i > 1)
+ {
+ i--;
+ }
- // This method has been taken out of PDBChain to allow
- // Applet and Application specific sequence renderers to be used
- void colourBySequence(PDBChain chain)
+ if ( (j == sequence.getEnd()) && (j < pos))
+ {
+ return sequence.getEnd() + 1;
+ }
+ else
{
- boolean showFeatures = false;
+ return i;
+ }
+ }
- if(seqcanvas.getViewport().getShowSequenceFeatures())
- {
- if(fr==null)
- {
- fr = new jalview.appletgui.FeatureRenderer(seqcanvas.getViewport());
- }
- fr.transferSettings( seqcanvas.getFeatureRenderer());
- showFeatures = true;
- }
+ // This method has been taken out of PDBChain to allow
+ // Applet and Application specific sequence renderers to be used
+ void colourBySequence(PDBChain chain)
+ {
+ boolean showFeatures = false;
- for (int i = 0; i < chain.bonds.size(); i++)
+ if (seqcanvas.getViewport().getShowSequenceFeatures())
+ {
+ if (fr == null)
{
- Bond tmp = (Bond) chain.bonds.elementAt(i);
- tmp.startCol = Color.lightGray;
- tmp.endCol = Color.lightGray;
- if(chain!=mainchain)
- continue;
-
- if ( (tmp.at1.resNumber >= ( (chain.offset + chain.pdbstart) - 1)) &&
- (tmp.at1.resNumber <= ( (chain.offset + chain.pdbend) - 1)))
- {
+ fr = new jalview.appletgui.FeatureRenderer(seqcanvas.getViewport());
+ }
+ fr.transferSettings(seqcanvas.getFeatureRenderer());
+ showFeatures = true;
+ }
- int index = findTrueIndex(tmp.at1.alignmentMapping);
- //sequence.findIndex(tmp.at1.alignmentMapping);
- if (index != -1)
- {
- tmp.startCol = seqcanvas.getSequenceRenderer().
- getResidueBoxColour( sequence, index);
+ for (int i = 0; i < chain.bonds.size(); i++)
+ {
+ Bond tmp = (Bond) chain.bonds.elementAt(i);
+ tmp.startCol = Color.lightGray;
+ tmp.endCol = Color.lightGray;
+ if (chain != mainchain)
+ {
+ continue;
+ }
- if(showFeatures)
- tmp.startCol = fr.findFeatureColour(tmp.startCol, sequence, index);
- }
- }
+ if ( (tmp.at1.resNumber >= ( (chain.offset + chain.pdbstart) - 1)) &&
+ (tmp.at1.resNumber <= ( (chain.offset + chain.pdbend) - 1)))
+ {
- int index = findTrueIndex(tmp.at2.alignmentMapping);
- //sequence.findIndex( tmp.at2.alignmentMapping );
+ int index = findTrueIndex(tmp.at1.alignmentMapping);
+ //sequence.findIndex(tmp.at1.alignmentMapping);
if (index != -1)
{
- tmp.endCol = seqcanvas.getSequenceRenderer().
- getResidueBoxColour( sequence, index);
+ tmp.startCol = seqcanvas.getSequenceRenderer().
+ getResidueBoxColour(sequence, index);
- if(showFeatures)
- tmp.endCol = fr.findFeatureColour(tmp.endCol, sequence, index);
+ if (showFeatures)
+ {
+ tmp.startCol = fr.findFeatureColour(tmp.startCol, sequence, index);
+ }
}
}
- }
+ int index = findTrueIndex(tmp.at2.alignmentMapping);
+ //sequence.findIndex( tmp.at2.alignmentMapping );
+ if (index != -1)
+ {
+ tmp.endCol = seqcanvas.getSequenceRenderer().
+ getResidueBoxColour(sequence, index);
- Zsort zsort;
- public void drawScene(Graphics g)
- {
- if (zbuffer)
+ if (showFeatures)
{
- if(zsort ==null)
- zsort = new Zsort();
-
- zsort.Zsort(visiblebonds);
+ tmp.endCol = fr.findFeatureColour(tmp.endCol, sequence, index);
}
+ }
+ }
+ }
+ Zsort zsort;
+ public void drawScene(Graphics g)
+ {
+ if (zbuffer)
+ {
+ if (zsort == null)
+ {
+ zsort = new Zsort();
+ }
- Bond tmpBond=null;
- for (int i = 0; i < visiblebonds.size(); i++)
- {
- tmpBond = (Bond) visiblebonds.elementAt(i);
+ zsort.Zsort(visiblebonds);
+ }
+ Bond tmpBond = null;
+ for (int i = 0; i < visiblebonds.size(); i++)
+ {
+ tmpBond = (Bond) visiblebonds.elementAt(i);
- xstart = (int) (((tmpBond.start[0] - centre[0]) * scale) +
- (getSize().width / 2));
- ystart = (int) (((tmpBond.start[1] - centre[1]) * scale) +
- (getSize().height / 2));
+ xstart = (int) ( ( (tmpBond.start[0] - centre[0]) * scale) +
+ (getSize().width / 2));
+ ystart = (int) ( ( (tmpBond.start[1] - centre[1]) * scale) +
+ (getSize().height / 2));
- xend = (int) (((tmpBond.end[0] - centre[0]) * scale) +
- (getSize().width / 2));
- yend = (int) (((tmpBond.end[1] - centre[1]) * scale) +
- (getSize().height / 2));
+ xend = (int) ( ( (tmpBond.end[0] - centre[0]) * scale) +
+ (getSize().width / 2));
+ yend = (int) ( ( (tmpBond.end[1] - centre[1]) * scale) +
+ (getSize().height / 2));
- xmid = (xend + xstart) / 2;
- ymid = (yend + ystart) / 2;
+ xmid = (xend + xstart) / 2;
+ ymid = (yend + ystart) / 2;
- if (depthcue && !bymolecule)
- {
- if (tmpBond.start[2] < (centre[2] - (maxwidth / 6))) {
- g.setColor(tmpBond.startCol.darker().darker());
- drawLine(g, xstart, ystart, xmid, ymid);
-
- g.setColor(tmpBond.endCol.darker().darker());
- drawLine(g, xmid, ymid, xend, yend);
- } else if (tmpBond.start[2] < (centre[2] + (maxwidth / 6))) {
- g.setColor(tmpBond.startCol.darker());
- drawLine(g, xstart, ystart, xmid, ymid);
-
- g.setColor(tmpBond.endCol.darker());
- drawLine(g, xmid, ymid, xend, yend);
- } else {
- g.setColor(tmpBond.startCol);
- drawLine(g, xstart, ystart, xmid, ymid);
-
- g.setColor(tmpBond.endCol);
- drawLine(g, xmid, ymid, xend, yend);
- }
-
- } else if (depthcue && bymolecule) {
- if (tmpBond.start[2] < (centre[2] - (maxwidth / 6))) {
- g.setColor(Color.green.darker().darker());
- drawLine(g, xstart, ystart, xend, yend);
- } else if (tmpBond.start[2] < (centre[2] + (maxwidth / 6))) {
- g.setColor(Color.green.darker());
- drawLine(g, xstart, ystart, xend, yend);
- } else {
- g.setColor(Color.green);
- drawLine(g, xstart, ystart, xend, yend);
- }
- } else if (!depthcue && !bymolecule) {
- g.setColor(tmpBond.startCol);
- drawLine(g, xstart, ystart, xmid, ymid);
- g.setColor(tmpBond.endCol);
- drawLine(g, xmid, ymid, xend, yend);
- } else {
- drawLine(g, xstart, ystart, xend, yend);
- }
+ if (depthcue && !bymolecule)
+ {
+ if (tmpBond.start[2] < (centre[2] - (maxwidth / 6)))
+ {
+ g.setColor(tmpBond.startCol.darker().darker());
+ drawLine(g, xstart, ystart, xmid, ymid);
- if(highlightBond1!=null && highlightBond1==tmpBond)
- {
- g.setColor(Color.white);
- drawLine(g, xmid, ymid, xend, yend);
- }
+ g.setColor(tmpBond.endCol.darker().darker());
+ drawLine(g, xmid, ymid, xend, yend);
+ }
+ else if (tmpBond.start[2] < (centre[2] + (maxwidth / 6)))
+ {
+ g.setColor(tmpBond.startCol.darker());
+ drawLine(g, xstart, ystart, xmid, ymid);
- if(highlightBond2!=null && highlightBond2==tmpBond)
- {
- g.setColor(Color.white);
- drawLine(g, xstart, ystart, xmid, ymid);
- }
+ g.setColor(tmpBond.endCol.darker());
+ drawLine(g, xmid, ymid, xend, yend);
+ }
+ else
+ {
+ g.setColor(tmpBond.startCol);
+ drawLine(g, xstart, ystart, xmid, ymid);
+ g.setColor(tmpBond.endCol);
+ drawLine(g, xmid, ymid, xend, yend);
}
- }
- public void drawLine(Graphics g, int x1, int y1, int x2, int y2) {
- if (!wire) {
- if (((float) Math.abs(y2 - y1) / (float) Math.abs(x2 - x1)) < 0.5) {
- g.drawLine(x1, y1, x2, y2);
- g.drawLine(x1 + 1, y1 + 1, x2 + 1, y2 + 1);
- g.drawLine(x1, y1 - 1, x2, y2 - 1);
- } else {
- g.setColor(g.getColor().brighter());
- g.drawLine(x1, y1, x2, y2);
- g.drawLine(x1 + 1, y1, x2 + 1, y2);
- g.drawLine(x1 - 1, y1, x2 - 1, y2);
- }
- } else {
- g.drawLine(x1, y1, x2, y2);
+ }
+ else if (depthcue && bymolecule)
+ {
+ if (tmpBond.start[2] < (centre[2] - (maxwidth / 6)))
+ {
+ g.setColor(Color.green.darker().darker());
+ drawLine(g, xstart, ystart, xend, yend);
}
- }
+ else if (tmpBond.start[2] < (centre[2] + (maxwidth / 6)))
+ {
+ g.setColor(Color.green.darker());
+ drawLine(g, xstart, ystart, xend, yend);
+ }
+ else
+ {
+ g.setColor(Color.green);
+ drawLine(g, xstart, ystart, xend, yend);
+ }
+ }
+ else if (!depthcue && !bymolecule)
+ {
+ g.setColor(tmpBond.startCol);
+ drawLine(g, xstart, ystart, xmid, ymid);
+ g.setColor(tmpBond.endCol);
+ drawLine(g, xmid, ymid, xend, yend);
+ }
+ else
+ {
+ drawLine(g, xstart, ystart, xend, yend);
+ }
- public Dimension minimumsize() {
- return prefsize;
- }
+ if (highlightBond1 != null && highlightBond1 == tmpBond)
+ {
+ g.setColor(Color.white);
+ drawLine(g, xmid, ymid, xend, yend);
+ }
+
+ if (highlightBond2 != null && highlightBond2 == tmpBond)
+ {
+ g.setColor(Color.white);
+ drawLine(g, xstart, ystart, xmid, ymid);
+ }
- public Dimension preferredsize() {
- return prefsize;
}
+ }
- public void doKeyPressed(KeyEvent evt)
+ public void drawLine(Graphics g, int x1, int y1, int x2, int y2)
+ {
+ if (!wire)
{
- if (evt.getKeyCode() == KeyEvent.VK_UP)
+ if ( ( (float) Math.abs(y2 - y1) / (float) Math.abs(x2 - x1)) < 0.5)
{
- scale = (float) (scale * 1.1);
- redrawneeded = true;
- repaint();
+ g.drawLine(x1, y1, x2, y2);
+ g.drawLine(x1 + 1, y1 + 1, x2 + 1, y2 + 1);
+ g.drawLine(x1, y1 - 1, x2, y2 - 1);
}
- else if (evt.getKeyCode() == KeyEvent.VK_DOWN)
+ else
{
- scale = (float) (scale * 0.9);
- redrawneeded = true;
- repaint();
+ g.setColor(g.getColor().brighter());
+ g.drawLine(x1, y1, x2, y2);
+ g.drawLine(x1 + 1, y1, x2 + 1, y2);
+ g.drawLine(x1 - 1, y1, x2 - 1, y2);
}
}
+ else
+ {
+ g.drawLine(x1, y1, x2, y2);
+ }
+ }
- public void mousePressed(MouseEvent e) {
- pdbAction = true;
- Atom fatom = findAtom(e.getX(), e.getY());
- if(fatom!=null)
- {
- fatom.isSelected = !fatom.isSelected;
+ public Dimension minimumsize()
+ {
+ return prefsize;
+ }
- redrawneeded = true;
- repaint();
- if (foundchain != -1)
+ public Dimension preferredsize()
+ {
+ return prefsize;
+ }
+
+ public void doKeyPressed(KeyEvent evt)
+ {
+ if (evt.getKeyCode() == KeyEvent.VK_UP)
+ {
+ scale = (float) (scale * 1.1);
+ redrawneeded = true;
+ repaint();
+ }
+ else if (evt.getKeyCode() == KeyEvent.VK_DOWN)
+ {
+ scale = (float) (scale * 0.9);
+ redrawneeded = true;
+ repaint();
+ }
+ }
+
+ public void mousePressed(MouseEvent e)
+ {
+ pdbAction = true;
+ Atom fatom = findAtom(e.getX(), e.getY());
+ if (fatom != null)
+ {
+ fatom.isSelected = !fatom.isSelected;
+
+ redrawneeded = true;
+ repaint();
+ if (foundchain != -1)
+ {
+ PDBChain chain = (PDBChain) pdb.chains.elementAt(foundchain);
+ if (chain == mainchain)
{
- PDBChain chain = (PDBChain) pdb.chains.elementAt(foundchain);
- if (chain == mainchain)
+ if (fatom.alignmentMapping != -1)
{
- if (fatom.alignmentMapping != -1)
+ if (highlightRes == null)
{
- if (highlightRes == null)
- highlightRes = new Vector();
+ highlightRes = new Vector();
+ }
- if (highlightRes.contains(fatom.alignmentMapping+"" + ""))
- highlightRes.removeElement(fatom.alignmentMapping + "");
- else
- highlightRes.addElement(fatom.alignmentMapping + "");
+ if (highlightRes.contains(fatom.alignmentMapping + "" + ""))
+ {
+ highlightRes.removeElement(fatom.alignmentMapping + "");
+ }
+ else
+ {
+ highlightRes.addElement(fatom.alignmentMapping + "");
}
}
}
+ }
- }
- mx = e.getX();
- my = e.getY();
- omx = mx;
- omy = my;
- dragging = false;
}
+ mx = e.getX();
+ my = e.getY();
+ omx = mx;
+ omy = my;
+ dragging = false;
+ }
+
+ public void mouseMoved(MouseEvent e)
+ {
+ pdbAction = true;
+ if (highlightBond1 != null)
+ {
+ highlightBond1.at2.isSelected = false;
+ highlightBond2.at1.isSelected = false;
+ highlightBond1 = null;
+ highlightBond2 = null;
+ }
+
+ Atom fatom = findAtom(e.getX(), e.getY());
- public void mouseMoved(MouseEvent e) {
- pdbAction = true;
- if(highlightBond1!=null)
+ PDBChain chain = null;
+ if (foundchain != -1)
+ {
+ chain = (PDBChain) pdb.chains.elementAt(foundchain);
+ if (chain == mainchain)
{
- highlightBond1.at2.isSelected = false;
- highlightBond2.at1.isSelected = false;
- highlightBond1 = null;
- highlightBond2 = null;
+ highlightSeqcanvas(fatom.alignmentMapping);
}
+ }
- Atom fatom = findAtom(e.getX(), e.getY());
-
- PDBChain chain = null;
- if(foundchain!=-1)
- {
- chain = (PDBChain) pdb.chains.elementAt(foundchain);
- if(chain == mainchain)
- {
- highlightSeqcanvas( fatom.alignmentMapping );
- }
- }
+ if (fatom != null)
+ {
+ toolx = e.getX();
+ tooly = e.getY();
- if (fatom != null) {
- toolx = e.getX();
- tooly = e.getY();
-
- appletToolTip = chain.id+":"+ fatom.resNumber+" "+ fatom.resName;
- redrawneeded = true;
- repaint();
- } else {
- highlightSeqcanvas( -1);
- appletToolTip = null;
- redrawneeded = true;
- repaint();
- }
+ appletToolTip = chain.id + ":" + fatom.resNumber + " " + fatom.resName;
+ redrawneeded = true;
+ repaint();
}
+ else
+ {
+ highlightSeqcanvas( -1);
+ appletToolTip = null;
+ redrawneeded = true;
+ repaint();
+ }
+ }
-
- void highlightSeqcanvas(int pos)
+ void highlightSeqcanvas(int pos)
+ {
+ SearchResults searchResults = new SearchResults();
+ if (highlightRes != null)
{
- SearchResults searchResults = new SearchResults();
- if(highlightRes!=null)
+ for (int i = 0; i < highlightRes.size(); i++)
{
- for (int i = 0; i < highlightRes.size(); i++)
- {
- int a = Integer.parseInt(highlightRes.elementAt(
- i).toString())+1;
+ int a = Integer.parseInt(highlightRes.elementAt(
+ i).toString()) + 1;
- searchResults.addResult(sequence, a, a);
- }
- }
-
- if(pos!=-1)
- {
- searchResults.addResult(sequence, pos+1, pos+1);
+ searchResults.addResult(sequence, a, a);
}
+ }
- seqcanvas.highlightSearchResults(searchResults);
+ if (pos != -1)
+ {
+ searchResults.addResult(sequence, pos + 1, pos + 1);
}
+ seqcanvas.highlightSearchResults(searchResults);
+ }
- public void mouseClicked(MouseEvent e) {
- }
+ public void mouseClicked(MouseEvent e)
+ {
+ }
- public void mouseEntered(MouseEvent e) {
- }
+ public void mouseEntered(MouseEvent e)
+ {
+ }
- public void mouseExited(MouseEvent e) {
- }
+ public void mouseExited(MouseEvent e)
+ {
+ }
- public void mouseDragged(MouseEvent evt) {
- int x = evt.getX();
- int y = evt.getY();
- mx = x;
- my = y;
+ public void mouseDragged(MouseEvent evt)
+ {
+ int x = evt.getX();
+ int y = evt.getY();
+ mx = x;
+ my = y;
- MCMatrix objmat = new MCMatrix(3, 3);
- objmat.setIdentity();
+ MCMatrix objmat = new MCMatrix(3, 3);
+ objmat.setIdentity();
- if ((evt.getModifiers() & Event.META_MASK) != 0) {
- objmat.rotatez((float) ((mx - omx)));
- } else {
- objmat.rotatex((float) ((my - omy)));
- objmat.rotatey((float) ((omx - mx)));
- }
+ if ( (evt.getModifiers() & Event.META_MASK) != 0)
+ {
+ objmat.rotatez( (float) ( (mx - omx)));
+ }
+ else
+ {
+ objmat.rotatex( (float) ( (my - omy)));
+ objmat.rotatey( (float) ( (omx - mx)));
+ }
- //Alter the bonds
- for (int ii = 0; ii < pdb.chains.size(); ii++) {
- Vector bonds = ((PDBChain) pdb.chains.elementAt(ii)).bonds;
+ //Alter the bonds
+ for (int ii = 0; ii < pdb.chains.size(); ii++)
+ {
+ Vector bonds = ( (PDBChain) pdb.chains.elementAt(ii)).bonds;
- for (int i = 0; i < bonds.size(); i++) {
- Bond tmpBond = (Bond) bonds.elementAt(i);
+ for (int i = 0; i < bonds.size(); i++)
+ {
+ Bond tmpBond = (Bond) bonds.elementAt(i);
- //Translate the bond so the centre is 0,0,0
- tmpBond.translate(-centre[0], -centre[1], -centre[2]);
+ //Translate the bond so the centre is 0,0,0
+ tmpBond.translate( -centre[0], -centre[1], -centre[2]);
- //Now apply the rotation matrix
- tmpBond.start = objmat.vectorMultiply(tmpBond.start);
- tmpBond.end = objmat.vectorMultiply(tmpBond.end);
+ //Now apply the rotation matrix
+ tmpBond.start = objmat.vectorMultiply(tmpBond.start);
+ tmpBond.end = objmat.vectorMultiply(tmpBond.end);
- //Now translate back again
- tmpBond.translate(centre[0], centre[1], centre[2]);
- }
- }
+ //Now translate back again
+ tmpBond.translate(centre[0], centre[1], centre[2]);
+ }
+ }
- objmat = null;
+ objmat = null;
- omx = mx;
- omy = my;
+ omx = mx;
+ omy = my;
- dragging = true;
+ dragging = true;
- redrawneeded = true;
+ redrawneeded = true;
- repaint();
- }
+ repaint();
+ }
- public void mouseReleased(MouseEvent evt) {
- dragging = false;
- return;
- }
+ public void mouseReleased(MouseEvent evt)
+ {
+ dragging = false;
+ return;
+ }
- void drawLabels(Graphics g) {
+ void drawLabels(Graphics g)
+ {
- for (int ii = 0; ii < pdb.chains.size(); ii++)
- {
- PDBChain chain = (PDBChain) pdb.chains.elementAt(ii);
+ for (int ii = 0; ii < pdb.chains.size(); ii++)
+ {
+ PDBChain chain = (PDBChain) pdb.chains.elementAt(ii);
- if (chain.isVisible)
- {
- Vector bonds = ((PDBChain) pdb.chains.elementAt(ii)).bonds;
+ if (chain.isVisible)
+ {
+ Vector bonds = ( (PDBChain) pdb.chains.elementAt(ii)).bonds;
- for (int i = 0; i < bonds.size(); i++)
- {
- Bond tmpBond = (Bond) bonds.elementAt(i);
+ for (int i = 0; i < bonds.size(); i++)
+ {
+ Bond tmpBond = (Bond) bonds.elementAt(i);
- if (tmpBond.at1.isSelected)
- {
- labelAtom(g, tmpBond, 1);
- }
+ if (tmpBond.at1.isSelected)
+ {
+ labelAtom(g, tmpBond, 1);
+ }
- if (tmpBond.at2.isSelected)
- {
+ if (tmpBond.at2.isSelected)
+ {
- labelAtom(g, tmpBond, 2);
- }
- }
- }
+ labelAtom(g, tmpBond, 2);
+ }
}
+ }
}
+ }
- public void labelAtom(Graphics g, Bond b, int n) {
- g.setFont(font);
+ public void labelAtom(Graphics g, Bond b, int n)
+ {
+ g.setFont(font);
- if (n == 1) {
- int xstart = (int) (((b.start[0] - centre[0]) * scale) +
- (getSize().width / 2));
- int ystart = (int) (((b.start[1] - centre[1]) * scale) +
- (getSize().height / 2));
+ if (n == 1)
+ {
+ int xstart = (int) ( ( (b.start[0] - centre[0]) * scale) +
+ (getSize().width / 2));
+ int ystart = (int) ( ( (b.start[1] - centre[1]) * scale) +
+ (getSize().height / 2));
- g.setColor(Color.red);
- g.drawString(b.at1.resName + "-" + b.at1.resNumber, xstart, ystart);
- }
+ g.setColor(Color.red);
+ g.drawString(b.at1.resName + "-" + b.at1.resNumber, xstart, ystart);
+ }
- if (n == 2) {
- int xstart = (int) (((b.end[0] - centre[0]) * scale) +
- (getSize().width / 2));
- int ystart = (int) (((b.end[1] - centre[1]) * scale) +
- (getSize().height / 2));
+ if (n == 2)
+ {
+ int xstart = (int) ( ( (b.end[0] - centre[0]) * scale) +
+ (getSize().width / 2));
+ int ystart = (int) ( ( (b.end[1] - centre[1]) * scale) +
+ (getSize().height / 2));
- g.setColor(Color.red);
- g.drawString(b.at2.resName + "-" + b.at2.resNumber, xstart, ystart);
- }
+ g.setColor(Color.red);
+ g.drawString(b.at2.resName + "-" + b.at2.resNumber, xstart, ystart);
}
+ }
- int foundchain = -1;
- public Atom findAtom(int x, int y) {
- Atom fatom = null;
+ int foundchain = -1;
+ public Atom findAtom(int x, int y)
+ {
+ Atom fatom = null;
- foundchain = -1;
+ foundchain = -1;
- for (int ii = 0; ii < pdb.chains.size(); ii++)
+ for (int ii = 0; ii < pdb.chains.size(); ii++)
+ {
+ PDBChain chain = (PDBChain) pdb.chains.elementAt(ii);
+ int truex;
+ Bond tmpBond = null;
+
+ if (chain.isVisible)
+ {
+ Vector bonds = ( (PDBChain) pdb.chains.elementAt(ii)).bonds;
+
+ for (int i = 0; i < bonds.size(); i++)
{
- PDBChain chain = (PDBChain) pdb.chains.elementAt(ii);
- int truex;
- Bond tmpBond=null;
+ tmpBond = (Bond) bonds.elementAt(i);
- if (chain.isVisible)
- {
- Vector bonds = ((PDBChain) pdb.chains.elementAt(ii)).bonds;
-
- for (int i = 0; i < bonds.size(); i++)
- {
- tmpBond = (Bond) bonds.elementAt(i);
-
- truex = (int) (((tmpBond.start[0] - centre[0]) * scale) +
- (getSize().width / 2));
-
- if (Math.abs(truex - x) <= 2)
- {
- int truey = (int) (((tmpBond.start[1] - centre[1]) * scale) +
- (getSize().height / 2));
-
- if (Math.abs(truey - y) <= 2)
- {
- fatom = tmpBond.at1;
- foundchain = ii;
- break;
- }
- }
- }
-
- // Still here? Maybe its the last bond
-
- truex = (int) ( ( (tmpBond.end[0] - centre[0]) * scale) +
- (getSize().width / 2));
-
- if (Math.abs(truex - x) <= 2)
- {
- int truey = (int) ( ( (tmpBond.end[1] - centre[1]) * scale) +
- (getSize().height / 2));
-
- if (Math.abs(truey - y) <= 2)
- {
- fatom = tmpBond.at2;
- foundchain = ii;
- break;
- }
- }
+ truex = (int) ( ( (tmpBond.start[0] - centre[0]) * scale) +
+ (getSize().width / 2));
- }
+ if (Math.abs(truex - x) <= 2)
+ {
+ int truey = (int) ( ( (tmpBond.start[1] - centre[1]) * scale) +
+ (getSize().height / 2));
- if (fatom != null) //)&& chain.ds != null)
- {
- chain = (PDBChain) pdb.chains.elementAt(foundchain);
+ if (Math.abs(truey - y) <= 2)
+ {
+ fatom = tmpBond.at1;
+ foundchain = ii;
+ break;
}
+ }
}
- return fatom;
- }
+ // Still here? Maybe its the last bond
- public void update(Graphics g)
- {
- paint(g);
+ truex = (int) ( ( (tmpBond.end[0] - centre[0]) * scale) +
+ (getSize().width / 2));
+
+ if (Math.abs(truex - x) <= 2)
+ {
+ int truey = (int) ( ( (tmpBond.end[1] - centre[1]) * scale) +
+ (getSize().height / 2));
+
+ if (Math.abs(truey - y) <= 2)
+ {
+ fatom = tmpBond.at2;
+ foundchain = ii;
+ break;
+ }
+ }
+
+ }
+
+ if (fatom != null) //)&& chain.ds != null)
+ {
+ chain = (PDBChain) pdb.chains.elementAt(foundchain);
+ }
}
- public void highlightRes(int ii)
- {
- if(!seqColoursReady)
- return;
+ return fatom;
+ }
- if (highlightRes != null
- && highlightRes.contains((ii-1) + ""))
- {
- return;
- }
+ public void update(Graphics g)
+ {
+ paint(g);
+ }
- int index = -1;
- Bond tmpBond;
- for(index=0; index<mainchain.bonds.size(); index++)
- {
- tmpBond = (Bond) mainchain.bonds.elementAt(index);
- if (tmpBond.at1.alignmentMapping == ii - 1)
- {
- if (highlightBond1 != null)
- highlightBond1.at2.isSelected = false;
+ public void highlightRes(int ii)
+ {
+ if (!seqColoursReady)
+ {
+ return;
+ }
- if (highlightBond2 != null)
- highlightBond2.at1.isSelected = false;
+ if (highlightRes != null
+ && highlightRes.contains( (ii - 1) + ""))
+ {
+ return;
+ }
- highlightBond1 = null;
- highlightBond2 = null;
+ int index = -1;
+ Bond tmpBond;
+ for (index = 0; index < mainchain.bonds.size(); index++)
+ {
+ tmpBond = (Bond) mainchain.bonds.elementAt(index);
+ if (tmpBond.at1.alignmentMapping == ii - 1)
+ {
+ if (highlightBond1 != null)
+ {
+ highlightBond1.at2.isSelected = false;
+ }
- if (index > 0)
- {
- highlightBond1 = (Bond) mainchain.bonds.elementAt(index - 1);
- highlightBond1.at2.isSelected = true;
- }
+ if (highlightBond2 != null)
+ {
+ highlightBond2.at1.isSelected = false;
+ }
- if (index != mainchain.bonds.size())
- {
- highlightBond2 = (Bond) mainchain.bonds.elementAt(index);
- highlightBond2.at1.isSelected = true;
- }
+ highlightBond1 = null;
+ highlightBond2 = null;
- break;
- }
- }
+ if (index > 0)
+ {
+ highlightBond1 = (Bond) mainchain.bonds.elementAt(index - 1);
+ highlightBond1.at2.isSelected = true;
+ }
+
+ if (index != mainchain.bonds.size())
+ {
+ highlightBond2 = (Bond) mainchain.bonds.elementAt(index);
+ highlightBond2.at1.isSelected = true;
+ }
- redrawneeded = true;
- repaint();
- }
+ break;
+ }
+ }
+ redrawneeded = true;
+ repaint();
+ }
- public void setAllchainsVisible(boolean b)
+ public void setAllchainsVisible(boolean b)
+ {
+ for (int ii = 0; ii < pdb.chains.size(); ii++)
{
- for (int ii = 0; ii < pdb.chains.size(); ii++)
- {
- PDBChain chain = (PDBChain) pdb.chains.elementAt(ii);
- chain.isVisible = b;
- }
- mainchain.isVisible = true;
- findCentre();
- setupBonds();
+ PDBChain chain = (PDBChain) pdb.chains.elementAt(ii);
+ chain.isVisible = b;
}
+ mainchain.isVisible = true;
+ findCentre();
+ setupBonds();
+ }
}
/*\r
* Jalview - A Sequence Alignment Editor and Viewer\r
- * Copyright (C) 2006 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle\r
+ * Copyright (C) 2007 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle\r
*\r
* This program is free software; you can redistribute it and/or\r
* modify it under the terms of the GNU General Public License\r
package MCview;\r
\r
import java.awt.*;\r
-\r
import java.awt.event.*;\r
-import jalview.datamodel.*;\r
+\r
import jalview.appletgui.*;\r
+import jalview.datamodel.*;\r
import jalview.schemes.*;\r
-import java.awt.event.ActionListener;\r
-import java.awt.event.ActionEvent;\r
-\r
\r
-public class AppletPDBViewer extends Frame implements ActionListener, ItemListener\r
+public class AppletPDBViewer\r
+ extends Frame implements ActionListener, ItemListener\r
{\r
- AppletPDBCanvas pdbcanvas;\r
- public AppletPDBViewer(String pdbtext,String type,\r
- Sequence seq,\r
- SeqCanvas seqcanvas)\r
- {\r
+ AppletPDBCanvas pdbcanvas;\r
+ public AppletPDBViewer(String pdbtext, String type,\r
+ Sequence seq,\r
+ SeqCanvas seqcanvas)\r
+ {\r
\r
- try\r
- {\r
- jbInit();\r
- }\r
- catch (Exception ex)\r
- {\r
- ex.printStackTrace();\r
- }\r
+ try\r
+ {\r
+ jbInit();\r
+ }\r
+ catch (Exception ex)\r
+ {\r
+ ex.printStackTrace();\r
+ }\r
\r
- pdbcanvas = new AppletPDBCanvas(seqcanvas, seq);\r
+ pdbcanvas = new AppletPDBCanvas(seqcanvas, seq);\r
\r
- add(pdbcanvas, BorderLayout.CENTER);\r
+ add(pdbcanvas, BorderLayout.CENTER);\r
\r
- StringBuffer title = new StringBuffer(seq.getName() + ":");\r
+ StringBuffer title = new StringBuffer(seq.getName() + ":");\r
\r
- jalview.bin.JalviewLite.addFrame(this,title.toString(),400, 400);\r
+ jalview.bin.JalviewLite.addFrame(this, title.toString(), 400, 400);\r
\r
- try{\r
- PDBfile pdbfile = new PDBfile(pdbtext, type);\r
- pdbcanvas.setPDBFile(pdbfile);\r
- }\r
- catch(Exception ex){\r
- ex.printStackTrace();\r
- pdbcanvas.errorLoading = true;\r
- pdbcanvas.repaint();\r
- }\r
- }\r
-\r
- public void actionPerformed(ActionEvent evt)\r
- {\r
- if(evt.getSource()==mapping)\r
- mapping_actionPerformed();\r
- else if(evt.getSource()==wire)\r
- wire_actionPerformed();\r
- else if(evt.getSource()==depth)\r
- depth_actionPerformed();\r
- else if(evt.getSource()==zbuffer)\r
- zbuffer_actionPerformed();\r
- else if(evt.getSource()==charge)\r
- charge_actionPerformed();\r
+ try\r
+ {\r
+ PDBfile pdbfile = new PDBfile(pdbtext, type);\r
+ pdbcanvas.setPDBFile(pdbfile);\r
+ }\r
+ catch (Exception ex)\r
+ {\r
+ ex.printStackTrace();\r
+ pdbcanvas.errorLoading = true;\r
+ pdbcanvas.repaint();\r
+ }\r
+ }\r
\r
- else if(evt.getSource()==chain)\r
- chain_actionPerformed();\r
- else if(evt.getSource()==seqButton)\r
- seqButton_actionPerformed();\r
- else if(evt.getSource()==zappo)\r
- pdbcanvas.setColours(new ZappoColourScheme());\r
- else if(evt.getSource()==taylor)\r
- pdbcanvas.setColours(new TaylorColourScheme());\r
- else if(evt.getSource()==hydro)\r
- pdbcanvas.setColours(new HydrophobicColourScheme());\r
- else if(evt.getSource()==helix)\r
- pdbcanvas.setColours(new HelixColourScheme());\r
- else if(evt.getSource()==strand)\r
- pdbcanvas.setColours(new StrandColourScheme());\r
- else if(evt.getSource()==turn)\r
- pdbcanvas.setColours(new TurnColourScheme());\r
- else if(evt.getSource()==buried)\r
- pdbcanvas.setColours(new BuriedColourScheme());\r
- else if(evt.getSource()==user)\r
- {\r
- pdbcanvas.bysequence = false;\r
- new jalview.appletgui.UserDefinedColours(pdbcanvas);\r
- }\r
- }\r
+ public void actionPerformed(ActionEvent evt)\r
+ {\r
+ if (evt.getSource() == mapping)\r
+ {\r
+ mapping_actionPerformed();\r
+ }\r
+ else if (evt.getSource() == wire)\r
+ {\r
+ wire_actionPerformed();\r
+ }\r
+ else if (evt.getSource() == depth)\r
+ {\r
+ depth_actionPerformed();\r
+ }\r
+ else if (evt.getSource() == zbuffer)\r
+ {\r
+ zbuffer_actionPerformed();\r
+ }\r
+ else if (evt.getSource() == charge)\r
+ {\r
+ charge_actionPerformed();\r
+ }\r
\r
- public void itemStateChanged(ItemEvent evt)\r
- {\r
- if (evt.getSource() == allchains)\r
- allchains_itemStateChanged();\r
- else if (evt.getSource() == wire)\r
- wire_actionPerformed();\r
- else if (evt.getSource() == depth)\r
- depth_actionPerformed();\r
- else if (evt.getSource() == zbuffer)\r
- zbuffer_actionPerformed();\r
- }\r
+ else if (evt.getSource() == chain)\r
+ {\r
+ chain_actionPerformed();\r
+ }\r
+ else if (evt.getSource() == seqButton)\r
+ {\r
+ seqButton_actionPerformed();\r
+ }\r
+ else if (evt.getSource() == zappo)\r
+ {\r
+ pdbcanvas.setColours(new ZappoColourScheme());\r
+ }\r
+ else if (evt.getSource() == taylor)\r
+ {\r
+ pdbcanvas.setColours(new TaylorColourScheme());\r
+ }\r
+ else if (evt.getSource() == hydro)\r
+ {\r
+ pdbcanvas.setColours(new HydrophobicColourScheme());\r
+ }\r
+ else if (evt.getSource() == helix)\r
+ {\r
+ pdbcanvas.setColours(new HelixColourScheme());\r
+ }\r
+ else if (evt.getSource() == strand)\r
+ {\r
+ pdbcanvas.setColours(new StrandColourScheme());\r
+ }\r
+ else if (evt.getSource() == turn)\r
+ {\r
+ pdbcanvas.setColours(new TurnColourScheme());\r
+ }\r
+ else if (evt.getSource() == buried)\r
+ {\r
+ pdbcanvas.setColours(new BuriedColourScheme());\r
+ }\r
+ else if (evt.getSource() == user)\r
+ {\r
+ pdbcanvas.bysequence = false;\r
+ new jalview.appletgui.UserDefinedColours(pdbcanvas);\r
+ }\r
+ }\r
\r
+ public void itemStateChanged(ItemEvent evt)\r
+ {\r
+ if (evt.getSource() == allchains)\r
+ {\r
+ allchains_itemStateChanged();\r
+ }\r
+ else if (evt.getSource() == wire)\r
+ {\r
+ wire_actionPerformed();\r
+ }\r
+ else if (evt.getSource() == depth)\r
+ {\r
+ depth_actionPerformed();\r
+ }\r
+ else if (evt.getSource() == zbuffer)\r
+ {\r
+ zbuffer_actionPerformed();\r
+ }\r
+ }\r
\r
- private void jbInit()\r
- throws Exception\r
- {\r
- setMenuBar(jMenuBar1);\r
- fileMenu.setLabel("File");\r
- coloursMenu.setLabel("Colours");\r
- mapping.setLabel("View Mapping");\r
- mapping.addActionListener(this);\r
- wire.setLabel("Wireframe");\r
- wire.addItemListener(this);\r
- depth.setState(true);\r
- depth.setLabel("Depthcue");\r
- depth.addItemListener(this);\r
- zbuffer.setState(true);\r
- zbuffer.setLabel("Z Buffering");\r
- zbuffer.addItemListener(this);\r
- charge.setLabel("Charge & Cysteine");\r
- charge.addActionListener(this);\r
- hydro.setLabel("Hydrophobicity");\r
- hydro.addActionListener(this);\r
- chain.setLabel("By Chain");\r
- chain.addActionListener(this);\r
- seqButton.setLabel("By Sequence");\r
- seqButton.addActionListener(this);\r
+ private void jbInit()\r
+ throws Exception\r
+ {\r
+ setMenuBar(jMenuBar1);\r
+ fileMenu.setLabel("File");\r
+ coloursMenu.setLabel("Colours");\r
+ mapping.setLabel("View Mapping");\r
+ mapping.addActionListener(this);\r
+ wire.setLabel("Wireframe");\r
+ wire.addItemListener(this);\r
+ depth.setState(true);\r
+ depth.setLabel("Depthcue");\r
+ depth.addItemListener(this);\r
+ zbuffer.setState(true);\r
+ zbuffer.setLabel("Z Buffering");\r
+ zbuffer.addItemListener(this);\r
+ charge.setLabel("Charge & Cysteine");\r
+ charge.addActionListener(this);\r
+ hydro.setLabel("Hydrophobicity");\r
+ hydro.addActionListener(this);\r
+ chain.setLabel("By Chain");\r
+ chain.addActionListener(this);\r
+ seqButton.setLabel("By Sequence");\r
+ seqButton.addActionListener(this);\r
allchains.setLabel("All Chains Visible");\r
allchains.addItemListener(this);\r
viewMenu.setLabel("View");\r
user.setLabel("User Defined...");\r
user.addActionListener(this);\r
jMenuBar1.add(fileMenu);\r
- jMenuBar1.add(coloursMenu);\r
+ jMenuBar1.add(coloursMenu);\r
jMenuBar1.add(viewMenu);\r
- fileMenu.add(mapping);;\r
+ fileMenu.add(mapping); ;\r
\r
- coloursMenu.add(seqButton);\r
- coloursMenu.add(chain);\r
+ coloursMenu.add(seqButton);\r
+ coloursMenu.add(chain);\r
coloursMenu.add(charge);\r
coloursMenu.add(zappo);\r
coloursMenu.add(taylor);\r
allchains.setState(true);\r
}\r
\r
- MenuBar jMenuBar1 = new MenuBar();\r
- Menu fileMenu = new Menu();\r
- Menu coloursMenu = new Menu();\r
- MenuItem mapping = new MenuItem();\r
- CheckboxGroup bg = new CheckboxGroup();\r
- CheckboxMenuItem wire = new CheckboxMenuItem();\r
- CheckboxMenuItem depth = new CheckboxMenuItem();\r
- CheckboxMenuItem zbuffer = new CheckboxMenuItem();\r
+ MenuBar jMenuBar1 = new MenuBar();\r
+ Menu fileMenu = new Menu();\r
+ Menu coloursMenu = new Menu();\r
+ MenuItem mapping = new MenuItem();\r
+ CheckboxGroup bg = new CheckboxGroup();\r
+ CheckboxMenuItem wire = new CheckboxMenuItem();\r
+ CheckboxMenuItem depth = new CheckboxMenuItem();\r
+ CheckboxMenuItem zbuffer = new CheckboxMenuItem();\r
\r
- MenuItem charge = new MenuItem();\r
- MenuItem hydro = new MenuItem();\r
- MenuItem chain = new MenuItem();\r
- MenuItem seqButton = new MenuItem();\r
+ MenuItem charge = new MenuItem();\r
+ MenuItem hydro = new MenuItem();\r
+ MenuItem chain = new MenuItem();\r
+ MenuItem seqButton = new MenuItem();\r
\r
- CheckboxMenuItem allchains = new CheckboxMenuItem();\r
+ CheckboxMenuItem allchains = new CheckboxMenuItem();\r
Menu viewMenu = new Menu();\r
MenuItem turn = new MenuItem();\r
MenuItem strand = new MenuItem();\r
MenuItem user = new MenuItem();\r
\r
public void charge_actionPerformed()\r
- {\r
- pdbcanvas.bysequence = false;\r
- pdbcanvas.pdb.setChargeColours();\r
- pdbcanvas.redrawneeded=true;\r
- pdbcanvas.repaint();\r
- }\r
-\r
- public void chain_actionPerformed()\r
- {\r
- pdbcanvas.bysequence = false;\r
- pdbcanvas.pdb.setChainColours();\r
- pdbcanvas.redrawneeded=true;\r
- pdbcanvas.repaint();\r
- }\r
+ {\r
+ pdbcanvas.bysequence = false;\r
+ pdbcanvas.pdb.setChargeColours();\r
+ pdbcanvas.redrawneeded = true;\r
+ pdbcanvas.repaint();\r
+ }\r
\r
- public void zbuffer_actionPerformed()\r
- {\r
- pdbcanvas.zbuffer = ! pdbcanvas.zbuffer;\r
- pdbcanvas.redrawneeded=true;\r
- pdbcanvas.repaint();\r
- }\r
+ public void chain_actionPerformed()\r
+ {\r
+ pdbcanvas.bysequence = false;\r
+ pdbcanvas.pdb.setChainColours();\r
+ pdbcanvas.redrawneeded = true;\r
+ pdbcanvas.repaint();\r
+ }\r
\r
- public void depth_actionPerformed()\r
- {\r
- pdbcanvas.depthcue = ! pdbcanvas.depthcue;\r
- pdbcanvas.redrawneeded=true;\r
- pdbcanvas.repaint();\r
- }\r
+ public void zbuffer_actionPerformed()\r
+ {\r
+ pdbcanvas.zbuffer = !pdbcanvas.zbuffer;\r
+ pdbcanvas.redrawneeded = true;\r
+ pdbcanvas.repaint();\r
+ }\r
\r
- public void wire_actionPerformed()\r
- {\r
- pdbcanvas.wire = ! pdbcanvas.wire;\r
- pdbcanvas.redrawneeded=true;\r
- pdbcanvas.repaint();\r
- }\r
+ public void depth_actionPerformed()\r
+ {\r
+ pdbcanvas.depthcue = !pdbcanvas.depthcue;\r
+ pdbcanvas.redrawneeded = true;\r
+ pdbcanvas.repaint();\r
+ }\r
\r
- public void seqButton_actionPerformed()\r
- {\r
- pdbcanvas.bysequence = true;\r
- pdbcanvas.updateSeqColours();\r
- pdbcanvas.repaint();\r
- }\r
+ public void wire_actionPerformed()\r
+ {\r
+ pdbcanvas.wire = !pdbcanvas.wire;\r
+ pdbcanvas.redrawneeded = true;\r
+ pdbcanvas.repaint();\r
+ }\r
\r
+ public void seqButton_actionPerformed()\r
+ {\r
+ pdbcanvas.bysequence = true;\r
+ pdbcanvas.updateSeqColours();\r
+ pdbcanvas.repaint();\r
+ }\r
\r
- public void mapping_actionPerformed()\r
- {\r
- jalview.appletgui.CutAndPasteTransfer cap\r
- = new jalview.appletgui.CutAndPasteTransfer(false, null);\r
- Frame frame = new Frame();\r
- frame.add(cap);\r
- jalview.bin.JalviewLite.addFrame(frame, "PDB - Sequence Mapping", 500, 600);\r
- cap.setText(pdbcanvas.mappingDetails.toString());\r
- }\r
+ public void mapping_actionPerformed()\r
+ {\r
+ jalview.appletgui.CutAndPasteTransfer cap\r
+ = new jalview.appletgui.CutAndPasteTransfer(false, null);\r
+ Frame frame = new Frame();\r
+ frame.add(cap);\r
+ jalview.bin.JalviewLite.addFrame(frame, "PDB - Sequence Mapping", 500, 600);\r
+ cap.setText(pdbcanvas.mappingDetails.toString());\r
+ }\r
\r
- public void allchains_itemStateChanged()\r
- {\r
- pdbcanvas.setAllchainsVisible(allchains.getState());\r
- }\r
+ public void allchains_itemStateChanged()\r
+ {\r
+ pdbcanvas.setAllchainsVisible(allchains.getState());\r
+ }\r
\r
}\r
/*
-* Jalview - A Sequence Alignment Editor and Viewer
-* Copyright (C) 2006 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle
-*
-* This program is free software; you can redistribute it and/or
-* modify it under the terms of the GNU General Public License
-* as published by the Free Software Foundation; either version 2
-* of the License, or (at your option) any later version.
-*
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with this program; if not, write to the Free Software
-* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
-*/
+ * Jalview - A Sequence Alignment Editor and Viewer
+ * Copyright (C) 2007 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+ */
package MCview;
import java.awt.*;
+public class Atom
+{
+ public float x;
+ public float y;
+ public float z;
+ public int number;
+ public String name;
+ public String resName;
+ public int resNumber;
+ public char insCode = ' ';
+ public String resNumIns = null;
+ public int type;
+ Color color = Color.lightGray;
+ public String chain;
+ int alignmentMapping = -1;
-public class Atom {
- public float x;
- public float y;
- public float z;
- public int number;
- public String name;
- public String resName;
- public int resNumber;
- public char insCode=' ';
- public String resNumIns=null;
- public int type;
- Color color = Color.lightGray;
- public String chain;
- int alignmentMapping=-1;
+ public boolean isSelected = false;
- public boolean isSelected = false;
+ public Atom(String str)
+ {
+ name = str.substring(12, 15).trim();
- public Atom(String str)
- {
- name = str.substring(12,15).trim();
+ resName = str.substring(17, 20);
- resName = str.substring(17,20);
+ chain = str.substring(21, 22);
- chain = str.substring(21,22);
+ resNumber = Integer.parseInt(str.substring(22, 26).trim());
+ resNumIns = str.substring(22, 27);
+ insCode = str.substring(26, 27).charAt(0);
+ this.x = (float) (new Float(str.substring(30, 38).trim()).floatValue());
+ this.y = (float) (new Float(str.substring(38, 46).trim()).floatValue());
+ this.z = (float) (new Float(str.substring(47, 55).trim()).floatValue());
- resNumber = Integer.parseInt(str.substring(22,26).trim());
- resNumIns=str.substring(22,27);
- insCode = str.substring(26,27).charAt(0);
- this.x = (float) (new Float(str.substring(30,38).trim()).floatValue());
- this.y = (float) (new Float(str.substring(38,46).trim()).floatValue());
- this.z = (float) (new Float(str.substring(47,55).trim()).floatValue());
+ }
- }
- public Atom(float x,float y, float z) {
- this.x = x;
- this.y = y;
- this.z = z;
- }
+ public Atom(float x, float y, float z)
+ {
+ this.x = x;
+ this.y = y;
+ this.z = z;
+ }
// public void setColor(Color col) {
// this.color = col;
// }
/*\r
-* Jalview - A Sequence Alignment Editor and Viewer\r
-* Copyright (C) 2006 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle\r
-*\r
-* This program is free software; you can redistribute it and/or\r
-* modify it under the terms of the GNU General Public License\r
-* as published by the Free Software Foundation; either version 2\r
-* of the License, or (at your option) any later version.\r
-*\r
-* This program is distributed in the hope that it will be useful,\r
-* but WITHOUT ANY WARRANTY; without even the implied warranty of\r
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
-* GNU General Public License for more details.\r
-*\r
-* You should have received a copy of the GNU General Public License\r
-* along with this program; if not, write to the Free Software\r
-* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA\r
-*/\r
+ * Jalview - A Sequence Alignment Editor and Viewer\r
+ * Copyright (C) 2007 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle\r
+ *\r
+ * This program is free software; you can redistribute it and/or\r
+ * modify it under the terms of the GNU General Public License\r
+ * as published by the Free Software Foundation; either version 2\r
+ * of the License, or (at your option) any later version.\r
+ *\r
+ * This program is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
+ * GNU General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU General Public License\r
+ * along with this program; if not, write to the Free Software\r
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA\r
+ */\r
package MCview;\r
\r
import java.awt.*;\r
\r
+public class Bond\r
+{\r
+ float[] start;\r
+ float[] end;\r
+ Color startCol = Color.lightGray;\r
+ Color endCol = Color.lightGray;\r
+ public Atom at1;\r
+ public Atom at2;\r
\r
-public class Bond {\r
- float[] start;\r
- float[] end;\r
- Color startCol = Color.lightGray;\r
- Color endCol= Color.lightGray;\r
- public Atom at1;\r
- public Atom at2;\r
-\r
- public Bond(float[] start, float[] end, Atom at1, Atom at2) {\r
- this.start = start;\r
- this.end = end;\r
- this.startCol = at1.color;\r
- this.endCol = at2.color;\r
- this.at1 = at1;\r
- this.at2 = at2;\r
- }\r
+ public Bond(float[] start, float[] end, Atom at1, Atom at2)\r
+ {\r
+ this.start = start;\r
+ this.end = end;\r
+ this.startCol = at1.color;\r
+ this.endCol = at2.color;\r
+ this.at1 = at1;\r
+ this.at2 = at2;\r
+ }\r
\r
/* public Bond(Bond bond) {\r
this.start = new float[3];\r
return len;\r
}*/\r
\r
- public void translate(float x, float y, float z) {\r
- start[0] = (start[0] + x);\r
- end[0] = (end[0] + x);\r
+ public void translate(float x, float y, float z)\r
+ {\r
+ start[0] = (start[0] + x);\r
+ end[0] = (end[0] + x);\r
\r
- start[1] = (start[1] + y);\r
- end[1] = (end[1] + y);\r
+ start[1] = (start[1] + y);\r
+ end[1] = (end[1] + y);\r
\r
- start[2] = (start[2] + z);\r
- end[2] = (end[2] + z);\r
- }\r
+ start[2] = (start[2] + z);\r
+ end[2] = (end[2] + z);\r
+ }\r
}\r
/*\r
-* Jalview - A Sequence Alignment Editor and Viewer\r
-* Copyright (C) 2006 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle\r
-*\r
-* This program is free software; you can redistribute it and/or\r
-* modify it under the terms of the GNU General Public License\r
-* as published by the Free Software Foundation; either version 2\r
-* of the License, or (at your option) any later version.\r
-*\r
-* This program is distributed in the hope that it will be useful,\r
-* but WITHOUT ANY WARRANTY; without even the implied warranty of\r
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
-* GNU General Public License for more details.\r
-*\r
-* You should have received a copy of the GNU General Public License\r
-* along with this program; if not, write to the Free Software\r
-* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA\r
-*/\r
+ * Jalview - A Sequence Alignment Editor and Viewer\r
+ * Copyright (C) 2007 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle\r
+ *\r
+ * This program is free software; you can redistribute it and/or\r
+ * modify it under the terms of the GNU General Public License\r
+ * as published by the Free Software Foundation; either version 2\r
+ * of the License, or (at your option) any later version.\r
+ *\r
+ * This program is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
+ * GNU General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU General Public License\r
+ * along with this program; if not, write to the Free Software\r
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA\r
+ */\r
package MCview;\r
\r
-public class MCMatrix {\r
- float[][] matrix;\r
- float[][] tmp;\r
- float mycos;\r
- float mysin;\r
- float myconst = (float) (Math.PI / 180);\r
-\r
- public MCMatrix(int rows, int cols) {\r
- matrix = new float[rows][cols];\r
- tmp = new float[rows][cols];\r
+public class MCMatrix\r
+{\r
+ float[][] matrix;\r
+ float[][] tmp;\r
+ float mycos;\r
+ float mysin;\r
+ float myconst = (float) (Math.PI / 180);\r
+\r
+ public MCMatrix(int rows, int cols)\r
+ {\r
+ matrix = new float[rows][cols];\r
+ tmp = new float[rows][cols];\r
+ }\r
+\r
+ public void addElement(int i, int j, float value)\r
+ {\r
+ matrix[i][j] = value;\r
+ }\r
+\r
+ public void rotatex(float degrees)\r
+ {\r
+ mycos = (float) (Math.cos(degrees * myconst));\r
+ mysin = (float) (Math.sin(degrees * myconst));\r
+\r
+ tmp[0][0] = 1;\r
+ tmp[0][1] = 0;\r
+ tmp[0][2] = 0;\r
+ tmp[1][0] = 0;\r
+ tmp[1][1] = mycos;\r
+ tmp[1][2] = mysin;\r
+ tmp[2][0] = 0;\r
+ tmp[2][1] = -mysin;\r
+ tmp[2][2] = mycos;\r
+ preMultiply(tmp);\r
+ }\r
+\r
+ public void rotatez(float degrees)\r
+ {\r
+ mycos = (float) (Math.cos(degrees * myconst));\r
+ mysin = (float) (Math.sin(degrees * myconst));\r
+\r
+ tmp[0][0] = mycos;\r
+ tmp[0][1] = -mysin;\r
+ tmp[0][2] = 0;\r
+ tmp[1][0] = mysin;\r
+ tmp[1][1] = mycos;\r
+ tmp[1][2] = 0;\r
+ tmp[2][0] = 0;\r
+ tmp[2][1] = 0;\r
+ tmp[2][2] = 1;\r
+\r
+ preMultiply(tmp);\r
+ }\r
+\r
+ public void rotatey(float degrees)\r
+ {\r
+ mycos = (float) (Math.cos(degrees * myconst));\r
+ mysin = (float) (Math.sin(degrees * myconst));\r
+\r
+ tmp[0][0] = mycos;\r
+ tmp[0][1] = 0;\r
+ tmp[0][2] = -mysin;\r
+ tmp[1][0] = 0;\r
+ tmp[1][1] = 1;\r
+ tmp[1][2] = 0;\r
+ tmp[2][0] = mysin;\r
+ tmp[2][1] = 0;\r
+ tmp[2][2] = mycos;\r
+\r
+ preMultiply(tmp);\r
+ }\r
+\r
+ public float[] vectorMultiply(float[] vect)\r
+ {\r
+ float[] temp = new float[3];\r
+\r
+ temp[0] = vect[0];\r
+ temp[1] = vect[1];\r
+ temp[2] = vect[2];\r
+\r
+ for (int i = 0; i < 3; i++)\r
+ {\r
+ temp[i] = ( (float) matrix[i][0] * vect[0]) +\r
+ ( (float) matrix[i][1] * vect[1]) +\r
+ ( (float) matrix[i][2] * vect[2]);\r
}\r
\r
- public void addElement(int i, int j, float value) {\r
- matrix[i][j] = value;\r
- }\r
+ vect[0] = temp[0];\r
+ vect[1] = temp[1];\r
+ vect[2] = temp[2];\r
\r
- public void rotatex(float degrees) {\r
- mycos = (float) (Math.cos(degrees * myconst));\r
- mysin = (float) (Math.sin(degrees * myconst));\r
-\r
- tmp[0][0] = 1;\r
- tmp[0][1] = 0;\r
- tmp[0][2] = 0;\r
- tmp[1][0] = 0;\r
- tmp[1][1] = mycos;\r
- tmp[1][2] = mysin;\r
- tmp[2][0] = 0;\r
- tmp[2][1] = -mysin;\r
- tmp[2][2] = mycos;\r
- preMultiply(tmp);\r
- }\r
+ return vect;\r
+ }\r
\r
- public void rotatez(float degrees) {\r
- mycos = (float) (Math.cos(degrees * myconst));\r
- mysin = (float) (Math.sin(degrees * myconst));\r
-\r
- tmp[0][0] = mycos;\r
- tmp[0][1] = -mysin;\r
- tmp[0][2] = 0;\r
- tmp[1][0] = mysin;\r
- tmp[1][1] = mycos;\r
- tmp[1][2] = 0;\r
- tmp[2][0] = 0;\r
- tmp[2][1] = 0;\r
- tmp[2][2] = 1;\r
-\r
- preMultiply(tmp);\r
- }\r
+ public void preMultiply(float[][] mat)\r
+ {\r
+ float[][] tmp = new float[3][3];\r
\r
- public void rotatey(float degrees) {\r
- mycos = (float) (Math.cos(degrees * myconst));\r
- mysin = (float) (Math.sin(degrees * myconst));\r
-\r
- tmp[0][0] = mycos;\r
- tmp[0][1] = 0;\r
- tmp[0][2] = -mysin;\r
- tmp[1][0] = 0;\r
- tmp[1][1] = 1;\r
- tmp[1][2] = 0;\r
- tmp[2][0] = mysin;\r
- tmp[2][1] = 0;\r
- tmp[2][2] = mycos;\r
-\r
- preMultiply(tmp);\r
+ for (int i = 0; i < 3; i++)\r
+ {\r
+ for (int j = 0; j < 3; j++)\r
+ {\r
+ tmp[i][j] = (mat[i][0] * matrix[0][j]) +\r
+ (mat[i][1] * matrix[1][j]) + (mat[i][2] * matrix[2][j]);\r
+ }\r
}\r
\r
- public float[] vectorMultiply(float[] vect) {\r
- float[] temp = new float[3];\r
-\r
- temp[0] = vect[0];\r
- temp[1] = vect[1];\r
- temp[2] = vect[2];\r
-\r
- for (int i = 0; i < 3; i++) {\r
- temp[i] = ((float) matrix[i][0] * vect[0]) +\r
- ((float) matrix[i][1] * vect[1]) +\r
- ((float) matrix[i][2] * vect[2]);\r
- }\r
-\r
- vect[0] = temp[0];\r
- vect[1] = temp[1];\r
- vect[2] = temp[2];\r
-\r
- return vect;\r
+ for (int i = 0; i < 3; i++)\r
+ {\r
+ for (int j = 0; j < 3; j++)\r
+ {\r
+ matrix[i][j] = tmp[i][j];\r
+ }\r
}\r
-\r
- public void preMultiply(float[][] mat) {\r
- float[][] tmp = new float[3][3];\r
-\r
- for (int i = 0; i < 3; i++) {\r
- for (int j = 0; j < 3; j++) {\r
- tmp[i][j] = (mat[i][0] * matrix[0][j]) +\r
- (mat[i][1] * matrix[1][j]) + (mat[i][2] * matrix[2][j]);\r
- }\r
- }\r
-\r
- for (int i = 0; i < 3; i++) {\r
- for (int j = 0; j < 3; j++) {\r
- matrix[i][j] = tmp[i][j];\r
- }\r
- }\r
- }\r
-\r
- public void postMultiply(float[][] mat) {\r
- float[][] tmp = new float[3][3];\r
-\r
- for (int i = 0; i < 3; i++) {\r
- for (int j = 0; j < 3; j++) {\r
- tmp[i][j] = (matrix[i][0] * mat[0][j]) +\r
- (matrix[i][1] * mat[1][j]) + (matrix[i][2] * mat[2][j]);\r
- }\r
- }\r
-\r
- for (int i = 0; i < 3; i++) {\r
- for (int j = 0; j < 3; j++) {\r
- matrix[i][j] = tmp[i][j];\r
- }\r
- }\r
+ }\r
+\r
+ public void postMultiply(float[][] mat)\r
+ {\r
+ float[][] tmp = new float[3][3];\r
+\r
+ for (int i = 0; i < 3; i++)\r
+ {\r
+ for (int j = 0; j < 3; j++)\r
+ {\r
+ tmp[i][j] = (matrix[i][0] * mat[0][j]) +\r
+ (matrix[i][1] * mat[1][j]) + (matrix[i][2] * mat[2][j]);\r
+ }\r
}\r
\r
- public void setIdentity() {\r
- matrix[0][0] = 1;\r
- matrix[1][1] = 1;\r
- matrix[2][2] = 1;\r
- matrix[0][1] = 0;\r
- matrix[0][2] = 0;\r
- matrix[1][0] = 0;\r
- matrix[1][2] = 0;\r
- matrix[2][0] = 0;\r
- matrix[2][1] = 0;\r
+ for (int i = 0; i < 3; i++)\r
+ {\r
+ for (int j = 0; j < 3; j++)\r
+ {\r
+ matrix[i][j] = tmp[i][j];\r
+ }\r
}\r
+ }\r
+\r
+ public void setIdentity()\r
+ {\r
+ matrix[0][0] = 1;\r
+ matrix[1][1] = 1;\r
+ matrix[2][2] = 1;\r
+ matrix[0][1] = 0;\r
+ matrix[0][2] = 0;\r
+ matrix[1][0] = 0;\r
+ matrix[1][2] = 0;\r
+ matrix[2][0] = 0;\r
+ matrix[2][1] = 0;\r
+ }\r
}\r
/*
-* Jalview - A Sequence Alignment Editor and Viewer
-* Copyright (C) 2006 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle
-*
-* This program is free software; you can redistribute it and/or
-* modify it under the terms of the GNU General Public License
-* as published by the Free Software Foundation; either version 2
-* of the License, or (at your option) any later version.
-*
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with this program; if not, write to the Free Software
-* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
-*/
+ * Jalview - A Sequence Alignment Editor and Viewer
+ * Copyright (C) 2007 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+ */
package MCview;
-import jalview.analysis.AlignSeq;
-
-import jalview.datamodel.*;
+import java.io.*;
+import java.util.*;
// JBPNote TODO: This class is quite noisy - needs proper log.info/log.debug
import java.awt.*;
import java.awt.event.*;
-
-import java.io.*;
-
-import java.util.*;
-
import javax.swing.*;
+import jalview.analysis.*;
+import jalview.datamodel.*;
-public class PDBCanvas extends JPanel implements MouseListener, MouseMotionListener
+public class PDBCanvas
+ extends JPanel implements MouseListener, MouseMotionListener
{
- MCMatrix idmat = new MCMatrix(3, 3);
- MCMatrix objmat = new MCMatrix(3, 3);
- boolean redrawneeded = true;
- int omx = 0;
- int mx = 0;
- int omy = 0;
- int my = 0;
- public PDBfile pdb;
- int bsize;
- Image img;
- Graphics ig;
- Dimension prefsize;
- float[] centre = new float[3];
- float[] width = new float[3];
- float maxwidth;
- float scale;
- String inStr;
- String inType;
- boolean bysequence = true;
- boolean depthcue = true;
- boolean wire = false;
- boolean bymolecule = false;
- boolean zbuffer = true;
- boolean dragging;
- int xstart;
- int xend;
- int ystart;
- int yend;
- int xmid;
- int ymid;
- Font font = new Font("Helvetica", Font.PLAIN, 10);
- jalview.gui.SeqCanvas seqcanvas;
- public Sequence sequence;
- final StringBuffer mappingDetails = new StringBuffer();
- PDBChain mainchain;
- Vector highlightRes;
- boolean pdbAction = false;
- boolean seqColoursReady = false;
- jalview.gui.FeatureRenderer fr;
- Color backgroundColour = Color.black;
-
- public PDBCanvas(jalview.gui.SeqCanvas seqcanvas, Sequence seq)
- {
- this.seqcanvas = seqcanvas;
- this.sequence = seq;
- seqcanvas.setPDBCanvas(this);
- }
+ MCMatrix idmat = new MCMatrix(3, 3);
+ MCMatrix objmat = new MCMatrix(3, 3);
+ boolean redrawneeded = true;
+ int omx = 0;
+ int mx = 0;
+ int omy = 0;
+ int my = 0;
+ public PDBfile pdb;
+ int bsize;
+ Image img;
+ Graphics ig;
+ Dimension prefsize;
+ float[] centre = new float[3];
+ float[] width = new float[3];
+ float maxwidth;
+ float scale;
+ String inStr;
+ String inType;
+ boolean bysequence = true;
+ boolean depthcue = true;
+ boolean wire = false;
+ boolean bymolecule = false;
+ boolean zbuffer = true;
+ boolean dragging;
+ int xstart;
+ int xend;
+ int ystart;
+ int yend;
+ int xmid;
+ int ymid;
+ Font font = new Font("Helvetica", Font.PLAIN, 10);
+ jalview.gui.SeqCanvas seqcanvas;
+ public Sequence sequence;
+ final StringBuffer mappingDetails = new StringBuffer();
+ PDBChain mainchain;
+ Vector highlightRes;
+ boolean pdbAction = false;
+ boolean seqColoursReady = false;
+ jalview.gui.FeatureRenderer fr;
+ Color backgroundColour = Color.black;
+
+ public PDBCanvas(jalview.gui.SeqCanvas seqcanvas, Sequence seq)
+ {
+ this.seqcanvas = seqcanvas;
+ this.sequence = seq;
+ seqcanvas.setPDBCanvas(this);
+ }
public void setPDBFile(PDBfile pdb)
- {
- int max = -10;
- int maxchain = -1;
- int pdbstart = 0;
- int pdbend = 0;
- int seqstart = 0;
- int seqend = 0;
- AlignSeq maxAlignseq = null;
-
- for (int i = 0; i < pdb.chains.size(); i++)
- {
-
- mappingDetails.append("\n\nPDB Sequence is :\nSequence = " + ((PDBChain) pdb.chains.elementAt(i)).sequence.getSequenceAsString());
- mappingDetails.append("\nNo of residues = " + ((PDBChain) pdb.chains.elementAt(i)).residues.size()+"\n\n");
+ {
+ int max = -10;
+ int maxchain = -1;
+ int pdbstart = 0;
+ int pdbend = 0;
+ int seqstart = 0;
+ int seqend = 0;
+ AlignSeq maxAlignseq = null;
+
+ for (int i = 0; i < pdb.chains.size(); i++)
+ {
- // Now lets compare the sequences to get
- // the start and end points.
- // Align the sequence to the pdb
- AlignSeq as = new AlignSeq(sequence,
- ((PDBChain) pdb.chains.elementAt(i)).sequence, AlignSeq.PEP);
- as.calcScoreMatrix();
- as.traceAlignment();
- PrintStream ps = new PrintStream(System.out)
- {
- public void print(String x) {
- mappingDetails.append(x);
- }
- public void println()
- {
- mappingDetails.append("\n");
- }
- };
+ mappingDetails.append("\n\nPDB Sequence is :\nSequence = " +
+ ( (PDBChain) pdb.chains.elementAt(i)).sequence.
+ getSequenceAsString());
+ mappingDetails.append("\nNo of residues = " +
+ ( (PDBChain) pdb.chains.elementAt(i)).residues.size() +
+ "\n\n");
+
+ // Now lets compare the sequences to get
+ // the start and end points.
+ // Align the sequence to the pdb
+ AlignSeq as = new AlignSeq(sequence,
+ ( (PDBChain) pdb.chains.elementAt(i)).sequence,
+ AlignSeq.PEP);
+ as.calcScoreMatrix();
+ as.traceAlignment();
+ PrintStream ps = new PrintStream(System.out)
+ {
+ public void print(String x)
+ {
+ mappingDetails.append(x);
+ }
- as.printAlignment(ps);
+ public void println()
+ {
+ mappingDetails.append("\n");
+ }
+ };
+ as.printAlignment(ps);
+ if (as.maxscore > max)
+ {
+ max = as.maxscore;
+ maxchain = i;
+ pdbstart = as.seq2start;
+ pdbend = as.seq2end;
+ seqstart = as.seq1start + sequence.getStart() - 1;
+ seqend = as.seq1end + sequence.getEnd() - 1;
+ maxAlignseq = as;
+ }
- if (as.maxscore > max)
- {
- max = as.maxscore;
- maxchain = i;
- pdbstart = as.seq2start;
- pdbend = as.seq2end;
- seqstart = as.seq1start + sequence.getStart()-1;
- seqend = as.seq1end + sequence.getEnd()-1;
- maxAlignseq = as;
- }
+ mappingDetails.append("\nPDB start/end " + pdbstart + " " + pdbend);
+ mappingDetails.append("\nSEQ start/end " + seqstart + " " + seqend);
+ }
- mappingDetails.append("\nPDB start/end " + pdbstart + " " + pdbend);
- mappingDetails.append("\nSEQ start/end "+ seqstart + " " + seqend);
+ mainchain = (PDBChain) pdb.chains.elementAt(maxchain);
+
+ mainchain.pdbstart = pdbstart;
+ mainchain.pdbend = pdbend;
+ mainchain.seqstart = seqstart;
+ mainchain.seqend = seqend;
+ mainchain.isVisible = true;
+ mainchain.makeExactMapping(maxAlignseq, sequence);
+ mainchain.transferRESNUMFeatures(sequence, null);
+ seqcanvas.getFeatureRenderer().featuresAdded();
+ this.pdb = pdb;
+ this.prefsize = new Dimension(getWidth(), getHeight());
+
+ //Initialize the matrices to identity
+ for (int i = 0; i < 3; i++)
+ {
+ for (int j = 0; j < 3; j++)
+ {
+ if (i != j)
+ {
+ idmat.addElement(i, j, 0);
+ objmat.addElement(i, j, 0);
}
-
- mainchain = (PDBChain) pdb.chains.elementAt(maxchain);
-
- mainchain.pdbstart = pdbstart;
- mainchain.pdbend = pdbend;
- mainchain.seqstart = seqstart;
- mainchain.seqend = seqend;
- mainchain.isVisible = true;
- mainchain.makeExactMapping(maxAlignseq, sequence);
- mainchain.transferRESNUMFeatures(sequence, null);
- seqcanvas.getFeatureRenderer().featuresAdded();
- this.pdb = pdb;
- this.prefsize = new Dimension(getWidth(), getHeight());
-
- //Initialize the matrices to identity
- for (int i = 0; i < 3; i++) {
- for (int j = 0; j < 3; j++) {
- if (i != j) {
- idmat.addElement(i, j, 0);
- objmat.addElement(i, j, 0);
- } else {
- idmat.addElement(i, j, 1);
- objmat.addElement(i, j, 1);
- }
- }
+ else
+ {
+ idmat.addElement(i, j, 1);
+ objmat.addElement(i, j, 1);
}
+ }
+ }
- addMouseMotionListener(this);
- addMouseListener(this);
+ addMouseMotionListener(this);
+ addMouseListener(this);
- addMouseWheelListener(new MouseWheelListener()
+ addMouseWheelListener(new MouseWheelListener()
+ {
+ public void mouseWheelMoved(MouseWheelEvent e)
+ {
+ if (e.getWheelRotation() > 0)
{
- public void mouseWheelMoved(MouseWheelEvent e)
- {
- if (e.getWheelRotation() > 0)
- {
- scale = (float) (scale * 1.1);
- redrawneeded = true;
- repaint();
- }
-
- else
- {
- scale = (float) (scale * 0.9);
- redrawneeded = true;
- repaint();
- }
- }
- });
+ scale = (float) (scale * 1.1);
+ redrawneeded = true;
+ repaint();
+ }
+ else
+ {
+ scale = (float) (scale * 0.9);
+ redrawneeded = true;
+ repaint();
+ }
+ }
+ });
- findCentre();
- findWidth();
+ findCentre();
+ findWidth();
- setupBonds();
+ setupBonds();
- scale = findScale();
+ scale = findScale();
- ToolTipManager.sharedInstance().registerComponent(this);
- ToolTipManager.sharedInstance().setInitialDelay(0);
- ToolTipManager.sharedInstance().setDismissDelay(10000);
- }
+ ToolTipManager.sharedInstance().registerComponent(this);
+ ToolTipManager.sharedInstance().setInitialDelay(0);
+ ToolTipManager.sharedInstance().setDismissDelay(10000);
+ }
+ Vector visiblebonds;
+ void setupBonds()
+ {
+ seqColoursReady = false;
+ // Sort the bonds by z coord
+ visiblebonds = new Vector();
- Vector visiblebonds;
- void setupBonds()
+ for (int ii = 0; ii < pdb.chains.size(); ii++)
{
- seqColoursReady = false;
- // Sort the bonds by z coord
- visiblebonds = new Vector();
-
- for (int ii = 0; ii < pdb.chains.size(); ii++)
+ if ( ( (PDBChain) pdb.chains.elementAt(ii)).isVisible)
{
- if ( ( (PDBChain) pdb.chains.elementAt(ii)).isVisible)
- {
- Vector tmp = ( (PDBChain) pdb.chains.elementAt(ii)).bonds;
+ Vector tmp = ( (PDBChain) pdb.chains.elementAt(ii)).bonds;
- for (int i = 0; i < tmp.size(); i++)
- {
- visiblebonds.addElement(tmp.elementAt(i));
- }
+ for (int i = 0; i < tmp.size(); i++)
+ {
+ visiblebonds.addElement(tmp.elementAt(i));
}
}
-
- updateSeqColours();
- seqColoursReady = true;
- redrawneeded = true;
- repaint();
}
+ updateSeqColours();
+ seqColoursReady = true;
+ redrawneeded = true;
+ repaint();
+ }
- public void findWidth() {
- float[] max = new float[3];
- float[] min = new float[3];
+ public void findWidth()
+ {
+ float[] max = new float[3];
+ float[] min = new float[3];
- max[0] = (float) -1e30;
- max[1] = (float) -1e30;
- max[2] = (float) -1e30;
+ max[0] = (float) - 1e30;
+ max[1] = (float) - 1e30;
+ max[2] = (float) - 1e30;
- min[0] = (float) 1e30;
- min[1] = (float) 1e30;
- min[2] = (float) 1e30;
+ min[0] = (float) 1e30;
+ min[1] = (float) 1e30;
+ min[2] = (float) 1e30;
- for (int ii = 0; ii < pdb.chains.size(); ii++) {
- if (((PDBChain) pdb.chains.elementAt(ii)).isVisible) {
- Vector bonds = ((PDBChain) pdb.chains.elementAt(ii)).bonds;
+ for (int ii = 0; ii < pdb.chains.size(); ii++)
+ {
+ if ( ( (PDBChain) pdb.chains.elementAt(ii)).isVisible)
+ {
+ Vector bonds = ( (PDBChain) pdb.chains.elementAt(ii)).bonds;
- for (int i = 0; i < bonds.size(); i++) {
- Bond tmp = (Bond) bonds.elementAt(i);
+ for (int i = 0; i < bonds.size(); i++)
+ {
+ Bond tmp = (Bond) bonds.elementAt(i);
- if (tmp.start[0] >= max[0]) {
- max[0] = tmp.start[0];
- }
+ if (tmp.start[0] >= max[0])
+ {
+ max[0] = tmp.start[0];
+ }
- if (tmp.start[1] >= max[1]) {
- max[1] = tmp.start[1];
- }
+ if (tmp.start[1] >= max[1])
+ {
+ max[1] = tmp.start[1];
+ }
- if (tmp.start[2] >= max[2]) {
- max[2] = tmp.start[2];
- }
+ if (tmp.start[2] >= max[2])
+ {
+ max[2] = tmp.start[2];
+ }
- if (tmp.start[0] <= min[0]) {
- min[0] = tmp.start[0];
- }
+ if (tmp.start[0] <= min[0])
+ {
+ min[0] = tmp.start[0];
+ }
- if (tmp.start[1] <= min[1]) {
- min[1] = tmp.start[1];
- }
+ if (tmp.start[1] <= min[1])
+ {
+ min[1] = tmp.start[1];
+ }
- if (tmp.start[2] <= min[2]) {
- min[2] = tmp.start[2];
- }
+ if (tmp.start[2] <= min[2])
+ {
+ min[2] = tmp.start[2];
+ }
- if (tmp.end[0] >= max[0]) {
- max[0] = tmp.end[0];
- }
+ if (tmp.end[0] >= max[0])
+ {
+ max[0] = tmp.end[0];
+ }
- if (tmp.end[1] >= max[1]) {
- max[1] = tmp.end[1];
- }
+ if (tmp.end[1] >= max[1])
+ {
+ max[1] = tmp.end[1];
+ }
- if (tmp.end[2] >= max[2]) {
- max[2] = tmp.end[2];
- }
+ if (tmp.end[2] >= max[2])
+ {
+ max[2] = tmp.end[2];
+ }
- if (tmp.end[0] <= min[0]) {
- min[0] = tmp.end[0];
- }
+ if (tmp.end[0] <= min[0])
+ {
+ min[0] = tmp.end[0];
+ }
- if (tmp.end[1] <= min[1]) {
- min[1] = tmp.end[1];
- }
+ if (tmp.end[1] <= min[1])
+ {
+ min[1] = tmp.end[1];
+ }
- if (tmp.end[2] <= min[2]) {
- min[2] = tmp.end[2];
- }
- }
- }
+ if (tmp.end[2] <= min[2])
+ {
+ min[2] = tmp.end[2];
+ }
}
- /*
- System.out.println("xmax " + max[0] + " min " + min[0]);
- System.out.println("ymax " + max[1] + " min " + min[1]);
- System.out.println("zmax " + max[2] + " min " + min[2]);*/
-
- width[0] = (float) Math.abs(max[0] - min[0]);
- width[1] = (float) Math.abs(max[1] - min[1]);
- width[2] = (float) Math.abs(max[2] - min[2]);
+ }
+ }
+ /*
+ System.out.println("xmax " + max[0] + " min " + min[0]);
+ System.out.println("ymax " + max[1] + " min " + min[1]);
+ System.out.println("zmax " + max[2] + " min " + min[2]);*/
- maxwidth = width[0];
+ width[0] = (float) Math.abs(max[0] - min[0]);
+ width[1] = (float) Math.abs(max[1] - min[1]);
+ width[2] = (float) Math.abs(max[2] - min[2]);
- if (width[1] > width[0]) {
- maxwidth = width[1];
- }
+ maxwidth = width[0];
- if (width[2] > width[1]) {
- maxwidth = width[2];
- }
+ if (width[1] > width[0])
+ {
+ maxwidth = width[1];
+ }
- // System.out.println("Maxwidth = " + maxwidth);
+ if (width[2] > width[1])
+ {
+ maxwidth = width[2];
}
- public float findScale() {
- int dim;
- int width;
- int height;
+ // System.out.println("Maxwidth = " + maxwidth);
+ }
- if (getWidth() != 0) {
- width = getWidth();
- height = getHeight();
- } else {
- width = prefsize.width;
- height = prefsize.height;
- }
+ public float findScale()
+ {
+ int dim;
+ int width;
+ int height;
- if (width < height) {
- dim = width;
- } else {
- dim = height;
- }
+ if (getWidth() != 0)
+ {
+ width = getWidth();
+ height = getHeight();
+ }
+ else
+ {
+ width = prefsize.width;
+ height = prefsize.height;
+ }
- return (float) (dim / (1.5d * maxwidth));
+ if (width < height)
+ {
+ dim = width;
+ }
+ else
+ {
+ dim = height;
}
- public void findCentre() {
- float xtot = 0;
- float ytot = 0;
- float ztot = 0;
+ return (float) (dim / (1.5d * maxwidth));
+ }
- int bsize = 0;
+ public void findCentre()
+ {
+ float xtot = 0;
+ float ytot = 0;
+ float ztot = 0;
- //Find centre coordinate
- for (int ii = 0; ii < pdb.chains.size(); ii++) {
- if (((PDBChain) pdb.chains.elementAt(ii)).isVisible) {
- Vector bonds = ((PDBChain) pdb.chains.elementAt(ii)).bonds;
+ int bsize = 0;
- bsize += bonds.size();
+ //Find centre coordinate
+ for (int ii = 0; ii < pdb.chains.size(); ii++)
+ {
+ if ( ( (PDBChain) pdb.chains.elementAt(ii)).isVisible)
+ {
+ Vector bonds = ( (PDBChain) pdb.chains.elementAt(ii)).bonds;
- for (int i = 0; i < bonds.size(); i++) {
- xtot = xtot + ((Bond) bonds.elementAt(i)).start[0] +
- ((Bond) bonds.elementAt(i)).end[0];
+ bsize += bonds.size();
- ytot = ytot + ((Bond) bonds.elementAt(i)).start[1] +
- ((Bond) bonds.elementAt(i)).end[1];
+ for (int i = 0; i < bonds.size(); i++)
+ {
+ xtot = xtot + ( (Bond) bonds.elementAt(i)).start[0] +
+ ( (Bond) bonds.elementAt(i)).end[0];
- ztot = ztot + ((Bond) bonds.elementAt(i)).start[2] +
- ((Bond) bonds.elementAt(i)).end[2];
- }
- }
- }
+ ytot = ytot + ( (Bond) bonds.elementAt(i)).start[1] +
+ ( (Bond) bonds.elementAt(i)).end[1];
- centre[0] = xtot / (2 * (float) bsize);
- centre[1] = ytot / (2 * (float) bsize);
- centre[2] = ztot / (2 * (float) bsize);
+ ztot = ztot + ( (Bond) bonds.elementAt(i)).start[2] +
+ ( (Bond) bonds.elementAt(i)).end[2];
+ }
+ }
}
- public void paintComponent(Graphics g)
- {
- super.paintComponent(g);
+ centre[0] = xtot / (2 * (float) bsize);
+ centre[1] = ytot / (2 * (float) bsize);
+ centre[2] = ztot / (2 * (float) bsize);
+ }
- if(!seqColoursReady)
- {
- g.setColor(Color.black);
- g.setFont(new Font("Verdana", Font.BOLD, 14));
- g.drawString("Retrieving PDB data....", 20, getHeight()/2);
- return;
- }
+ public void paintComponent(Graphics g)
+ {
+ super.paintComponent(g);
+ if (!seqColoursReady)
+ {
+ g.setColor(Color.black);
+ g.setFont(new Font("Verdana", Font.BOLD, 14));
+ g.drawString("Retrieving PDB data....", 20, getHeight() / 2);
+ return;
+ }
- //Only create the image at the beginning -
- //this saves much memory usage
- if ((img == null)
- || (prefsize.width != getWidth())
- || (prefsize.height != getHeight()))
+ //Only create the image at the beginning -
+ //this saves much memory usage
+ if ( (img == null)
+ || (prefsize.width != getWidth())
+ || (prefsize.height != getHeight()))
- {
- prefsize.width = getWidth();
- prefsize.height = getHeight();
+ {
+ prefsize.width = getWidth();
+ prefsize.height = getHeight();
- scale = findScale();
- img = createImage(prefsize.width, prefsize.height);
- ig = img.getGraphics();
- Graphics2D ig2 = (Graphics2D) ig;
+ scale = findScale();
+ img = createImage(prefsize.width, prefsize.height);
+ ig = img.getGraphics();
+ Graphics2D ig2 = (Graphics2D) ig;
- ig2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
- RenderingHints.VALUE_ANTIALIAS_ON);
+ ig2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
+ RenderingHints.VALUE_ANTIALIAS_ON);
- redrawneeded = true;
- }
+ redrawneeded = true;
+ }
+ if (redrawneeded)
+ {
+ drawAll(ig, prefsize.width, prefsize.height);
+ redrawneeded = false;
+ }
- if (redrawneeded)
- {
- drawAll(ig, prefsize.width, prefsize.height);
- redrawneeded = false;
- }
+ g.drawImage(img, 0, 0, this);
- g.drawImage(img, 0, 0, this);
+ pdbAction = false;
+ }
- pdbAction = false;
- }
+ public void drawAll(Graphics g, int width, int height)
+ {
+ g.setColor(backgroundColour);
+ g.fillRect(0, 0, width, height);
+ drawScene(g);
+ drawLabels(g);
+ }
- public void drawAll(Graphics g, int width, int height)
+ public void updateSeqColours()
+ {
+ if (pdbAction)
{
- g.setColor(backgroundColour);
- g.fillRect(0, 0, width, height);
- drawScene(g);
- drawLabels(g);
+ return;
}
-
- public void updateSeqColours()
+ // System.out.println("update seq colours");
+ if (bysequence && pdb != null)
{
- if(pdbAction)
+ for (int ii = 0; ii < pdb.chains.size(); ii++)
{
- return;
+ colourBySequence( (PDBChain) pdb.chains.elementAt(ii));
}
+ }
+
+ redrawneeded = true;
+ repaint();
+ }
+
+ int findTrueIndex(int pos)
+ {
+ // returns the alignment position for a residue
+ int j = sequence.getStart(); // first position in PDB atom coordinate sequence
+ int i = 0;
- // System.out.println("update seq colours");
- if(bysequence && pdb!=null)
+ while ( (i < sequence.getLength()) && (j <= pos + 1))
+ {
+ if (!jalview.util.Comparison.isGap(sequence.getCharAt(i)))
{
- for (int ii = 0; ii < pdb.chains.size(); ii++)
- {
- colourBySequence( (PDBChain) pdb.chains.elementAt(ii));
- }
+ j++;
}
- redrawneeded=true;
- repaint();
+ i++;
}
- int findTrueIndex(int pos)
+ if (i > 1)
{
- // returns the alignment position for a residue
- int j = sequence.getStart(); // first position in PDB atom coordinate sequence
- int i = 0;
-
- while ( (i < sequence.getLength()) && (j <= pos+1))
- {
- if (!jalview.util.Comparison.isGap(sequence.getCharAt(i)))
- {
- j++;
- }
-
- i++;
- }
+ i--;
+ }
- if(i>1)
- i--;
+ if (j < pos)
+ {
+ return sequence.getEnd() + 1;
+ }
+ else
+ {
+ return i;
+ }
+ }
- if (j < pos)
- {
- return sequence.getEnd() + 1;
- }
- else
+ // This method has been taken out of PDBChain to allow
+ // Applet and Application specific sequence renderers to be used
+ void colourBySequence(PDBChain chain)
+ {
+ // System.out.println("colour by seq");
+ boolean showFeatures = false;
+ if (seqcanvas.getViewport().getShowSequenceFeatures())
+ {
+ showFeatures = true;
+ if (fr == null)
{
- return i;
+ fr = new jalview.gui.FeatureRenderer(seqcanvas.getViewport());
}
+
+ fr.transferSettings(seqcanvas.getFeatureRenderer());
}
- // This method has been taken out of PDBChain to allow
- // Applet and Application specific sequence renderers to be used
- void colourBySequence(PDBChain chain)
+ Bond tmp;
+ for (int i = 0; i < chain.bonds.size(); i++)
{
- // System.out.println("colour by seq");
- boolean showFeatures = false;
- if(seqcanvas.getViewport().getShowSequenceFeatures())
- {
- showFeatures = true;
- if (fr == null)
- fr = new jalview.gui.FeatureRenderer(seqcanvas.getViewport());
-
- fr.transferSettings( seqcanvas.getFeatureRenderer() );
- }
+ tmp = (Bond) chain.bonds.elementAt(i);
- Bond tmp;
- for (int i = 0; i < chain.bonds.size(); i++)
+ if (chain != mainchain)
{
- tmp = (Bond) chain.bonds.elementAt(i);
-
- if(chain!=mainchain)
- continue;
+ continue;
+ }
- //if ( (tmp.at1.resNumber >= ( (chain.offset + chain.pdbstart) - 1)) &&
- // (tmp.at1.resNumber <= ( (chain.offset + chain.pdbend) - 1)))
+ //if ( (tmp.at1.resNumber >= ( (chain.offset + chain.pdbstart) - 1)) &&
+ // (tmp.at1.resNumber <= ( (chain.offset + chain.pdbend) - 1)))
+ {
+ int index = findTrueIndex(tmp.at1.alignmentMapping);
+ //sequence.findIndex(tmp.at1.alignmentMapping);
+ if (index != -1)
{
- int index = findTrueIndex(tmp.at1.alignmentMapping);
- //sequence.findIndex(tmp.at1.alignmentMapping);
- if (index != -1)
- {
- tmp.startCol = seqcanvas.getSequenceRenderer().
- getResidueBoxColour( sequence, index);
+ tmp.startCol = seqcanvas.getSequenceRenderer().
+ getResidueBoxColour(sequence, index);
- if(showFeatures)
- tmp.startCol = fr.findFeatureColour(tmp.startCol, sequence, index);
+ if (showFeatures)
+ {
+ tmp.startCol = fr.findFeatureColour(tmp.startCol, sequence, index);
+ }
- if(tmp.startCol==null)
- tmp.startCol = Color.white;
- }
+ if (tmp.startCol == null)
+ {
+ tmp.startCol = Color.white;
+ }
}
+ }
- //if ( (tmp.at2.resNumber >= ( (chain.offset + chain.pdbstart) - 1)) &&
- // (tmp.at2.resNumber <= ( (chain.pdbend + chain.offset) - 1)))
- {
+ //if ( (tmp.at2.resNumber >= ( (chain.offset + chain.pdbstart) - 1)) &&
+ // (tmp.at2.resNumber <= ( (chain.pdbend + chain.offset) - 1)))
+ {
- int index = findTrueIndex(tmp.at2.alignmentMapping);
- //sequence.findIndex( tmp.at2.alignmentMapping );
- if (index != -1)
- {
- tmp.endCol = seqcanvas.getSequenceRenderer().
- getResidueBoxColour( sequence, index);
+ int index = findTrueIndex(tmp.at2.alignmentMapping);
+ //sequence.findIndex( tmp.at2.alignmentMapping );
+ if (index != -1)
+ {
+ tmp.endCol = seqcanvas.getSequenceRenderer().
+ getResidueBoxColour(sequence, index);
- if(showFeatures)
- tmp.endCol = fr.findFeatureColour(tmp.endCol, sequence, index);
+ if (showFeatures)
+ {
+ tmp.endCol = fr.findFeatureColour(tmp.endCol, sequence, index);
+ }
- if(tmp.endCol==null)
- tmp.endCol = Color.white;
- }
+ if (tmp.endCol == null)
+ {
+ tmp.endCol = Color.white;
+ }
}
}
}
+ }
-
- Zsort zsort;
- public void drawScene(Graphics g)
+ Zsort zsort;
+ public void drawScene(Graphics g)
+ {
+ if (zbuffer)
{
- if (zbuffer)
+ if (zsort == null)
{
- if (zsort == null)
- zsort = new Zsort();
-
- zsort.Zsort(visiblebonds);
+ zsort = new Zsort();
}
- Bond tmpBond = null;
- for (int i = 0; i < visiblebonds.size(); i++)
- {
- tmpBond = (Bond) visiblebonds.elementAt(i);
+ zsort.Zsort(visiblebonds);
+ }
- xstart = (int) ( ( (tmpBond.start[0] - centre[0]) * scale) +
- (getWidth() / 2));
- ystart = (int) ( ( (tmpBond.start[1] - centre[1]) * scale) +
- (getHeight() / 2));
+ Bond tmpBond = null;
+ for (int i = 0; i < visiblebonds.size(); i++)
+ {
+ tmpBond = (Bond) visiblebonds.elementAt(i);
- xend = (int) ( ( (tmpBond.end[0] - centre[0]) * scale) +
+ xstart = (int) ( ( (tmpBond.start[0] - centre[0]) * scale) +
(getWidth() / 2));
- yend = (int) ( ( (tmpBond.end[1] - centre[1]) * scale) +
+ ystart = (int) ( ( (tmpBond.start[1] - centre[1]) * scale) +
(getHeight() / 2));
- xmid = (xend + xstart) / 2;
- ymid = (yend + ystart) / 2;
- if (depthcue && !bymolecule)
- {
- if (tmpBond.start[2] < (centre[2] - (maxwidth / 6)))
- {
-
- g.setColor(tmpBond.startCol.darker().darker());
- drawLine(g, xstart, ystart, xmid, ymid);
- g.setColor(tmpBond.endCol.darker().darker());
- drawLine(g, xmid, ymid, xend, yend);
+ xend = (int) ( ( (tmpBond.end[0] - centre[0]) * scale) +
+ (getWidth() / 2));
+ yend = (int) ( ( (tmpBond.end[1] - centre[1]) * scale) +
+ (getHeight() / 2));
- }
- else if (tmpBond.start[2] < (centre[2] + (maxwidth / 6)))
- {
- g.setColor(tmpBond.startCol.darker());
- drawLine(g, xstart, ystart, xmid, ymid);
+ xmid = (xend + xstart) / 2;
+ ymid = (yend + ystart) / 2;
+ if (depthcue && !bymolecule)
+ {
+ if (tmpBond.start[2] < (centre[2] - (maxwidth / 6)))
+ {
- g.setColor(tmpBond.endCol.darker());
- drawLine(g, xmid, ymid, xend, yend);
- }
- else
- {
- g.setColor(tmpBond.startCol);
- drawLine(g, xstart, ystart, xmid, ymid);
+ g.setColor(tmpBond.startCol.darker().darker());
+ drawLine(g, xstart, ystart, xmid, ymid);
+ g.setColor(tmpBond.endCol.darker().darker());
+ drawLine(g, xmid, ymid, xend, yend);
- g.setColor(tmpBond.endCol);
- drawLine(g, xmid, ymid, xend, yend);
- }
}
- else if (depthcue && bymolecule)
+ else if (tmpBond.start[2] < (centre[2] + (maxwidth / 6)))
{
- if (tmpBond.start[2] < (centre[2] - (maxwidth / 6)))
- {
- g.setColor(Color.green.darker().darker());
- drawLine(g, xstart, ystart, xend, yend);
- }
- else if (tmpBond.start[2] < (centre[2] + (maxwidth / 6)))
- {
- g.setColor(Color.green.darker());
- drawLine(g, xstart, ystart, xend, yend);
- }
- else
- {
- g.setColor(Color.green);
- drawLine(g, xstart, ystart, xend, yend);
- }
+ g.setColor(tmpBond.startCol.darker());
+ drawLine(g, xstart, ystart, xmid, ymid);
+
+ g.setColor(tmpBond.endCol.darker());
+ drawLine(g, xmid, ymid, xend, yend);
}
- else if (!depthcue && !bymolecule)
+ else
{
g.setColor(tmpBond.startCol);
drawLine(g, xstart, ystart, xmid, ymid);
+
g.setColor(tmpBond.endCol);
drawLine(g, xmid, ymid, xend, yend);
}
- else
+ }
+ else if (depthcue && bymolecule)
+ {
+ if (tmpBond.start[2] < (centre[2] - (maxwidth / 6)))
{
+ g.setColor(Color.green.darker().darker());
drawLine(g, xstart, ystart, xend, yend);
}
-
- if (highlightBond1 != null && highlightBond1 == tmpBond)
+ else if (tmpBond.start[2] < (centre[2] + (maxwidth / 6)))
{
- g.setColor(tmpBond.endCol.brighter().brighter().brighter().brighter());
- drawLine(g, xmid, ymid, xend, yend);
+ g.setColor(Color.green.darker());
+ drawLine(g, xstart, ystart, xend, yend);
}
-
- if (highlightBond2 != null && highlightBond2 == tmpBond)
+ else
{
- g.setColor(tmpBond.startCol.brighter().brighter().brighter().brighter());
- drawLine(g, xstart, ystart, xmid, ymid);
+ g.setColor(Color.green);
+ drawLine(g, xstart, ystart, xend, yend);
}
-
+ }
+ else if (!depthcue && !bymolecule)
+ {
+ g.setColor(tmpBond.startCol);
+ drawLine(g, xstart, ystart, xmid, ymid);
+ g.setColor(tmpBond.endCol);
+ drawLine(g, xmid, ymid, xend, yend);
+ }
+ else
+ {
+ drawLine(g, xstart, ystart, xend, yend);
}
+ if (highlightBond1 != null && highlightBond1 == tmpBond)
+ {
+ g.setColor(tmpBond.endCol.brighter().brighter().brighter().brighter());
+ drawLine(g, xmid, ymid, xend, yend);
+ }
- }
-
- public void drawLine(Graphics g, int x1, int y1, int x2, int y2) {
- if (!wire) {
- if (((float) Math.abs(y2 - y1) / (float) Math.abs(x2 - x1)) < 0.5) {
- g.drawLine(x1, y1, x2, y2);
- g.drawLine(x1 + 1, y1 + 1, x2 + 1, y2 + 1);
- g.drawLine(x1, y1 - 1, x2, y2 - 1);
- } else {
- g.setColor(g.getColor().brighter());
- g.drawLine(x1, y1, x2, y2);
- g.drawLine(x1 + 1, y1, x2 + 1, y2);
- g.drawLine(x1 - 1, y1, x2 - 1, y2);
- }
- } else {
- g.drawLine(x1, y1, x2, y2);
- }
- }
+ if (highlightBond2 != null && highlightBond2 == tmpBond)
+ {
+ g.setColor(tmpBond.startCol.brighter().brighter().brighter().brighter());
+ drawLine(g, xstart, ystart, xmid, ymid);
+ }
- public Dimension minimumsize() {
- return prefsize;
}
- public Dimension preferredsize() {
- return prefsize;
- }
+ }
- public void keyPressed(KeyEvent evt)
+ public void drawLine(Graphics g, int x1, int y1, int x2, int y2)
+ {
+ if (!wire)
{
- if (evt.getKeyCode() == KeyEvent.VK_UP)
+ if ( ( (float) Math.abs(y2 - y1) / (float) Math.abs(x2 - x1)) < 0.5)
{
- scale = (float) (scale * 1.1);
- redrawneeded = true;
- repaint();
+ g.drawLine(x1, y1, x2, y2);
+ g.drawLine(x1 + 1, y1 + 1, x2 + 1, y2 + 1);
+ g.drawLine(x1, y1 - 1, x2, y2 - 1);
}
- else if (evt.getKeyCode() == KeyEvent.VK_DOWN)
+ else
{
- scale = (float) (scale * 0.9);
- redrawneeded = true;
- repaint();
+ g.setColor(g.getColor().brighter());
+ g.drawLine(x1, y1, x2, y2);
+ g.drawLine(x1 + 1, y1, x2 + 1, y2);
+ g.drawLine(x1 - 1, y1, x2 - 1, y2);
}
}
-
- public void mousePressed(MouseEvent e)
+ else
{
- pdbAction = true;
- Atom fatom = findAtom(e.getX(), e.getY());
- if(fatom!=null)
- {
- fatom.isSelected = !fatom.isSelected;
+ g.drawLine(x1, y1, x2, y2);
+ }
+ }
- redrawneeded = true;
- repaint();
- if (foundchain != -1)
- {
- PDBChain chain = (PDBChain) pdb.chains.elementAt(foundchain);
- if (chain == mainchain)
- {
- if (fatom.alignmentMapping != -1)
- {
- if (highlightRes == null)
- highlightRes = new Vector();
-
- if (highlightRes.contains(fatom.alignmentMapping+""))
- highlightRes.remove(fatom.alignmentMapping + "");
- else
- highlightRes.add(fatom.alignmentMapping + "");
- }
- }
- }
+ public Dimension minimumsize()
+ {
+ return prefsize;
+ }
- }
- mx = e.getX();
- my = e.getY();
- omx = mx;
- omy = my;
- dragging = false;
- }
+ public Dimension preferredsize()
+ {
+ return prefsize;
+ }
- public void mouseMoved(MouseEvent e)
+ public void keyPressed(KeyEvent evt)
+ {
+ if (evt.getKeyCode() == KeyEvent.VK_UP)
{
- pdbAction = true;
- if(highlightBond1!=null)
- {
- highlightBond1.at2.isSelected = false;
- highlightBond2.at1.isSelected = false;
- highlightBond1 = null;
- highlightBond2 = null;
- }
+ scale = (float) (scale * 1.1);
+ redrawneeded = true;
+ repaint();
+ }
+ else if (evt.getKeyCode() == KeyEvent.VK_DOWN)
+ {
+ scale = (float) (scale * 0.9);
+ redrawneeded = true;
+ repaint();
+ }
+ }
- Atom fatom = findAtom(e.getX(), e.getY());
+ public void mousePressed(MouseEvent e)
+ {
+ pdbAction = true;
+ Atom fatom = findAtom(e.getX(), e.getY());
+ if (fatom != null)
+ {
+ fatom.isSelected = !fatom.isSelected;
- PDBChain chain = null;
- if(foundchain!=-1)
+ redrawneeded = true;
+ repaint();
+ if (foundchain != -1)
+ {
+ PDBChain chain = (PDBChain) pdb.chains.elementAt(foundchain);
+ if (chain == mainchain)
{
- chain = (PDBChain) pdb.chains.elementAt(foundchain);
- if(chain == mainchain)
+ if (fatom.alignmentMapping != -1)
{
- highlightSeqcanvas( fatom.alignmentMapping );
+ if (highlightRes == null)
+ {
+ highlightRes = new Vector();
+ }
+
+ if (highlightRes.contains(fatom.alignmentMapping + ""))
+ {
+ highlightRes.remove(fatom.alignmentMapping + "");
+ }
+ else
+ {
+ highlightRes.add(fatom.alignmentMapping + "");
+ }
}
}
+ }
- if (fatom != null)
- {
- this.setToolTipText(chain.id+":"+ fatom.resNumber+" "+ fatom.resName);
- } else
- {
- highlightSeqcanvas( -1);
- this.setToolTipText(null);
- }
+ }
+ mx = e.getX();
+ my = e.getY();
+ omx = mx;
+ omy = my;
+ dragging = false;
+ }
+
+ public void mouseMoved(MouseEvent e)
+ {
+ pdbAction = true;
+ if (highlightBond1 != null)
+ {
+ highlightBond1.at2.isSelected = false;
+ highlightBond2.at1.isSelected = false;
+ highlightBond1 = null;
+ highlightBond2 = null;
}
+ Atom fatom = findAtom(e.getX(), e.getY());
- void highlightSeqcanvas(int pos)
+ PDBChain chain = null;
+ if (foundchain != -1)
{
- SearchResults searchResults = new SearchResults();
- if(highlightRes!=null)
+ chain = (PDBChain) pdb.chains.elementAt(foundchain);
+ if (chain == mainchain)
{
- for (int i = 0; i < highlightRes.size(); i++)
- {
- int a = Integer.parseInt(highlightRes.elementAt(
- i).toString())+1;
-
- searchResults.addResult(sequence, a, a);
- }
+ highlightSeqcanvas(fatom.alignmentMapping);
}
+ }
+
+ if (fatom != null)
+ {
+ this.setToolTipText(chain.id + ":" + fatom.resNumber + " " +
+ fatom.resName);
+ }
+ else
+ {
+ highlightSeqcanvas( -1);
+ this.setToolTipText(null);
+ }
+ }
- if(pos!=-1)
+ void highlightSeqcanvas(int pos)
+ {
+ SearchResults searchResults = new SearchResults();
+ if (highlightRes != null)
+ {
+ for (int i = 0; i < highlightRes.size(); i++)
{
- searchResults.addResult(sequence, pos+1, pos+1);
+ int a = Integer.parseInt(highlightRes.elementAt(
+ i).toString()) + 1;
+
+ searchResults.addResult(sequence, a, a);
}
+ }
- seqcanvas.highlightSearchResults(searchResults);
+ if (pos != -1)
+ {
+ searchResults.addResult(sequence, pos + 1, pos + 1);
}
+ seqcanvas.highlightSearchResults(searchResults);
+ }
- public void mouseClicked(MouseEvent e) { }
+ public void mouseClicked(MouseEvent e)
+ {}
- public void mouseEntered(MouseEvent e) { }
+ public void mouseEntered(MouseEvent e)
+ {}
- public void mouseExited(MouseEvent e) { }
+ public void mouseExited(MouseEvent e)
+ {}
- public void mouseDragged(MouseEvent evt)
- {
- int x = evt.getX();
- int y = evt.getY();
- mx = x;
- my = y;
+ public void mouseDragged(MouseEvent evt)
+ {
+ int x = evt.getX();
+ int y = evt.getY();
+ mx = x;
+ my = y;
+ MCMatrix objmat = new MCMatrix(3, 3);
+ objmat.setIdentity();
- MCMatrix objmat = new MCMatrix(3, 3);
- objmat.setIdentity();
+ if ( (evt.getModifiers() & Event.META_MASK) != 0)
+ {
+ objmat.rotatez( (float) ( (mx - omx)));
+ }
+ else
+ {
+ objmat.rotatex( (float) ( (my - omy)));
+ objmat.rotatey( (float) ( (omx - mx)));
+ }
- if ((evt.getModifiers() & Event.META_MASK) != 0) {
- objmat.rotatez((float) ((mx - omx)));
- } else {
- objmat.rotatex((float) ((my - omy)));
- objmat.rotatey((float) ((omx - mx)));
- }
+ //Alter the bonds
+ for (int ii = 0; ii < pdb.chains.size(); ii++)
+ {
+ Vector bonds = ( (PDBChain) pdb.chains.elementAt(ii)).bonds;
- //Alter the bonds
- for (int ii = 0; ii < pdb.chains.size(); ii++) {
- Vector bonds = ((PDBChain) pdb.chains.elementAt(ii)).bonds;
+ for (int i = 0; i < bonds.size(); i++)
+ {
+ Bond tmpBond = (Bond) bonds.elementAt(i);
- for (int i = 0; i < bonds.size(); i++) {
- Bond tmpBond = (Bond) bonds.elementAt(i);
+ //Translate the bond so the centre is 0,0,0
+ tmpBond.translate( -centre[0], -centre[1], -centre[2]);
- //Translate the bond so the centre is 0,0,0
- tmpBond.translate(-centre[0], -centre[1], -centre[2]);
+ //Now apply the rotation matrix
+ tmpBond.start = objmat.vectorMultiply(tmpBond.start);
+ tmpBond.end = objmat.vectorMultiply(tmpBond.end);
- //Now apply the rotation matrix
- tmpBond.start = objmat.vectorMultiply(tmpBond.start);
- tmpBond.end = objmat.vectorMultiply(tmpBond.end);
+ //Now translate back again
+ tmpBond.translate(centre[0], centre[1], centre[2]);
+ }
+ }
- //Now translate back again
- tmpBond.translate(centre[0], centre[1], centre[2]);
- }
- }
+ objmat = null;
- objmat = null;
+ omx = mx;
+ omy = my;
- omx = mx;
- omy = my;
+ dragging = true;
- dragging = true;
+ redrawneeded = true;
- redrawneeded = true;
+ repaint();
+ }
- repaint();
- }
+ public void mouseReleased(MouseEvent evt)
+ {
+ dragging = false;
+ return;
+ }
+
+ void drawLabels(Graphics g)
+ {
- public void mouseReleased(MouseEvent evt)
+ for (int ii = 0; ii < pdb.chains.size(); ii++)
{
- dragging = false;
- return;
- }
+ PDBChain chain = (PDBChain) pdb.chains.elementAt(ii);
- void drawLabels(Graphics g) {
+ if (chain.isVisible)
+ {
+ Vector bonds = ( (PDBChain) pdb.chains.elementAt(ii)).bonds;
- for (int ii = 0; ii < pdb.chains.size(); ii++)
+ for (int i = 0; i < bonds.size(); i++)
{
- PDBChain chain = (PDBChain) pdb.chains.elementAt(ii);
-
- if (chain.isVisible)
- {
- Vector bonds = ((PDBChain) pdb.chains.elementAt(ii)).bonds;
-
- for (int i = 0; i < bonds.size(); i++)
- {
- Bond tmpBond = (Bond) bonds.elementAt(i);
+ Bond tmpBond = (Bond) bonds.elementAt(i);
- if (tmpBond.at1.isSelected)
- {
- labelAtom(g, tmpBond, 1);
- }
+ if (tmpBond.at1.isSelected)
+ {
+ labelAtom(g, tmpBond, 1);
+ }
- if (tmpBond.at2.isSelected)
- {
+ if (tmpBond.at2.isSelected)
+ {
- labelAtom(g, tmpBond, 2);
- }
- }
- }
+ labelAtom(g, tmpBond, 2);
+ }
}
+ }
}
+ }
- public void labelAtom(Graphics g, Bond b, int n) {
- g.setFont(font);
- g.setColor(Color.red);
- if (n == 1)
- {
- int xstart = (int) (((b.start[0] - centre[0]) * scale) +
- (getWidth() / 2));
- int ystart = (int) (((b.start[1] - centre[1]) * scale) +
- (getHeight() / 2));
+ public void labelAtom(Graphics g, Bond b, int n)
+ {
+ g.setFont(font);
+ g.setColor(Color.red);
+ if (n == 1)
+ {
+ int xstart = (int) ( ( (b.start[0] - centre[0]) * scale) +
+ (getWidth() / 2));
+ int ystart = (int) ( ( (b.start[1] - centre[1]) * scale) +
+ (getHeight() / 2));
- g.drawString(b.at1.resName + "-" + b.at1.resNumber, xstart, ystart);
- }
+ g.drawString(b.at1.resName + "-" + b.at1.resNumber, xstart, ystart);
+ }
- if (n == 2) {
- int xstart = (int) (((b.end[0] - centre[0]) * scale) +
- (getWidth() / 2));
- int ystart = (int) (((b.end[1] - centre[1]) * scale) +
- (getHeight() / 2));
+ if (n == 2)
+ {
+ int xstart = (int) ( ( (b.end[0] - centre[0]) * scale) +
+ (getWidth() / 2));
+ int ystart = (int) ( ( (b.end[1] - centre[1]) * scale) +
+ (getHeight() / 2));
- g.drawString(b.at2.resName + "-" + b.at2.resNumber, xstart, ystart);
- }
+ g.drawString(b.at2.resName + "-" + b.at2.resNumber, xstart, ystart);
}
+ }
+
+ int foundchain = -1;
+ public Atom findAtom(int x, int y)
+ {
+ Atom fatom = null;
- int foundchain = -1;
- public Atom findAtom(int x, int y) {
- Atom fatom = null;
+ foundchain = -1;
+
+ for (int ii = 0; ii < pdb.chains.size(); ii++)
+ {
+ PDBChain chain = (PDBChain) pdb.chains.elementAt(ii);
+ int truex;
+ Bond tmpBond = null;
- foundchain = -1;
+ if (chain.isVisible)
+ {
+ Vector bonds = ( (PDBChain) pdb.chains.elementAt(ii)).bonds;
- for (int ii = 0; ii < pdb.chains.size(); ii++)
+ for (int i = 0; i < bonds.size(); i++)
{
- PDBChain chain = (PDBChain) pdb.chains.elementAt(ii);
- int truex;
- Bond tmpBond=null;
+ tmpBond = (Bond) bonds.elementAt(i);
- if (chain.isVisible)
- {
- Vector bonds = ((PDBChain) pdb.chains.elementAt(ii)).bonds;
-
- for (int i = 0; i < bonds.size(); i++)
- {
- tmpBond = (Bond) bonds.elementAt(i);
-
- truex = (int) (((tmpBond.start[0] - centre[0]) * scale) +
- (getWidth() / 2));
-
- if (Math.abs(truex - x) <= 2)
- {
- int truey = (int) (((tmpBond.start[1] - centre[1]) * scale) +
- (getHeight() / 2));
-
- if (Math.abs(truey - y) <= 2)
- {
- fatom = tmpBond.at1;
- foundchain = ii;
- break;
- }
- }
- }
-
- // Still here? Maybe its the last bond
-
- truex = (int) ( ( (tmpBond.end[0] - centre[0]) * scale) +
- (getWidth() / 2));
-
- if (Math.abs(truex - x) <= 2)
- {
- int truey = (int) ( ( (tmpBond.end[1] - centre[1]) * scale) +
- (getHeight() / 2));
-
- if (Math.abs(truey - y) <= 2)
- {
- fatom = tmpBond.at2;
- foundchain = ii;
- break;
- }
- }
+ truex = (int) ( ( (tmpBond.start[0] - centre[0]) * scale) +
+ (getWidth() / 2));
- }
+ if (Math.abs(truex - x) <= 2)
+ {
+ int truey = (int) ( ( (tmpBond.start[1] - centre[1]) * scale) +
+ (getHeight() / 2));
- if (fatom != null) //)&& chain.ds != null)
- {
- chain = (PDBChain) pdb.chains.elementAt(foundchain);
+ if (Math.abs(truey - y) <= 2)
+ {
+ fatom = tmpBond.at1;
+ foundchain = ii;
+ break;
}
+ }
}
- return fatom;
+ // Still here? Maybe its the last bond
+
+ truex = (int) ( ( (tmpBond.end[0] - centre[0]) * scale) +
+ (getWidth() / 2));
+
+ if (Math.abs(truex - x) <= 2)
+ {
+ int truey = (int) ( ( (tmpBond.end[1] - centre[1]) * scale) +
+ (getHeight() / 2));
+
+ if (Math.abs(truey - y) <= 2)
+ {
+ fatom = tmpBond.at2;
+ foundchain = ii;
+ break;
+ }
+ }
+
+ }
+
+ if (fatom != null) //)&& chain.ds != null)
+ {
+ chain = (PDBChain) pdb.chains.elementAt(foundchain);
+ }
}
- Bond highlightBond1, highlightBond2;
- public void highlightRes(int ii)
+ return fatom;
+ }
+
+ Bond highlightBond1, highlightBond2;
+ public void highlightRes(int ii)
{
- if( !seqColoursReady )
+ if (!seqColoursReady)
+ {
return;
+ }
if (highlightRes != null
- && highlightRes.contains((ii-1) + ""))
+ && highlightRes.contains( (ii - 1) + ""))
{
return;
}
int index = -1;
Bond tmpBond;
- for(index=0; index<mainchain.bonds.size(); index++)
+ for (index = 0; index < mainchain.bonds.size(); index++)
{
tmpBond = (Bond) mainchain.bonds.elementAt(index);
if (tmpBond.at1.alignmentMapping == ii - 1)
{
if (highlightBond1 != null)
+ {
highlightBond1.at2.isSelected = false;
+ }
if (highlightBond2 != null)
+ {
highlightBond2.at1.isSelected = false;
+ }
highlightBond1 = null;
highlightBond2 = null;
repaint();
}
- public void setAllchainsVisible(boolean b)
+ public void setAllchainsVisible(boolean b)
+ {
+ for (int ii = 0; ii < pdb.chains.size(); ii++)
{
- for (int ii = 0; ii < pdb.chains.size(); ii++)
- {
- PDBChain chain = (PDBChain) pdb.chains.elementAt(ii);
- chain.isVisible = b;
- }
- mainchain.isVisible = true;
- findCentre();
- setupBonds();
+ PDBChain chain = (PDBChain) pdb.chains.elementAt(ii);
+ chain.isVisible = b;
}
+ mainchain.isVisible = true;
+ findCentre();
+ setupBonds();
+ }
}
/*
-* Jalview - A Sequence Alignment Editor and Viewer
-* Copyright (C) 2006 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle
-*
-* This program is free software; you can redistribute it and/or
-* modify it under the terms of the GNU General Public License
-* as published by the Free Software Foundation; either version 2
-* of the License, or (at your option) any later version.
-*
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with this program; if not, write to the Free Software
-* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
-*/
+ * Jalview - A Sequence Alignment Editor and Viewer
+ * Copyright (C) 2007 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+ */
package MCview;
-import jalview.datamodel.*;
-
-import jalview.schemes.ResidueProperties;
-
-import java.awt.*;
-
import java.util.*;
-import jalview.analysis.AlignSeq;
+import java.awt.*;
-public class PDBChain {
- /**
- * SequenceFeature group for PDB File features added to sequences
- */
- private static final String PDBFILEFEATURE = "PDBFile";
- private static final String IEASTATUS = "IEA:jalview";
- public String id;
- public Vector bonds = new Vector();
- public Vector atoms = new Vector();
- public Vector residues = new Vector();
- public int offset;
- public Sequence sequence;
- public boolean isVisible = true;
- public int pdbstart = 0;
- public int pdbend = 0;
- public int seqstart = 0;
- public int seqend = 0;
- public String pdbid="";
- public PDBChain(String pdbid, String id) {
- this.pdbid=pdbid.toLowerCase();
- this.id = id;
+import jalview.analysis.*;
+import jalview.datamodel.*;
+import jalview.schemes.*;
+
+public class PDBChain
+{
+ /**
+ * SequenceFeature group for PDB File features added to sequences
+ */
+ private static final String PDBFILEFEATURE = "PDBFile";
+ private static final String IEASTATUS = "IEA:jalview";
+ public String id;
+ public Vector bonds = new Vector();
+ public Vector atoms = new Vector();
+ public Vector residues = new Vector();
+ public int offset;
+ public Sequence sequence;
+ public boolean isVisible = true;
+ public int pdbstart = 0;
+ public int pdbend = 0;
+ public int seqstart = 0;
+ public int seqend = 0;
+ public String pdbid = "";
+ public PDBChain(String pdbid, String id)
+ {
+ this.pdbid = pdbid.toLowerCase();
+ this.id = id;
+ }
+
+ public String print()
+ {
+ String tmp = "";
+
+ for (int i = 0; i < bonds.size(); i++)
+ {
+ tmp = tmp + ( (Bond) bonds.elementAt(i)).at1.resName + " " +
+ ( (Bond) bonds.elementAt(i)).at1.resNumber + " " + offset +
+ "\n";
}
- public String print() {
- String tmp = "";
-
- for (int i = 0; i < bonds.size(); i++) {
- tmp = tmp + ((Bond) bonds.elementAt(i)).at1.resName + " " +
- ((Bond) bonds.elementAt(i)).at1.resNumber + " " + offset +
- "\n";
- }
+ return tmp;
+ }
- return tmp;
- }
+ void makeExactMapping(AlignSeq as, Sequence s1)
+ {
+ int pdbpos = as.getSeq2Start() - 2;
+ int alignpos = s1.getStart() + as.getSeq1Start() - 3;
- void makeExactMapping(AlignSeq as, Sequence s1)
+ for (int i = 0; i < as.astr1.length(); i++)
{
- int pdbpos = as.getSeq2Start()-2;
- int alignpos = s1.getStart() + as.getSeq1Start()-3;
-
- for(int i=0; i<as.astr1.length(); i++)
+ if (as.astr1.charAt(i) != '-')
+ {
+ alignpos++;
+ }
+
+ if (as.astr2.charAt(i) != '-')
+ {
+ pdbpos++;
+ }
+
+ if (as.astr1.charAt(i) == as.astr2.charAt(i))
+ {
+ Residue res = (Residue) residues.elementAt(pdbpos);
+ Enumeration en = res.atoms.elements();
+ while (en.hasMoreElements())
{
- if (as.astr1.charAt(i) != '-')
- {
- alignpos++;
- }
-
- if (as.astr2.charAt(i) != '-')
- {
- pdbpos++;
- }
-
- if (as.astr1.charAt(i) == as.astr2.charAt(i))
- {
- Residue res = (Residue) residues.elementAt(pdbpos);
- Enumeration en = res.atoms.elements();
- while (en.hasMoreElements())
- {
- Atom atom = (Atom) en.nextElement();
- atom.alignmentMapping = alignpos;
- }
- }
+ Atom atom = (Atom) en.nextElement();
+ atom.alignmentMapping = alignpos;
}
+ }
+ }
+ }
+
+ /**
+ * copy over the RESNUM seqfeatures from the internal chain sequence to the mapped sequence
+ * @param seq
+ * @param status The Status of the transferred annotation
+ * @return the features added to sq (or its dataset)
+ */
+ public SequenceFeature[] transferRESNUMFeatures(SequenceI seq, String status)
+ {
+ SequenceI sq = seq;
+ while (sq != null)
+ {
+ if (sq == sequence)
+ {
+ return null;
+ }
+ sq = sq.getDatasetSequence();
}
/**
- * copy over the RESNUM seqfeatures from the internal chain sequence to the mapped sequence
- * @param seq
- * @param status The Status of the transferred annotation
- * @return the features added to sq (or its dataset)
- */
- public SequenceFeature[] transferRESNUMFeatures(SequenceI seq, String status) {
- SequenceI sq = seq;
- while (sq!=null) {
- if (sq==sequence)
- return null;
- sq = sq.getDatasetSequence();
- }
- /**
- * Remove any existing features for this chain if they exist ?
- * SequenceFeature[] seqsfeatures=seq.getSequenceFeatures();
- int totfeat=seqsfeatures.length;
- // Remove any features for this exact chain ?
- for (int i=0; i<seqsfeatures.length; i++) {
- } */
- if (status==null)
- status = PDBChain.IEASTATUS;
- SequenceFeature[] features = sequence.getSequenceFeatures();
- for (int i=0; i<features.length; i++) {
- if (features[i].getFeatureGroup().equals(PDBChain.PDBFILEFEATURE)) {
- SequenceFeature tx = new SequenceFeature(features[i]);
- tx.setBegin(1+((Atom)((Residue)residues.elementAt(tx.getBegin()-offset)).atoms.elementAt(0)).alignmentMapping);
- tx.setEnd(1+((Atom)((Residue)residues.elementAt(tx.getEnd()-offset)).atoms.elementAt(0)).alignmentMapping);
- tx.setStatus(status+((tx.getStatus()==null || tx.getStatus().length()==0) ? "" : ":"+tx.getStatus()));
- seq.addSequenceFeature(tx);
- }
- }
- return features;
+ * Remove any existing features for this chain if they exist ?
+ * SequenceFeature[] seqsfeatures=seq.getSequenceFeatures();
+ int totfeat=seqsfeatures.length;
+ // Remove any features for this exact chain ?
+ for (int i=0; i<seqsfeatures.length; i++) {
+ } */
+ if (status == null)
+ {
+ status = PDBChain.IEASTATUS;
+ }
+ SequenceFeature[] features = sequence.getSequenceFeatures();
+ for (int i = 0; i < features.length; i++)
+ {
+ if (features[i].getFeatureGroup().equals(PDBChain.PDBFILEFEATURE))
+ {
+ SequenceFeature tx = new SequenceFeature(features[i]);
+ tx.setBegin(1 +
+ ( (Atom) ( (Residue) residues.elementAt(tx.getBegin() - offset)).
+ atoms.elementAt(0)).alignmentMapping);
+ tx.setEnd(1 +
+ ( (Atom) ( (Residue) residues.elementAt(tx.getEnd() - offset)).
+ atoms.elementAt(0)).alignmentMapping);
+ tx.setStatus(status +
+ ( (tx.getStatus() == null || tx.getStatus().length() == 0) ?
+ "" : ":" + tx.getStatus()));
+ seq.addSequenceFeature(tx);
+ }
}
+ return features;
+ }
- public void makeCaBondList()
+ public void makeCaBondList()
+ {
+ for (int i = 0; i < (residues.size() - 1); i++)
{
- for (int i = 0; i < (residues.size() - 1); i++)
+ Residue tmpres = (Residue) residues.elementAt(i);
+ Residue tmpres2 = (Residue) residues.elementAt(i + 1);
+ Atom at1 = tmpres.findAtom("CA");
+ Atom at2 = tmpres2.findAtom("CA");
+
+ if ( (at1 != null) && (at2 != null))
+ {
+ if (at1.chain.equals(at2.chain))
{
- Residue tmpres = (Residue) residues.elementAt(i);
- Residue tmpres2 = (Residue) residues.elementAt(i + 1);
- Atom at1 = tmpres.findAtom("CA");
- Atom at2 = tmpres2.findAtom("CA");
-
- if ((at1 != null) && (at2 != null))
- {
- if (at1.chain.equals(at2.chain))
- {
- makeBond(at1, at2);
- }
- }
- else
- System.out.println("not found "+i);
+ makeBond(at1, at2);
}
+ }
+ else
+ {
+ System.out.println("not found " + i);
+ }
+ }
+ }
+
+ public void makeBond(Atom at1, Atom at2)
+ {
+ float[] start = new float[3];
+ float[] end = new float[3];
+
+ start[0] = at1.x;
+ start[1] = at1.y;
+ start[2] = at1.z;
+
+ end[0] = at2.x;
+ end[1] = at2.y;
+ end[2] = at2.z;
+
+ bonds.addElement(new Bond(start, end, at1, at2));
+ }
+
+ public void makeResidueList()
+ {
+ int count = 0;
+ StringBuffer seq = new StringBuffer();
+ Vector resFeatures = new Vector();
+ int i, iSize = atoms.size() - 1;
+ int resNumber = -1;
+ for (i = 0; i <= iSize; i++)
+ {
+ Atom tmp = (Atom) atoms.elementAt(i);
+ resNumber = tmp.resNumber;
+ int res = resNumber;
+
+ if (i == 0)
+ {
+ offset = resNumber;
+ }
+
+ Vector resAtoms = new Vector();
+ //Add atoms to a vector while the residue number
+ //remains the same as the first atom's resNumber (res)
+ while ( (resNumber == res) && (i < atoms.size()))
+ {
+ resAtoms.addElement( (Atom) atoms.elementAt(i));
+ i++;
+
+ if (i < atoms.size())
+ {
+ resNumber = ( (Atom) atoms.elementAt(i)).resNumber;
+ }
+ else
+ {
+ resNumber++;
+ }
+ }
+
+ //We need this to keep in step with the outer for i = loop
+ i--;
+
+ //Make a new Residue object with the new atoms vector
+ residues.addElement(new Residue(resAtoms, resNumber - 1, count));
+
+ Residue tmpres = (Residue) residues.lastElement();
+ Atom tmpat = (Atom) tmpres.atoms.elementAt(0);
+ // Make A new SequenceFeature for the current residue numbering
+ SequenceFeature sf =
+ new SequenceFeature("RESNUM",
+ tmpat.resName + ":" + tmpat.resNumIns + " " +
+ pdbid + id,
+ "", offset + count, offset + count,
+ MCview.PDBChain.PDBFILEFEATURE);
+ resFeatures.addElement(sf);
+ // Keep totting up the sequence
+ if (ResidueProperties.getAA3Hash().get(tmpat.resName) == null)
+ {
+ seq.append("X");
+ // System.err.println("PDBReader:Null aa3Hash for " +
+ // tmpat.resName);
+ }
+ else
+ {
+
+ seq.append(ResidueProperties.aa[ ( (Integer) ResidueProperties.
+ getAA3Hash()
+ .get(tmpat.resName)).intValue()]);
+ }
+ count++;
}
- public void makeBond(Atom at1, Atom at2) {
- float[] start = new float[3];
- float[] end = new float[3];
-
- start[0] = at1.x;
- start[1] = at1.y;
- start[2] = at1.z;
-
- end[0] = at2.x;
- end[1] = at2.y;
- end[2] = at2.z;
+ if (id.length() < 1 || id.equals(" "))
+ {
+ id = "_";
+ }
- bonds.addElement(new Bond(start, end, at1, at2));
+ sequence = new Sequence(id, seq.toString(), offset, resNumber - 1); // Note: resNumber-offset ~= seq.size()
+ // System.out.println("PDB Sequence is :\nSequence = " + seq);
+ // System.out.println("No of residues = " + residues.size());
+ for (i = 0, iSize = resFeatures.size(); i < iSize; i++)
+ {
+ sequence.addSequenceFeature( (SequenceFeature) resFeatures.elementAt(i));
+ resFeatures.setElementAt(null, i);
}
+ }
+
+ public void setChargeColours()
+ {
+ for (int i = 0; i < bonds.size(); i++)
+ {
+ try
+ {
+ Bond b = (Bond) bonds.elementAt(i);
- public void makeResidueList() {
- int count = 0;
- StringBuffer seq = new StringBuffer();
- Vector resFeatures=new Vector();
- int i, iSize = atoms.size()-1;
- int resNumber=-1;
- for (i = 0; i <= iSize; i++)
+ if (b.at1.resName.equalsIgnoreCase("ASP") ||
+ b.at1.resName.equalsIgnoreCase("GLU"))
{
- Atom tmp = (Atom) atoms.elementAt(i);
- resNumber = tmp.resNumber;
- int res = resNumber;
-
- if (i == 0) {
- offset = resNumber;
- }
-
- Vector resAtoms = new Vector();
- //Add atoms to a vector while the residue number
- //remains the same as the first atom's resNumber (res)
- while ((resNumber == res) && (i < atoms.size())) {
- resAtoms.addElement((Atom) atoms.elementAt(i));
- i++;
-
- if (i < atoms.size()) {
- resNumber = ((Atom) atoms.elementAt(i)).resNumber;
- } else {
- resNumber++;
- }
- }
-
- //We need this to keep in step with the outer for i = loop
- i--;
-
- //Make a new Residue object with the new atoms vector
- residues.addElement(new Residue(resAtoms, resNumber - 1, count));
-
- Residue tmpres = (Residue) residues.lastElement();
- Atom tmpat = (Atom) tmpres.atoms.elementAt(0);
- // Make A new SequenceFeature for the current residue numbering
- SequenceFeature sf =
- new SequenceFeature("RESNUM",tmpat.resName+":"+tmpat.resNumIns+" "+pdbid+id,
- "",offset+count,offset+count,MCview.PDBChain.PDBFILEFEATURE);
- resFeatures.addElement(sf);
- // Keep totting up the sequence
- if (ResidueProperties.getAA3Hash().get(tmpat.resName) == null)
- {
- seq.append("X") ;
- // System.err.println("PDBReader:Null aa3Hash for " +
- // tmpat.resName);
- } else {
-
- seq.append(ResidueProperties.aa[((Integer) ResidueProperties.getAA3Hash()
- .get(tmpat.resName)).intValue()]);
- }
- count++;
+ b.startCol = Color.red;
+ }
+ else if (b.at1.resName.equalsIgnoreCase("LYS") ||
+ b.at1.resName.equalsIgnoreCase("ARG"))
+ {
+ b.startCol = Color.blue;
+ }
+ else if (b.at1.resName.equalsIgnoreCase("CYS"))
+ {
+ b.startCol = Color.yellow;
+ }
+ else
+ {
+ b.startCol = Color.lightGray;
}
- if(id.length()<1 || id.equals(" "))
- id = "_";
-
- sequence = new Sequence(id, seq.toString(), offset, resNumber-1); // Note: resNumber-offset ~= seq.size()
- // System.out.println("PDB Sequence is :\nSequence = " + seq);
- // System.out.println("No of residues = " + residues.size());
- for (i=0,iSize=resFeatures.size(); i<iSize; i++) {
- sequence.addSequenceFeature((SequenceFeature) resFeatures.elementAt(i));
- resFeatures.setElementAt(null, i);
+ if (b.at2.resName.equalsIgnoreCase("ASP") ||
+ b.at2.resName.equalsIgnoreCase("GLU"))
+ {
+ b.endCol = Color.red;
+ }
+ else if (b.at2.resName.equalsIgnoreCase("LYS") ||
+ b.at2.resName.equalsIgnoreCase("ARG"))
+ {
+ b.endCol = Color.blue;
}
- }
-
- public void setChargeColours() {
- for (int i = 0; i < bonds.size(); i++) {
- try {
- Bond b = (Bond) bonds.elementAt(i);
-
- if (b.at1.resName.equalsIgnoreCase("ASP") ||
- b.at1.resName.equalsIgnoreCase("GLU")) {
- b.startCol = Color.red;
- } else if (b.at1.resName.equalsIgnoreCase("LYS") ||
- b.at1.resName.equalsIgnoreCase("ARG")) {
- b.startCol = Color.blue;
- } else if (b.at1.resName.equalsIgnoreCase("CYS")) {
- b.startCol = Color.yellow;
- } else {
- b.startCol = Color.lightGray;
- }
-
- if (b.at2.resName.equalsIgnoreCase("ASP") ||
- b.at2.resName.equalsIgnoreCase("GLU")) {
- b.endCol = Color.red;
- } else if (b.at2.resName.equalsIgnoreCase("LYS") ||
- b.at2.resName.equalsIgnoreCase("ARG")) {
- b.endCol = Color.blue;
- } else if (b.at2.resName.equalsIgnoreCase("CYS")) {
- b.endCol = Color.yellow;
- } else {
- b.endCol = Color.lightGray;
- }
- } catch (Exception e) {
- Bond b = (Bond) bonds.elementAt(i);
- b.startCol = Color.gray;
- b.endCol = Color.gray;
- }
+ else if (b.at2.resName.equalsIgnoreCase("CYS"))
+ {
+ b.endCol = Color.yellow;
+ }
+ else
+ {
+ b.endCol = Color.lightGray;
}
+ }
+ catch (Exception e)
+ {
+ Bond b = (Bond) bonds.elementAt(i);
+ b.startCol = Color.gray;
+ b.endCol = Color.gray;
+ }
}
+ }
-
- public void setChainColours(jalview.schemes.ColourSchemeI cs)
+ public void setChainColours(jalview.schemes.ColourSchemeI cs)
+ {
+ Bond b;
+ int index;
+ for (int i = 0; i < bonds.size(); i++)
{
- Bond b;
- int index;
- for (int i = 0; i < bonds.size(); i++) {
- try {
- b = (Bond) bonds.elementAt(i);
-
- index = ( (Integer) ResidueProperties.aa3Hash.get(b.at1.
- resName)).intValue();
- b.startCol = cs.findColour(ResidueProperties.aa[index].charAt(0));
-
- index = ( (Integer) ResidueProperties.aa3Hash.get(b.at2.resName)).
- intValue();
- b.endCol = cs.findColour(ResidueProperties.aa[index].charAt(0));
-
- } catch (Exception e)
- {
- b = (Bond) bonds.elementAt(i);
- b.startCol = Color.gray;
- b.endCol = Color.gray;
- }
- }
+ try
+ {
+ b = (Bond) bonds.elementAt(i);
+
+ index = ( (Integer) ResidueProperties.aa3Hash.get(b.at1.
+ resName)).intValue();
+ b.startCol = cs.findColour(ResidueProperties.aa[index].charAt(0));
+
+ index = ( (Integer) ResidueProperties.aa3Hash.get(b.at2.resName)).
+ intValue();
+ b.endCol = cs.findColour(ResidueProperties.aa[index].charAt(0));
+
+ }
+ catch (Exception e)
+ {
+ b = (Bond) bonds.elementAt(i);
+ b.startCol = Color.gray;
+ b.endCol = Color.gray;
+ }
}
+ }
-
-
- public void setChainColours(Color col)
+ public void setChainColours(Color col)
+ {
+ for (int i = 0; i < bonds.size(); i++)
{
- for (int i = 0; i < bonds.size(); i++)
- {
- Bond tmp = (Bond) bonds.elementAt(i);
- tmp.startCol = col;
- tmp.endCol = col;
- }
+ Bond tmp = (Bond) bonds.elementAt(i);
+ tmp.startCol = col;
+ tmp.endCol = col;
}
+ }
}
/*
* Jalview - A Sequence Alignment Editor and Viewer
- * Copyright (C) 2006 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle
+ * Copyright (C) 2007 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
*/
package MCview;
-import javax.swing.*;
+import java.io.*;
+
import java.awt.event.*;
+import javax.swing.*;
+
import jalview.datamodel.*;
-import jalview.schemes.*;
import jalview.gui.*;
-import jalview.io.EBIFetchClient;
-import java.awt.event.ActionListener;
-import java.awt.event.ActionEvent;
-import java.io.*;
-import jalview.io.JalviewFileChooser;
-import jalview.io.JalviewFileView;
+import jalview.io.*;
+import jalview.schemes.*;
-public class PDBViewer extends JInternalFrame implements Runnable
+public class PDBViewer
+ extends JInternalFrame implements Runnable
{
PDBEntry pdb;
/**
PDBCanvas pdbcanvas;
String tmpPDBFile;
-
public PDBViewer(PDBEntry entry,
Sequence seq,
SeqCanvas seqcanvas)
ex.printStackTrace();
}
-
- if (entry==null)
+ if (entry == null)
+ {
return;
+ }
pdb = entry;
sequence = seq;
pdbcanvas = new PDBCanvas(seqcanvas, sequence);
- if(pdb.getFile()!=null)
+ if (pdb.getFile() != null)
{
- try{
- tmpPDBFile = pdb.getFile();
- PDBfile pdbfile = new PDBfile(tmpPDBFile,
- jalview.io.AppletFormatAdapter.FILE);
- pdbcanvas.setPDBFile(pdbfile);
+ try
+ {
+ tmpPDBFile = pdb.getFile();
+ PDBfile pdbfile = new PDBfile(tmpPDBFile,
+ jalview.io.AppletFormatAdapter.FILE);
+ pdbcanvas.setPDBFile(pdbfile);
- }catch(java.io.IOException ex)
- {
- ex.printStackTrace();
- }
+ }
+ catch (java.io.IOException ex)
+ {
+ ex.printStackTrace();
+ }
}
else
{
worker.start();
}
-
-
setContentPane(pdbcanvas);
StringBuffer title = new StringBuffer(sequence.getName() + ":" + pdb.getId());
- if(pdb.getProperty()!=null)
+ if (pdb.getProperty() != null)
{
- if (pdb.getProperty().get("method")!=null)
+ if (pdb.getProperty().get("method") != null)
{
title.append(" Method: ");
title.append(pdb.getProperty().get("method"));
title.append(pdb.getProperty().get("chains"));
}
}
- Desktop.addInternalFrame(this,title.toString(),400, 400);
+ Desktop.addInternalFrame(this, title.toString(), 400, 400);
}
public void run()
{
try
{
- EBIFetchClient ebi = new EBIFetchClient();
- String query = "pdb:" + pdb.getId();
- tmpPDBFile = ebi.fetchDataAsFile(query, "default", "raw").getAbsolutePath();
- if (tmpPDBFile != null)
- {
- PDBfile pdbfile = new PDBfile(tmpPDBFile, jalview.io.AppletFormatAdapter.FILE);
- pdbcanvas.setPDBFile(pdbfile);
- }
- else
- {
- throw new Exception("Empty result for WSDbFetch Query: " + query);
- }
+ EBIFetchClient ebi = new EBIFetchClient();
+ String query = "pdb:" + pdb.getId();
+ tmpPDBFile = ebi.fetchDataAsFile(query, "default", "raw").getAbsolutePath();
+ if (tmpPDBFile != null)
+ {
+ PDBfile pdbfile = new PDBfile(tmpPDBFile,
+ jalview.io.AppletFormatAdapter.FILE);
+ pdbcanvas.setPDBFile(pdbfile);
+ }
+ else
+ {
+ throw new Exception("Empty result for WSDbFetch Query: " + query);
+ }
}
catch (Exception ex)
{
throws Exception
{
this.addKeyListener(new KeyAdapter()
- {
- public void keyPressed(KeyEvent evt)
- {
- pdbcanvas.keyPressed(evt);
- }
- });
+ {
+ public void keyPressed(KeyEvent evt)
+ {
+ pdbcanvas.keyPressed(evt);
+ }
+ });
this.setJMenuBar(jMenuBar1);
fileMenu.setText("File");
bg.add(buried);
bg.add(user);
-
- if(jalview.gui.UserDefinedColours.getUserColourSchemes()!=null)
+ if (jalview.gui.UserDefinedColours.getUserColourSchemes() != null)
{
java.util.Enumeration userColours = jalview.gui.UserDefinedColours.
getUserColourSchemes().keys();
while (userColours.hasMoreElements())
{
- final JRadioButtonMenuItem radioItem = new JRadioButtonMenuItem(userColours.
+ final JRadioButtonMenuItem radioItem = new JRadioButtonMenuItem(
+ userColours.
nextElement().toString());
radioItem.setName("USER_DEFINED");
radioItem.addMouseListener(new MouseAdapter()
+ {
+ public void mousePressed(MouseEvent evt)
+ {
+ if (evt.isControlDown() || SwingUtilities.isRightMouseButton(evt))
{
- public void mousePressed(MouseEvent evt)
+ radioItem.removeActionListener(radioItem.getActionListeners()[0]);
+
+ int option = JOptionPane.showInternalConfirmDialog(jalview.gui.
+ Desktop.desktop,
+ "Remove from default list?",
+ "Remove user defined colour",
+ JOptionPane.YES_NO_OPTION);
+ if (option == JOptionPane.YES_OPTION)
+ {
+ jalview.gui.UserDefinedColours.removeColourFromDefaults(
+ radioItem.getText());
+ coloursMenu.remove(radioItem);
+ }
+ else
{
- if(evt.isControlDown() || SwingUtilities.isRightMouseButton(evt))
+ radioItem.addActionListener(new ActionListener()
{
- radioItem.removeActionListener(radioItem.getActionListeners()[0]);
-
- int option = JOptionPane.showInternalConfirmDialog(jalview.gui.Desktop.desktop,
- "Remove from default list?",
- "Remove user defined colour",
- JOptionPane.YES_NO_OPTION);
- if(option == JOptionPane.YES_OPTION)
+ public void actionPerformed(ActionEvent evt)
{
- jalview.gui.UserDefinedColours.removeColourFromDefaults(radioItem.getText());
- coloursMenu.remove(radioItem);
+ user_actionPerformed(evt);
}
- else
- radioItem.addActionListener(new ActionListener()
- {
- public void actionPerformed(ActionEvent evt)
- {
- user_actionPerformed(evt);
- }
- });
- }
+ });
}
- });
+ }
+ }
+ });
radioItem.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent evt)
JRadioButtonMenuItem seqButton = new JRadioButtonMenuItem();
JRadioButtonMenuItem hydro = new JRadioButtonMenuItem();
JRadioButtonMenuItem taylor = new JRadioButtonMenuItem();
- JRadioButtonMenuItem zappo = new JRadioButtonMenuItem();
+ JRadioButtonMenuItem zappo = new JRadioButtonMenuItem();
JRadioButtonMenuItem user = new JRadioButtonMenuItem();
JRadioButtonMenuItem buried = new JRadioButtonMenuItem();
JRadioButtonMenuItem turn = new JRadioButtonMenuItem();
*/
public void png_actionPerformed(ActionEvent e)
{
- makePDBImage(jalview.util.ImageMaker.PNG);
+ makePDBImage(jalview.util.ImageMaker.PNG);
}
void makePDBImage(int type)
jalview.util.ImageMaker im;
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);
+ }
else
+ {
im = new jalview.util.ImageMaker(this,
jalview.util.ImageMaker.EPS,
"Make EPS file from view",
width, height,
null, this.getTitle());
+ }
if (im.getGraphics() != null)
{
im.writeImage();
}
}
+
public void charge_actionPerformed(ActionEvent e)
{
pdbcanvas.bysequence = false;
pdbcanvas.pdb.setChargeColours();
- pdbcanvas.redrawneeded=true;
+ pdbcanvas.redrawneeded = true;
pdbcanvas.repaint();
}
{
pdbcanvas.bysequence = false;
pdbcanvas.pdb.setColours(new HydrophobicColourScheme());
- pdbcanvas.redrawneeded=true;
+ pdbcanvas.redrawneeded = true;
pdbcanvas.repaint();
}
{
pdbcanvas.bysequence = false;
pdbcanvas.pdb.setChainColours();
- pdbcanvas.redrawneeded=true;
+ pdbcanvas.redrawneeded = true;
pdbcanvas.repaint();
}
public void zbuffer_actionPerformed(ActionEvent e)
{
- pdbcanvas.zbuffer = ! pdbcanvas.zbuffer;
- pdbcanvas.redrawneeded=true;
+ pdbcanvas.zbuffer = !pdbcanvas.zbuffer;
+ pdbcanvas.redrawneeded = true;
pdbcanvas.repaint();
}
public void molecule_actionPerformed(ActionEvent e)
{
- pdbcanvas.bymolecule = ! pdbcanvas.bymolecule;
- pdbcanvas.redrawneeded=true;
+ pdbcanvas.bymolecule = !pdbcanvas.bymolecule;
+ pdbcanvas.redrawneeded = true;
pdbcanvas.repaint();
}
public void depth_actionPerformed(ActionEvent e)
{
- pdbcanvas.depthcue = ! pdbcanvas.depthcue;
- pdbcanvas.redrawneeded=true;
+ pdbcanvas.depthcue = !pdbcanvas.depthcue;
+ pdbcanvas.redrawneeded = true;
pdbcanvas.repaint();
}
public void wire_actionPerformed(ActionEvent e)
{
- pdbcanvas.wire = ! pdbcanvas.wire;
- pdbcanvas.redrawneeded=true;
+ pdbcanvas.wire = !pdbcanvas.wire;
+ pdbcanvas.redrawneeded = true;
pdbcanvas.repaint();
}
pdbcanvas.updateSeqColours();
}
-
public void mapping_actionPerformed(ActionEvent e)
{
jalview.gui.CutAndPasteTransfer cap = new jalview.gui.CutAndPasteTransfer();
{
pdbcanvas.setAllchainsVisible(allchains.getState());
}
+
void showErrorMessage(String error)
{
JOptionPane.showInternalMessageDialog(Desktop.desktop,
- error, "PDB Viewer Error", JOptionPane.WARNING_MESSAGE);
+ error, "PDB Viewer Error",
+ JOptionPane.WARNING_MESSAGE);
}
-
public void zappo_actionPerformed(ActionEvent e)
{
pdbcanvas.bysequence = false;
pdbcanvas.pdb.setColours(new ZappoColourScheme());
- pdbcanvas.redrawneeded=true;
+ pdbcanvas.redrawneeded = true;
pdbcanvas.repaint();
}
{
pdbcanvas.bysequence = false;
pdbcanvas.pdb.setColours(new TaylorColourScheme());
- pdbcanvas.redrawneeded=true;
+ pdbcanvas.redrawneeded = true;
pdbcanvas.repaint();
}
{
pdbcanvas.bysequence = false;
pdbcanvas.pdb.setColours(new HelixColourScheme());
- pdbcanvas.redrawneeded=true;
+ pdbcanvas.redrawneeded = true;
pdbcanvas.repaint();
}
{
pdbcanvas.bysequence = false;
pdbcanvas.pdb.setColours(new StrandColourScheme());
- pdbcanvas.redrawneeded=true;
+ pdbcanvas.redrawneeded = true;
pdbcanvas.repaint();
}
{
pdbcanvas.bysequence = false;
pdbcanvas.pdb.setColours(new TurnColourScheme());
- pdbcanvas.redrawneeded=true;
+ pdbcanvas.redrawneeded = true;
pdbcanvas.repaint();
}
{
pdbcanvas.bysequence = false;
pdbcanvas.pdb.setColours(new BuriedColourScheme());
- pdbcanvas.redrawneeded=true;
+ pdbcanvas.redrawneeded = true;
pdbcanvas.repaint();
}
getUserColourSchemes().get(e.getActionCommand());
pdbcanvas.pdb.setColours(udc);
- pdbcanvas.redrawneeded=true;
+ pdbcanvas.redrawneeded = true;
pdbcanvas.repaint();
}
}
public void background_actionPerformed(ActionEvent e)
{
- java.awt.Color col = JColorChooser.showDialog(this, "Select Background Colour",
- pdbcanvas.backgroundColour);
-
- if(col!=null)
- {
- pdbcanvas.backgroundColour = col;
- pdbcanvas.redrawneeded = true;
- pdbcanvas.repaint();
- }
+ java.awt.Color col = JColorChooser.showDialog(this,
+ "Select Background Colour",
+ pdbcanvas.backgroundColour);
+
+ if (col != null)
+ {
+ pdbcanvas.backgroundColour = col;
+ pdbcanvas.redrawneeded = true;
+ pdbcanvas.repaint();
+ }
}
public void savePDB_actionPerformed(ActionEvent e)
if (value == JalviewFileChooser.APPROVE_OPTION)
{
- try
- {
- BufferedReader in = new BufferedReader(new FileReader(tmpPDBFile));
- File outFile = chooser.getSelectedFile();
+ try
+ {
+ BufferedReader in = new BufferedReader(new FileReader(tmpPDBFile));
+ File outFile = chooser.getSelectedFile();
- PrintWriter out = new PrintWriter(new FileOutputStream(outFile));
- String data;
- while ( (data = in.readLine()) != null)
+ PrintWriter out = new PrintWriter(new FileOutputStream(outFile));
+ String data;
+ while ( (data = in.readLine()) != null)
+ {
+ if (
+ ! (data.indexOf("<PRE>") > -1 || data.indexOf("</PRE>") > -1)
+ )
{
- if (
- !( data.indexOf("<PRE>") > -1 || data.indexOf("</PRE>") > -1)
- )
- out.println(data);
+ out.println(data);
}
- out.close();
- }
- catch (Exception ex)
- {
- ex.printStackTrace();
}
+ out.close();
+ }
+ catch (Exception ex)
+ {
+ ex.printStackTrace();
}
+ }
}
}
/*
-* Jalview - A Sequence Alignment Editor and Viewer
-* Copyright (C) 2006 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle
-*
-* This program is free software; you can redistribute it and/or
-* modify it under the terms of the GNU General Public License
-* as published by the Free Software Foundation; either version 2
-* of the License, or (at your option) any later version.
-*
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with this program; if not, write to the Free Software
-* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
-*/
+ * Jalview - A Sequence Alignment Editor and Viewer
+ * Copyright (C) 2007 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+ */
package MCview;
-import jalview.datamodel.*;
-
import java.io.*;
-
import java.util.*;
-import java.awt.Color;
+import java.awt.*;
-public class PDBfile extends jalview.io.AlignFile {
- public Vector chains;
- public String id;
+import jalview.datamodel.*;
- public PDBfile(String inFile, String inType) throws IOException
+public class PDBfile
+ extends jalview.io.AlignFile
+{
+ public Vector chains;
+ public String id;
+
+ public PDBfile(String inFile, String inType)
+ throws IOException
+ {
+ super(inFile, inType);
+ }
+
+ public String print()
+ {
+ return null;
+ }
+
+ public void parse()
+ throws IOException
+ {
+ try
{
- super(inFile, inType);
- }
+ chains = new Vector();
- public String print()
- {
- return null;
- }
+ PDBChain tmpchain;
+ String line;
+ boolean modelFlag = false;
+ boolean terFlag = false;
- public void parse() throws IOException
- {
- try{
- chains = new Vector();
+ int index = 0;
+ while ( (line = nextLine()) != null)
+ {
+ if (line.indexOf("HEADER") == 0)
+ {
+ id = line.substring(62, 67).trim();
+ continue;
+ }
+ // Were we to do anything with SEQRES - we start it here
+ if (line.indexOf("SEQRES") == 0)
+ {
+ }
+
+ if (line.indexOf("MODEL") == 0)
+ {
+ modelFlag = true;
+ }
- PDBChain tmpchain;
- String line;
- boolean modelFlag = false;
- boolean terFlag = false;
+ if (line.indexOf("TER") == 0)
+ {
+ terFlag = true;
+ }
- int index = 0;
- while ( (line = nextLine()) != null)
+ if (modelFlag && line.indexOf("ENDMDL") == 0)
{
- if (line.indexOf("HEADER") == 0)
+ break;
+ }
+ if (line.indexOf("ATOM") == 0
+ || (line.indexOf("HETATM") == 0 && !terFlag)
+ )
+ {
+ terFlag = false;
+
+ //Jalview is only interested in CA bonds????
+ if (!line.substring(12, 15).trim().equals("CA"))
{
- id = line.substring(62, 67).trim();
continue;
}
- // Were we to do anything with SEQRES - we start it here
- if (line.indexOf("SEQRES") == 0) {
+
+ Atom tmpatom = new Atom(line);
+ tmpchain = findChain(tmpatom.chain);
+ if (tmpchain != null)
+ {
+ tmpchain.atoms.addElement(tmpatom);
}
-
- if (line.indexOf("MODEL") == 0)
- modelFlag = true;
-
- if (line.indexOf("TER") == 0)
- terFlag = true;
-
- if (modelFlag && line.indexOf("ENDMDL") == 0)
- break;
- if (line.indexOf("ATOM") == 0
- || (line.indexOf("HETATM") == 0 && !terFlag)
- )
+ else
{
- terFlag = false;
-
- //Jalview is only interested in CA bonds????
- if (!line.substring(12, 15).trim().equals("CA"))
- {
- continue;
- }
-
- Atom tmpatom = new Atom(line);
- tmpchain = findChain(tmpatom.chain);
- if (tmpchain != null)
- {
- tmpchain.atoms.addElement(tmpatom);
- }
- else
- {
- tmpchain = new PDBChain(id,tmpatom.chain);
- chains.addElement(tmpchain);
- tmpchain.atoms.addElement(tmpatom);
- }
+ tmpchain = new PDBChain(id, tmpatom.chain);
+ chains.addElement(tmpchain);
+ tmpchain.atoms.addElement(tmpatom);
}
- index++;
}
+ index++;
+ }
- makeResidueList();
- makeCaBondList();
+ makeResidueList();
+ makeCaBondList();
- if (id == null)
- {
- id = inFile.getName();
- }
- for (int i = 0; i < chains.size(); i++)
+ if (id == null)
+ {
+ id = inFile.getName();
+ }
+ for (int i = 0; i < chains.size(); i++)
+ {
+ SequenceI dataset = ( (PDBChain) chains.elementAt(i)).
+ sequence;
+ dataset.setName(id + "|" + dataset.getName());
+ PDBEntry entry = new PDBEntry();
+ entry.setId(id);
+ if (inFile != null)
{
- SequenceI dataset = ( (PDBChain) chains.elementAt(i)).
- sequence;
- dataset.setName(id + "|" + dataset.getName());
- PDBEntry entry = new PDBEntry();
- entry.setId(id);
- if (inFile != null)
- entry.setFile(inFile.getAbsolutePath());
- dataset.addPDBId(entry);
- getSeqs().addElement(dataset.deriveSequence()); // PDBChain objects maintain reference to dataset
+ entry.setFile(inFile.getAbsolutePath());
}
- }catch(OutOfMemoryError er)
- {
- System.out.println("OUT OF MEMORY LOADING PDB FILE");
- throw new IOException("Out of memory loading PDB File");
+ dataset.addPDBId(entry);
+ getSeqs().addElement(dataset.deriveSequence()); // PDBChain objects maintain reference to dataset
}
}
-
- public void makeResidueList() {
- for (int i = 0; i < chains.size(); i++) {
- ((PDBChain) chains.elementAt(i)).makeResidueList();
- }
+ catch (OutOfMemoryError er)
+ {
+ System.out.println("OUT OF MEMORY LOADING PDB FILE");
+ throw new IOException("Out of memory loading PDB File");
}
+ }
- public void makeCaBondList() {
- for (int i = 0; i < chains.size(); i++) {
- ((PDBChain) chains.elementAt(i)).makeCaBondList();
- }
+ public void makeResidueList()
+ {
+ for (int i = 0; i < chains.size(); i++)
+ {
+ ( (PDBChain) chains.elementAt(i)).makeResidueList();
}
+ }
- public PDBChain findChain(String id) {
- for (int i = 0; i < chains.size(); i++) {
- if (((PDBChain) chains.elementAt(i)).id.equals(id)) {
- return (PDBChain) chains.elementAt(i);
- }
- }
+ public void makeCaBondList()
+ {
+ for (int i = 0; i < chains.size(); i++)
+ {
+ ( (PDBChain) chains.elementAt(i)).makeCaBondList();
+ }
+ }
- return null;
+ public PDBChain findChain(String id)
+ {
+ for (int i = 0; i < chains.size(); i++)
+ {
+ if ( ( (PDBChain) chains.elementAt(i)).id.equals(id))
+ {
+ return (PDBChain) chains.elementAt(i);
+ }
}
- public void setChargeColours() {
- for (int i = 0; i < chains.size(); i++) {
- ((PDBChain) chains.elementAt(i)).setChargeColours();
- }
+ return null;
+ }
+
+ public void setChargeColours()
+ {
+ for (int i = 0; i < chains.size(); i++)
+ {
+ ( (PDBChain) chains.elementAt(i)).setChargeColours();
}
+ }
- public void setColours(jalview.schemes.ColourSchemeI cs) {
- for (int i = 0; i < chains.size(); i++) {
- ((PDBChain) chains.elementAt(i)).setChainColours(cs);
- }
+ public void setColours(jalview.schemes.ColourSchemeI cs)
+ {
+ for (int i = 0; i < chains.size(); i++)
+ {
+ ( (PDBChain) chains.elementAt(i)).setChainColours(cs);
}
+ }
- public void setChainColours()
+ public void setChainColours()
+ {
+ for (int i = 0; i < chains.size(); i++)
{
- for (int i = 0; i < chains.size(); i++)
- {
- ((PDBChain) chains.elementAt(i)).setChainColours(
- Color.getHSBColor(1.0f / (float)i, .4f, 1.0f)
- );
- }
+ ( (PDBChain) chains.elementAt(i)).setChainColours(
+ Color.getHSBColor(1.0f / (float) i, .4f, 1.0f)
+ );
}
+ }
}
/*\r
-* Jalview - A Sequence Alignment Editor and Viewer\r
-* Copyright (C) 2006 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle\r
-*\r
-* This program is free software; you can redistribute it and/or\r
-* modify it under the terms of the GNU General Public License\r
-* as published by the Free Software Foundation; either version 2\r
-* of the License, or (at your option) any later version.\r
-*\r
-* This program is distributed in the hope that it will be useful,\r
-* but WITHOUT ANY WARRANTY; without even the implied warranty of\r
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
-* GNU General Public License for more details.\r
-*\r
-* You should have received a copy of the GNU General Public License\r
-* along with this program; if not, write to the Free Software\r
-* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA\r
-*/\r
+ * Jalview - A Sequence Alignment Editor and Viewer\r
+ * Copyright (C) 2007 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle\r
+ *\r
+ * This program is free software; you can redistribute it and/or\r
+ * modify it under the terms of the GNU General Public License\r
+ * as published by the Free Software Foundation; either version 2\r
+ * of the License, or (at your option) any later version.\r
+ *\r
+ * This program is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
+ * GNU General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU General Public License\r
+ * along with this program; if not, write to the Free Software\r
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA\r
+ */\r
package MCview;\r
\r
import java.util.*;\r
\r
+public class Residue\r
+{\r
+ Vector atoms = new Vector();\r
+ int number;\r
+ int count;\r
+ int seqnumber;\r
\r
-public class Residue {\r
- Vector atoms = new Vector();\r
- int number;\r
- int count;\r
- int seqnumber;\r
+ public Residue(Vector atoms, int number, int count)\r
+ {\r
+ this.atoms = atoms;\r
+ this.number = number;\r
+ this.count = count;\r
+ }\r
\r
- public Residue(Vector atoms, int number, int count) {\r
- this.atoms = atoms;\r
- this.number = number;\r
- this.count = count;\r
- }\r
-\r
- public Atom findAtom(String name)\r
+ public Atom findAtom(String name)\r
+ {\r
+ for (int i = 0; i < atoms.size(); i++)\r
{\r
- for (int i = 0; i < atoms.size(); i++)\r
- {\r
- if (((Atom) atoms.elementAt(i)).name.equals(name))\r
- {\r
- return (Atom) atoms.elementAt(i);\r
- }\r
- }\r
-\r
- return null;\r
+ if ( ( (Atom) atoms.elementAt(i)).name.equals(name))\r
+ {\r
+ return (Atom) atoms.elementAt(i);\r
+ }\r
}\r
+\r
+ return null;\r
+ }\r
}\r
/*\r
-* Jalview - A Sequence Alignment Editor and Viewer\r
-* Copyright (C) 2006 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle\r
-*\r
-* This program is free software; you can redistribute it and/or\r
-* modify it under the terms of the GNU General Public License\r
-* as published by the Free Software Foundation; either version 2\r
-* of the License, or (at your option) any later version.\r
-*\r
-* This program is distributed in the hope that it will be useful,\r
-* but WITHOUT ANY WARRANTY; without even the implied warranty of\r
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
-* GNU General Public License for more details.\r
-*\r
-* You should have received a copy of the GNU General Public License\r
-* along with this program; if not, write to the Free Software\r
-* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA\r
-*/\r
+ * Jalview - A Sequence Alignment Editor and Viewer\r
+ * Copyright (C) 2007 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle\r
+ *\r
+ * This program is free software; you can redistribute it and/or\r
+ * modify it under the terms of the GNU General Public License\r
+ * as published by the Free Software Foundation; either version 2\r
+ * of the License, or (at your option) any later version.\r
+ *\r
+ * This program is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
+ * GNU General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU General Public License\r
+ * along with this program; if not, write to the Free Software\r
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA\r
+ */\r
package MCview;\r
\r
import java.util.*;\r
\r
+public class Zsort\r
+{\r
+ public void Zsort(Vector bonds)\r
+ {\r
+ sort(bonds, 0, bonds.size() - 1);\r
+ }\r
\r
-public class Zsort {\r
- public void Zsort(Vector bonds) {\r
- sort(bonds, 0, bonds.size() - 1);\r
- }\r
-\r
- public void sort(Vector bonds, int p, int r) {\r
- int q;\r
+ public void sort(Vector bonds, int p, int r)\r
+ {\r
+ int q;\r
\r
- if (p < r) {\r
- q = partition(bonds, p, r);\r
- sort(bonds, p, q);\r
- sort(bonds, q + 1, r);\r
- }\r
+ if (p < r)\r
+ {\r
+ q = partition(bonds, p, r);\r
+ sort(bonds, p, q);\r
+ sort(bonds, q + 1, r);\r
}\r
+ }\r
\r
- private int partition(Vector bonds, int p, int r) {\r
- float x = ((Bond) bonds.elementAt(p)).start[2];\r
- int i = p - 1;\r
- int j = r + 1;\r
- Bond tmp;\r
- while (true) {\r
- do {\r
- j --;\r
- } while ((j >= 0) && (((Bond) bonds.elementAt(j)).start[2] > x));\r
+ private int partition(Vector bonds, int p, int r)\r
+ {\r
+ float x = ( (Bond) bonds.elementAt(p)).start[2];\r
+ int i = p - 1;\r
+ int j = r + 1;\r
+ Bond tmp;\r
+ while (true)\r
+ {\r
+ do\r
+ {\r
+ j--;\r
+ }\r
+ while ( (j >= 0) && ( ( (Bond) bonds.elementAt(j)).start[2] > x));\r
\r
- do {\r
- i ++;\r
- } while ((i < bonds.size()) &&\r
- (((Bond) bonds.elementAt(i)).start[2] < x));\r
+ do\r
+ {\r
+ i++;\r
+ }\r
+ while ( (i < bonds.size()) &&\r
+ ( ( (Bond) bonds.elementAt(i)).start[2] < x));\r
\r
- if (i < j) {\r
- tmp = (Bond) bonds.elementAt(i);\r
- bonds.setElementAt(bonds.elementAt(j), i);\r
- bonds.setElementAt(tmp, j);\r
- } else {\r
- return j;\r
- }\r
- }\r
+ if (i < j)\r
+ {\r
+ tmp = (Bond) bonds.elementAt(i);\r
+ bonds.setElementAt(bonds.elementAt(j), i);\r
+ bonds.setElementAt(tmp, j);\r
+ }\r
+ else\r
+ {\r
+ return j;\r
+ }\r
}\r
+ }\r
}\r