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: www.phylosoft.org/forester
26 package org.forester.ws.uniprot;
28 import java.util.List;
30 import org.forester.util.ForesterUtil;
32 public final class EbiDbEntry implements SequenceDatabaseEntry {
34 //http://www.ebi.ac.uk/Tools/dbfetch/dbfetch/emb/AAR37336/
38 private String _tax_id;
39 private String _symbol;
41 private EbiDbEntry() {
45 public Object clone() throws CloneNotSupportedException {
46 throw new CloneNotSupportedException();
50 public static SequenceDatabaseEntry createInstanceForRefSeq( final List<String> lines ) {
51 final EbiDbEntry e = new EbiDbEntry();
52 for( final String line : lines ) {
53 System.out.println( "-" + line );
54 if ( line.startsWith( "ACCESSION" ) ) {
55 e.setPA( DatabaseTools.extract( line, "ACCESSION" ) );
57 else if ( line.startsWith( "DEFINITION" ) ) {
58 if ( line.indexOf( "[" ) > 0 ) {
59 e.setDe( DatabaseTools.extract( line, "DEFINITION", "[" ) );
62 e.setDe( DatabaseTools.extract( line, "DEFINITION" ) );
68 else if ( line.startsWith( "SOURCE" ) ) {
69 if ( line.indexOf( "(" ) > 0 ) {
70 e.setOs( DatabaseTools.extract( line, "SOURCE", "(" ) );
73 e.setOs( DatabaseTools.extract( line, "SOURCE" ) );
83 public static SequenceDatabaseEntry createInstanceFromPlainText( final List<String> lines ) {
84 final EbiDbEntry e = new EbiDbEntry();
85 for( final String line : lines ) {
86 System.out.println( "->" + line );
87 if ( line.startsWith( "PA" ) ) {
88 e.setPA( DatabaseTools.extract( line, "PA" ) );
90 else if ( line.startsWith( "DE" ) ) {
91 // if ( ( line.indexOf( "RecName:" ) > 0 ) && ( line.indexOf( "Full=" ) > 0 ) ) {
92 e.setDe( DatabaseTools.extract( line, "DE" ) );
95 // else if ( line.startsWith( "GN" ) ) {
96 // if ( ( line.indexOf( "Name=" ) > 0 ) ) {
97 // e.setSymbol( extract( line, "Name=", ";" ) );
100 else if ( line.startsWith( "OS" ) ) {
101 if ( line.indexOf( "(" ) > 0 ) {
102 e.setOs( DatabaseTools.extract( line, "OS", "(" ) );
105 e.setOs( DatabaseTools.extract( line, "OS" ) );
108 else if ( line.startsWith( "OX" ) ) {
109 if ( line.indexOf( "NCBI_TaxID=" ) > 0 ) {
110 e.setTaxId( DatabaseTools.extract( line, "NCBI_TaxID=", ";" ) );
118 public String getAccession() {
122 private void setPA( final String pa ) {
129 public String getSequenceName() {
133 private void setDe( final String rec_name ) {
140 public String getTaxonomyScientificName() {
144 private void setOs( final String os ) {
151 public String getTaxonomyIdentifier() {
155 private void setTaxId( final String tax_id ) {
156 if ( _tax_id == null ) {
162 public String getSequenceSymbol() {
166 private void setSymbol( final String symbol ) {
167 if ( _symbol == null ) {
173 public boolean isEmpty() {
174 return ( ForesterUtil.isEmpty( getAccession() ) && ForesterUtil.isEmpty( getSequenceName() )
175 && ForesterUtil.isEmpty( getTaxonomyScientificName() )
176 && ForesterUtil.isEmpty( getTaxonomyIdentifier() ) && ForesterUtil.isEmpty( getSequenceSymbol() ) );