@Test public void testRichIni_valuesWithSpaces() throws Exception { String path = getClass().getResource("workflow_fromPDE_1444.ini").getPath(); Map<String, Map<String, String>> hm = new HashMap<>(); MapTools.ini2RichMap(path, hm); Assert.assertTrue("ini2RichMap with spaced values failed", hm.size() == 5); Assert.assertTrue( "white spaced value for ini2RichMap failed", hm.get("annotate_params").size() == 2 && hm.get("annotate_params") .get("default_value") .equals("--dbsnp ${workflow_bundle_dir}/Workflow_Bundle_${workflow-directory-name}/${version}/data/resources/dbSNP135_chr.vcf -resource:snp ${workflow_bundle_dir}/Workflow_Bundle_${workflow-directory-name}/${version}/data/resources/dbSNP135_chr.vcf -E snp.dbSNPBuildID -E snp.G5 -E snp.G5A -E snp.GMAF -comp:1KG_CEU ${workflow_bundle_dir}/Workflow_Bundle_${workflow-directory-name}/${version}/data/resources/1000g_20100804_chr.vcf -comp:HapMap ${workflow_bundle_dir}/Workflow_Bundle_${workflow-directory-name}/${version}/data/resources/HapMap_r27_nr_hg19_chr.vcf -comp:Nmblhg19 ${workflow_bundle_dir}/Workflow_Bundle_${workflow-directory-name}/${version}/data/resources/nimblegen_hg19_2.1M_Human_Exome.gatk.vcf.gz -comp:AgilentICGChg19 ${workflow_bundle_dir}/Workflow_Bundle_${workflow-directory-name}/${version}/data/resources/agilent_icgc_sanger.exons.hg19.sorted.fixed.gatk.vcf.gz -comp:MOUSE0001 ${workflow_bundle_dir}/Workflow_Bundle_${workflow-directory-name}/${version}/data/resources/MOUSE0001.bam.realigned.recal.bam.snps.raw.filtered.vcf.gz -comp:MOUSE0002 ${workflow_bundle_dir}/Workflow_Bundle_${workflow-directory-name}/${version}/data/resources/MOUSE0002.bam.realigned.recal.bam.snps.raw.filtered.vcf.gz")); Assert.assertTrue("white spaced value defaults for ini2RichMap failed", hm.get("annotate_params").size() == 2 && hm.get("annotate_params").get("key").equals("annotate_params")); }
public static void ini2RichMap(String iniFile, Map<String, Map<String, String>> hm) { HashMap<String, String> detailsMap = null; try { BufferedReader br = new BufferedReader(new FileReader(new File(iniFile))); String line; while ((line = br.readLine()) != null) { if (line.startsWith("#") && line.matches("^#\\s*key=.*$")) { detailsMap = new HashMap<>(); line = line.replaceAll("#\\s*", ""); String[] kvs = line.split(":"); for (String pair : kvs) { String[] kv = pair.split("="); if (kv.length == 2) detailsMap.put(kv[0], kv[1]); else detailsMap.put(kv[0], ""); } } else if (isLineMatchesKeyValue(line)) { String[] kv = line.split("\\s*=\\s*"); if (detailsMap == null || !kv[0].equals(detailsMap.get("key"))) { detailsMap = new HashMap<>(); detailsMap.put("key", kv[0]); } if (kv.length == 1) { detailsMap.put("default_value", ""); } else { detailsMap.put("default_value", kv[1]); } hm.put(kv[0], detailsMap); } } } catch (Exception e) { throw rethrow(e); } }
MapTools { public static void ini2RichMap(String iniFile, Map<String, Map<String, String>> hm) { HashMap<String, String> detailsMap = null; try { BufferedReader br = new BufferedReader(new FileReader(new File(iniFile))); String line; while ((line = br.readLine()) != null) { if (line.startsWith("#") && line.matches("^#\\s*key=.*$")) { detailsMap = new HashMap<>(); line = line.replaceAll("#\\s*", ""); String[] kvs = line.split(":"); for (String pair : kvs) { String[] kv = pair.split("="); if (kv.length == 2) detailsMap.put(kv[0], kv[1]); else detailsMap.put(kv[0], ""); } } else if (isLineMatchesKeyValue(line)) { String[] kv = line.split("\\s*=\\s*"); if (detailsMap == null || !kv[0].equals(detailsMap.get("key"))) { detailsMap = new HashMap<>(); detailsMap.put("key", kv[0]); } if (kv.length == 1) { detailsMap.put("default_value", ""); } else { detailsMap.put("default_value", kv[1]); } hm.put(kv[0], detailsMap); } } } catch (Exception e) { throw rethrow(e); } } }
MapTools { public static void ini2RichMap(String iniFile, Map<String, Map<String, String>> hm) { HashMap<String, String> detailsMap = null; try { BufferedReader br = new BufferedReader(new FileReader(new File(iniFile))); String line; while ((line = br.readLine()) != null) { if (line.startsWith("#") && line.matches("^#\\s*key=.*$")) { detailsMap = new HashMap<>(); line = line.replaceAll("#\\s*", ""); String[] kvs = line.split(":"); for (String pair : kvs) { String[] kv = pair.split("="); if (kv.length == 2) detailsMap.put(kv[0], kv[1]); else detailsMap.put(kv[0], ""); } } else if (isLineMatchesKeyValue(line)) { String[] kv = line.split("\\s*=\\s*"); if (detailsMap == null || !kv[0].equals(detailsMap.get("key"))) { detailsMap = new HashMap<>(); detailsMap.put("key", kv[0]); } if (kv.length == 1) { detailsMap.put("default_value", ""); } else { detailsMap.put("default_value", kv[1]); } hm.put(kv[0], detailsMap); } } } catch (Exception e) { throw rethrow(e); } }  }
MapTools { public static void ini2RichMap(String iniFile, Map<String, Map<String, String>> hm) { HashMap<String, String> detailsMap = null; try { BufferedReader br = new BufferedReader(new FileReader(new File(iniFile))); String line; while ((line = br.readLine()) != null) { if (line.startsWith("#") && line.matches("^#\\s*key=.*$")) { detailsMap = new HashMap<>(); line = line.replaceAll("#\\s*", ""); String[] kvs = line.split(":"); for (String pair : kvs) { String[] kv = pair.split("="); if (kv.length == 2) detailsMap.put(kv[0], kv[1]); else detailsMap.put(kv[0], ""); } } else if (isLineMatchesKeyValue(line)) { String[] kv = line.split("\\s*=\\s*"); if (detailsMap == null || !kv[0].equals(detailsMap.get("key"))) { detailsMap = new HashMap<>(); detailsMap.put("key", kv[0]); } if (kv.length == 1) { detailsMap.put("default_value", ""); } else { detailsMap.put("default_value", kv[1]); } hm.put(kv[0], detailsMap); } } } catch (Exception e) { throw rethrow(e); } }  static void ini2Map(String iniFile, Map<String, String> hm); static void ini2RichMap(String iniFile, Map<String, Map<String, String>> hm); static void ini2Map(String iniFile, Map<String, String> hm, boolean keyToUpper); static void ini2Map(InputStream iniFile, Map<String, String> hm, boolean keyToUpper); static void cli2Map(String[] args, Map<String, String> hm); static Map mapString2Int(Map map); static void provideBundleVersion(Map<String, String> m, String bundleVersion); static void provideBundleDir(Map<String, String> m, String bundleDir); static Map<String, String> providedMap(String bundleDir, String bundleSeqwareVersion); static String generatedValue(String key); static Map<String, String> expandVariables(Map<String, String> raw); static Map<String, String> expandVariables(Map<String, String> raw, Map<String, String> provided); static Map<String, String> expandVariables(Map<String, String> raw, Map<String, String> provided, boolean allowMissingVars); static Map<String, String> iniString2Map(String iniString); static SortedSet<WorkflowRunParam> createWorkflowRunParameters(HashMap<String, String> map); }
MapTools { public static void ini2RichMap(String iniFile, Map<String, Map<String, String>> hm) { HashMap<String, String> detailsMap = null; try { BufferedReader br = new BufferedReader(new FileReader(new File(iniFile))); String line; while ((line = br.readLine()) != null) { if (line.startsWith("#") && line.matches("^#\\s*key=.*$")) { detailsMap = new HashMap<>(); line = line.replaceAll("#\\s*", ""); String[] kvs = line.split(":"); for (String pair : kvs) { String[] kv = pair.split("="); if (kv.length == 2) detailsMap.put(kv[0], kv[1]); else detailsMap.put(kv[0], ""); } } else if (isLineMatchesKeyValue(line)) { String[] kv = line.split("\\s*=\\s*"); if (detailsMap == null || !kv[0].equals(detailsMap.get("key"))) { detailsMap = new HashMap<>(); detailsMap.put("key", kv[0]); } if (kv.length == 1) { detailsMap.put("default_value", ""); } else { detailsMap.put("default_value", kv[1]); } hm.put(kv[0], detailsMap); } } } catch (Exception e) { throw rethrow(e); } }  static void ini2Map(String iniFile, Map<String, String> hm); static void ini2RichMap(String iniFile, Map<String, Map<String, String>> hm); static void ini2Map(String iniFile, Map<String, String> hm, boolean keyToUpper); static void ini2Map(InputStream iniFile, Map<String, String> hm, boolean keyToUpper); static void cli2Map(String[] args, Map<String, String> hm); static Map mapString2Int(Map map); static void provideBundleVersion(Map<String, String> m, String bundleVersion); static void provideBundleDir(Map<String, String> m, String bundleDir); static Map<String, String> providedMap(String bundleDir, String bundleSeqwareVersion); static String generatedValue(String key); static Map<String, String> expandVariables(Map<String, String> raw); static Map<String, String> expandVariables(Map<String, String> raw, Map<String, String> provided); static Map<String, String> expandVariables(Map<String, String> raw, Map<String, String> provided, boolean allowMissingVars); static Map<String, String> iniString2Map(String iniString); static SortedSet<WorkflowRunParam> createWorkflowRunParameters(HashMap<String, String> map); static final String VAR_RANDOM; static final String VAR_DATE; static final String VAR_DATETIME; static final String VAR_TIMESTAMP; static final String VAR_UUID; static final String VAR_BUNDLE_DIR; static final String LEGACY_VAR_RANDOM; static final String LEGACY_VAR_DATE; static final String LEGACY_VAR_BUNDLE_DIR; static final String VAR_WORKFLOW_VERSION; }