2 * Jalview - A Sequence Alignment Editor and Viewer (Development Version 2.4.1)
\r
3 * Copyright (C) 2009 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle
\r
5 * This program is free software; you can redistribute it and/or
\r
6 * modify it under the terms of the GNU General Public License
\r
7 * as published by the Free Software Foundation; either version 2
\r
8 * of the License, or (at your option) any later version.
\r
10 * This program is distributed in the hope that it will be useful,
\r
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
13 * GNU General Public License for more details.
\r
15 * You should have received a copy of the GNU General Public License
\r
16 * along with this program; if not, write to the Free Software
\r
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
\r
19 package jalview.ws.dbsources;
\r
21 import java.util.Hashtable;
\r
23 import com.stevesoft.pat.Regex;
\r
25 import jalview.datamodel.AlignmentI;
\r
26 import jalview.datamodel.DBRefEntry;
\r
27 import jalview.io.AppletFormatAdapter;
\r
28 import jalview.io.FastaFile;
\r
29 import jalview.io.StockholmFile;
\r
30 import jalview.ws.seqfetcher.DbSourceProxy;
\r
31 import jalview.ws.seqfetcher.DbSourceProxyImpl;
\r
34 * TODO: later PFAM is a complex datasource - it could return a tree in addition
\r
35 * to an alignment TODO: create interface to pass alignment properties and tree
\r
36 * back to sequence fetcher
\r
41 abstract public class Pfam extends DbSourceProxyImpl implements
\r
48 // all extensions of this PFAM source base class are DOMAINDB sources
\r
49 addDbSourceProperty(jalview.datamodel.DBRefSource.DOMAINDB);
\r
55 * @see jalview.ws.DbSourceProxy#getAccessionSeparator()
\r
57 public String getAccessionSeparator()
\r
59 // TODO Auto-generated method stub
\r
66 * @see jalview.ws.DbSourceProxy#getAccessionValidator()
\r
68 public Regex getAccessionValidator()
\r
70 // TODO Auto-generated method stub
\r
77 * @see jalview.ws.DbSourceProxy#getDbSource() public String getDbSource() { *
\r
78 * this doesn't work - DbSource is key for the hash of DbSourceProxy
\r
79 * instances - 1:many mapping for DbSource to proxy will be lost. *
\r
80 * suggest : PFAM is an 'alignment' source - means proxy is higher level
\r
81 * than a sequence source. return jalview.datamodel.DBRefSource.PFAM; }
\r
87 * @see jalview.ws.DbSourceProxy#getDbSourceProperties() public Hashtable
\r
88 * getDbSourceProperties() {
\r
96 * @see jalview.ws.DbSourceProxy#getDbVersion()
\r
98 public String getDbVersion()
\r
100 // TODO Auto-generated method stub
\r
106 * @return PFAM URL stub for this DbSource
\r
108 protected abstract String getPFAMURL();
\r
113 * @see jalview.ws.DbSourceProxy#getSequenceRecords(java.lang.String[])
\r
115 public AlignmentI getSequenceRecords(String queries) throws Exception
\r
117 // TODO: this is not a perfect implementation. We need to be able to add
\r
118 // individual references to each sequence in each family alignment that's
\r
121 AlignmentI rcds = new jalview.io.FormatAdapter().readFile(getPFAMURL()
\r
122 + queries.trim().toUpperCase(), jalview.io.FormatAdapter.URL,
\r
124 for (int s = 0, sNum = rcds.getHeight(); s < sNum; s++)
\r
126 rcds.getSequenceAt(s).addDBRef(
\r
127 new DBRefEntry(jalview.datamodel.DBRefSource.PFAM,
\r
129 getDbVersion(), queries.trim().toUpperCase()));
\r
130 if (!getDbSource().equals(jalview.datamodel.DBRefSource.PFAM))
\r
131 { // add the specific ref too
\r
132 rcds.getSequenceAt(s).addDBRef(
\r
133 new DBRefEntry(getDbSource(), getDbVersion(), queries
\r
134 .trim().toUpperCase()));
\r
144 * @see jalview.ws.DbSourceProxy#isValidReference(java.lang.String)
\r
146 public boolean isValidReference(String accession)
\r
148 return accession.indexOf("PF") == 0;
\r
152 * public String getDbName() { return "PFAM"; // getDbSource(); }
\r