From 71ce94a16981fdb88eaecd2078c6bd3f1cf8d0b8 Mon Sep 17 00:00:00 2001 From: Ben Soares Date: Wed, 12 Apr 2023 11:17:53 +0100 Subject: [PATCH] JAL-629 allow comments in argfiles '#' --- src/jalview/bin/argparser/ArgParser.java | 37 ++++++++++++++++++++++------- src/jalview/ws/dbsources/EBIAlfaFold.java | 11 +++++---- 2 files changed, 35 insertions(+), 13 deletions(-) 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; } -- 1.7.10.2