X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fws%2FSequenceFetcher.java;h=ef5cd9151eddb43b8fddc35bc47cc6543c42ced0;hb=797df64fa2a0a30773d0f48f5494d4155e5a8be3;hp=b20ebbb5f2d611b1a6d20f3e31fcc958cd525d13;hpb=506d60f0e188723ddc91c26824b41ac7034df3fe;p=jalview.git diff --git a/src/jalview/ws/SequenceFetcher.java b/src/jalview/ws/SequenceFetcher.java index b20ebbb..ef5cd91 100644 --- a/src/jalview/ws/SequenceFetcher.java +++ b/src/jalview/ws/SequenceFetcher.java @@ -1,20 +1,19 @@ /* - * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4) - * Copyright (C) 2008 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * Jalview - A Sequence Alignment Editor and Viewer (Version 2.7) + * Copyright (C) 2011 J Procter, AM Waterhouse, J Engelhardt, LM Lui, G Barton, M Clamp, S Searle * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. + * This file is part of Jalview. * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. + * Jalview is free software: you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + * Jalview is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with Jalview. If not, see . */ package jalview.ws; @@ -31,6 +30,7 @@ import jalview.datamodel.Alignment; import jalview.datamodel.AlignmentI; import jalview.datamodel.DBRefSource; import jalview.datamodel.SequenceI; +import jalview.ws.dbsources.DasSequenceSource; import jalview.ws.seqfetcher.ASequenceFetcher; import jalview.ws.seqfetcher.DbSourceProxy; @@ -58,9 +58,11 @@ public class SequenceFetcher extends ASequenceFetcher addDBRefSourceImpl(jalview.ws.dbsources.Pdb.class); addDBRefSourceImpl(jalview.ws.dbsources.PfamFull.class); addDBRefSourceImpl(jalview.ws.dbsources.PfamSeed.class); // ensures Seed - // alignment is - // 'default' for - // PFAM + // alignment is + // 'default' for + // PFAM + addDBRefSourceImpl(jalview.ws.dbsources.RfamFull.class); + addDBRefSourceImpl(jalview.ws.dbsources.RfamSeed.class); registerDasSequenceSources(); } @@ -319,58 +321,89 @@ public class SequenceFetcher extends ASequenceFetcher { DasSource[] sources = jalview.ws.DasSequenceFeatureFetcher .getDASSources(); - for (int s = 0; s < sources.length; s++) + if (sources != null) { - Das1Source d1s = null; - if (sources[s].hasCapability("sequence")) + for (int s = 0; sources != null && s < sources.length; s++) { - if (sources[s] instanceof Das2Source) - { - if (((Das2Source) sources[s]).hasDas1Capabilities()) - { - try - { - d1s = org.biojava.dasobert.das2.DasSourceConverter - .toDas1Source((Das2Source) sources[s]); - } catch (Exception e) - { - System.err.println("Ignoring DAS2 sequence source " - + sources[s].getNickname() - + " - couldn't map to Das1Source.\n"); - e.printStackTrace(); - } - } - } - else - { - if (sources[s] instanceof Das1Source) - { - d1s = (Das1Source) sources[s]; - } - } + addDasSequenceSource(sources[s]); } - if (d1s != null) + } + + Vector localsources = jalview.bin.Cache.getLocalDasSources(); + if (localsources != null) + { + for (Enumeration ls = localsources.elements(); ls.hasMoreElements();) { - DasCoordinateSystem[] css = d1s.getCoordinateSystem(); - for (int c = 0; c < css.length; c++) + addDasSequenceSource((DasSource) ls.nextElement()); + } + } + } + + /** + * Try to create and add a DasSequenceSource to the list of sources. + * + * @param source + * @return null if no source was added, or the new DasSequenceSource created + */ + DasSequenceSource addDasSequenceSource(DasSource source) + { + DasSequenceSource ds = null; + Das1Source d1s = null; + if (source.hasCapability("sequence")) + { + if (source instanceof Das2Source) + { + if (((Das2Source) source).hasDas1Capabilities()) { try { - addDbRefSourceImpl(new jalview.ws.dbsources.DasSequenceSource( - "das:" + d1s.getNickname() + " (" + css[c].getName() - + ")", css[c].getName(), d1s, css[c])); + d1s = org.biojava.dasobert.das2.DasSourceConverter + .toDas1Source((Das2Source) source); } catch (Exception e) { - System.err.println("Ignoring sequence coord system " + c + " (" - + css[c].getName() + ") for source " - + d1s.getNickname() - + "- threw exception when constructing fetcher.\n"); + System.err.println("Ignoring DAS2 sequence source " + + source.getNickname() + + " - couldn't map to Das1Source.\n"); e.printStackTrace(); } } } - + else + { + if (source instanceof Das1Source) + { + d1s = (Das1Source) source; + } + } + } + if (d1s != null) + { + DasCoordinateSystem[] css = d1s.getCoordinateSystem(); + if (css == null || css.length == 0) + { + // TODO: query das source directly to identify coordinate system... or + // have to make up a coordinate system + css = new DasCoordinateSystem[] + { new DasCoordinateSystem() }; + css[0].setName(d1s.getNickname()); + css[0].setUniqueId(d1s.getNickname()); + } + for (int c = 0; c < css.length; c++) + { + try + { + addDbRefSourceImpl(ds = new DasSequenceSource("das:" + + d1s.getNickname() + " (" + css[c].getName() + ")", + css[c].getName(), d1s, css[c])); + } catch (Exception e) + { + System.err.println("Ignoring sequence coord system " + c + " (" + + css[c].getName() + ") for source " + d1s.getNickname() + + "- threw exception when constructing fetcher.\n"); + e.printStackTrace(); + } + } } + return ds; } - }