import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
+import java.util.Set;
/**
* Parses and writes features files, which may be in Jalview, GFF2 or GFF3
FeatureRenderer fr, String[] featureTypes,
SequenceI[] sequences, boolean includeNonPositional)
{
- List<String> featureGroups = fr.getFeatureGroups();
+ /*
+ * get all positional feature groups
+ */
+ Set<String> featureGroups = new HashSet<>(fr.getFeatureGroups());
+
+ /*
+ * add non-positional feature groups, just in case any are not
+ * also positional feature groups
+ */
+ for (SequenceI seq : sequences)
+ {
+ Set<String> nonPosGroups = seq.getFeatures().getFeatureGroups(false);
+ featureGroups.addAll(nonPosGroups);
+ }
/*
* sort groups alphabetically, and ensure that features with a
+ "Iron\tFER_CAPAA\t-1\t39\t39\tMETAL\n"
+ "Turn\tFER_CAPAA\t-1\t36\t38\tGAMMA-TURN\n"
+ "<html>Pfam domain<a href=\"http://pfam.xfam.org/family/PF00111\">Pfam_3_4</a></html>\tFER_CAPAA\t-1\t20\t20\tPfam\n"
- + "ENDGROUP\tuniprot\n";
+ + "ENDGROUP\tuniprot\n" + "STARTGROUP\tfoobar\n"
+ + "Foo\tFER_CAPAN\t-1\t0\t0\tBar\n" // non-positional feature
+ + "ENDGROUP\tfoobar\n";
FeaturesFile featuresFile = new FeaturesFile(features,
DataSourceType.PASTE);
featuresFile.parse(al.getDataset(), colours, false);
fr.setGroupVisibility("uniprot", true);
exported = featuresFile.printJalviewFormat(al.getSequencesArray(), fr,
true);
- expected = "\nSTARTGROUP\tuniprot\n"
+ expected = "\nSTARTGROUP\tfoobar\n"
+ + "Foo\tFER_CAPAN\t-1\t0\t0\tBar\t0.0\n"
+ + "ENDGROUP\tfoobar\n" + "\nSTARTGROUP\tuniprot\n"
+ "Cath\tFER_CAPAA\t-1\t0\t0\tDomain\t0.0\n"
+ "ENDGROUP\tuniprot\n\n"
+ "desc1\tFER_CAPAN\t-1\t0\t0\tPfam\t1.3\n\n"
assertEquals(expected, exported);
/*
- * include non-positional (overrides group not shown)
+ * include non-positional (overrides group not shown);
+ * uniprot non-positional (but not positional)
+ * features should be exported
*/
exported = featuresFile.printJalviewFormat(al.getSequencesArray(), fr,
true);
expected = "METAL\tcc9900\n" + "Pfam\tff0000\n"
+ "GAMMA-TURN\tscore|ff0000|00ffff|noValueMin|20.0|95.0|below|66.0\n"
+ + "\nSTARTGROUP\tfoobar\n"
+ + "Foo\tFER_CAPAN\t-1\t0\t0\tBar\t0.0\n" + "ENDGROUP\tfoobar\n"
+ "\nSTARTGROUP\tuniprot\n"
+ "Cath\tFER_CAPAA\t-1\t0\t0\tDomain\t0.0\n"
+ "ENDGROUP\tuniprot\n"