X-Git-Url: http://source.jalview.org/gitweb/?p=jalview.git;a=blobdiff_plain;f=src%2Fjalview%2Fio%2FFeaturesFile.java;h=46467c53296759899ff575543c1369d5b6be5c25;hp=40f83d3559c65a731b6934c8168657c203d46663;hb=refs%2Fheads%2Ffeatures%2FJAL-2094_colourInterface;hpb=d737688dfdb8d00ed63a699fb86548499d75bcf2 diff --git a/src/jalview/io/FeaturesFile.java b/src/jalview/io/FeaturesFile.java index 40f83d3..46467c5 100755 --- a/src/jalview/io/FeaturesFile.java +++ b/src/jalview/io/FeaturesFile.java @@ -36,7 +36,6 @@ import jalview.io.gff.GffHelperFactory; import jalview.io.gff.GffHelperI; import jalview.schemes.FeatureColour; import jalview.schemes.UserColourScheme; -import jalview.util.Format; import jalview.util.MapList; import jalview.util.ParseHtmlBodyAndLinks; import jalview.util.StringUtils; @@ -233,12 +232,18 @@ public class FeaturesFile extends AlignFile implements FeaturesSourceI else if (ft.equalsIgnoreCase("endgroup")) { // We should check whether this is the current group, - // but at present theres no way of showing more than 1 group + // but at present there's no way of showing more than 1 group featureGroup = null; } else { - parseFeatureColour(line, ft, gffColumns, colours); + String colscheme = gffColumns[1]; + FeatureColourI colour = FeatureColour + .parseJalviewFeatureColour(colscheme); + if (colour != null) + { + colours.put(ft, colour); + } } continue; } @@ -744,50 +749,14 @@ public class FeaturesFile extends AlignFile implements FeaturesSourceI // viewed features // TODO: decide if feature links should also be written here ? Iterator en = featureColours.keySet().iterator(); - String featureType, color; while (en.hasNext()) { - featureType = en.next(); - FeatureColourI fc = featureColours.get(featureType); - if (fc.isSimpleColour()) - { - color = Format.getHexString(fc.getColour()); - } - else - { - color = (fc.isColourByLabel() ? "label|" : "") - + Format.getHexString(fc.getMinColour()) + "|" - + Format.getHexString(fc.getMaxColour()) - + (fc.isAutoScaled() ? "|" : "|abso|") + fc.getMin() + "|" - + fc.getMax() + "|"; - if (fc.isBelowThreshold()) - { - color += "below"; - } - else if (fc.isAboveThreshold()) - { - color += "above"; - } - // add the value - color += "|" + fc.getThreshold(); - } -// else -// { -// color += "none"; -// } - // else - // { - // // legacy support for integer objects containing colour triplet - // values - // color = Format.getHexString(new Color(Integer - // .parseInt(fc.toString()))); - // } - out.append(featureType); - out.append(TAB); - out.append(color); - out.append(newline); + String featureType = en.next(); + FeatureColourI colour = featureColours.get(featureType); + out.append(colour.toJalviewFormat(featureType)).append(newline); } } + // Work out which groups are both present and visible List groups = new ArrayList(); int groupIndex = 0; @@ -839,12 +808,12 @@ public class FeaturesFile extends AlignFile implements FeaturesSourceI features = sequences[i].getSequenceFeatures(); if (features != null) { - for (int j = 0; j < features.length; j++) + for (SequenceFeature sequenceFeature : features) { - isnonpos = features[j].begin == 0 && features[j].end == 0; + isnonpos = sequenceFeature.begin == 0 && sequenceFeature.end == 0; if ((!nonpos && isnonpos) || (!isnonpos && visOnly && !featureColours - .containsKey(features[j].type))) + .containsKey(sequenceFeature.type))) { // skip if feature is nonpos and we ignore them or if we only // output visible and it isn't non-pos and it's not visible @@ -852,47 +821,48 @@ public class FeaturesFile extends AlignFile implements FeaturesSourceI } if (group != null - && (features[j].featureGroup == null || !features[j].featureGroup + && (sequenceFeature.featureGroup == null || !sequenceFeature.featureGroup .equals(group))) { continue; } - if (group == null && features[j].featureGroup != null) + if (group == null && sequenceFeature.featureGroup != null) { continue; } // we have features to output featuresGen = true; - if (features[j].description == null - || features[j].description.equals("")) + if (sequenceFeature.description == null + || sequenceFeature.description.equals("")) { - out.append(features[j].type).append(TAB); + out.append(sequenceFeature.type).append(TAB); } else { - if (features[j].links != null - && features[j].getDescription().indexOf("") == -1) + if (sequenceFeature.links != null + && sequenceFeature.getDescription().indexOf("") == -1) { out.append(""); } - out.append(features[j].description + " "); - if (features[j].links != null) + out.append(sequenceFeature.description); + if (sequenceFeature.links != null) { - for (int l = 0; l < features[j].links.size(); l++) + for (int l = 0; l < sequenceFeature.links.size(); l++) { - String label = features[j].links.elementAt(l).toString(); + String label = sequenceFeature.links.elementAt(l); String href = label.substring(label.indexOf("|") + 1); label = label.substring(0, label.indexOf("|")); - if (features[j].description.indexOf(href) == -1) + if (sequenceFeature.description.indexOf(href) == -1) { - out.append("" + label + ""); + out.append(" " + label + + ""); } } - if (features[j].getDescription().indexOf("") == -1) + if (sequenceFeature.getDescription().indexOf("") == -1) { out.append(""); } @@ -902,15 +872,15 @@ public class FeaturesFile extends AlignFile implements FeaturesSourceI } out.append(sequences[i].getName()); out.append("\t-1\t"); - out.append(features[j].begin); + out.append(sequenceFeature.begin); out.append(TAB); - out.append(features[j].end); + out.append(sequenceFeature.end); out.append(TAB); - out.append(features[j].type); - if (!Float.isNaN(features[j].score)) + out.append(sequenceFeature.type); + if (!Float.isNaN(sequenceFeature.score)) { out.append(TAB); - out.append(features[j].score); + out.append(sequenceFeature.score); } out.append(newline); } @@ -1022,7 +992,8 @@ public class FeaturesFile extends AlignFile implements FeaturesSourceI boolean includeNonPositionalFeatures) { StringBuilder out = new StringBuilder(256); - out.append(String.format("%s %d\n", GFF_VERSION, gffVersion)); + int version = gffVersion == 0 ? 2 : gffVersion; + out.append(String.format("%s %d\n", GFF_VERSION, version)); String source; boolean isnonpos; for (SequenceI seq : sequences)