Difference between revisions of "PKU journal Task5"
From Bioinformatikpedia
(Created page with "== Plot of the mapping == We used the java library Graphics2D here and apart from some parsing, and preprocessing of the data, the plot is pretty much the following class. For th…") |
|||
Line 1: | Line 1: | ||
+ | [[Phenylketonuria]]»[[Researching and mapping point mutations]]»journal |
||
+ | |||
== Plot of the mapping == |
== Plot of the mapping == |
||
We used the java library Graphics2D here and apart from some parsing, and preprocessing of the data, the plot is pretty much the following class. For the complete sourcecode please write to [mailto:sebastian.hollizeck@campus.lmu.de Sebastian]. |
We used the java library Graphics2D here and apart from some parsing, and preprocessing of the data, the plot is pretty much the following class. For the complete sourcecode please write to [mailto:sebastian.hollizeck@campus.lmu.de Sebastian]. |
Revision as of 16:35, 9 June 2012
Phenylketonuria»Researching and mapping point mutations»journal
Plot of the mapping
We used the java library Graphics2D here and apart from some parsing, and preprocessing of the data, the plot is pretty much the following class. For the complete sourcecode please write to Sebastian.
<source lang="java"> package SNPMapping;
import java.awt.Color; import java.awt.Font; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.geom.RoundRectangle2D; import java.awt.image.BufferedImage; import java.io.File; import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; import java.util.LinkedList; import javax.imageio.ImageIO;
/**
* Created on 09.06.2012, 15:03:25 * @author Sebastian Hollizeck <sebastian.hollizeck@campus.lmu.de> */
public class MapPainter {
public static void paint(LinkedList<Residue> input,String output) throws IOException { int multi = 10; //get maximal residue position Residue last = input.peekLast(); int max = last.getPosition(); max *= multi; //drawing default picture; BufferedImage off_Image = new BufferedImage(900, max + 150, BufferedImage.TYPE_INT_ARGB); Graphics2D g2 = off_Image.createGraphics(); g2.setBackground(Color.white); g2.setColor(Color.white); g2.fillRect(0, 0, max + 100, max + 150); RoundRectangle2D sequence = new RoundRectangle2D.Double(70, 100, 20, max, 10, 10); g2.setColor(Color.black); g2.draw(sequence); Font original = g2.getFont(); //print caption Font caption = new Font("SanSerif",Font.BOLD,24); g2.setFont(caption); g2.drawString("SNP mapping for PAH",300,50);
//revert font g2.setFont(original);
for (Residue r : input) { int pos = r.getPosition(); ArrayList<String> muts = r.getMutations(); String effect = r.getEffect(); int paintpos = 100 + pos * multi; if (pos % 10 == 0) { g2.drawString(pos + "", 40, paintpos); } if (muts == null&&effect==null) { //muts is only null if nothing but the position is in the file; continue; }
g2.drawLine(70, paintpos, 140, paintpos); int offset = 75; int count = 1; for (String s : muts) { if (s.endsWith("*")) { g2.setColor(Color.red); } else if (s.endsWith("+")) { g2.setColor(Color.orange); } else if (s.endsWith("#")) { g2.setColor(Color.green); } if (s.length() > 1) { String mut = s.substring(0, s.length() - 1); g2.drawString(mut, 90 + offset * count, paintpos); count++; } } g2.setColor(Color.black); if (effect != null) { if (effect.equals("*")) { g2.setColor(Color.red); g2.drawString("conserved, probably disease effect", 90 + offset * 6, paintpos); } else if (effect.equals("+")) { g2.setColor(Color.green); g2.drawString("not conserved, little effect", 90 + offset * 6, paintpos); } } g2.setColor(Color.black); }
File out = new File(output); ImageIO.write(off_Image, "png", out); }
}
</source>