in progress...
[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 import sun.reflect.generics.reflectiveObjects.NotImplementedException;
31
32 public final class EbiDbEntry implements SequenceDatabaseEntry {
33 //http://www.ebi.ac.uk/Tools/dbfetch/dbfetch/emb/AAR37336/
34     
35     
36     private String _pa;
37     private String _de;
38     private String _os;
39     private String _tax_id;
40     private String _symbol;
41
42     private EbiDbEntry() {
43     }
44
45     
46     public Object clone() {
47         throw new NotImplementedException();
48     }
49     
50     public static SequenceDatabaseEntry createInstanceFromPlainText( final List<String> lines ) {
51         final EbiDbEntry e = new EbiDbEntry();
52         for( final String line : lines ) {
53             if ( line.startsWith( "PA" ) ) {
54                 e.setPA( DatabaseTools.extract( line, "PA", ";" ) );
55             }
56             else if ( line.startsWith( "DE" ) ) {
57                // if ( ( line.indexOf( "RecName:" ) > 0 ) && ( line.indexOf( "Full=" ) > 0 ) ) {
58                     e.setDe( DatabaseTools.extract( line, "DE" ) );
59                 //}
60             }
61           //  else if ( line.startsWith( "GN" ) ) {
62           //      if ( ( line.indexOf( "Name=" ) > 0 ) ) {
63           //          e.setSymbol( extract( line, "Name=", ";" ) );
64           //      }
65           //  }
66             else if ( line.startsWith( "OS" ) ) {
67                 if ( line.indexOf( "(" ) > 0 ) {
68                     e.setOs( DatabaseTools.extract( line, "OS", "(" ) );
69                 }
70                 else {
71                     e.setOs( DatabaseTools.extract( line, "OS" ) );
72                 }
73             }
74             else if ( line.startsWith( "OX" ) ) {
75                 if ( line.indexOf( "NCBI_TaxID=" ) > 0 ) {
76                     e.setTaxId( DatabaseTools.extract( line, "NCBI_TaxID=", ";" ) );
77                 }
78             }
79         }
80         return e;
81     }
82
83     @Override
84     public String getAccession() {
85         return _pa;
86     }
87
88     private void setPA( final String pa ) {
89         if ( _pa == null ) {
90             _pa= pa;
91         }
92     }
93
94     @Override
95     public String getSequenceName() {
96         return _de;
97     }
98
99     private void setDe( final String rec_name ) {
100         if ( _de == null ) {
101             _de = rec_name;
102         }
103     }
104
105     @Override
106     public String getTaxonomyScientificName() {
107         return _os;
108     }
109
110     private void setOs( final String os ) {
111         if ( _os== null ) {
112             _os = os;
113         }
114     }
115
116     @Override
117     public String getTaxonomyIdentifier() {
118         return _tax_id;
119     }
120
121     private void setTaxId( final String tax_id ) {
122         if ( _tax_id == null ) {
123             _tax_id = tax_id;
124         }
125     }
126
127     @Override
128     public String getSequenceSymbol() {
129         return _symbol;
130     }
131
132     private void setSymbol( final String symbol ) {
133         if ( _symbol == null ) {
134             _symbol = symbol;
135         }
136     }
137 }