X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fio%2FSequenceAnnotationReport.java;h=175723983958b801d73907e21c5df2ad5e40acb4;hb=7b39c1ea0410b4cc8410b69b2d008ed0af3b6cb5;hp=86424465c2595c1c2aef13d627bcaef3009a1a4c;hpb=3eef76298c55f3def21eed2516b5ace4405bed0a;p=jalview.git diff --git a/src/jalview/io/SequenceAnnotationReport.java b/src/jalview/io/SequenceAnnotationReport.java index 8642446..1757239 100644 --- a/src/jalview/io/SequenceAnnotationReport.java +++ b/src/jalview/io/SequenceAnnotationReport.java @@ -1,7 +1,28 @@ +/* + * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.2) + * Copyright (C) 2014 The Jalview Authors + * + * This file is part of Jalview. + * + * 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. + * + * 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 . + * The Jalview Authors are detailed in the 'AUTHORS' file. + */ package jalview.io; import java.util.ArrayList; import java.util.Hashtable; +import java.util.List; import java.util.Vector; import jalview.datamodel.DBRefEntry; @@ -34,30 +55,30 @@ public class SequenceAnnotationReport * TODO refactor to Jalview 'utilities' somehow. */ public void appendFeatures(final StringBuffer tooltipText2, int rpos, - SequenceFeature[] features) + List features) { appendFeatures(tooltipText2, rpos, features, null); } public void appendFeatures(final StringBuffer tooltipText2, int rpos, - SequenceFeature[] features, Hashtable minmax) + List features, Hashtable minmax) { String tmpString; if (features != null) { - for (int i = 0; i < features.length; i++) + for (SequenceFeature feature:features) { - if (features[i].getType().equals("disulfide bond")) + if (feature.getType().equals("disulfide bond")) { - if (features[i].getBegin() == rpos - || features[i].getEnd() == rpos) + if (feature.getBegin() == rpos + || feature.getEnd() == rpos) { if (tooltipText2.length() > 6) { tooltipText2.append("
"); } - tooltipText2.append("disulfide bond " + features[i].getBegin() - + ":" + features[i].getEnd()); + tooltipText2.append("disulfide bond " + feature.getBegin() + + ":" + feature.getEnd()); } } else @@ -67,25 +88,25 @@ public class SequenceAnnotationReport tooltipText2.append("
"); } // TODO: remove this hack to display link only features - boolean linkOnly = features[i].getValue("linkonly") != null; + boolean linkOnly = feature.getValue("linkonly") != null; if (!linkOnly) { - tooltipText2.append(features[i].getType() + " "); + tooltipText2.append(feature.getType() + " "); if (rpos != 0) { // we are marking a positional feature - tooltipText2.append(features[i].begin); + tooltipText2.append(feature.begin); } - if (features[i].begin != features[i].end) + if (feature.begin != feature.end) { - tooltipText2.append(" " + features[i].end); + tooltipText2.append(" " + feature.end); } - if (features[i].getDescription() != null - && !features[i].description.equals(features[i] + if (feature.getDescription() != null + && !feature.description.equals(feature .getType())) { - tmpString = features[i].getDescription(); + tmpString = feature.getDescription(); String tmp2up = tmpString.toUpperCase(); int startTag = tmp2up.indexOf(""); if (startTag > -1) @@ -130,27 +151,27 @@ public class SequenceAnnotationReport } } // check score should be shown - if (features[i].getScore() != Float.NaN) + if (feature.getScore() != Float.NaN) { float[][] rng = (minmax == null) ? null : ((float[][]) minmax - .get(features[i].getType())); + .get(feature.getType())); if (rng != null && rng[0] != null && rng[0][0] != rng[0][1]) { - tooltipText2.append(" Score=" + features[i].getScore()); + tooltipText2.append(" Score=" + feature.getScore()); } } - if (features[i].getValue("status") != null) + if (feature.getValue("status") != null) { - String status = features[i].getValue("status").toString(); + String status = feature.getValue("status").toString(); if (status.length() > 0) { - tooltipText2.append("; (" + features[i].getValue("status") + tooltipText2.append("; (" + feature.getValue("status") + ")"); } } } } - if (features[i].links != null) + if (feature.links != null) { if (linkImageURL != null) { @@ -158,15 +179,21 @@ public class SequenceAnnotationReport } else { - for (String urlstring : (Vector) features[i].links) + for (String urlstring : (Vector) feature.links) { try { for (String[] urllink : createLinksFrom(null, urlstring)) { - tooltipText2.append("
" - + (urllink[0].toLowerCase().equals(urllink[1].toLowerCase()) ? urllink[0] : (urllink[0]+ ":" + urllink[1])) + "
"); + tooltipText2.append("
" + + (urllink[0].toLowerCase().equals( + urllink[1].toLowerCase()) ? urllink[0] + : (urllink[0] + ":" + urllink[1])) + + "
"); } } catch (Exception x) { @@ -192,7 +219,7 @@ public class SequenceAnnotationReport public String[][] createLinksFrom(SequenceI seq, String link) { ArrayList urlSets = new ArrayList(); - ArrayList uniques=new ArrayList(); + ArrayList uniques = new ArrayList(); UrlLink urlLink = new UrlLink(link); if (!urlLink.isValid()) { @@ -232,11 +259,11 @@ public class SequenceAnnotationReport { for (int u = 0; u < urls.length; u += 2) { - String unq=urls[u]+"|"+urls[u+1]; + String unq = urls[u] + "|" + urls[u + 1]; if (!uniques.contains(unq)) { urlSets.add(new String[] - { target, label, urls[u], urls[u + 1] }); + { target, label, urls[u], urls[u + 1] }); uniques.add(unq); } } @@ -251,11 +278,11 @@ public class SequenceAnnotationReport { for (int u = 0; u < urls.length; u += 2) { - String unq=urls[u]+"|"+urls[u+1]; + String unq = urls[u] + "|" + urls[u + 1]; if (!uniques.contains(unq)) { urlSets.add(new String[] - { target, label, urls[u], urls[u + 1] }); + { target, label, urls[u], urls[u + 1] }); uniques.add(unq); } } @@ -269,23 +296,27 @@ public class SequenceAnnotationReport { for (int u = 0; u < urls.length; u += 2) { - String unq=urls[u]+"|"+urls[u+1]; + String unq = urls[u] + "|" + urls[u + 1]; if (!uniques.contains(unq)) { urlSets.add(new String[] - { target, label, urls[u], urls[u + 1] }); + { target, label, urls[u], urls[u + 1] }); uniques.add(unq); } } } } - } else { - String unq=label + "|" + urlLink.getUrl_prefix(); - if (!uniques.contains(unq)){ + } + else + { + String unq = label + "|" + urlLink.getUrl_prefix(); + if (!uniques.contains(unq)) + { uniques.add(unq); // Add a non-dynamic link - urlSets.add(new String[] {target, label, null, urlLink.getUrl_prefix()}); + urlSets.add(new String[] + { target, label, null, urlLink.getUrl_prefix() }); } } @@ -293,17 +324,17 @@ public class SequenceAnnotationReport {}); } - public void createSequenceAnnotationReport(final StringBuffer tip, SequenceI sequence, boolean showDbRefs, boolean showNpFeats, Hashtable minmax) { - createSequenceAnnotationReport(tip, sequence, showDbRefs, showNpFeats, true, minmax); + createSequenceAnnotationReport(tip, sequence, showDbRefs, showNpFeats, + true, minmax); } public void createSequenceAnnotationReport(final StringBuffer tip, - SequenceI sequence, boolean showDbRefs, boolean showNpFeats, boolean tableWrap, - Hashtable minmax) + SequenceI sequence, boolean showDbRefs, boolean showNpFeats, + boolean tableWrap, Hashtable minmax) { String tmp; tip.append(""); @@ -315,8 +346,12 @@ public class SequenceAnnotationReport tip.append("
" + tmp); maxWidth = Math.max(maxWidth, tmp.length()); } - - DBRefEntry[] dbrefs = sequence.getDatasetSequence().getDBRef(); + SequenceI ds = sequence; + while (ds.getDatasetSequence() != null) + { + ds = ds.getDatasetSequence(); + } + DBRefEntry[] dbrefs = ds.getDBRef(); if (showDbRefs && dbrefs != null) { for (int i = 0; i < dbrefs.length; i++) @@ -329,9 +364,7 @@ public class SequenceAnnotationReport } // ADD NON POSITIONAL SEQUENCE INFO - SequenceFeature[] features = sequence.getDatasetSequence() - .getSequenceFeatures(); - SequenceFeature[] tfeat = new SequenceFeature[1]; + SequenceFeature[] features = ds.getSequenceFeatures(); if (showNpFeats && features != null) { for (int i = 0; i < features.length; i++) @@ -339,7 +372,8 @@ public class SequenceAnnotationReport if (features[i].begin == 0 && features[i].end == 0) { int sz = -tip.length(); - tfeat[0] = features[i]; + List tfeat = new ArrayList(); + tfeat.add(features[i]); appendFeatures(tip, 0, tfeat, minmax); sz += tip.length(); maxWidth = Math.max(maxWidth, sz);