Team:Freiburg software/Code/DisplaySequence.java
From 2009.igem.org
(Difference between revisions)
Paul.S (Talk | contribs)
(New page: <div style="display: none;"><html><style> #tabs a.code_active { background-position:0% -42px; } #tabs a.code_active span { background-position:100% -42px; color:#213340; } #toc { display:n...)
Newer edit →
(New page: <div style="display: none;"><html><style> #tabs a.code_active { background-position:0% -42px; } #tabs a.code_active span { background-position:100% -42px; color:#213340; } #toc { display:n...)
Newer edit →
Revision as of 21:59, 20 October 2009
/* Copyright: synbiowave License: GPL Authors: Paul Staab Version: 0.1 DESCRIPTION: This class can be used to create different visualizations of a DNA-Sequence */ package org.synbiowave.biojava; import org.biojava.bio.seq.DNATools; import org.biojava.bio.seq.RNATools; import org.biojava.bio.symbol.SymbolList; /** * <p>Class to create various visualizations of a DNA-Sequence</p> */ public class DisplaySequence { private SymbolList symL; public DisplaySequence(String[] args) throws Exception { } public DisplaySequence(SymbolList symL) throws Exception { //ToDo: Check for DNA and throw error this.symL = symL; } /** Setter for the DNA-Sequence stored in a SymbolList */ public void set_Sequenz(SymbolList symL) throws Exception { //ToDo: Check for DNA and throw error this.symL = symL; } /** Getter for the DNA-Sequence stored in a SymbolList */ public SymbolList get_Sequenz() throws Exception { return this.symL; } /** Displays a Single ReadingFrame (number in 1-6 with 1-3 * being forward and 4-6 being backward readingframes) plus the sequence */ public String displaySingleReadingFrame(int number) throws Exception { if (number > 3) return displaySingleReadingFrame(number-3,true); else return displaySingleReadingFrame(number,false); } /** Displays the Sequence and a single readingframe; * number is the number of the readingframe to display (1-3) * backwards = false means forward reading frames, true backward ones */ public String displaySingleReadingFrame(int number, boolean backwards) throws Exception { return generateReadingframe(number,backwards) + this.symL.seqString() + "\n" + addNumberation(this.symL.length()); } /** Displays the Sequence and the 3 forward readingframes */ public String displayFwReadingFrames() throws Exception { return generateReadingframe(1,false) + generateReadingframe(2,false) + generateReadingframe(3,false) + this.symL.seqString() + "\n" + addNumberation(this.symL.length()); } /** Displays the Sequence and the 3 backward readingframes */ public String displayRevReadingFrames() throws Exception { return generateReadingframe(1,true) + generateReadingframe(2,true) + generateReadingframe(3,true) + DNATools.reverseComplement(this.symL).seqString() + "\n" + addNumberation(this.symL.length()); } /** Displays the Sequence and all 6 readingframes */ public String displayAllReadingFrames() throws Exception { return generateReadingframe(1,false) + //"<br>" + generateReadingframe(2,false) + //"<br>" + generateReadingframe(3,false) + //"<br>" + this.symL.seqString() + //"<br>" + addNumberation(this.symL.length()) + //"<br>" + DNATools.reverseComplement(this.symL).seqString() + //"<br>" + generateReadingframe(3,true) + //"<br>" + generateReadingframe(2,true) + //"<br>" + generateReadingframe(1,true) ; //"<br>"; } static private String addNumberation(int end) { String returnvalue = "1"; for (int i = 2; i <= end; i++) { if (i%10 == 0) returnvalue += Integer.toString(i); else if (i%10 < Integer.toString(i).length()) ; else returnvalue += " "; } return returnvalue + "\n"; } /** Generates a basic formatted readingframe */ private String generateReadingframe(int number, boolean backwards) throws Exception { SymbolList symL; String formattedReadingframe = ""; //ToDo: FEHLER AUSGEBEN WENN NUMBER > 3 number --; if (backwards) symL = DNATools.reverseComplement(this.symL); else symL = this.symL; //Translate the DNA into AA symL = symL.subList(number+1, symL.length() - (symL.length() - number)%3); symL = DNATools.toRNA(symL); symL = RNATools.translate(symL); //Insert beginning spaces for (int i = 1; i < number + 1; i++) { formattedReadingframe += " "; } //Insert 2 spaces between each AA for (int i = 1; i <= symL.length() ; i++) { formattedReadingframe += symL.subStr(i, i) + " " ; } return formattedReadingframe + "\n"; } }