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 _symbol;
37 private String _gene_name;
38 private String _os_scientific_name;
39 private String _tax_id;
41 private UniProtEntry() {
45 public Object clone() throws CloneNotSupportedException {
46 throw new CloneNotSupportedException();
49 public static SequenceDatabaseEntry createInstanceFromPlainText( final List<String> lines ) {
50 final UniProtEntry e = new UniProtEntry();
51 for( final String line : lines ) {
52 System.out.println( line );
53 if ( line.startsWith( "AC" ) ) {
54 e.setAc( DatabaseTools.extract( line, "AC", ";" ) );
56 else if ( line.startsWith( "DE" ) && ForesterUtil.isEmpty( e.getSequenceName() ) ) {
57 if ( ( line.indexOf( "RecName:" ) > 0 ) && ( line.indexOf( "Full=" ) > 0 ) ) {
58 e.setSequenceName( DatabaseTools.extract( line, "Full=", ";" ) );
60 else if ( ( line.indexOf( "SubName:" ) > 0 ) && ( line.indexOf( "Full=" ) > 0 ) ) {
61 e.setSequenceName( DatabaseTools.extract( line, "Full=", ";" ) );
64 else if ( line.startsWith( "DE" ) && ForesterUtil.isEmpty( e.getSequenceSymbol() ) ) {
65 if ( line.indexOf( "Short=" ) > 0 ) {
66 e.setSequenceSymbol( DatabaseTools.extract( line, "Short=", ";" ) );
69 else if ( line.startsWith( "GN" ) && ForesterUtil.isEmpty( e.getGeneName() ) ) {
70 if ( line.indexOf( "Name=" ) > 0 ) {
71 e.setGeneName( DatabaseTools.extract( line, "Name=", ";" ) );
74 else if ( line.startsWith( "OS" ) ) {
75 if ( line.indexOf( "(" ) > 0 ) {
76 e.setOsScientificName( DatabaseTools.extract( line, "OS", "(" ) );
79 e.setOsScientificName( DatabaseTools.extract( line, "OS", "." ) );
82 else if ( line.startsWith( "OX" ) ) {
83 if ( line.indexOf( "NCBI_TaxID=" ) > 0 ) {
84 e.setTaxId( DatabaseTools.extract( line, "NCBI_TaxID=", ";" ) );
91 private void setSequenceSymbol( String symbol ) {
96 public String getAccession() {
100 private void setAc( final String ac ) {
107 public String getSequenceName() {
111 private void setSequenceName( final String name ) {
112 if ( _name == null ) {
118 public String getTaxonomyScientificName() {
119 return _os_scientific_name;
122 private void setOsScientificName( final String os_scientific_name ) {
123 if ( _os_scientific_name == null ) {
124 _os_scientific_name = os_scientific_name;
129 public String getTaxonomyIdentifier() {
133 private void setTaxId( final String tax_id ) {
134 if ( _tax_id == null ) {
139 private void setGeneName( final String gene_name ) {
140 if ( _gene_name == null ) {
141 _gene_name = gene_name;
146 public String getSequenceSymbol() {
151 public boolean isEmpty() {
152 return ( ForesterUtil.isEmpty( getAccession() ) && ForesterUtil.isEmpty( getSequenceName() )
153 && ForesterUtil.isEmpty( getTaxonomyScientificName() ) && ForesterUtil.isEmpty( getSequenceSymbol() )
154 && ForesterUtil.isEmpty( getGeneName() ) && ForesterUtil.isEmpty( getTaxonomyIdentifier() ) && ForesterUtil
155 .isEmpty( getSequenceSymbol() ) );
159 public String getProvider() {
164 public String getGeneName() {