X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fws%2FDasSequenceFeatureFetcher.java;h=4262f7ebc9027830e77c337b595bcb2e49709e36;hb=ec1ba9894335243c7b6af28f73d3c686a6e88903;hp=8fc49b16de0033aa1d15fed024b15fb236a6de4d;hpb=9365a90059ec5d2f8ff094d9defcc021f63483d5;p=jalview.git diff --git a/src/jalview/ws/DasSequenceFeatureFetcher.java b/src/jalview/ws/DasSequenceFeatureFetcher.java index 8fc49b1..4262f7e 100644 --- a/src/jalview/ws/DasSequenceFeatureFetcher.java +++ b/src/jalview/ws/DasSequenceFeatureFetcher.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.6) + * Copyright (C) 2010 J Procter, AM Waterhouse, 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; @@ -80,9 +79,9 @@ public class DasSequenceFeatureFetcher * Creates a new SequenceFeatureFetcher object. Uses default * * @param align - * DOCUMENT ME! + * DOCUMENT ME! * @param ap - * DOCUMENT ME! + * DOCUMENT ME! */ public DasSequenceFeatureFetcher(SequenceI[] sequences, FeatureSettings fsettings, Vector selectedSources) @@ -94,18 +93,20 @@ public class DasSequenceFeatureFetcher FeatureSettings fsettings, Vector ourselectedSources, boolean checkDbrefs, boolean promptFetchDbrefs) { - this.selectedSources = new Vector(); + this.selectedSources = new Vector(); Enumeration sources = ourselectedSources.elements(); // filter both sequences and sources to eliminate duplicates while (sources.hasMoreElements()) { Object src = sources.nextElement(); - if (!selectedSources.contains(src)) { - selectedSources.addElement(src); - }; + if (!selectedSources.contains(src)) + { + selectedSources.addElement(src); + } + ; } Vector sqs = new Vector(); - for (int i=0; i jalview sequence feature transformation - SequenceFeature f = newSequenceFeature(features[i], source - .getNickname()); + SequenceFeature f = newSequenceFeature(features[i], + source.getNickname()); if (!parseSeqFeature(seq, f, features[i], source)) { if (dbref.getMap() != null && f.getBegin() > 0 @@ -609,8 +614,8 @@ public class DasSequenceFeatureFetcher for (int i = 0; i < features.length; i++) { // standard DAS feature-> jalview sequence feature transformation - SequenceFeature f = newSequenceFeature(features[i], source - .getNickname()); + SequenceFeature f = newSequenceFeature(features[i], + source.getNickname()); if (!parseSeqFeature(seq, f, features[i], source)) { // just add as a simple sequence feature @@ -648,20 +653,20 @@ public class DasSequenceFeatureFetcher * simple sequence feature. * * @param seq - * the sequence to annotate + * the sequence to annotate * @param f - * the jalview sequence feature generated from the DAS feature + * the jalview sequence feature generated from the DAS feature * @param map - * the sequence feature attributes + * the sequence feature attributes * @param source - * the source that emitted the feature + * the source that emitted the feature * @return true if feature was consumed as another kind of annotation. */ protected boolean parseSeqFeature(SequenceI seq, SequenceFeature f, Map map, Das1Source source) { SequenceI mseq = seq; - while (seq.getDatasetSequence()!=null) + while (seq.getDatasetSequence() != null) { seq = seq.getDatasetSequence(); } @@ -671,14 +676,18 @@ public class DasSequenceFeatureFetcher if (type.equalsIgnoreCase("protein_name")) { // parse name onto the alignment sequence or the dataset sequence. - if (seq.getDescription()==null || seq.getDescription().trim().length() == 0) + if (seq.getDescription() == null + || seq.getDescription().trim().length() == 0) { - // could look at the note series to pick out the first long name, for the moment just use the whole description string + // could look at the note series to pick out the first long name, for + // the moment just use the whole description string seq.setDescription(f.getDescription()); } - if (mseq.getDescription()==null || mseq.getDescription().trim().length() == 0) + if (mseq.getDescription() == null + || mseq.getDescription().trim().length() == 0) { - // could look at the note series to pick out the first long name, for the moment just use the whole description string + // could look at the note series to pick out the first long name, for + // the moment just use the whole description string mseq.setDescription(f.getDescription()); } return true; @@ -700,29 +709,36 @@ public class DasSequenceFeatureFetcher dbr.setAccessionId(st.nextToken()); } seq.addDBRef(dbr); - + if (f.links != null && f.links.size() > 0) { // feature is also appended to enable links to be seen. // TODO: consider extending dbrefs to have their own links ? - // TODO: new feature: extract dbref links from DAS servers and add the URL pattern to the list of DB name associated links in the user's preferences ? - // for the moment - just fix up the existing feature so it displays correctly. + // TODO: new feature: extract dbref links from DAS servers and add the + // URL pattern to the list of DB name associated links in the user's + // preferences ? + // for the moment - just fix up the existing feature so it displays + // correctly. // f.setType(dbr.getSource()); - //f.setDescription(); + // f.setDescription(); f.setValue("linkonly", Boolean.TRUE); - //f.setDescription(""); + // f.setDescription(""); Vector newlinks = new Vector(); Enumeration it = f.links.elements(); while (it.hasMoreElements()) { String elm; - UrlLink urllink = new UrlLink(elm = (String)it.nextElement()); - if (urllink.isValid()) { + UrlLink urllink = new UrlLink(elm = (String) it.nextElement()); + if (urllink.isValid()) + { urllink.setLabel(f.getDescription()); newlinks.addElement(urllink.toString()); - } else { - // couldn't parse the link properly. Keep it anyway - just in case. - debug("couldn't parse link string - "+elm); + } + else + { + // couldn't parse the link properly. Keep it anyway - just in + // case. + debug("couldn't parse link string - " + elm); newlinks.addElement(elm); } } @@ -788,8 +804,9 @@ public class DasSequenceFeatureFetcher { } - SequenceFeature f = new SequenceFeature((String) dasfeature - .get("TYPE"), desc, start, end, score, nickname); + SequenceFeature f = new SequenceFeature( + (String) dasfeature.get("TYPE"), desc, start, end, score, + nickname); if (dasfeature.containsKey("LINK")) { @@ -835,7 +852,7 @@ public class DasSequenceFeatureFetcher * query the given URL for DasSources. * * @param registryURL - * return sources from registryURL + * return sources from registryURL */ public static DasSource[] getDASSources(String registryURL) { @@ -871,6 +888,8 @@ public class DasSequenceFeatureFetcher .size()]); } catch (Exception ex) { + System.err.println("Failed to contact DAS1 registry at " + + registryURL); ex.printStackTrace(); return null; }