From: Ben Soares Date: Wed, 12 Apr 2023 10:17:53 +0000 (+0100) Subject: JAL-629 allow comments in argfiles '#' X-Git-Tag: Release_2_11_4_0~402 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=71ce94a16981fdb88eaecd2078c6bd3f1cf8d0b8;p=jalview.git JAL-629 allow comments in argfiles '#' --- diff --git a/src/jalview/bin/argparser/ArgParser.java b/src/jalview/bin/argparser/ArgParser.java index f3306d6..5f0cad6 100644 --- a/src/jalview/bin/argparser/ArgParser.java +++ b/src/jalview/bin/argparser/ArgParser.java @@ -100,6 +100,8 @@ public class ArgParser protected List argList; + private static final char ARGFILECOMMENT = '#'; + static { argMap = new HashMap<>(); @@ -282,7 +284,7 @@ public class ArgParser if (a.hasOption(Opt.GLOB)) { // strip off and save the SubVals to be added individually later - globSubVals = ArgParser.getSubVals(val); + globSubVals = new SubVals(val); // make substitutions before looking for files String fileGlob = makeSubstitutions(globSubVals.getContent(), linkedId); @@ -414,7 +416,7 @@ public class ArgParser } // check for unique id - SubVals idsv = ArgParser.getSubVals(val); + SubVals idsv = new SubVals(val); String id = idsv.get(ArgValues.ID); if (id != null && avm.hasId(a, id)) { @@ -635,11 +637,6 @@ public class ArgParser return sb.toString(); } - public static SubVals getSubVals(String item) - { - return new SubVals(item); - } - public static ArgParser parseArgFiles(List argFilenameGlobs, boolean initsubstitutions) { @@ -672,7 +669,7 @@ public class ArgParser .append(EQUALS).append(argFile.getCanonicalPath()) .toString(); argsList.add(setargfile); - argsList.addAll(Files.readAllLines(Paths.get(argFile.getPath()))); + argsList.addAll(readArgFile(argFile)); argsList.add(Arg.UNSETARGFILE.argString()); } catch (IOException e) { @@ -686,4 +683,28 @@ public class ArgParser return new ArgParser(argsList, initsubstitutions, true); } + protected static List readArgFile(File argFile) + { + List args = new ArrayList<>(); + if (argFile != null && argFile.exists()) + { + try + { + for (String line : Files.readAllLines(Paths.get(argFile.getPath()))) + { + if (line != null && line.length() > 0 + && line.charAt(0) != ARGFILECOMMENT) + args.add(line); + } + } catch (IOException e) + { + String message = Arg.ARGFILE.argString() + "=\"" + argFile.getPath() + + "\": File could not be read."; + Console.debug(message, e); + Jalview.exit(message, 3); + } + } + return args; + } + } \ No newline at end of file diff --git a/src/jalview/ws/dbsources/EBIAlfaFold.java b/src/jalview/ws/dbsources/EBIAlfaFold.java index 5165d04..19eaf78 100644 --- a/src/jalview/ws/dbsources/EBIAlfaFold.java +++ b/src/jalview/ws/dbsources/EBIAlfaFold.java @@ -498,16 +498,17 @@ public class EBIAlfaFold extends EbiFileRetrievedProxy return false; } - ContactMatrixI matrix = new PAEContactMatrix(sm.getSequence(), - (Map) pae_obj); + SequenceI seq = sm.getSequence(); + Console.debug("##### SEQUENCE FOUND=" + seq.getName()); + Map paeObject = (Map) pae_obj; - AlignmentAnnotation cmannot = sm.getSequence().addContactList(matrix); + ContactMatrixI matrix = new PAEContactMatrix(seq, paeObject); + AlignmentAnnotation cmannot = seq.addContactList(matrix); if (label != null) { - Console.debug("Setting annotation label to '" + label + "'"); cmannot.label = label; } - sm.getSequence().addAlignmentAnnotation(cmannot); + // seq.addAlignmentAnnotation(cmannot); return true; }