001/* 002 * BioJava development code 003 * 004 * This code may be freely distributed and modified under the 005 * terms of the GNU Lesser General Public Licence. This should 006 * be distributed with the code. If you do not have a copy, 007 * see: 008 * 009 * http://www.gnu.org/copyleft/lesser.html 010 * 011 * Copyright for this code is held jointly by the individual 012 * authors. These should be listed in @author doc comments. 013 * 014 * For more information on the BioJava project and its aims, 015 * or to join the biojava-l mailing list, visit the home page 016 * at: 017 * 018 * http://www.biojava.org/ 019 * 020 */ 021 022package org.biojava.bio.molbio; 023 024import org.biojava.bio.BioError; 025import org.biojava.bio.seq.DNATools; 026import org.biojava.bio.symbol.IllegalSymbolException; 027 028/** 029 * Computes composition statistics about a DNA <code>SymbolList</code>. 030 * 031 * @author Mark Schreiber 032 * @since 1.6 033 */ 034public class DNAComposition extends Composition{ 035 036 037 public DNAComposition(){ 038 super(); 039 try { 040 setSymbolList(DNATools.createDNA("acgt")); 041 } catch (IllegalSymbolException ex) { 042 System.err.println("Severe Error. Cannot create DNA SymbolList with 'acgt"); 043 } 044 } 045 046 /** 047 * Get the relative compositon of 'A'. 048 * @return between 0.0 and 1.0 049 */ 050 public double getA(){ 051 try { 052 return getDistribution().getWeight(DNATools.a()); 053 } catch (IllegalSymbolException ex) { 054 throw new BioError("Severe Error with DNA configuration.",ex); 055 } 056 } 057 058 /** 059 * Get the relative compositon of 'C'. 060 * @return between 0.0 and 1.0 061 */ 062 public double getC(){ 063 try { 064 return getDistribution().getWeight(DNATools.c()); 065 } catch (IllegalSymbolException ex) { 066 throw new BioError("Severe Error with DNA configuration.",ex); 067 } 068 } 069 070 /** 071 * Get the relative compositon of 'G'. 072 * @return between 0.0 and 1.0 073 */ 074 public double getG(){ 075 try { 076 return getDistribution().getWeight(DNATools.g()); 077 } catch (IllegalSymbolException ex) { 078 throw new BioError("Severe Error with DNA configuration.",ex); 079 } 080 } 081 082 /** 083 * Get the relative compositon of 'T'. 084 * @return between 0.0 and 1.0 085 */ 086 public double getT(){ 087 try { 088 return getDistribution().getWeight(DNATools.t()); 089 } catch (IllegalSymbolException ex) { 090 throw new BioError("Severe Error with DNA configuration.",ex); 091 } 092 } 093}