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