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.phylogeny.data.Accession;
32 import org.forester.util.ForesterUtil;
34 public final class EbiDbEntry implements SequenceDatabaseEntry {
36 //http://www.ebi.ac.uk/Tools/dbfetch/dbfetch/emb/AAR37336/
40 private String _tax_id;
41 private String _symbol;
42 private String _provider;
44 private EbiDbEntry() {
48 public Object clone() throws CloneNotSupportedException {
49 throw new CloneNotSupportedException();
52 public static SequenceDatabaseEntry createInstanceFromPlainTextForRefSeq( final List<String> lines ) {
53 final EbiDbEntry e = new EbiDbEntry();
54 for( final String line : lines ) {
55 // System.out.println( "-" + line );
56 if ( line.startsWith( "ACCESSION" ) ) {
57 e.setPA( DatabaseTools.extract( line, "ACCESSION" ) );
59 else if ( line.startsWith( "DEFINITION" ) ) {
60 if ( line.indexOf( "[" ) > 0 ) {
61 e.setDe( DatabaseTools.extract( line, "DEFINITION", "[" ) );
64 e.setDe( DatabaseTools.extract( line, "DEFINITION" ) );
67 else if ( line.startsWith( "SOURCE" ) ) {
68 if ( line.indexOf( "(" ) > 0 ) {
69 e.setOs( DatabaseTools.extract( line, "SOURCE", "(" ) );
72 e.setOs( DatabaseTools.extract( line, "SOURCE" ) );
79 public static SequenceDatabaseEntry createInstanceFromPlainText( final List<String> lines ) {
80 final EbiDbEntry e = new EbiDbEntry();
81 for( final String line : lines ) {
82 if ( line.startsWith( "PA" ) ) {
83 e.setPA( DatabaseTools.extract( line, "PA" ) );
85 else if ( line.startsWith( "DE" ) ) {
86 e.setDe( DatabaseTools.extract( line, "DE" ) );
88 else if ( line.startsWith( "OS" ) ) {
89 if ( line.indexOf( "(" ) > 0 ) {
90 e.setOs( DatabaseTools.extract( line, "OS", "(" ) );
93 e.setOs( DatabaseTools.extract( line, "OS" ) );
96 else if ( line.startsWith( "OX" ) ) {
97 if ( line.indexOf( "NCBI_TaxID=" ) > 0 ) {
98 e.setTaxId( DatabaseTools.extract( line, "NCBI_TaxID=", ";" ) );
106 public String getAccession() {
110 private void setPA( final String pa ) {
117 public String getSequenceName() {
121 private void setDe( final String rec_name ) {
128 public String getTaxonomyScientificName() {
132 private void setOs( final String os ) {
139 public String getTaxonomyIdentifier() {
143 private void setTaxId( final String tax_id ) {
144 if ( _tax_id == null ) {
150 public String getSequenceSymbol() {
155 public boolean isEmpty() {
156 return ( ForesterUtil.isEmpty( getAccession() ) && ForesterUtil.isEmpty( getSequenceName() )
157 && ForesterUtil.isEmpty( getTaxonomyScientificName() )
158 && ForesterUtil.isEmpty( getTaxonomyIdentifier() ) && ForesterUtil.isEmpty( getSequenceSymbol() ) );
162 public String getProvider() {
166 public void setProvider( final String provider ) {
167 _provider = provider;
171 public String getGeneName() {
176 public List<GoTerm> getGoTerms() {
181 public List<Accession> getCrossReferences() {