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 GoNameSpace {
30 public final String MOLECULAR_FUNCTION_STR = "molecular_function";
31 public final String BIOLOGICAL_PROCESS_STR = "biological_process";
32 public final String CELLULAR_COMPONENT_STR = "cellular_component";
33 public final String UNASSIGNED_STR = "unassigned";
34 private final GoNamespaceType _type;
36 public GoNameSpace( final GoNamespaceType type ) {
40 public GoNameSpace( final String type ) {
41 if ( type.toLowerCase().equals( MOLECULAR_FUNCTION_STR ) ) {
42 _type = GoNamespaceType.MOLECULAR_FUNCTION;
44 else if ( type.toLowerCase().equals( BIOLOGICAL_PROCESS_STR ) ) {
45 _type = GoNamespaceType.BIOLOGICAL_PROCESS;
47 else if ( type.toLowerCase().equals( CELLULAR_COMPONENT_STR ) ) {
48 _type = GoNamespaceType.CELLULAR_COMPONENT;
50 else if ( type.toLowerCase().equals( UNASSIGNED_STR ) ) {
51 _type = GoNamespaceType.UNASSIGNED;
54 throw new IllegalArgumentException( "unknown GO namespace: " + type );
59 public boolean equals( final Object o ) {
63 else if ( ( o == null ) || ( o.getClass() != this.getClass() ) ) {
67 return getType() == ( ( GoNameSpace ) o ).getType();
71 public GoNamespaceType getType() {
75 public boolean isBiologicalProcess() {
76 return getType() == GoNamespaceType.BIOLOGICAL_PROCESS;
79 public boolean isCellularComponent() {
80 return getType() == GoNamespaceType.CELLULAR_COMPONENT;
83 public boolean isMolecularFunction() {
84 return getType() == GoNamespaceType.MOLECULAR_FUNCTION;
87 public boolean isUnassigned() {
88 return getType() == GoNamespaceType.UNASSIGNED;
91 public String toShortString() {
93 case BIOLOGICAL_PROCESS:
95 case CELLULAR_COMPONENT:
97 case MOLECULAR_FUNCTION:
102 throw new RuntimeException();
107 public String toString() {
109 case BIOLOGICAL_PROCESS:
110 return ( BIOLOGICAL_PROCESS_STR );
111 case CELLULAR_COMPONENT:
112 return ( CELLULAR_COMPONENT_STR );
113 case MOLECULAR_FUNCTION:
114 return ( MOLECULAR_FUNCTION_STR );
116 return ( UNASSIGNED_STR );
118 throw new RuntimeException();
122 public static GoNameSpace createBiologicalProcess() {
123 return new GoNameSpace( GoNamespaceType.BIOLOGICAL_PROCESS );
126 public static GoNameSpace createCellularComponent() {
127 return new GoNameSpace( GoNamespaceType.CELLULAR_COMPONENT );
130 public static GoNameSpace createMolecularFunction() {
131 return new GoNameSpace( GoNamespaceType.MOLECULAR_FUNCTION );
134 public static GoNameSpace createUnassigned() {
135 return new GoNameSpace( GoNamespaceType.UNASSIGNED );
138 public static enum GoNamespaceType {
139 MOLECULAR_FUNCTION, BIOLOGICAL_PROCESS, CELLULAR_COMPONENT, UNASSIGNED;