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: https://sites.google.com/site/cmzmasek/home/software/forester
26 package org.forester.ws.seqdb;
28 import java.util.List;
30 import org.forester.util.ForesterUtil;
32 public final class UniProtEntry implements SequenceDatabaseEntry {
36 private String _os_scientific_name;
37 private String _tax_id;
39 private UniProtEntry() {
43 public Object clone() throws CloneNotSupportedException {
44 throw new CloneNotSupportedException();
47 public static SequenceDatabaseEntry createInstanceFromPlainText( final List<String> lines ) {
48 final UniProtEntry e = new UniProtEntry();
49 for( final String line : lines ) {
50 if ( line.startsWith( "AC" ) ) {
51 e.setAc( DatabaseTools.extract( line, "AC", ";" ) );
53 else if ( line.startsWith( "DE" ) && ForesterUtil.isEmpty( e.getSequenceName() ) ) {
54 if ( ( line.indexOf( "RecName:" ) > 0 ) && ( line.indexOf( "Full=" ) > 0 ) ) {
55 e.setSequenceName( DatabaseTools.extract( line, "Full=", ";" ) );
57 else if ( ( line.indexOf( "SubName:" ) > 0 ) && ( line.indexOf( "Full=" ) > 0 ) ) {
58 e.setSequenceName( DatabaseTools.extract( line, "Full=", ";" ) );
61 else if ( line.startsWith( "OS" ) ) {
62 if ( line.indexOf( "(" ) > 0 ) {
63 e.setOsScientificName( DatabaseTools.extract( line, "OS", "(" ) );
66 e.setOsScientificName( DatabaseTools.extract( line, "OS", "." ) );
69 else if ( line.startsWith( "OX" ) ) {
70 if ( line.indexOf( "NCBI_TaxID=" ) > 0 ) {
71 e.setTaxId( DatabaseTools.extract( line, "NCBI_TaxID=", ";" ) );
79 public String getAccession() {
83 private void setAc( final String ac ) {
90 public String getSequenceName() {
94 private void setSequenceName( final String name ) {
95 if ( _name == null ) {
101 public String getTaxonomyScientificName() {
102 return _os_scientific_name;
105 private void setOsScientificName( final String os_scientific_name ) {
106 if ( _os_scientific_name == null ) {
107 _os_scientific_name = os_scientific_name;
112 public String getTaxonomyIdentifier() {
116 private void setTaxId( final String tax_id ) {
117 if ( _tax_id == null ) {
123 public String getSequenceSymbol() {
128 public boolean isEmpty() {
129 return ( ForesterUtil.isEmpty( getAccession() ) && ForesterUtil.isEmpty( getSequenceName() )
130 && ForesterUtil.isEmpty( getTaxonomyScientificName() )
131 && ForesterUtil.isEmpty( getTaxonomyIdentifier() ) && ForesterUtil.isEmpty( getSequenceSymbol() ) );
135 public String getProvider() {