From: amwaterhouse Date: Tue, 1 Nov 2005 15:34:35 +0000 (+0000) Subject: disulfide bond exceptions X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=7daa352541756250e798b0d7479b2bc7f807de0b;p=jalview.git disulfide bond exceptions --- diff --git a/src/jalview/gui/FeatureRenderer.java b/src/jalview/gui/FeatureRenderer.java index 372ecd7..829bafb 100755 --- a/src/jalview/gui/FeatureRenderer.java +++ b/src/jalview/gui/FeatureRenderer.java @@ -39,6 +39,8 @@ public class FeatureRenderer Color resBoxColour; Graphics graphics; float transparency = 1.0f; + FontMetrics fm; + int charOffset; // The following vector holds the features which are // to be added, in the correct order or rendering @@ -75,6 +77,8 @@ public class FeatureRenderer if (seq.getDatasetSequence().getSequenceFeatures() == null) return; + fm = g.getFontMetrics(); + if (transparency != 1) { Graphics2D g2 = (Graphics2D) g; @@ -83,88 +87,52 @@ public class FeatureRenderer AlphaComposite.SRC_OVER, transparency)); } - Enumeration e, e2; String type; SequenceFeature sf; - if (featuresDisplayed != null) - { - e = featuresDisplayed.elements(); - while(e.hasMoreElements()) - { - type = e.nextElement().toString(); - e2 = seq.getDatasetSequence().getSequenceFeatures().elements(); - while(e2.hasMoreElements()) - { - sf = (SequenceFeature) e2.nextElement(); - if(!type.equals(sf.getType() ) ) - continue; - - if (sf.getBegin() > seq.getEnd()) - continue; - - renderFeature(g,seq, - seq.findIndex(sf.getBegin()) - 1, - seq.findIndex(sf.getEnd()) - 1, - type,start,end,x1,y1,width,height); - } - } - } - else + if (featuresDisplayed == null || featuresDisplayed.size()==0) + findAllFeatures(); + + Enumeration e = featuresDisplayed.elements(), e2; + + // Loop through each visible feature + while (e.hasMoreElements()) { - e = seq.getDatasetSequence().getSequenceFeatures().elements(); - while (e.hasMoreElements()) + + type = e.nextElement().toString(); + e2 = seq.getDatasetSequence().getSequenceFeatures().elements(); + // loop through all features in sequence to find + // current feature to render + while (e2.hasMoreElements()) { - sf = (SequenceFeature) e.nextElement(); - type = sf.getType(); + + sf = (SequenceFeature) e2.nextElement(); + if (!type.equals(sf.getType())) + continue; if (sf.getBegin() > seq.getEnd()) - { continue; - } - renderFeature(g,seq, - seq.findIndex(sf.getBegin()) - 1, - seq.findIndex(sf.getEnd()) - 1, - type,start,end,x1,y1,width,height); + if (type.equals("disulfide bond")) + { + + renderFeature(g, seq, + seq.findIndex(sf.getBegin()) - 1, + seq.findIndex(sf.getBegin()) - 1, + type, start, end, x1, y1, width, height); + renderFeature(g, seq, + seq.findIndex(sf.getEnd()) - 1, + seq.findIndex(sf.getEnd()) - 1, + type, start, end, x1, y1, width, height); + } + else + renderFeature(g, seq, + seq.findIndex(sf.getBegin()) - 1, + seq.findIndex(sf.getEnd()) - 1, + type, start, end, x1, y1, width, height); } } - /* while (e.hasMoreElements()) - { - SequenceFeature sf=null; - if(featuresDisplayed!=null) - { - e2 = seq.getDatasetSequence().getSequenceFeatures().elements(); - type = e.nextElement().toString(); - while(e2.hasMoreElements()) - { - sf = (SequenceFeature) e2.nextElement(); - if(sf.getType().equals(type)) - break; - else - sf = null; - } - } - else - { - sf = (SequenceFeature) e.nextElement(); - type = sf.getType(); - } - - if(sf==null) - continue; - - - if (sf.getBegin() > seq.getEnd()) - { - continue; - } - - int fstart = seq.findIndex(sf.getBegin()) - 1; - int fend = seq.findIndex(sf.getEnd()) - 1; -*/ - if(transparency!=1.0f) { Graphics2D g2 = (Graphics2D) g; @@ -174,9 +142,11 @@ public class FeatureRenderer } } + void renderFeature(Graphics g, SequenceI seq, int fstart, int fend, String type, int start, int end, int x1, int y1, int width, int height) { + if (((fstart <= end) && (fend >= start))) { if (fstart < start) @@ -186,48 +156,53 @@ public class FeatureRenderer if (fend >= end) { - fend = end; + fend = end; } - - if (fstart == fend) + for (int i = fstart; i <= fend; i++) { - g.setColor(getColour(type)); - g.fillRoundRect((fstart - start) * width, y1, width, - height, 4, 4); - g.setColor(Color.white); - - char s = seq.getSequence().charAt(fstart); - FontMetrics fm = g.getFontMetrics(); - int charOffset = (width - fm.charWidth(s)) / 2; - int pady = height / 5; - g.drawString(String.valueOf(s), - charOffset + x1 + (width * (fstart - start)), - (y1 + height) - pady); + char s = seq.getSequence().charAt(i); + + if (jalview.util.Comparison.isGap(s)) + { + continue; + } + + g.setColor(getColour(type)); + + g.fillRect( (i - start) * width, y1, width, height); + + g.setColor(Color.white); + + charOffset = (width - fm.charWidth(s)) / 2; + g.drawString(String.valueOf(s), + charOffset + x1 + (width * (i - start)), + (y1 + height) - height/5);//pady = height / 5; } - else + } + } + + void findAllFeatures() + { + Vector features = new Vector(); + SequenceFeature sf; + featuresDisplayed = new Vector(); + Enumeration e; + for (int i = 0; i < av.alignment.getHeight(); i++) + { + features = av.alignment.getSequenceAt(i).getDatasetSequence(). + getSequenceFeatures(); + if (features == null) + continue; + + e = features.elements(); + while (e.hasMoreElements()) + { + sf = (SequenceFeature) e.nextElement(); + if (!featuresDisplayed.contains(sf.getType())) { - for (int i = fstart; i <= fend; i++) - { - char s = seq.getSequence().charAt(i); - - if (jalview.util.Comparison.isGap(s)) - { - continue; - } - - g.setColor(getColour(type)); - g.fillRect((i - start) * width, y1, width, height); - - g.setColor(Color.white); - - FontMetrics fm = g.getFontMetrics(); - int charOffset = (width - fm.charWidth(s)) / 2; - int pady = height / 5; - g.drawString(String.valueOf(s), - charOffset + x1 + (width * (i - start)), - (y1 + height) - pady); - } + featuresDisplayed.addElement(sf.getType()); } + } } } @@ -276,7 +251,7 @@ public class FeatureRenderer featureColours.put("coiled-coil region", new Color(215, 115, 0)); featureColours.put("compositionally biased region", new Color(205, 125, 0)); featureColours.put("cross-link", new Color(195, 135, 0)); - featureColours.put("disulfide bond", new Color(185, 145, 0)); + featureColours.put("disulfide bond", new Color(230,230,0)); featureColours.put("DNA-binding region", new Color(175, 155, 0)); featureColours.put("domain", new Color(165, 165, 0)); featureColours.put("glycosylation site", new Color(155, 175, 0)); @@ -288,8 +263,7 @@ public class FeatureRenderer featureColours.put("mutagenesis site", new Color(95, 235, 45)); featureColours.put("non-consecutive residues", new Color(85, 245, 55)); featureColours.put("non-terminal residue", new Color(75, 255, 65)); - featureColours.put("nucleotide phosphate-binding region", - new Color(65, 245, 75)); + featureColours.put("nucleotide phosphate-binding region",new Color(65, 245, 75)); featureColours.put("peptide", new Color(55, 235, 85)); featureColours.put("propeptide", new Color(45, 225, 95)); featureColours.put("region of interest", new Color(35, 215, 105)); diff --git a/src/jalview/gui/IdPanel.java b/src/jalview/gui/IdPanel.java index 011502b..7c70c01 100755 --- a/src/jalview/gui/IdPanel.java +++ b/src/jalview/gui/IdPanel.java @@ -59,6 +59,7 @@ public class IdPanel extends JPanel implements MouseListener, add(idCanvas, BorderLayout.CENTER); addMouseListener(this); addMouseMotionListener(this); + ToolTipManager.sharedInstance().registerComponent(this); } /** @@ -68,6 +69,28 @@ public class IdPanel extends JPanel implements MouseListener, */ public void mouseMoved(MouseEvent e) { + int y = e.getY(); + + if (av.getWrapAlignment()) + { + y = getWrappedY(y); + } + + int seq = av.getIndex(y); + if(seq!=-1) + { + StringBuffer tip = new StringBuffer(""); + tip.append(av.alignment.getSequenceAt(seq).getDisplayId(true, true)); + if (av.alignment.getSequenceAt(seq).getDescription() != null) + { + tip.append("
"); + tip.append(av.alignment.getSequenceAt(seq).getDescription()); + tip.append(""); + } + tip.append(""); + setToolTipText(tip.toString()); + } + } int getWrappedY(int y) @@ -124,7 +147,7 @@ public class IdPanel extends JPanel implements MouseListener, */ public void mouseClicked(MouseEvent e) { - if (e.getClickCount() < 2) + if (e.getClickCount() < 2) return; java.util.Vector links = Preferences.sequenceURLLinks; diff --git a/src/jalview/gui/SeqPanel.java b/src/jalview/gui/SeqPanel.java index 600da64..491b667 100755 --- a/src/jalview/gui/SeqPanel.java +++ b/src/jalview/gui/SeqPanel.java @@ -402,16 +402,29 @@ public class SeqPanel extends JPanel if ( (sf.getBegin() <= sequence.findPosition(res)) && (sf.getEnd() >= sequence.findPosition(res))) { - if (sbuffer.length() > 6) - sbuffer.append("
"); - - sbuffer.append(sf.getType()); - if (sf.getDescription() != null) - sbuffer.append(" " + sf.getDescription()); - - if (sf.getStatus() != null) + if (sf.getType().equals("disulfide bond")) { - sbuffer.append(" (" + sf.getStatus() + ")"); + if (sf.getBegin() == sequence.findPosition(res) + || sf.getEnd() == sequence.findPosition(res)) + { + if (sbuffer.length() > 6) + sbuffer.append("
"); + sbuffer.append("disulfide bond " + sf.getBegin() + ":" + + sf.getEnd()); + } + } + else + { + if (sbuffer.length() > 6) + sbuffer.append("
"); + sbuffer.append(sf.getType()); + if (sf.getDescription() != null) + sbuffer.append(" " + sf.getDescription()); + + if (sf.getStatus() != null) + { + sbuffer.append(" (" + sf.getStatus() + ")"); + } } }