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.go.GoTerm;
31 import org.forester.util.ForesterUtil;
33 public final class EbiDbEntry implements SequenceDatabaseEntry {
35 //http://www.ebi.ac.uk/Tools/dbfetch/dbfetch/emb/AAR37336/
39 private String _tax_id;
40 private String _symbol;
41 private String _provider;
43 private EbiDbEntry() {
47 public Object clone() throws CloneNotSupportedException {
48 throw new CloneNotSupportedException();
51 public static SequenceDatabaseEntry createInstanceFromPlainTextForRefSeq( final List<String> lines ) {
52 final EbiDbEntry e = new EbiDbEntry();
53 for( final String line : lines ) {
54 // System.out.println( "-" + line );
55 if ( line.startsWith( "ACCESSION" ) ) {
56 e.setPA( DatabaseTools.extract( line, "ACCESSION" ) );
58 else if ( line.startsWith( "DEFINITION" ) ) {
59 if ( line.indexOf( "[" ) > 0 ) {
60 e.setDe( DatabaseTools.extract( line, "DEFINITION", "[" ) );
63 e.setDe( DatabaseTools.extract( line, "DEFINITION" ) );
66 else if ( line.startsWith( "SOURCE" ) ) {
67 if ( line.indexOf( "(" ) > 0 ) {
68 e.setOs( DatabaseTools.extract( line, "SOURCE", "(" ) );
71 e.setOs( DatabaseTools.extract( line, "SOURCE" ) );
78 public static SequenceDatabaseEntry createInstanceFromPlainText( final List<String> lines ) {
79 final EbiDbEntry e = new EbiDbEntry();
80 for( final String line : lines ) {
81 if ( line.startsWith( "PA" ) ) {
82 e.setPA( DatabaseTools.extract( line, "PA" ) );
84 else if ( line.startsWith( "DE" ) ) {
85 e.setDe( DatabaseTools.extract( line, "DE" ) );
87 else if ( line.startsWith( "OS" ) ) {
88 if ( line.indexOf( "(" ) > 0 ) {
89 e.setOs( DatabaseTools.extract( line, "OS", "(" ) );
92 e.setOs( DatabaseTools.extract( line, "OS" ) );
95 else if ( line.startsWith( "OX" ) ) {
96 if ( line.indexOf( "NCBI_TaxID=" ) > 0 ) {
97 e.setTaxId( DatabaseTools.extract( line, "NCBI_TaxID=", ";" ) );
105 public String getAccession() {
109 private void setPA( final String pa ) {
116 public String getSequenceName() {
120 private void setDe( final String rec_name ) {
127 public String getTaxonomyScientificName() {
131 private void setOs( final String os ) {
138 public String getTaxonomyIdentifier() {
142 private void setTaxId( final String tax_id ) {
143 if ( _tax_id == null ) {
149 public String getSequenceSymbol() {
154 public boolean isEmpty() {
155 return ( ForesterUtil.isEmpty( getAccession() ) && ForesterUtil.isEmpty( getSequenceName() )
156 && ForesterUtil.isEmpty( getTaxonomyScientificName() )
157 && ForesterUtil.isEmpty( getTaxonomyIdentifier() ) && ForesterUtil.isEmpty( getSequenceSymbol() ) );
161 public String getProvider() {
165 public void setProvider( final String provider ) {
166 _provider = provider;
170 public String getGeneName() {
175 public List<GoTerm> getGoTerms() {