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.uniprot;
28 import java.util.ArrayList;
29 import java.util.List;
31 import org.forester.util.ForesterUtil;
33 public final class UniProtTaxonomy {
35 private final String[] _lineage;
36 private final String _code;
37 private final String _scientific_name;
38 private final String _common_name;
39 private final String _synonym;
40 private final String _rank;
41 private final String _id;
42 public final static UniProtTaxonomy DROSOPHILA_GENUS = new UniProtTaxonomy( new String[] { "Eukaryota",
43 "Metazoa", "Arthropoda", "Hexapoda", "Insecta", "Pterygota", "Neoptera", "Endopterygota", "Diptera",
44 "Brachycera", "Muscomorpha", "Ephydroidea", "Drosophilidae" },
51 public final static UniProtTaxonomy XENOPUS_GENUS = new UniProtTaxonomy( new String[] { "Eukaryota",
52 "Metazoa", "Chordata", "Craniata", "Vertebrata", "Euteleostomi", "Amphibia", "Batrachia", "Anura",
53 "Mesobatrachia", "Pipoidea", "Pipidae", "Xenopodinae" }, "", "", "Xenopus", "", "genus", "8353" );
54 public final static UniProtTaxonomy CAPITELLA_TELATA_SPECIES = new UniProtTaxonomy( new String[] { "Eukaryota",
55 "Metazoa", "Annelida", "Polychaeta", "Scolecida", "Capitellida", "Capitellidae", "Capitella" },
63 public UniProtTaxonomy( final String line ) {
64 final String[] items = line.split( "\t" );
65 if ( items.length < 5 ) {
66 throw new IllegalArgumentException( "cannot parse uniprot taxonomy from: " + line );
68 _id = items[ 0 ].trim();
69 _code = items[ 1 ].trim();
70 _scientific_name = items[ 2 ].trim();
71 _common_name = items[ 3 ].trim();
72 _synonym = items[ 4 ].trim();
73 if ( items.length > 6 ) {
74 _rank = items[ 7 ].trim();
80 if ( items.length > 7 ) {
81 lin = items[ 8 ].split( "; " );
83 if ( ( lin != null ) && ( lin.length > 0 ) ) {
84 final List<String> temp = new ArrayList<String>();
85 for( final String t : lin ) {
86 if ( !ForesterUtil.isEmpty( t ) ) {
90 _lineage = new String[ temp.size() ];
91 for( int i = 0; i < temp.size(); ++i ) {
92 _lineage[ i ] = temp.get( i );
96 _lineage = new String[ 0 ];
100 public UniProtTaxonomy( final String[] lineage,
102 final String common_name,
103 final String scientific_name,
104 final String synonym,
109 _scientific_name = scientific_name;
110 _common_name = common_name;
117 * Creates deep copy for all fields, except lineage.
121 public UniProtTaxonomy copy() {
122 return new UniProtTaxonomy( getLineage(),
123 getCode() != null ? new String( getCode() ) : null,
124 getCommonName() != null ? new String( getCommonName() ) : null,
125 getScientificName() != null ? new String( getScientificName() ) : null,
126 getSynonym() != null ? new String( getSynonym() ) : null,
127 getRank() != null ? new String( getRank() ) : null,
128 getId() != null ? new String( getId() ) : null );
131 public String getCode() {
135 public String getCommonName() {
139 public String getId() {
143 public String[] getLineage() {
147 public String getRank() {
151 public String getScientificName() {
152 return _scientific_name;
155 public String getSynonym() {