public void paintItem(Graphics2D g, int x1, int y1, int x2, int y2) { if (!canPaint()) { return; } Iterator<ScoredRegion> regions = model.getResults(); while (regions.hasNext()) { ScoredRegion r = regions.next(); int minx = getXPos(r.getStart(), getRegion().getStart(), getRegion().getEnd(), x1, x2); int maxx = getXPos(r.getEnd(), getRegion().getStart(), getRegion().getEnd(), x1, x2); float percent = (float) (1.0 - r.getScore() / maxScore); g.setColor(new Color(percent, percent, percent, (float) 1.0)); g.fillRect(minx, y1, maxx - minx, (y2 - y1)); } if (props.DrawTrackLabel) { g.setColor(new Color((float) 0.0, (float) 0.0, (float) 0.0, (float) 0.5)); g.drawString(getLabel(), x1, y2); } }
public static void main(String args[]) throws Exception { Genome genome = Args.parseGenome(args).cdr(); ChipChipDataset dataset = new ChipChipDataset(genome); List<Region> regions = Args.parseRegionsOrDefault(args); double means[] = new double[CGHCallExpander.numStates], stddevs[] = new double[CGHCallExpander.numStates]; String[] pieces = Args.parseString( args, "low", String.format( "%f;%f", CGHCallExpander.defaultParams[0][0], Math.sqrt(CGHCallExpander.defaultParams[0][1]))) .split(";"); means[CGHCallExpander.LOW] = Double.parseDouble(pieces[0]); stddevs[CGHCallExpander.LOW] = Math.pow(Double.parseDouble(pieces[1]), 2); pieces = Args.parseString( args, "middle", String.format( "%f;%f", CGHCallExpander.defaultParams[0][0], Math.sqrt(CGHCallExpander.defaultParams[0][1]))) .split(";"); means[CGHCallExpander.ONE] = Double.parseDouble(pieces[0]); stddevs[CGHCallExpander.ONE] = Math.pow(Double.parseDouble(pieces[1]), 2); pieces = Args.parseString( args, "high", String.format( "%f;%f", CGHCallExpander.defaultParams[0][0], Math.sqrt(CGHCallExpander.defaultParams[0][1]))) .split(";"); means[CGHCallExpander.HIGH] = Double.parseDouble(pieces[0]); stddevs[CGHCallExpander.HIGH] = Math.pow(Double.parseDouble(pieces[1]), 2); for (ExptNameVersion env : Args.parseENV(args)) { ChipChipData ccd = dataset.getData(env); CGHCallExpander cgh = new CGHCallExpander(ccd); cgh.setStateParameters( CGHCallExpander.LOW, means[CGHCallExpander.LOW], stddevs[CGHCallExpander.LOW]); cgh.setStateParameters( CGHCallExpander.ONE, means[CGHCallExpander.ONE], stddevs[CGHCallExpander.ONE]); cgh.setStateParameters( CGHCallExpander.HIGH, means[CGHCallExpander.HIGH], stddevs[CGHCallExpander.HIGH]); cgh.resetHMM(); for (Region r : regions) { List<ScoredRegion> calls = cgh.executeList(r); for (ScoredRegion call : calls) { System.out.println(call.getScore() + "\t" + call.regionString()); } } } }