98fe38db99f3e63f584380745571d56415e8eba7
[jalview.git] / forester / java / src / org / forester / ws / uniprot / EbiDbEntry.java
1 // $Id:
2 // forester -- software libraries and applications
3 // for genomics and evolutionary biology research.
4 //
5 // Copyright (C) 2010 Christian M Zmasek
6 // Copyright (C) 2010 Sanford-Burnham Medical Research Institute
7 // All rights reserved
8 //
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.
13 //
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.
18 //
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
22 //
23 // Contact: phylosoft @ gmail . com
24 // WWW: www.phylosoft.org/forester
25
26 package org.forester.ws.uniprot;
27
28 import java.util.List;
29
30 public final class EbiDbEntry implements SequenceDatabaseEntry {
31
32     //http://www.ebi.ac.uk/Tools/dbfetch/dbfetch/emb/AAR37336/
33     private String _pa;
34     private String _de;
35     private String _os;
36     private String _tax_id;
37     private String _symbol;
38
39     private EbiDbEntry() {
40     }
41
42     @Override
43     public Object clone() throws CloneNotSupportedException {
44         throw new CloneNotSupportedException();
45     }
46
47     public static SequenceDatabaseEntry createInstanceFromPlainText( final List<String> lines ) {
48         final EbiDbEntry e = new EbiDbEntry();
49         for( final String line : lines ) {
50             if ( line.startsWith( "PA" ) ) {
51                 e.setPA( DatabaseTools.extract( line, "PA", ";" ) );
52             }
53             else if ( line.startsWith( "DE" ) ) {
54                 // if ( ( line.indexOf( "RecName:" ) > 0 ) && ( line.indexOf( "Full=" ) > 0 ) ) {
55                 e.setDe( DatabaseTools.extract( line, "DE" ) );
56                 //}
57             }
58             //  else if ( line.startsWith( "GN" ) ) {
59             //      if ( ( line.indexOf( "Name=" ) > 0 ) ) {
60             //          e.setSymbol( extract( line, "Name=", ";" ) );
61             //      }
62             //  }
63             else if ( line.startsWith( "OS" ) ) {
64                 if ( line.indexOf( "(" ) > 0 ) {
65                     e.setOs( DatabaseTools.extract( line, "OS", "(" ) );
66                 }
67                 else {
68                     e.setOs( DatabaseTools.extract( line, "OS" ) );
69                 }
70             }
71             else if ( line.startsWith( "OX" ) ) {
72                 if ( line.indexOf( "NCBI_TaxID=" ) > 0 ) {
73                     e.setTaxId( DatabaseTools.extract( line, "NCBI_TaxID=", ";" ) );
74                 }
75             }
76         }
77         return e;
78     }
79
80     @Override
81     public String getAccession() {
82         return _pa;
83     }
84
85     private void setPA( final String pa ) {
86         if ( _pa == null ) {
87             _pa = pa;
88         }
89     }
90
91     @Override
92     public String getSequenceName() {
93         return _de;
94     }
95
96     private void setDe( final String rec_name ) {
97         if ( _de == null ) {
98             _de = rec_name;
99         }
100     }
101
102     @Override
103     public String getTaxonomyScientificName() {
104         return _os;
105     }
106
107     private void setOs( final String os ) {
108         if ( _os == null ) {
109             _os = os;
110         }
111     }
112
113     @Override
114     public String getTaxonomyIdentifier() {
115         return _tax_id;
116     }
117
118     private void setTaxId( final String tax_id ) {
119         if ( _tax_id == null ) {
120             _tax_id = tax_id;
121         }
122     }
123
124     @Override
125     public String getSequenceSymbol() {
126         return _symbol;
127     }
128
129     private void setSymbol( final String symbol ) {
130         if ( _symbol == null ) {
131             _symbol = symbol;
132         }
133     }
134 }