2 // FORESTER -- software libraries and applications
3 // for evolutionary biology research and applications.
5 // Copyright (C) 2008-2009 Christian M. Zmasek
6 // Copyright (C) 2008-2009 Burnham Institute for Medical Research
9 // This library is free software; you can redistribute it and/or
10 // modify it under the terms of the GNU Lesser General Public
11 // License as published by the Free Software Foundation; either
12 // version 2.1 of the License, or (at your option) any later version.
14 // This library is distributed in the hope that it will be useful,
15 // but WITHOUT ANY WARRANTY; without even the implied warranty of
16 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 // Lesser General Public License for more details.
19 // You should have received a copy of the GNU Lesser General Public
20 // License along with this library; if not, write to the Free Software
21 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23 // Contact: phylosoft @ gmail . com
24 // WWW: https://sites.google.com/site/cmzmasek/home/software/forester
26 package org.forester.go;
28 public class BasicGoSubset implements GoSubset {
32 public BasicGoSubset( final String s ) {
33 final String my_s = s.trim().toLowerCase();
34 if ( my_s.equals( GOSLIM_GENERIC_STR ) ) {
35 _type = Type.GOSLIM_GENERIC;
37 else if ( my_s.equals( GOSLIM_GOA_STR ) ) {
38 _type = Type.GOSLIM_GOA;
40 else if ( my_s.equals( GOSLIM_PIR_STR ) ) {
41 _type = Type.GOSLIM_PIR;
43 else if ( my_s.equals( GOSUBSET_PROK_STR ) ) {
44 _type = Type.GOSUBSET_PROK;
46 else if ( my_s.equals( GOSLIM_CANDIDA_STR ) ) {
47 _type = Type.GOSLIM_CANDIDA;
49 else if ( my_s.equals( GOSLIM_ASPERGILLUS_STR ) ) {
50 _type = Type.GOSLIM_ASPERGILLUS;
52 else if ( my_s.equals( GOSLIM_PLANT_STR ) ) {
53 _type = Type.GOSLIM_PLANT;
55 else if ( my_s.equals( GOSLIM_YEAST_STR ) ) {
56 _type = Type.GOSLIM_YEAST;
58 else if ( my_s.equals( GOSLIM_POMBE_STR ) ) {
59 _type = Type.GOSLIM_POMBE;
66 public BasicGoSubset( final Type type ) {
71 public int compareTo( final GoSubset sub ) {
72 return getType().compareTo( sub.getType() );
76 public boolean equals( final Object o ) {
80 else if ( o == null ) {
81 throw new IllegalArgumentException( "attempt to check go subset equality to null" );
83 else if ( o.getClass() != this.getClass() ) {
84 throw new IllegalArgumentException( "attempt to check go subset equality to " + o + " [" + o.getClass()
88 return ( getType() == ( ( GoSubset ) o ).getType() );
93 public Type getType() {
98 public String toString() {
99 final StringBuilder sb = new StringBuilder();
100 switch ( getType() ) {
102 sb.append( GOSLIM_CANDIDA_STR );
105 sb.append( GOSLIM_GENERIC_STR );
108 sb.append( GOSLIM_GOA_STR );
111 sb.append( GOSLIM_PIR_STR );
114 sb.append( GOSLIM_PLANT_STR );
116 case GOSLIM_ASPERGILLUS:
117 sb.append( GOSLIM_ASPERGILLUS_STR );
120 sb.append( GOSLIM_YEAST_STR );
123 sb.append( GOSUBSET_PROK_STR );
126 sb.append( GOSLIM_POMBE_STR );
129 sb.append( "other" );
132 return sb.toString();