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.biojavax.ga.impl; 023import org.biojava.bio.symbol.SimpleSymbolList; 024import org.biojava.bio.symbol.SymbolList; 025import org.biojava.utils.ChangeVetoException; 026import org.biojavax.ga.Organism; 027 028/** 029 * A Simple Haploid Organism implementation 030 * 031 * @author Mark Schreiber 032 * @version 1.0 033 * @since 1.5 034 */ 035 036public class SimpleOrganism extends AbstractOrganism { 037 038 public SimpleOrganism(){ 039 super(); 040 } 041 public SimpleOrganism(String name){ 042 super(); 043 try { 044 setName(name); 045 } 046 catch (ChangeVetoException ex) { 047 //can't happen till after the organism has been made 048 } 049 } 050 051 public SimpleOrganism(Organism org, String name){ 052 super(org, name); 053 } 054 055 protected void setChromImpl(SymbolList[] chromosomes) { 056 this.chromosomes = chromosomes; 057 } 058 059 /** 060 * Simple Organisms are Halpoid 061 * @return true 062 */ 063 public boolean isHaploid() { 064 return true; 065 } 066 067 public Organism replicate(String name){ 068 SimpleOrganism o = new SimpleOrganism(name); 069 SymbolList[] symls = new SymbolList[this.getChromosomes().length]; 070 for (int i = 0; i < symls.length; i++) { 071 symls[i] = new SimpleSymbolList(this.getChromosomes()[i]); 072 } 073 074 o.setChromImpl(symls); 075 return o; 076 } 077 078}