package jalview.gui; import jalview.datamodel.*; import jalview.schemes.*; import jalview.util.*; import jalview.analysis.*; import java.awt.*; import java.awt.geom.*; import java.util.*; public class CpGRenderer implements RendererI { protected Color color = Color.black; public Color getResidueBoxColour(ColourSchemeI cs, SequenceI seq, int i) { Color c = cs.findColour(seq,seq.getSequence(i,i+1),i,null); return c; } public void drawSequence(Graphics g,ColourSchemeI cs,SequenceI seq,int start, int end, int x1, int y1, double width, int height,boolean showScores, boolean displayBoxes, boolean displayText,Vector pid, int seqnum,AlignViewport av) { int i = start; int length = seq.getLength(); Color currentColor = Color.white; g.setColor(Color.black); int window = 1000; int max = window/5; int step = window/10; if (step > window) { step = window; } if (window < 2) { window = 2; step = 1; } int cpgstart = start; int cpgend = end; if (cpgstart <= window/2 ) { cpgstart = window/2; } if (cpgend+window/2 >= length) { cpgend = length-window/2; } Hashtable vals = AAFrequency.findKmerCount(seq,cpgstart,cpgend,window,step,av.getKmers()); Enumeration en = vals.keys(); Vector valset = new Vector(); while (en.hasMoreElements()) { valset.add((Integer)en.nextElement()); } Collections.sort(valset); g.setColor(Color.black); int j = 0; while (j < valset.size()) { Integer posInt = (Integer)valset.elementAt(j); int count = ((Integer)vals.get(posInt)).intValue(); int pos = posInt.intValue(); if (count > 40) { g.setColor(Color.red); } else { g.setColor(Color.black); } g.fillRect(x1 + (int)(width*(pos-start-width/2)), y1+height - (int)(count*height/max), (int)(step*width), (int)(count*height/max)); j++; } } }