in progress
[jalview.git] / forester / java / src / org / forester / ws / uniprot / UniProtEntry.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 UniProtEntry implements SequenceDatabaseEntry {
31
32     private String _ac;
33     private String _rec_name;
34     private String _os_scientific_name;
35     private String _tax_id;
36     private String _symbol;
37
38     private UniProtEntry() {
39     }
40
41     @Override
42     public Object clone() throws CloneNotSupportedException {
43         throw new CloneNotSupportedException();
44     }
45
46     public static SequenceDatabaseEntry createInstanceFromPlainText( final List<String> lines ) {
47         final UniProtEntry e = new UniProtEntry();
48         for( final String line : lines ) {
49             if ( line.startsWith( "AC" ) ) {
50                 e.setAc( DatabaseTools.extract( line, "AC", ";" ) );
51             }
52             else if ( line.startsWith( "DE" ) ) {
53                 if ( ( line.indexOf( "RecName:" ) > 0 ) && ( line.indexOf( "Full=" ) > 0 ) ) {
54                     e.setRecName( DatabaseTools.extract( line, "Full=", ";" ) );
55                 }
56             }
57             else if ( line.startsWith( "GN" ) ) {
58                 if ( ( line.indexOf( "Name=" ) > 0 ) ) {
59                     e.setSymbol( DatabaseTools.extract( line, "Name=", ";" ) );
60                 }
61             }
62             else if ( line.startsWith( "OS" ) ) {
63                 if ( line.indexOf( "(" ) > 0 ) {
64                     e.setOsScientificName( DatabaseTools.extract( line, "OS", "(" ) );
65                 }
66                 else {
67                     e.setOsScientificName( DatabaseTools.extract( line, "OS", "." ) );
68                 }
69             }
70             else if ( line.startsWith( "OX" ) ) {
71                 if ( line.indexOf( "NCBI_TaxID=" ) > 0 ) {
72                     e.setTaxId( DatabaseTools.extract( line, "NCBI_TaxID=", ";" ) );
73                 }
74             }
75         }
76         return e;
77     }
78
79     @Override
80     public String getAccession() {
81         return _ac;
82     }
83
84     private void setAc( final String ac ) {
85         if ( _ac == null ) {
86             _ac = ac;
87         }
88     }
89
90     @Override
91     public String getSequenceName() {
92         return _rec_name;
93     }
94
95     private void setRecName( final String rec_name ) {
96         if ( _rec_name == null ) {
97             _rec_name = rec_name;
98         }
99     }
100
101     @Override
102     public String getTaxonomyScientificName() {
103         return _os_scientific_name;
104     }
105
106     private void setOsScientificName( final String os_scientific_name ) {
107         if ( _os_scientific_name == null ) {
108             _os_scientific_name = os_scientific_name;
109         }
110     }
111
112     @Override
113     public String getTaxonomyIdentifier() {
114         return _tax_id;
115     }
116
117     private void setTaxId( final String tax_id ) {
118         if ( _tax_id == null ) {
119             _tax_id = tax_id;
120         }
121     }
122
123     @Override
124     public String getSequenceSymbol() {
125         return _symbol;
126     }
127
128     private void setSymbol( final String symbol ) {
129         if ( _symbol == null ) {
130             _symbol = symbol;
131         }
132     }
133 }