2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.6)
\r
3 * Copyright (C) 2010 J Procter, AM Waterhouse, G Barton, M Clamp, S Searle
\r
5 * This file is part of Jalview.
\r
7 * Jalview is free software: you can redistribute it and/or
\r
8 * modify it under the terms of the GNU General Public License
\r
9 * as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
\r
11 * Jalview is distributed in the hope that it will be useful, but
\r
12 * WITHOUT ANY WARRANTY; without even the implied warranty
\r
13 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
\r
14 * PURPOSE. See the GNU General Public License for more details.
\r
16 * You should have received a copy of the GNU General Public License along with Jalview. If not, see <http://www.gnu.org/licenses/>.
\r
18 package jalview.ws.dbsources;
\r
20 import java.util.Hashtable;
\r
22 import com.stevesoft.pat.Regex;
\r
24 import jalview.datamodel.AlignmentI;
\r
25 import jalview.datamodel.DBRefEntry;
\r
26 import jalview.io.AppletFormatAdapter;
\r
27 import jalview.io.FastaFile;
\r
28 import jalview.io.StockholmFile;
\r
29 import jalview.ws.seqfetcher.DbSourceProxy;
\r
30 import jalview.ws.seqfetcher.DbSourceProxyImpl;
\r
33 * TODO: later PFAM is a complex datasource - it could return a tree in addition
\r
34 * to an alignment TODO: create interface to pass alignment properties and tree
\r
35 * back to sequence fetcher
\r
40 abstract public class Pfam extends DbSourceProxyImpl implements
\r
47 // all extensions of this PFAM source base class are DOMAINDB sources
\r
48 addDbSourceProperty(jalview.datamodel.DBRefSource.DOMAINDB);
\r
54 * @see jalview.ws.DbSourceProxy#getAccessionSeparator()
\r
56 public String getAccessionSeparator()
\r
58 // TODO Auto-generated method stub
\r
65 * @see jalview.ws.DbSourceProxy#getAccessionValidator()
\r
67 public Regex getAccessionValidator()
\r
69 // TODO Auto-generated method stub
\r
76 * @see jalview.ws.DbSourceProxy#getDbSource() public String getDbSource() { *
\r
77 * this doesn't work - DbSource is key for the hash of DbSourceProxy instances
\r
78 * - 1:many mapping for DbSource to proxy will be lost. * suggest : PFAM is an
\r
79 * 'alignment' source - means proxy is higher level than a sequence source.
\r
80 * return jalview.datamodel.DBRefSource.PFAM; }
\r
86 * @see jalview.ws.DbSourceProxy#getDbSourceProperties() public Hashtable
\r
87 * getDbSourceProperties() {
\r
95 * @see jalview.ws.DbSourceProxy#getDbVersion()
\r
97 public String getDbVersion()
\r
99 // TODO Auto-generated method stub
\r
105 * @return PFAM URL stub for this DbSource
\r
107 protected abstract String getPFAMURL();
\r
112 * @see jalview.ws.DbSourceProxy#getSequenceRecords(java.lang.String[])
\r
114 public AlignmentI getSequenceRecords(String queries) throws Exception
\r
116 // TODO: this is not a perfect implementation. We need to be able to add
\r
117 // individual references to each sequence in each family alignment that's
\r
120 AlignmentI rcds = new jalview.io.FormatAdapter().readFile(getPFAMURL()
\r
121 + queries.trim().toUpperCase(), jalview.io.FormatAdapter.URL,
\r
123 for (int s = 0, sNum = rcds.getHeight(); s < sNum; s++)
\r
125 rcds.getSequenceAt(s).addDBRef(
\r
126 new DBRefEntry(jalview.datamodel.DBRefSource.PFAM,
\r
128 getDbVersion(), queries.trim().toUpperCase()));
\r
129 if (!getDbSource().equals(jalview.datamodel.DBRefSource.PFAM))
\r
130 { // add the specific ref too
\r
131 rcds.getSequenceAt(s).addDBRef(
\r
132 new DBRefEntry(getDbSource(), getDbVersion(), queries
\r
133 .trim().toUpperCase()));
\r
143 * @see jalview.ws.DbSourceProxy#isValidReference(java.lang.String)
\r
145 public boolean isValidReference(String accession)
\r
147 return accession.indexOf("PF") == 0;
\r
151 * public String getDbName() { return "PFAM"; // getDbSource(); }
\r