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;
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;
}
// viewed features
// TODO: decide if feature links should also be written here ?
Iterator<String> 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<String> groups = new ArrayList<String>();
int groupIndex = 0;
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
}
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("<html>") == -1)
+ if (sequenceFeature.links != null
+ && sequenceFeature.getDescription().indexOf("<html>") == -1)
{
out.append("<html>");
}
- 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("<a href=\"" + href + "\">" + label + "</a>");
+ out.append(" <a href=\"" + href + "\">" + label
+ + "</a>");
}
}
- if (features[j].getDescription().indexOf("</html>") == -1)
+ if (sequenceFeature.getDescription().indexOf("</html>") == -1)
{
out.append("</html>");
}
}
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);
}
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)