2 // forester -- software libraries and applications
3 // for genomics and evolutionary biology research.
5 // Copyright (C) 2010 Christian M Zmasek
6 // Copyright (C) 2010 Sanford-Burnham Medical Research Institute
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: www.phylosoft.org/forester
26 package org.forester.ws.seqdb;
28 import java.util.ArrayList;
29 import java.util.List;
31 import org.forester.util.ForesterUtil;
33 public final class UniProtTaxonomy {
35 private static final String ARCHAEA = "Archaea";
36 private static final String BACTERIA = "Bacteria";
37 private static final String EUKARYOTA = "Eukaryota";
38 private final List<String> _lineage;
39 private final String _code;
40 private final String _scientific_name;
41 private final String _common_name;
42 private final String _synonym;
43 private final String _rank;
44 private final String _id;
45 public final static String CELLULAR_ORGANISMS = "cellular organisms";
46 public final static String VIRUSES = "Viruses";
47 public final static UniProtTaxonomy DROSOPHILA_GENUS = new UniProtTaxonomy( new String[] {
48 CELLULAR_ORGANISMS, EUKARYOTA, "Metazoa", "Arthropoda", "Hexapoda", "Insecta", "Pterygota", "Neoptera",
49 "Endopterygota", "Diptera", "Brachycera", "Muscomorpha", "Ephydroidea", "Drosophilidae", "Drosophila" },
56 public final static UniProtTaxonomy XENOPUS_GENUS = new UniProtTaxonomy( new String[] {
57 CELLULAR_ORGANISMS, EUKARYOTA, "Metazoa", "Chordata", "Craniata", "Vertebrata", "Euteleostomi", "Amphibia",
58 "Batrachia", "Anura", "Mesobatrachia", "Pipoidea", "Pipidae", "Xenopodinae", "Xenopus" },
65 public final static UniProtTaxonomy CAPITELLA_TELATA_SPECIES = new UniProtTaxonomy( new String[] {
66 CELLULAR_ORGANISMS, EUKARYOTA, "Metazoa", "Annelida", "Polychaeta", "Scolecida", "Capitellida",
67 "Capitellidae", "Capitella", "Capitella teleta" },
75 // public final static UniProtTaxonomy NUCLEARIIDAE_AND_FONTICULA = new UniProtTaxonomy( new String[] {
76 // CELLULAR_ORGANISMS, EUKARYOTA, "Nucleariidae and Fonticula group" }, "", "", "", "", "", "1001604" );
77 public UniProtTaxonomy( final String line ) {
78 final String[] items = line.split( "\t" );
79 if ( items.length < 5 ) {
80 throw new IllegalArgumentException( "cannot parse uniprot taxonomy from: " + line );
82 _id = items[ 0 ].trim();
83 _code = items[ 1 ].trim();
84 _scientific_name = items[ 2 ].trim();
85 _common_name = items[ 3 ].trim();
86 _synonym = items[ 4 ].trim();
87 if ( items.length > 6 ) {
88 _rank = items[ 7 ].trim();
94 if ( items.length > 8 ) {
95 lin = items[ 8 ].split( "; " );
97 _lineage = new ArrayList<String>();
98 if ( ( lin != null ) && ( lin.length > 0 ) ) {
99 final List<String> temp = new ArrayList<String>();
100 for( final String t : lin ) {
101 if ( !ForesterUtil.isEmpty( t ) ) {
102 temp.add( t.trim() );
105 for( int i = 0; i < temp.size(); ++i ) {
107 && ( temp.get( i ).equalsIgnoreCase( EUKARYOTA ) || temp.get( i ).equalsIgnoreCase( BACTERIA ) || temp
108 .get( i ).equalsIgnoreCase( ARCHAEA ) ) ) {
109 _lineage.add( CELLULAR_ORGANISMS );
111 _lineage.add( temp.get( i ) );
114 if ( _lineage.isEmpty()
115 && ( _scientific_name.equalsIgnoreCase( EUKARYOTA ) || _scientific_name.equalsIgnoreCase( BACTERIA ) || _scientific_name
116 .equalsIgnoreCase( ARCHAEA ) ) ) {
117 _lineage.add( CELLULAR_ORGANISMS );
119 _lineage.add( _scientific_name );
120 if ( _lineage.isEmpty() ) {
121 throw new IllegalArgumentException( "lineage in a UniProt Taxonomy can not be empty\n: " + line );
125 public UniProtTaxonomy( final List<String> lineage,
127 final String common_name,
128 final String scientific_name,
129 final String synonym,
134 _scientific_name = scientific_name;
135 _common_name = common_name;
139 if ( ( _lineage != null ) && !_lineage.get( _lineage.size() - 1 ).equalsIgnoreCase( _scientific_name ) ) {
140 _lineage.add( _scientific_name );
144 public UniProtTaxonomy( final String[] lineage,
146 final String common_name,
147 final String scientific_name,
148 final String synonym,
151 _lineage = new ArrayList<String>();
152 if ( lineage != null ) {
153 for( final String l : lineage ) {
158 _scientific_name = scientific_name;
159 _common_name = common_name;
163 if ( ( _lineage != null ) && !_lineage.get( _lineage.size() - 1 ).equalsIgnoreCase( _scientific_name ) ) {
164 _lineage.add( _scientific_name );
169 * Creates deep copy for all fields, except lineage.
173 public UniProtTaxonomy copy() {
174 return new UniProtTaxonomy( getLineage(),
175 getCode() != null ? new String( getCode() ) : null,
176 getCommonName() != null ? new String( getCommonName() ) : null,
177 getScientificName() != null ? new String( getScientificName() ) : null,
178 getSynonym() != null ? new String( getSynonym() ) : null,
179 getRank() != null ? new String( getRank() ) : null,
180 getId() != null ? new String( getId() ) : null );
183 public String getCode() {
187 public String getCommonName() {
191 public String getId() {
195 public List<String> getLineage() {
199 public String getRank() {
203 public String getScientificName() {
204 return _scientific_name;
207 public String getSynonym() {