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.das;
\r
21 import jalview.datamodel.AlignmentI;
\r
22 import jalview.datamodel.Alignment;
\r
23 import jalview.datamodel.DBRefEntry;
\r
24 import jalview.datamodel.Sequence;
\r
25 import jalview.datamodel.SequenceI;
\r
26 import jalview.ws.dbsources.DasSequenceSource;
\r
28 import org.biojava.dasobert.eventmodel.SequenceEvent;
\r
29 import org.biojava.dasobert.eventmodel.SequenceListener;
\r
32 * Listen for sequence fetch events from a dasobert SequenceThread started with a
\r
33 * query string and collect sequences returned from the DAS sequence source.
\r
37 public class DasSequenceSourceListener implements SequenceListener
\r
40 String ourAccession = null;
\r
41 DasSequenceSource oursource=null;
\r
44 * @param source the DAS Sequence DbProxy object containing database details for this source
\r
45 * @param query the query string sent to the das source that we should be listening for.
\r
47 public DasSequenceSourceListener(DasSequenceSource source, String query)
\r
53 public void clearSelection()
\r
55 // TODO Auto-generated method stub
\r
58 java.util.Vector seqs = null;
\r
59 public void newSequence(SequenceEvent e)
\r
61 if (!e.getAccessionCode().equals(ourAccession))
\r
63 System.err.println("Warning - received sequence event for strange accession code ("
\r
64 +e.getAccessionCode()+") - we expected "+ourAccession);
\r
70 if (e.getSequence().length()==0)
\r
72 System.err.println("Empty sequence returned for accession code ("
\r
73 +e.getAccessionCode()+") from "+oursource.getDbName());
\r
78 seqs = new java.util.Vector();
\r
80 Sequence sq = new Sequence(e.getAccessionCode(), e.getSequence());
\r
81 sq.addDBRef(new DBRefEntry(oursource.getDbSource(), oursource.getDbVersion()+":"+e.getVersion(), e.getAccessionCode()));
\r
82 seqs.addElement(sq);
\r
86 public void selectedSeqPosition(int position)
\r
88 // TODO Auto-generated method stub
\r
92 public void selectedSeqRange(int start, int end)
\r
94 // TODO Auto-generated method stub
\r
98 public void selectionLocked(boolean flag)
\r
100 // TODO Auto-generated method stub
\r
104 public void newObjectRequested(String accessionCode)
\r
106 // TODO Auto-generated method stub
\r
109 boolean noSequences=false;
\r
110 public void noObjectFound(String accessionCode)
\r
112 if (accessionCode.equals(ourAccession))
\r
118 public boolean hasNoSequences() {
\r
119 return noSequences;
\r
121 boolean called=false;
\r
122 public boolean isNotCalled()
\r
127 public AlignmentI getSequences()
\r
129 if (noSequences || seqs!=null && seqs.size()==0)
\r
131 SequenceI[] sqs = new SequenceI[seqs.size()];
\r
132 for (int i=0,iSize=seqs.size(); i<iSize;i++)
\r
134 sqs[i] = (SequenceI) seqs.elementAt(i);
\r
136 Alignment al = new Alignment(sqs);
\r
137 if (oursource.getSource().hasCapability("features"))
\r
139 java.util.Vector src = new java.util.Vector();
\r
140 src.addElement(oursource.getSource());
\r
141 new jalview.ws.DasSequenceFeatureFetcher(sqs,
\r
143 src, false, false);
\r