From 84ed42e8d0aa07b03441b045d240ebb51f94c53c Mon Sep 17 00:00:00 2001 From: gmungoc Date: Thu, 27 Sep 2018 16:40:27 +0100 Subject: [PATCH] JAL-2791 refactored Export Features to apply all visibility tests --- src/jalview/appletgui/AlignFrame.java | 6 +- src/jalview/gui/AnnotationExporter.java | 19 +-- src/jalview/io/FeaturesFile.java | 108 +++++++------- test/jalview/io/FeaturesFileTest.java | 243 ++++++++++++++++++++++++++----- 4 files changed, 269 insertions(+), 107 deletions(-) diff --git a/src/jalview/appletgui/AlignFrame.java b/src/jalview/appletgui/AlignFrame.java index 5ad212e..85fb03c 100644 --- a/src/jalview/appletgui/AlignFrame.java +++ b/src/jalview/appletgui/AlignFrame.java @@ -1447,14 +1447,12 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, { features = formatter.printJalviewFormat( viewport.getAlignment().getSequencesArray(), - getDisplayedFeatureCols(), null, getDisplayedFeatureGroups(), - true); + alignPanel.getFeatureRenderer(), true); } else { features = formatter.printGffFormat(viewport.getAlignment() - .getSequencesArray(), getDisplayedFeatureCols(), - getDisplayedFeatureGroups(), true); + .getSequencesArray(), alignPanel.getFeatureRenderer(), true); } if (displayTextbox) diff --git a/src/jalview/gui/AnnotationExporter.java b/src/jalview/gui/AnnotationExporter.java index 6fefbd0..fac531e 100644 --- a/src/jalview/gui/AnnotationExporter.java +++ b/src/jalview/gui/AnnotationExporter.java @@ -20,11 +20,10 @@ */ package jalview.gui; -import jalview.api.FeatureColourI; +import jalview.api.FeatureRenderer; import jalview.bin.Cache; import jalview.datamodel.AlignmentAnnotation; import jalview.datamodel.SequenceI; -import jalview.datamodel.features.FeatureMatcherSetI; import jalview.io.AnnotationFile; import jalview.io.FeaturesFile; import jalview.io.JalviewFileChooser; @@ -38,8 +37,6 @@ import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.io.FileWriter; import java.io.PrintWriter; -import java.util.List; -import java.util.Map; import javax.swing.BorderFactory; import javax.swing.ButtonGroup; @@ -214,24 +211,18 @@ public class AnnotationExporter extends JPanel { String text; SequenceI[] sequences = ap.av.getAlignment().getSequencesArray(); - Map featureColours = ap.getFeatureRenderer() - .getDisplayedFeatureCols(); - Map featureFilters = ap.getFeatureRenderer() - .getFeatureFilters(); - List featureGroups = ap.getFeatureRenderer() - .getDisplayedFeatureGroups(); boolean includeNonPositional = ap.av.isShowNPFeats(); FeaturesFile formatter = new FeaturesFile(); + final FeatureRenderer fr = ap.getFeatureRenderer(); if (GFFFormat.isSelected()) { - text = formatter.printGffFormat(sequences, featureColours, - featureGroups, includeNonPositional); + text = formatter.printGffFormat(sequences, fr, includeNonPositional); } else { - text = formatter.printJalviewFormat(sequences, featureColours, - featureFilters, featureGroups, includeNonPositional); + text = formatter.printJalviewFormat(sequences, fr, + includeNonPositional); } return text; } diff --git a/src/jalview/io/FeaturesFile.java b/src/jalview/io/FeaturesFile.java index 169da5a..39ec10d 100755 --- a/src/jalview/io/FeaturesFile.java +++ b/src/jalview/io/FeaturesFile.java @@ -24,6 +24,7 @@ import jalview.analysis.AlignmentUtils; import jalview.analysis.SequenceIdMatcher; import jalview.api.AlignViewportI; import jalview.api.FeatureColourI; +import jalview.api.FeatureRenderer; import jalview.api.FeaturesSourceI; import jalview.datamodel.AlignedCodonFrame; import jalview.datamodel.Alignment; @@ -562,28 +563,28 @@ public class FeaturesFile extends AlignFile implements FeaturesSourceI } /** - * Returns contents of a Jalview format features file, for visible features, as - * filtered by type and group. Features with a null group are displayed if their - * feature type is visible. Non-positional features may optionally be included - * (with no check on type or group). + * Returns contents of a Jalview format features file, for visible features, + * as filtered by type and group. Features with a null group are displayed if + * their feature type is visible. Non-positional features may optionally be + * included (with no check on type or group). * * @param sequences - * source of features - * @param visible - * map of colour for each visible feature type - * @param featureFilters - * @param visibleFeatureGroups + * @param fr * @param includeNonPositional * if true, include non-positional features (regardless of group or * type) * @return */ public String printJalviewFormat(SequenceI[] sequences, - Map visible, - Map featureFilters, - List visibleFeatureGroups, boolean includeNonPositional) + FeatureRenderer fr, boolean includeNonPositional) { - if (!includeNonPositional && (visible == null || visible.isEmpty())) + Map visibleColours = fr + .getDisplayedFeatureCols(); + Map featureFilters = fr.getFeatureFilters(); + List visibleFeatureGroups = fr.getDisplayedFeatureGroups(); + + if (!includeNonPositional + && (visibleColours == null || visibleColours.isEmpty())) { // no point continuing. return "No Features Visible"; @@ -594,9 +595,10 @@ public class FeaturesFile extends AlignFile implements FeaturesSourceI */ // TODO: decide if feature links should also be written here ? StringBuilder out = new StringBuilder(256); - if (visible != null) + if (visibleColours != null) { - for (Entry featureColour : visible.entrySet()) + for (Entry featureColour : visibleColours + .entrySet()) { FeatureColourI colour = featureColour.getValue(); out.append(colour.toJalviewFormat(featureColour.getKey())).append( @@ -604,13 +606,14 @@ public class FeaturesFile extends AlignFile implements FeaturesSourceI } } - String[] types = visible == null ? new String[0] : visible.keySet() - .toArray(new String[visible.keySet().size()]); + String[] types = visibleColours == null ? new String[0] + : visibleColours.keySet() + .toArray(new String[visibleColours.keySet().size()]); /* * feature filters if any */ - outputFeatureFilters(out, visible, featureFilters); + outputFeatureFilters(out, visibleColours, featureFilters); /* * sort groups alphabetically, and ensure that features with a @@ -645,7 +648,8 @@ public class FeaturesFile extends AlignFile implements FeaturesSourceI /* * positional features within groups */ - foundSome |= outputFeaturesByGroup(out, sortedGroups, types, sequences); + foundSome |= outputFeaturesByGroup(out, fr, sortedGroups, types, + sequences); return foundSome ? out.toString() : "No Features Visible"; } @@ -685,36 +689,33 @@ public class FeaturesFile extends AlignFile implements FeaturesSourceI } if (!first) { - out.append(ENDFILTERS).append(newline).append(newline); + out.append(ENDFILTERS).append(newline); } } /** - * Appends output of sequence features within feature groups to the output - * buffer. Groups other than the null or empty group are sandwiched by - * STARTGROUP and ENDGROUP lines. + * Appends output of visible sequence features within feature groups to the + * output buffer. Groups other than the null or empty group are sandwiched by + * STARTGROUP and ENDGROUP lines. Answers true if at least one feature was + * written, else false. * * @param out + * @param fr * @param groups * @param featureTypes * @param sequences * @return */ private boolean outputFeaturesByGroup(StringBuilder out, - List groups, String[] featureTypes, SequenceI[] sequences) + FeatureRenderer fr, List groups, String[] featureTypes, + SequenceI[] sequences) { boolean foundSome = false; for (String group : groups) { + boolean firstInGroup = true; boolean isNamedGroup = (group != null && !"".equals(group)); - if (isNamedGroup) - { - out.append(newline); - out.append(STARTGROUP).append(TAB); - out.append(group); - out.append(newline); - } /* * output positional features within groups @@ -731,16 +732,23 @@ public class FeaturesFile extends AlignFile implements FeaturesSourceI for (SequenceFeature sequenceFeature : features) { - foundSome = true; - out.append(formatJalviewFeature(sequenceName, sequenceFeature)); + if (fr.isVisible(sequenceFeature)) + { + foundSome = true; + if (firstInGroup && isNamedGroup) + { + out.append(newline).append(STARTGROUP).append(TAB) + .append(group).append(newline); + } + firstInGroup = false; + out.append(formatJalviewFeature(sequenceName, sequenceFeature)); + } } } - if (isNamedGroup) + if (isNamedGroup && !firstInGroup) { - out.append(ENDGROUP).append(TAB); - out.append(group); - out.append(newline); + out.append(ENDGROUP).append(TAB).append(group).append(newline); } } return foundSome; @@ -872,23 +880,23 @@ public class FeaturesFile extends AlignFile implements FeaturesSourceI * @return */ public String printGffFormat(SequenceI[] sequences, - Map visible, - List visibleFeatureGroups, - boolean includeNonPositionalFeatures) + FeatureRenderer fr, boolean includeNonPositionalFeatures) { + Map visibleColours = fr.getDisplayedFeatureCols(); + StringBuilder out = new StringBuilder(256); out.append(String.format("%s %d\n", GFF_VERSION, gffVersion == 0 ? 2 : gffVersion)); if (!includeNonPositionalFeatures - && (visible == null || visible.isEmpty())) + && (visibleColours == null || visibleColours.isEmpty())) { return out.toString(); } - String[] types = visible == null ? new String[0] : visible.keySet() - .toArray( - new String[visible.keySet().size()]); + String[] types = visibleColours == null ? new String[0] + : visibleColours.keySet() + .toArray(new String[visibleColours.keySet().size()]); for (SequenceI seq : sequences) { @@ -897,21 +905,23 @@ public class FeaturesFile extends AlignFile implements FeaturesSourceI { features.addAll(seq.getFeatures().getNonPositionalFeatures()); } - if (visible != null && !visible.isEmpty()) + if (visibleColours != null && !visibleColours.isEmpty()) { features.addAll(seq.getFeatures().getPositionalFeatures(types)); } for (SequenceFeature sf : features) { - String source = sf.featureGroup; - if (!sf.isNonPositional() && source != null - && !visibleFeatureGroups.contains(source)) + if (!sf.isNonPositional() && !fr.isVisible(sf)) { - // group is not visible + /* + * feature hidden by group visibility, colour threshold, + * or feature filter condition + */ continue; } + String source = sf.featureGroup; if (source == null) { source = sf.getDescription(); diff --git a/test/jalview/io/FeaturesFileTest.java b/test/jalview/io/FeaturesFileTest.java index 32ca841..ab07289 100644 --- a/test/jalview/io/FeaturesFileTest.java +++ b/test/jalview/io/FeaturesFileTest.java @@ -45,12 +45,12 @@ import jalview.gui.JvOptionPane; import jalview.schemes.FeatureColour; import jalview.structure.StructureSelectionManager; import jalview.util.matcher.Condition; +import jalview.viewmodel.seqfeatures.FeatureRendererModel; +import jalview.viewmodel.seqfeatures.FeatureRendererModel.FeatureSettingsBean; import java.awt.Color; import java.io.File; import java.io.IOException; -import java.util.ArrayList; -import java.util.Arrays; import java.util.HashMap; import java.util.Iterator; import java.util.List; @@ -475,24 +475,20 @@ public class FeaturesFileTest * first with no features displayed, exclude non-positional features */ FeatureRenderer fr = af.alignPanel.getFeatureRenderer(); - Map visible = fr.getDisplayedFeatureCols(); - List visibleGroups = new ArrayList<>( - Arrays.asList(new String[] {})); - String exported = featuresFile.printJalviewFormat( - al.getSequencesArray(), visible, null, visibleGroups, false); + String exported = featuresFile + .printJalviewFormat(al.getSequencesArray(), fr, false); String expected = "No Features Visible"; assertEquals(expected, exported); /* * include non-positional features */ - visibleGroups.add("uniprot"); - exported = featuresFile.printJalviewFormat(al.getSequencesArray(), - visible, null, visibleGroups, true); + fr.setGroupVisibility("uniprot", true); + exported = featuresFile.printJalviewFormat(al.getSequencesArray(), fr, + true); expected = "Cath\tFER_CAPAA\t-1\t0\t0\tDomain\t0.0\n" + "desc1\tFER_CAPAN\t-1\t0\t0\tPfam\t1.3\n" - + "desc3\tFER1_SOLLC\t-1\t0\t0\tPfam\n" // NaN is not output - + "\nSTARTGROUP\tuniprot\nENDGROUP\tuniprot\n"; + + "desc3\tFER1_SOLLC\t-1\t0\t0\tPfam\n"; // NaN is not output assertEquals(expected, exported); /* @@ -500,9 +496,8 @@ public class FeaturesFileTest */ fr.setVisible("METAL"); fr.setVisible("GAMMA-TURN"); - visible = fr.getDisplayedFeatureCols(); - exported = featuresFile.printJalviewFormat(al.getSequencesArray(), - visible, null, visibleGroups, false); + exported = featuresFile.printJalviewFormat(al.getSequencesArray(), fr, + false); expected = "METAL\tcc9900\n" + "GAMMA-TURN\tscore|ff0000|00ffff|noValueMin|20.0|95.0|below|66.0\n" + "\nSTARTGROUP\tuniprot\n" @@ -515,9 +510,8 @@ public class FeaturesFileTest * now set Pfam visible */ fr.setVisible("Pfam"); - visible = fr.getDisplayedFeatureCols(); - exported = featuresFile.printJalviewFormat(al.getSequencesArray(), - visible, null, visibleGroups, false); + exported = featuresFile.printJalviewFormat(al.getSequencesArray(), fr, + false); /* * features are output within group, ordered by sequence and by type */ @@ -547,16 +541,14 @@ public class FeaturesFileTest * no features */ FeaturesFile featuresFile = new FeaturesFile(); - FeatureRenderer fr = af.alignPanel.getFeatureRenderer(); - Map visible = new HashMap<>(); - List visibleGroups = new ArrayList<>( - Arrays.asList(new String[] {})); + FeatureRendererModel fr = (FeatureRendererModel) af.alignPanel + .getFeatureRenderer(); String exported = featuresFile.printGffFormat(al.getSequencesArray(), - visible, visibleGroups, false); + fr, false); String gffHeader = "##gff-version 2\n"; assertEquals(gffHeader, exported); - exported = featuresFile.printGffFormat(al.getSequencesArray(), visible, - visibleGroups, true); + exported = featuresFile.printGffFormat(al.getSequencesArray(), fr, + true); assertEquals(gffHeader, exported); /* @@ -578,18 +570,31 @@ public class FeaturesFileTest al.getSequenceAt(1).addSequenceFeature(sf); /* + * 'discover' features then hide all feature types + */ + fr.findAllFeatures(true); + FeatureSettingsBean[] data = new FeatureSettingsBean[4]; + FeatureColourI fc = new FeatureColour(Color.PINK); + data[0] = new FeatureSettingsBean("Domain", fc, null, false); + data[1] = new FeatureSettingsBean("METAL", fc, null, false); + data[2] = new FeatureSettingsBean("GAMMA-TURN", fc, null, false); + data[3] = new FeatureSettingsBean("Pfam", fc, null, false); + fr.setFeaturePriority(data); + + /* * with no features displayed, exclude non-positional features */ - exported = featuresFile.printGffFormat(al.getSequencesArray(), visible, - visibleGroups, false); + exported = featuresFile.printGffFormat(al.getSequencesArray(), fr, + false); assertEquals(gffHeader, exported); /* * include non-positional features */ - visibleGroups.add("Uniprot"); - exported = featuresFile.printGffFormat(al.getSequencesArray(), visible, - visibleGroups, true); + fr.setGroupVisibility("Uniprot", true); + fr.setGroupVisibility("s3dm", false); + exported = featuresFile.printGffFormat(al.getSequencesArray(), fr, + true); String expected = gffHeader + "FER_CAPAA\tUniprot\tDomain\t0\t0\t0.0\t.\t.\n"; assertEquals(expected, exported); @@ -600,9 +605,8 @@ public class FeaturesFileTest */ fr.setVisible("METAL"); fr.setVisible("GAMMA-TURN"); - visible = fr.getDisplayedFeatureCols(); - exported = featuresFile.printGffFormat(al.getSequencesArray(), visible, - visibleGroups, false); + exported = featuresFile.printGffFormat(al.getSequencesArray(), fr, + false); // METAL feature has null group: description used for column 2 expected = gffHeader + "FER_CAPAA\tCath\tMETAL\t39\t39\t1.2\t.\t.\n"; assertEquals(expected, exported); @@ -610,9 +614,9 @@ public class FeaturesFileTest /* * set s3dm group visible */ - visibleGroups.add("s3dm"); - exported = featuresFile.printGffFormat(al.getSequencesArray(), visible, - visibleGroups, false); + fr.setGroupVisibility("s3dm", true); + exported = featuresFile.printGffFormat(al.getSequencesArray(), fr, + false); // METAL feature has null group: description used for column 2 expected = gffHeader + "FER_CAPAA\tCath\tMETAL\t39\t39\t1.2\t.\t.\n" + "FER_CAPAN\ts3dm\tGAMMA-TURN\t36\t38\t2.1\t.\t.\n"; @@ -622,9 +626,8 @@ public class FeaturesFileTest * now set Pfam visible */ fr.setVisible("Pfam"); - visible = fr.getDisplayedFeatureCols(); - exported = featuresFile.printGffFormat(al.getSequencesArray(), visible, - visibleGroups, false); + exported = featuresFile.printGffFormat(al.getSequencesArray(), fr, + false); // Pfam feature columns include strand(+), phase(2), attributes expected = gffHeader + "FER_CAPAA\tCath\tMETAL\t39\t39\t1.2\t.\t.\n" @@ -704,7 +707,167 @@ public class FeaturesFileTest featureFilters.put("pfam", filter2); visible.put("foobar", new FeatureColour(Color.blue)); ff.outputFeatureFilters(sb, visible, featureFilters); - String expected = "\nSTARTFILTERS\nfoobar\tLabel Present\npfam\t(CSQ:PolyPhen Present) AND (Score LE -2.4)\nENDFILTERS\n\n"; + String expected = "\nSTARTFILTERS\nfoobar\tLabel Present\npfam\t(CSQ:PolyPhen Present) AND (Score LE -2.4)\nENDFILTERS\n"; assertEquals(expected, sb.toString()); } + + /** + * Output as GFF should not include features which are not visible due to + * colour threshold or feature filter settings + * + * @throws Exception + */ + @Test(groups = { "Functional" }) + public void testPrintGffFormat_withFilters() throws Exception + { + File f = new File("examples/uniref50.fa"); + AlignmentI al = readAlignmentFile(f); + AlignFrame af = new AlignFrame(al, 500, 500); + SequenceFeature sf1 = new SequenceFeature("METAL", "Cath", 39, 39, 1.2f, + null); + sf1.setValue("clin_sig", "Likely Pathogenic"); + sf1.setValue("AF", "24"); + al.getSequenceAt(0).addSequenceFeature(sf1); + SequenceFeature sf2 = new SequenceFeature("METAL", "Cath", 41, 41, 0.6f, + null); + sf2.setValue("clin_sig", "Benign"); + sf2.setValue("AF", "46"); + al.getSequenceAt(0).addSequenceFeature(sf2); + + FeaturesFile featuresFile = new FeaturesFile(); + FeatureRenderer fr = af.alignPanel.getFeatureRenderer(); + final String gffHeader = "##gff-version 2\n"; + + fr.setVisible("METAL"); + fr.setColour("METAL", new FeatureColour(Color.PINK)); + String exported = featuresFile.printGffFormat(al.getSequencesArray(), + fr, false); + String expected = gffHeader + + "FER_CAPAA\tCath\tMETAL\t39\t39\t1.2\t.\t.\n" + + "FER_CAPAA\tCath\tMETAL\t41\t41\t0.6\t.\t.\n"; + assertEquals(expected, exported); + + /* + * now threshold to Score > 1.1 - should exclude sf2 + */ + FeatureColourI fc = new FeatureColour(Color.white, Color.BLACK, + Color.white, 0f, 2f); + fc.setAboveThreshold(true); + fc.setThreshold(1.1f); + fr.setColour("METAL", fc); + exported = featuresFile.printGffFormat(al.getSequencesArray(), fr, + false); + expected = gffHeader + "FER_CAPAA\tCath\tMETAL\t39\t39\t1.2\t.\t.\n"; + assertEquals(expected, exported); + + /* + * remove threshold and check sf2 is exported + */ + fc.setAboveThreshold(false); + exported = featuresFile.printGffFormat(al.getSequencesArray(), fr, + false); + expected = gffHeader + "FER_CAPAA\tCath\tMETAL\t39\t39\t1.2\t.\t.\n" + + "FER_CAPAA\tCath\tMETAL\t41\t41\t0.6\t.\t.\n"; + assertEquals(expected, exported); + + /* + * filter on (clin_sig contains Benign) - should include sf2 and exclude sf1 + */ + FeatureMatcherSetI filter = new FeatureMatcherSet(); + filter.and(FeatureMatcher.byAttribute(Condition.Contains, "benign", + "clin_sig")); + fr.setFeatureFilter("METAL", filter); + exported = featuresFile.printGffFormat(al.getSequencesArray(), fr, + false); + expected = gffHeader + "FER_CAPAA\tCath\tMETAL\t41\t41\t0.6\t.\t.\n"; + assertEquals(expected, exported); + } + + /** + * Output as Jalview should not include features which are not visible due to + * colour threshold or feature filter settings + * + * @throws Exception + */ + @Test(groups = { "Functional" }) + public void testPrintJalviewFormat_withFilters() throws Exception + { + File f = new File("examples/uniref50.fa"); + AlignmentI al = readAlignmentFile(f); + AlignFrame af = new AlignFrame(al, 500, 500); + SequenceFeature sf1 = new SequenceFeature("METAL", "Cath", 39, 39, 1.2f, + "grp1"); + sf1.setValue("clin_sig", "Likely Pathogenic"); + sf1.setValue("AF", "24"); + al.getSequenceAt(0).addSequenceFeature(sf1); + SequenceFeature sf2 = new SequenceFeature("METAL", "Cath", 41, 41, 0.6f, + "grp2"); + sf2.setValue("clin_sig", "Benign"); + sf2.setValue("AF", "46"); + al.getSequenceAt(0).addSequenceFeature(sf2); + + FeaturesFile featuresFile = new FeaturesFile(); + FeatureRenderer fr = af.alignPanel.getFeatureRenderer(); + fr.findAllFeatures(true); + + fr.setVisible("METAL"); + fr.setColour("METAL", new FeatureColour(Color.PINK)); + String exported = featuresFile.printJalviewFormat( + al.getSequencesArray(), + fr, false); + String expected = "METAL\tffafaf\n\nSTARTGROUP\tgrp1\n" + + "Cath\tFER_CAPAA\t-1\t39\t39\tMETAL\t1.2\n" + + "ENDGROUP\tgrp1\n\nSTARTGROUP\tgrp2\n" + + "Cath\tFER_CAPAA\t-1\t41\t41\tMETAL\t0.6\n" + + "ENDGROUP\tgrp2\n"; + assertEquals(expected, exported); + + /* + * now threshold to Score > 1.1 - should exclude sf2 + * (and there should be no empty STARTGROUP/ENDGROUP output) + */ + FeatureColourI fc = new FeatureColour(Color.white, Color.BLACK, + Color.white, 0f, 2f); + fc.setAboveThreshold(true); + fc.setThreshold(1.1f); + fr.setColour("METAL", fc); + exported = featuresFile.printJalviewFormat(al.getSequencesArray(), fr, + false); + expected = "METAL\tscore|ffffff|000000|noValueMin|abso|0.0|2.0|above|1.1\n\n" + + "STARTGROUP\tgrp1\n" + + "Cath\tFER_CAPAA\t-1\t39\t39\tMETAL\t1.2\n" + + "ENDGROUP\tgrp1\n"; + assertEquals(expected, exported); + + /* + * remove threshold and check sf2 is exported + */ + fc.setAboveThreshold(false); + exported = featuresFile.printJalviewFormat(al.getSequencesArray(), fr, + false); + expected = "METAL\tscore|ffffff|000000|noValueMin|abso|0.0|2.0|none\n\n" + + "STARTGROUP\tgrp1\n" + + "Cath\tFER_CAPAA\t-1\t39\t39\tMETAL\t1.2\n" + + "ENDGROUP\tgrp1\n\nSTARTGROUP\tgrp2\n" + + "Cath\tFER_CAPAA\t-1\t41\t41\tMETAL\t0.6\n" + + "ENDGROUP\tgrp2\n"; + assertEquals(expected, exported); + + /* + * filter on (clin_sig contains Benign) - should include sf2 and exclude sf1 + */ + FeatureMatcherSetI filter = new FeatureMatcherSet(); + filter.and(FeatureMatcher.byAttribute(Condition.Contains, "benign", + "clin_sig")); + fr.setFeatureFilter("METAL", filter); + exported = featuresFile.printJalviewFormat(al.getSequencesArray(), fr, + false); + expected = "FER_CAPAA\tCath\tMETAL\t41\t41\t0.6\t.\t.\n"; + expected = "METAL\tscore|ffffff|000000|noValueMin|abso|0.0|2.0|none\n\n" + + "STARTFILTERS\nMETAL\tclin_sig Contains benign\nENDFILTERS\n\n" + + "STARTGROUP\tgrp2\n" + + "Cath\tFER_CAPAA\t-1\t41\t41\tMETAL\t0.6\n" + + "ENDGROUP\tgrp2\n"; + assertEquals(expected, exported); + } } -- 1.7.10.2