From: Ben Soares Date: Sun, 23 Apr 2023 11:35:42 +0000 (+0100) Subject: JAL-629 Change --open to --append and --opennew to --open. Make --open(new) part... X-Git-Tag: Release_2_11_4_0~388 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=2bb9cad4fa36d64cebbe09bc63732e8dbb4dcb32;p=jalview.git JAL-629 Change --open to --append and --opennew to --open. Make --open(new) part of the same default linkedId scheme. Add and adjust tests. --- diff --git a/src/jalview/bin/Commands.java b/src/jalview/bin/Commands.java index fc2ee1a..dafc342 100644 --- a/src/jalview/bin/Commands.java +++ b/src/jalview/bin/Commands.java @@ -2,16 +2,15 @@ package jalview.bin; import java.io.File; import java.io.IOException; -import java.util.AbstractMap; import java.util.ArrayList; import java.util.Arrays; +import java.util.Collections; import java.util.EnumSet; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Locale; import java.util.Map; -import java.util.Map.Entry; import jalview.analysis.AlignmentUtils; import jalview.bin.argparser.Arg; @@ -150,7 +149,7 @@ public class Commands * m.get(Arg.OPEN).getValue(); String data = null; FileFormatI format = null; * DataSourceType protocol = null; */ - if (avm.containsArg(Arg.OPEN) || avm.containsArg(Arg.OPENNEW)) + if (avm.containsArg(Arg.APPEND) || avm.containsArg(Arg.OPEN)) { commandArgsProvided = true; long progress = -1; @@ -158,21 +157,16 @@ public class Commands boolean first = true; boolean progressBarSet = false; AlignFrame af; - // Combine the OPEN and OPENNEW files into one list, along with whether it - // was OPEN or OPENNEW - List> openAvList = new ArrayList<>(); - avm.getArgValueList(Arg.OPEN).stream() - .forEachOrdered(av -> openAvList.add( - new AbstractMap.SimpleEntry(Arg.OPEN, - av))); - avm.getArgValueList(Arg.OPENNEW).stream() - .forEachOrdered(av -> openAvList - .add(new AbstractMap.SimpleEntry( - Arg.OPENNEW, av))); - for (Entry aav : openAvList) + // Combine the APPEND and OPEN files into one list, along with whether it + // was APPEND or OPEN + List openAvList = new ArrayList<>(); + openAvList.addAll(avm.getArgValueList(Arg.OPEN)); + openAvList.addAll(avm.getArgValueList(Arg.APPEND)); + // sort avlist based on av.getArgIndex() + Collections.sort(openAvList); + for (ArgValue av : openAvList) { - Arg a = aav.getKey(); - ArgValue av = aav.getValue(); + Arg a = av.getArg(); String openFile = av.getValue(); if (openFile == null) continue; @@ -221,7 +215,7 @@ public class Commands af = afMap.get(id); if (af == null || "true".equals(av.getSubVal("new")) - || a == Arg.OPENNEW || format == FileFormat.Jalview) + || a == Arg.OPEN || format == FileFormat.Jalview) { /* * this approach isn't working yet // get default annotations before opening @@ -340,7 +334,7 @@ public class Commands af.getCurrentView().addFile(new File(openFile), format, false); } - Console.debug("Command " + Arg.OPEN + " executed successfully!"); + Console.debug("Command " + Arg.APPEND + " executed successfully!"); } if (first) // first=true means nothing opened diff --git a/src/jalview/bin/argparser/Arg.java b/src/jalview/bin/argparser/Arg.java index f712010..07d8c28 100644 --- a/src/jalview/bin/argparser/Arg.java +++ b/src/jalview/bin/argparser/Arg.java @@ -11,7 +11,7 @@ public enum Arg { HELP("h"), CALCULATION, MENUBAR, STATUS, SHOWOVERVIEW, ANNOTATIONS, COLOUR, FEATURES, GROOVY, GROUPS, HEADLESS, JABAWS, DISPLAY, GUI, NEWS, - SORTBYTREE, USAGESTATS, OPEN, OPENNEW, PROPS, QUESTIONNAIRE, SETPROP, + SORTBYTREE, USAGESTATS, APPEND, OPEN, PROPS, QUESTIONNAIRE, SETPROP, TREE, VDOC, VSESS, OUTPUT, OUTPUTTYPE, SSANNOTATIONS, NOTEMPFAC, TEMPFAC, TITLE, PAEMATRIX, WRAP, NOSTRUCTURE, STRUCTURE, STRUCTUREVIEWER, IMAGE, QUIT, CLOSE, DEBUG("d"), QUIET("q"), ARGFILE, INCREMENT, NPP("n++"), @@ -47,9 +47,9 @@ public enum Arg // expects a string value SORTBYTREE.setOptions(true, Opt.BOOLEAN); USAGESTATS.setOptions(true, Opt.BOOLEAN); - OPEN.setOptions(Opt.STRING, Opt.LINKED, Opt.MULTI, Opt.GLOB, + APPEND.setOptions(Opt.STRING, Opt.LINKED, Opt.MULTI, Opt.GLOB, Opt.ALLOWSUBSTITUTIONS); - OPENNEW.setOptions(Opt.STRING, Opt.LINKED, Opt.MULTI, Opt.GLOB, + OPEN.setOptions(Opt.STRING, Opt.LINKED, Opt.MULTI, Opt.GLOB, Opt.ALLOWSUBSTITUTIONS); PROPS.setOptions(Opt.STRING, Opt.BOOTSTRAP); QUESTIONNAIRE.setOptions(Opt.BOOLEAN, Opt.BOOTSTRAP); diff --git a/src/jalview/bin/argparser/ArgParser.java b/src/jalview/bin/argparser/ArgParser.java index 70ed5d1..b31beab 100644 --- a/src/jalview/bin/argparser/ArgParser.java +++ b/src/jalview/bin/argparser/ArgParser.java @@ -55,11 +55,12 @@ public class ArgParser // the substitution string used to use the defaultLinkedIdCounter private static final String DEFAULTLINKEDIDCOUNTER = "{}"; - // the counter added to the default linked id prefix - private int opennewLinkedIdCounter = 0; + // the counter added to the default linked id prefix. NOW using + // linkedIdAutoCounter + // private int openLinkedIdCounter = 0; - // the linked id prefix used for --opennew files - protected static final String OPENNEWLINKEDIDPREFIX = "OPENNEW:"; + // the linked id prefix used for --open files. NOW the same as DEFAULT + protected static final String OPENLINKEDIDPREFIX = DEFAULTLINKEDIDPREFIX; // the counter used for {n} substitutions private int linkedIdAutoCounter = 0; @@ -71,12 +72,12 @@ public class ArgParser // the linked id substitution string used to use the idCounter private static final String LINKEDIDAUTOCOUNTER = "{n}"; - // the linked id substitution string used to use the base filename of --open - // or --opennew + // the linked id substitution string used to use the base filename of --append + // or --open private static final String LINKEDIDBASENAME = "{basename}"; - // the linked id substitution string used to use the dir path of --open - // or --opennew + // the linked id substitution string used to use the dir path of --append + // or --open private static final String LINKEDIDDIRNAME = "{dirname}"; // the current argfile @@ -141,7 +142,7 @@ public class ArgParser // Make a mutable new ArrayList so that shell globbing parser works. // (When shell file globbing is used, there are a sequence of non-Arg // arguments (which are the expanded globbed filenames) that need to be - // consumed by the --open/--argfile/etc Arg which is most easily done by + // consumed by the --append/--argfile/etc Arg which is most easily done by // removing these filenames from the list one at a time. This can't be done // with an ArrayList made with only Arrays.asList(String[] args). ) this(new ArrayList<>(Arrays.asList(args)), initsubstitutions); @@ -197,7 +198,7 @@ public class ArgParser if (openEachInitialFilenames && !arg.startsWith(DOUBLEDASH) && !arg.startsWith("-") && new File(arg).exists()) { - arg = Arg.OPENNEW.argString(); + arg = Arg.OPEN.argString(); } else { @@ -360,13 +361,14 @@ public class ArgParser { if (linkedId == null) { - if (a == Arg.OPENNEW) + if (a == Arg.OPEN) { - // use the next default prefixed OPENNEWLINKEDID - linkedId = new StringBuilder(OPENNEWLINKEDIDPREFIX) - .append(Integer.toString(opennewLinkedIdCounter)) + // use the next default prefixed OPENLINKEDID + // NOW using the linkedIdAutoCounter + defaultLinkedIdCounter++; + linkedId = new StringBuilder(OPENLINKEDIDPREFIX) + .append(Integer.toString(defaultLinkedIdCounter)) .toString(); - opennewLinkedIdCounter++; } else { diff --git a/src/jalview/bin/argparser/ArgValue.java b/src/jalview/bin/argparser/ArgValue.java index c9e86b8..36901df 100644 --- a/src/jalview/bin/argparser/ArgValue.java +++ b/src/jalview/bin/argparser/ArgValue.java @@ -3,8 +3,10 @@ package jalview.bin.argparser; /** * A helper class to keep an index of argument position with argument values */ -public class ArgValue +public class ArgValue implements Comparable { + private Arg arg; + private int argIndex; private String value; @@ -13,20 +15,27 @@ public class ArgValue private SubVals subVals; - protected ArgValue(SubVals sv, String content, int argIndex) + protected ArgValue(Arg a, SubVals sv, String content, int argIndex) { + this.arg = a; this.value = content; this.argIndex = argIndex; this.subVals = sv == null ? new SubVals("") : sv; } - protected ArgValue(String value, int argIndex) + protected ArgValue(Arg a, String value, int argIndex) { + this.arg = a; this.argIndex = argIndex; this.subVals = new SubVals(value); this.value = getSubVals().getContent(); } + public Arg getArg() + { + return arg; + } + public String getValue() { return value; @@ -63,4 +72,10 @@ public class ArgValue { this.subVals.put(key, val); } + + @Override + public int compareTo(ArgValue o) + { + return this.getArgIndex() - o.getArgIndex(); + } } \ No newline at end of file diff --git a/src/jalview/bin/argparser/ArgValues.java b/src/jalview/bin/argparser/ArgValues.java index c166da0..4a60efd 100644 --- a/src/jalview/bin/argparser/ArgValues.java +++ b/src/jalview/bin/argparser/ArgValues.java @@ -105,12 +105,12 @@ public class ArgValues protected void addValue(String val, int argIndex) { - addArgValue(new ArgValue(val, argIndex)); + addArgValue(new ArgValue(arg(), val, argIndex)); } protected void addValue(SubVals sv, String content, int argIndex) { - addArgValue(new ArgValue(sv, content, argIndex)); + addArgValue(new ArgValue(arg(), sv, content, argIndex)); } protected void addArgValue(ArgValue av) diff --git a/src/jalview/bin/argparser/ArgValuesMap.java b/src/jalview/bin/argparser/ArgValuesMap.java index 176dc7c..63e5302 100644 --- a/src/jalview/bin/argparser/ArgValuesMap.java +++ b/src/jalview/bin/argparser/ArgValuesMap.java @@ -193,7 +193,7 @@ public class ArgValuesMap } /* - * This method returns the basename of the first --open or --opennew value. + * This method returns the basename of the first --append or --open value. * Used primarily for substitutions in output filenames. */ public String getBasename() @@ -202,7 +202,7 @@ public class ArgValuesMap } /* - * This method returns the dirname of the first --open or --opennew value. + * This method returns the dirname of the first --append or --open value. * Used primarily for substitutions in output filenames. */ public String getDirname() @@ -213,12 +213,12 @@ public class ArgValuesMap public String getDirOrBasename(boolean dirname) { String filename = null; + String appendVal = getValue(Arg.APPEND); String openVal = getValue(Arg.OPEN); - String opennewVal = getValue(Arg.OPENNEW); - if (openVal != null) + if (appendVal != null) + filename = appendVal; + if (filename == null && openVal != null) filename = openVal; - if (filename == null && opennewVal != null) - filename = opennewVal; if (filename == null) return null; diff --git a/src/jalview/util/FileUtils.java b/src/jalview/util/FileUtils.java index 9b56c64..4d35cd2 100644 --- a/src/jalview/util/FileUtils.java +++ b/src/jalview/util/FileUtils.java @@ -130,7 +130,7 @@ public class FileUtils } /* - * This method returns the basename of the first --open or --opennew value. + * This method returns the basename of the first --append or --open value. * Used primarily for substitutions in output filenames. */ public static String getBasename(File file) @@ -153,7 +153,7 @@ public class FileUtils } /* - * This method returns the dirname of the first --open or --opennew value. + * This method returns the dirname of the first --append or --open value. * Used primarily for substitutions in output filenames. */ public static String getDirname(File file) diff --git a/test/jalview/bin/CommandsTest.java b/test/jalview/bin/CommandsTest.java index fda047c..2d3724b 100644 --- a/test/jalview/bin/CommandsTest.java +++ b/test/jalview/bin/CommandsTest.java @@ -83,7 +83,8 @@ public class CommandsTest Assert.assertEquals(cmds.argsWereParsed(), cmdArgs, "Overall command parse and operation is false"); - Assert.assertEquals(Desktop.getAlignFrames().length, numFrames); + Assert.assertEquals(Desktop.getAlignFrames().length, numFrames, + "Wrong number of AlignFrames"); if (sequences != null) { @@ -147,11 +148,11 @@ public class CommandsTest { testfiles + "/dir1/test1.png", testfiles + "/dir2/test1.png" } }, { "--argfile=" + testfiles + "/dir*/argfile.txt", new String[] { testfiles + "/dir1/test1.png", testfiles + "/dir2/test1.png" } }, - { "--initsubstitutions --open examples/uniref50.fa --image " + { "--initsubstitutions --append examples/uniref50.fa --image " + testfiles + "/{basename}.png", new String[] { testfiles + "/uniref50.png" } }, - { "--open examples/uniref50.fa --image " + testfiles + { "--append examples/uniref50.fa --image " + testfiles + "/{basename}.png", new String[] { testfiles + "/{basename}.png" } } }; @@ -166,24 +167,28 @@ public class CommandsTest String[] t2 = new String[] { "TEST2" }; String[] t3 = new String[] { "TEST3" }; return new Object[][] { - { "--open=examples/uniref50.fa", true, 1, someUniref50Seqs }, - { "--open examples/uniref50.fa", true, 1, someUniref50Seqs }, - { "--open=examples/uniref50*.fa", true, 1, someUniref50Seqs }, + /* + */ + { "--append=examples/uniref50.fa", true, 1, someUniref50Seqs }, + { "--append examples/uniref50.fa", true, 1, someUniref50Seqs }, + { "--append=examples/uniref50*.fa", true, 1, someUniref50Seqs }, // NOTE we cannot use shell expansion in tests, so list all files! - { "--open examples/uniref50.fa examples/uniref50_mz.fa", true, 1, + { "--append examples/uniref50.fa examples/uniref50_mz.fa", true, 1, someUniref50Seqs }, - { "--open=[new]examples/uniref50*.fa", true, 2, someUniref50Seqs }, - { "--opennew=examples/uniref50*.fa", true, 2, someUniref50Seqs }, + { "--append=[new]examples/uniref50*.fa", true, 2, + someUniref50Seqs }, + { "--open=examples/uniref50*.fa", true, 2, someUniref50Seqs }, { "examples/uniref50.fa", true, 1, someUniref50Seqs }, { "examples/uniref50.fa " + testfiles + "/test1.fa", true, 2, ArrayUtils.concatArrays(someUniref50Seqs, t1) }, { "examples/uniref50.fa " + testfiles + "/test1.fa", true, 2, t1 }, { "--argfile=" + testfiles + "/argfile0.txt", true, 1, ArrayUtils.concatArrays(t1, t3) }, - { "--argfile=" + testfiles + "/argfile*.txt", true, 4, + { "--argfile=" + testfiles + "/argfile*.txt", true, 5, ArrayUtils.concatArrays(t1, t2, t3) }, { "--argfile=" + testfiles + "/argfile.autocounter", true, 3, ArrayUtils.concatArrays(t1, t2) } }; + } public static boolean lookForSequenceName(String sequenceName) diff --git a/test/jalview/bin/CommandsTest2.java b/test/jalview/bin/CommandsTest2.java index 71452e2..ca0d3e4 100644 --- a/test/jalview/bin/CommandsTest2.java +++ b/test/jalview/bin/CommandsTest2.java @@ -125,40 +125,44 @@ public class CommandsTest2 int viewerNum, String propsFile */ - return new Object[][] { { "--nonews --nosplash --debug " - + "--open=examples/uniref50.fa " + "--colour=gecos:flower " - + "--structure=[seqid=FER1_SPIOL]examples/AlphaFold/AF-P00221-F1-model_v4.cif " - + "--paematrix=examples/AlphaFold/AF-P00221-F1-predicted_aligned_error_v4.json " - + "--props=test/jalview/bin/commandsTest2.jvprops1 ", - 15, 7, 1 }, - { "--nonews --nosplash --debug " + "--open=examples/uniref50.fa " + return new Object[][] { + // + /* + */ + { "--nonews --nosplash --debug " + "--append=examples/uniref50.fa " + + "--colour=gecos:flower " + + "--structure=[seqid=FER1_SPIOL]examples/AlphaFold/AF-P00221-F1-model_v4.cif " + + "--paematrix=examples/AlphaFold/AF-P00221-F1-predicted_aligned_error_v4.json " + + "--props=test/jalview/bin/commandsTest2.jvprops1 ", + 15, 7, 1 }, + { "--nonews --nosplash --debug " + "--append=examples/uniref50.fa " + "--colour=gecos:flower " + "--structure=[seqid=FER1_SPIOL]examples/AlphaFold/AF-P00221-F1-model_v4.cif " + "--paematrix=examples/AlphaFold/AF-P00221-F1-predicted_aligned_error_v4.json " + "--props=test/jalview/bin/commandsTest2.jvprops2 ", 15, 4, 1 }, - { "--nonews --nosplash --debug " + "--open=examples/uniref50.fa " + { "--nonews --nosplash --debug " + "--append=examples/uniref50.fa " + "--colour=gecos:flower " + "--structure=[seqid=FER1_SPIOL]examples/AlphaFold/AF-P00221-F1-model_v4.cif " + "--paematrix=examples/AlphaFold/AF-P00221-F1-predicted_aligned_error_v4.json " + "--nossannotations " + "--props=test/jalview/bin/commandsTest2.jvprops1 ", 15, 4, 1 }, - { "--nonews --nosplash --debug " + "--open=examples/uniref50.fa " + { "--nonews --nosplash --debug " + "--append=examples/uniref50.fa " + "--colour=gecos:flower " + "--structure=[seqid=FER1_SPIOL]examples/AlphaFold/AF-P00221-F1-model_v4.cif " + "--paematrix=examples/AlphaFold/AF-P00221-F1-predicted_aligned_error_v4.json " + "--noannotations " + "--props=test/jalview/bin/commandsTest2.jvprops1 ", 15, 3, 1 }, - { "--nonews --nosplash --debug " + "--open=examples/uniref50.fa " + { "--nonews --nosplash --debug " + "--append=examples/uniref50.fa " + "--colour=gecos:flower " + "--structure=[seqid=FER1_SPIOL]examples/AlphaFold/AF-P00221-F1-model_v4.cif " + "--paematrix=examples/AlphaFold/AF-P00221-F1-predicted_aligned_error_v4.json " + "--noannotations " + "--nossannotations " + "--props=test/jalview/bin/commandsTest2.jvprops1 ", 15, 0, 1 }, - { "--nonews --nosplash --debug " + "--open=examples/uniref50.fa " + { "--nonews --nosplash --debug " + "--append=examples/uniref50.fa " + "--colour=gecos:flower " + "--structure=[seqid=FER1_SPIOL]examples/AlphaFold/AF-P00221-F1-model_v4.cif " + "--paematrix=examples/AlphaFold/AF-P00221-F1-predicted_aligned_error_v4.json " diff --git a/test/jalview/bin/argparser/ArgParserTest.java b/test/jalview/bin/argparser/ArgParserTest.java index 6d7f88f..efd6cb8 100644 --- a/test/jalview/bin/argparser/ArgParserTest.java +++ b/test/jalview/bin/argparser/ArgParserTest.java @@ -63,8 +63,8 @@ public class ArgParserTest public void parseAutoIndexAndSubstitutionsTest(String commandLineArgs, String linkedId, Arg a, String filename) { - // { "--open=filename0 --increment --open=filename1", "JALVIEW:1", Arg.OPEN, - // "filename1" }, + // { "--append=filename0 --increment --append=filename1", "JALVIEW:1", + // Arg.OPEN, "filename1" }, String[] args = commandLineArgs.split("\\s+"); ArgParser argparser = new ArgParser(args); ArgValuesMap avm = argparser.linkedArgs(linkedId); @@ -118,7 +118,7 @@ public class ArgParserTest BootstrapArgs b = BootstrapArgs.getBootstrapArgs(args); Assert.assertTrue(b.contains(a)); - Assert.assertFalse(b.contains(Arg.OPEN)); + Assert.assertFalse(b.contains(Arg.APPEND)); if (a == Arg.PROPS) { Properties bP = Cache.bootstrapProperties(b.get(Arg.PROPS)); @@ -141,11 +141,11 @@ public class ArgParserTest public Object[][] argLines() { return new Object[][] { { - "--open=test/jalview/bin/argparser/testfiles/test1.fa --props=test/jalview/bin/argparser/testfiles/testProps.jvprops", + "--append=test/jalview/bin/argparser/testfiles/test1.fa --props=test/jalview/bin/argparser/testfiles/testProps.jvprops", Arg.PROPS, "true" }, - { "--debug --open=test/jalview/bin/argparser/testfiles/test1.fa", + { "--debug --append=test/jalview/bin/argparser/testfiles/test1.fa", Arg.DEBUG, null }, - { "--open=test/jalview/bin/argparser/testfiles/test1.fa --headless", + { "--append=test/jalview/bin/argparser/testfiles/test1.fa --headless", Arg.HEADLESS, null }, { "--argfile test/jalview/bin/argparser/testfiles/argfile0.txt", @@ -176,37 +176,65 @@ public class ArgParserTest public Object[][] argSubValsAndLinkedIds() { return new Object[][] { { - "--debug --open=[hi]test/jalview/bin/argparser/testfiles/test1.fa", - "JALVIEW:0", Arg.OPEN, "hi", "true", true }, - { "--open[linkedId1]=[new;hello=world;1]test/jalview/bin/argparser/testfiles/test1.fa --headless", - "linkedId1", Arg.OPEN, "new", "true", true }, - { "--open[linkedId2]=[new;hello=world;1]test/jalview/bin/argparser/testfiles/test1.fa --headless", - "linkedId2", Arg.OPEN, "hello", "world", true }, - { "--open[linkedId3]=[new;hello=world;1]test/jalview/bin/argparser/testfiles/test1.fa --headless", - "linkedId3", Arg.OPEN, "GETINDEX", "1", true }, - { "--open[linkedId4]=[new;hello=world;1]test/jalview/bin/argparser/testfiles/test1.fa --open[linkedId5]=[notnew;hello=world;1]test/jalview/bin/argparser/testfiles/test1.fa --headless", - "linkedId5", Arg.OPEN, "new", "true", false }, - { "--open[linkedId5]=[new;hello=worlddomination;1]test/jalview/bin/argparser/testfiles/test1.fa --open[linkedId2]=[new;hello=world;1]test/jalview/bin/argparser/testfiles/test1.fa --headless", - "linkedId5", Arg.OPEN, "hello", "world", false }, - { "--open[linkedId6]=[new;hello=world;0]test/jalview/bin/argparser/testfiles/test1.fa --open[linkedId7]=[new;hello=world;1]test/jalview/bin/argparser/testfiles/test1.fa --headless", - "linkedId7", Arg.OPEN, "GETINDEX", "0", false }, }; + "--debug --append=[hi]test/jalview/bin/argparser/testfiles/test1.fa", + "JALVIEW:0", Arg.APPEND, "hi", "true", true }, + { "--append[linkedId1]=[new;hello=world;1]test/jalview/bin/argparser/testfiles/test1.fa --headless", + "linkedId1", Arg.APPEND, "new", "true", true }, + { "--append[linkedId2]=[new;hello=world;1]test/jalview/bin/argparser/testfiles/test1.fa --headless", + "linkedId2", Arg.APPEND, "hello", "world", true }, + { "--append[linkedId3]=[new;hello=world;1]test/jalview/bin/argparser/testfiles/test1.fa --headless", + "linkedId3", Arg.APPEND, "GETINDEX", "1", true }, + { "--append[linkedId4]=[new;hello=world;1]test/jalview/bin/argparser/testfiles/test1.fa --append[linkedId5]=[notnew;hello=world;1]test/jalview/bin/argparser/testfiles/test1.fa --headless", + "linkedId5", Arg.APPEND, "new", "true", false }, + { "--append[linkedId5]=[new;hello=worlddomination;1]test/jalview/bin/argparser/testfiles/test1.fa --append[linkedId2]=[new;hello=world;1]test/jalview/bin/argparser/testfiles/test1.fa --headless", + "linkedId5", Arg.APPEND, "hello", "world", false }, + { "--append[linkedId6]=[new;hello=world;0]test/jalview/bin/argparser/testfiles/test1.fa --append[linkedId7]=[new;hello=world;1]test/jalview/bin/argparser/testfiles/test1.fa --headless", + "linkedId7", Arg.APPEND, "GETINDEX", "0", false }, }; } @DataProvider(name = "argAutoIndexAndSubstitutions") public Object[][] argAutoIndexAndSubstitutions() { - return new Object[][] { { "--open=filename0 --open=filename1", - "JALVIEW:0", Arg.OPEN, "filename0" }, - { "--open=filename0 --increment --open=filename1", "JALVIEW:1", - Arg.OPEN, "filename1" }, - { "--open=filename0 --increment --increment --open=filename2", - "JALVIEW:0", Arg.OPEN, "filename0" }, - { "--open=filename0 --increment --increment --open=filename2", - "JALVIEW:2", Arg.OPEN, "filename2" }, - { "--open[linkA-{n}]=filenameA0 --open[linkA-{++n}]=filenameA1", + return new Object[][] { + // + /* + */ + { "--append=filename0 --append=filename1", "JALVIEW:0", Arg.APPEND, + "filename0" }, + { "--append=filename0 --increment --append=filename1", "JALVIEW:1", + Arg.APPEND, "filename1" }, + { "--append=filename0 --increment --increment --append=filename2", + "JALVIEW:0", Arg.APPEND, "filename0" }, + { "--append=filename0 --increment --increment --append=filename2", + "JALVIEW:2", Arg.APPEND, "filename2" }, + { "--append[linkA-{n}]=filenameA0 --append[linkA-{++n}]=filenameA1", + "linkA-0", Arg.APPEND, "filenameA0" }, + { "--append[linkB-{n}]=filenameB0 --append[linkB-{++n}]=filenameB1", + "linkB-1", Arg.APPEND, "filenameB1" }, + { "--append[linkC-{n}]=filenameC0 --image[linkC-{n}]=outputC{n}.txt", + "linkC-0", Arg.IMAGE, "outputC{n}.txt" }, + { "--append[linkD-{n}]=filenameD0 --substitutions --image[linkD-{n}]=outputD{n}.txt", + "linkD-0", Arg.IMAGE, "outputD0.txt" }, + { "--append[linkE-{n}]=filenameE0 --substitutions --image[linkE-{n}]=output-E{n}.txt --nil[{++n}] --image[linkE-{n}]=outputE{n}.txt", + "linkE-0", Arg.IMAGE, "output-E0.txt" }, + { "--append[linkF-{n}]=filenameF0 --substitutions --image[linkF-{n}]=output-F{n}.txt --nil[{++n}] --image[linkF-{n}]=outputF{n}.txt", + "linkF-1", Arg.IMAGE, "outputF1.txt" }, + { "--append[linkG-{n}]=filenameG0 --substitutions --image[linkG-{n}]=output-G{n}.txt --nil[{++n}] --nosubstitutions --image[linkG-{n}]=outputG{n}.txt", + "linkG-1", Arg.IMAGE, "outputG{n}.txt" }, + { "--append[linkH-{n}]=filenameH0 --substitutions --image[linkH-{n}]=output-H{n}.txt --nil[{++n}] --nosubstitutions --image[linkH-{n}]=outputH{n}.txt", + "linkH-0", Arg.IMAGE, "output-H0.txt" }, + { "--open=filename0 --append=filename1", "JALVIEW:1", Arg.OPEN, + "filename0" }, + { "--open=filename0 --increment --append=filename1", "JALVIEW:2", + Arg.APPEND, "filename1" }, + { "--open=filename0 --increment --increment --append=filename2", + "JALVIEW:1", Arg.OPEN, "filename0" }, + { "--open=filename0 --increment --increment --append=filename2", + "JALVIEW:3", Arg.APPEND, "filename2" }, + { "--open[linkA-{n}]=filenameA0 --append[linkA-{++n}]=filenameA1", "linkA-0", Arg.OPEN, "filenameA0" }, - { "--open[linkB-{n}]=filenameB0 --open[linkB-{++n}]=filenameB1", - "linkB-1", Arg.OPEN, "filenameB1" }, + { "--open[linkB-{n}]=filenameB0 --append[linkB-{++n}]=filenameB1", + "linkB-1", Arg.APPEND, "filenameB1" }, { "--open[linkC-{n}]=filenameC0 --image[linkC-{n}]=outputC{n}.txt", "linkC-0", Arg.IMAGE, "outputC{n}.txt" }, { "--open[linkD-{n}]=filenameD0 --substitutions --image[linkD-{n}]=outputD{n}.txt", @@ -218,7 +246,10 @@ public class ArgParserTest { "--open[linkG-{n}]=filenameG0 --substitutions --image[linkG-{n}]=output-G{n}.txt --nil[{++n}] --nosubstitutions --image[linkG-{n}]=outputG{n}.txt", "linkG-1", Arg.IMAGE, "outputG{n}.txt" }, { "--open[linkH-{n}]=filenameH0 --substitutions --image[linkH-{n}]=output-H{n}.txt --nil[{++n}] --nosubstitutions --image[linkH-{n}]=outputH{n}.txt", - "linkH-0", Arg.IMAGE, "output-H0.txt" }, }; + "linkH-0", Arg.IMAGE, "output-H0.txt" }, + + // + }; } @DataProvider(name = "argFiles") diff --git a/test/jalview/bin/argparser/testfiles/argfile.autocounter b/test/jalview/bin/argparser/testfiles/argfile.autocounter index 7eaf95e..e35a99e 100644 --- a/test/jalview/bin/argparser/testfiles/argfile.autocounter +++ b/test/jalview/bin/argparser/testfiles/argfile.autocounter @@ -3,5 +3,5 @@ --open[{++n}]=test/jalview/bin/argparser/testfiles/test2.fa --colour[{n}]=zappo --open[{++n}]=test/jalview/bin/argparser/testfiles/test1.fa ---open[{n}]=test/jalview/bin/argparser/testfiles/test2.fa +--append[{n}]=test/jalview/bin/argparser/testfiles/test2.fa --colour[{n}]=taylor diff --git a/test/jalview/bin/argparser/testfiles/argfile0.txt b/test/jalview/bin/argparser/testfiles/argfile0.txt index 6e5185e..e8a8cdc 100644 --- a/test/jalview/bin/argparser/testfiles/argfile0.txt +++ b/test/jalview/bin/argparser/testfiles/argfile0.txt @@ -1,2 +1,2 @@ --open=test/jalview/bin/argparser/testfiles/test1.fa ---open=test/jalview/bin/argparser/testfiles/test3.fa +--append=test/jalview/bin/argparser/testfiles/test3.fa diff --git a/test/jalview/bin/argparser/testfiles/argfile1.txt b/test/jalview/bin/argparser/testfiles/argfile1.txt index bb33f21..e2d0fa4 100644 --- a/test/jalview/bin/argparser/testfiles/argfile1.txt +++ b/test/jalview/bin/argparser/testfiles/argfile1.txt @@ -1,4 +1,4 @@ --open[all]=test/jalview/bin/argparser/testfiles/test1.fa ---open[all]=test/jalview/bin/argparser/testfiles/test2.fa +--append[all]=test/jalview/bin/argparser/testfiles/test2.fa --open[1]=test/jalview/bin/argparser/testfiles/test1.fa --open[2]=test/jalview/bin/argparser/testfiles/test2.fa diff --git a/test/jalview/bin/argparser/testfiles/dir1/argfile.txt b/test/jalview/bin/argparser/testfiles/dir1/argfile.txt index cd6b31b..ee9580d 100644 --- a/test/jalview/bin/argparser/testfiles/dir1/argfile.txt +++ b/test/jalview/bin/argparser/testfiles/dir1/argfile.txt @@ -1,6 +1,6 @@ --substitutions --increment ---open={argfiledirname}/*.fa +--append={argfiledirname}/*.fa --colour=gecos:flower --image={argfiledirname}/{basename}.png --close diff --git a/test/jalview/bin/argparser/testfiles/dir2/argfile.txt b/test/jalview/bin/argparser/testfiles/dir2/argfile.txt index cd6b31b..ee9580d 100644 --- a/test/jalview/bin/argparser/testfiles/dir2/argfile.txt +++ b/test/jalview/bin/argparser/testfiles/dir2/argfile.txt @@ -1,6 +1,6 @@ --substitutions --increment ---open={argfiledirname}/*.fa +--append={argfiledirname}/*.fa --colour=gecos:flower --image={argfiledirname}/{basename}.png --close diff --git a/test/jalview/bin/argparser/testfiles/dir3/subdir/subdirfile.txt b/test/jalview/bin/argparser/testfiles/dir3/subdir/subdirfile.txt index cd6b31b..ee9580d 100644 --- a/test/jalview/bin/argparser/testfiles/dir3/subdir/subdirfile.txt +++ b/test/jalview/bin/argparser/testfiles/dir3/subdir/subdirfile.txt @@ -1,6 +1,6 @@ --substitutions --increment ---open={argfiledirname}/*.fa +--append={argfiledirname}/*.fa --colour=gecos:flower --image={argfiledirname}/{basename}.png --close diff --git a/test/jalview/bin/commandsTest2.argfile1 b/test/jalview/bin/commandsTest2.argfile1 index a9c602d..e46b746 100644 --- a/test/jalview/bin/commandsTest2.argfile1 +++ b/test/jalview/bin/commandsTest2.argfile1 @@ -2,7 +2,7 @@ --nonews --nosplash --substitutions ---open=examples/test_fab41.result/sample.a2m +--append=examples/test_fab41.result/sample.a2m --annotations --ssannotations --colour=gecos:flower diff --git a/test/jalview/bin/commandsTest2.argfile2 b/test/jalview/bin/commandsTest2.argfile2 index d057858..f8f1c65 100644 --- a/test/jalview/bin/commandsTest2.argfile2 +++ b/test/jalview/bin/commandsTest2.argfile2 @@ -2,7 +2,7 @@ --nonews --nosplash --substitutions ---open=examples/test_fab41.result/sample.a2m +--append=examples/test_fab41.result/sample.a2m --noannotations --nossannotations --colour=gecos:flower