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.List;
30 public final class UniProtEntry {
33 private String _rec_name;
34 private String _os_scientific_name;
35 private String _tax_id;
36 private String _symbol;
38 private UniProtEntry() {
41 public static UniProtEntry createInstanceFromPlainText( final List<String> lines ) {
42 final UniProtEntry e = new UniProtEntry();
43 for( final String line : lines ) {
44 if ( line.startsWith( "AC" ) ) {
45 e.setAc( extract( line, "AC", ";" ) );
47 else if ( line.startsWith( "DE" ) ) {
48 if ( ( line.indexOf( "RecName:" ) > 0 ) && ( line.indexOf( "Full=" ) > 0 ) ) {
49 e.setRecName( extract( line, "Full=", ";" ) );
52 else if ( line.startsWith( "GN" ) ) {
53 if ( ( line.indexOf( "Name=" ) > 0 ) ) {
54 e.setSymbol( extract( line, "Name=", ";" ) );
57 else if ( line.startsWith( "OS" ) ) {
58 if ( line.indexOf( "(" ) > 0 ) {
59 e.setOsScientificName( extract( line, "OS", "(" ) );
62 e.setOsScientificName( extract( line, "OS", "." ) );
65 else if ( line.startsWith( "OX" ) ) {
66 if ( line.indexOf( "NCBI_TaxID=" ) > 0 ) {
67 e.setTaxId( extract( line, "NCBI_TaxID=", ";" ) );
74 private static String extract( final String target, final String a, final String b ) {
75 final int i_a = target.indexOf( a );
76 final int i_b = target.indexOf( b );
77 if ( ( i_a < 0 ) || ( i_b < i_a ) ) {
78 throw new IllegalArgumentException( "attempt to extract from [" + target + "] between [" + a + "] and ["
81 return target.substring( i_a + a.length(), i_b ).trim();
84 public String getAc() {
88 private void setAc( final String ac ) {
94 public String getRecName() {
98 private void setRecName( final String rec_name ) {
99 if ( _rec_name == null ) {
100 _rec_name = rec_name;
104 public String getOsScientificName() {
105 return _os_scientific_name;
108 private void setOsScientificName( final String os_scientific_name ) {
109 if ( _os_scientific_name == null ) {
110 _os_scientific_name = os_scientific_name;
114 public String getTaxId() {
118 private void setTaxId( final String tax_id ) {
119 if ( _tax_id == null ) {
124 public String getSymbol() {
128 private void setSymbol( final String symbol ) {
129 if ( _symbol == null ) {