2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4)
\r
3 * Copyright (C) 2008 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
33 * TODO: later PFAM is a complex datasource - it could return a tree in addition to an alignment
\r
34 * TODO: create interface to pass alignment properties and tree back to sequence fetcher
\r
38 abstract public class Pfam extends DbSourceProxyImpl implements DbSourceProxy
\r
44 // all extensions of this PFAM source base class are DOMAINDB sources
\r
45 addDbSourceProperty(jalview.datamodel.DBRefSource.DOMAINDB);
\r
49 * @see jalview.ws.DbSourceProxy#getAccessionSeparator()
\r
51 public String getAccessionSeparator()
\r
53 // TODO Auto-generated method stub
\r
58 * @see jalview.ws.DbSourceProxy#getAccessionValidator()
\r
60 public Regex getAccessionValidator()
\r
62 // TODO Auto-generated method stub
\r
67 * @see jalview.ws.DbSourceProxy#getDbSource()
\r
68 public String getDbSource()
\r
70 ** this doesn't work - DbSource is key for the hash of DbSourceProxy instances - 1:many mapping for DbSource to proxy will be lost.
\r
71 ** suggest : PFAM is an 'alignment' source - means proxy is higher level than a sequence source.
\r
72 return jalview.datamodel.DBRefSource.PFAM;
\r
78 * @see jalview.ws.DbSourceProxy#getDbSourceProperties()
\r
79 public Hashtable getDbSourceProperties()
\r
87 * @see jalview.ws.DbSourceProxy#getDbVersion()
\r
89 public String getDbVersion()
\r
91 // TODO Auto-generated method stub
\r
96 * @return PFAM URL stub for this DbSource
\r
98 protected abstract String getPFAMURL();
\r
100 * @see jalview.ws.DbSourceProxy#getSequenceRecords(java.lang.String[])
\r
102 public AlignmentI getSequenceRecords(String queries) throws Exception
\r
104 // TODO: this is not a perfect implementation. We need to be able to add individual references to each sequence in each family alignment that's retrieved.
\r
106 AlignmentI rcds = new jalview.io.FormatAdapter().readFile(getPFAMURL()+queries.trim().toUpperCase(), jalview.io.FormatAdapter.URL,"STH");
\r
107 for (int s=0,sNum=rcds.getHeight(); s<sNum;s++)
\r
109 rcds.getSequenceAt(s).addDBRef(new DBRefEntry(jalview.datamodel.DBRefSource.PFAM,
\r
111 getDbVersion(), queries.trim().toUpperCase()));
\r
112 if (!getDbSource().equals(jalview.datamodel.DBRefSource.PFAM))
\r
113 { // add the specific ref too
\r
114 rcds.getSequenceAt(s).addDBRef(
\r
115 new DBRefEntry( getDbSource(),
\r
116 getDbVersion(), queries.trim().toUpperCase()));
\r
124 * @see jalview.ws.DbSourceProxy#isValidReference(java.lang.String)
\r
126 public boolean isValidReference(String accession)
\r
128 return accession.indexOf("PF")==0;
\r
132 /*public String getDbName()
\r
134 return "PFAM"; // getDbSource();
\r