From 4cebf7fec01288a54baf5fca70f33d16d5590c9c Mon Sep 17 00:00:00 2001 From: JUEST4 Date: Tue, 10 Apr 2018 15:22:43 -0400 Subject: [PATCH 1/8] release 0.3.1 --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index b0ce3c3..ac76a23 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ 4.0.0 edu.pitt.dbmi causal-cmd - 0.3.1-SNAPSHOT + 0.3.1 jar UTF-8 @@ -120,7 +120,7 @@ edu.cmu tetrad-lib - 6.4.0-SNAPSHOT + 6.4.0 log4j From 11ad014103e3199077d4fccc589b3381bb7f79d8 Mon Sep 17 00:00:00 2001 From: JUEST4 Date: Mon, 21 May 2018 13:23:59 -0400 Subject: [PATCH 2/8] Fix to pcall that prevents knowledge from being incorporated --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index ac76a23..2d9c04d 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ 4.0.0 edu.pitt.dbmi causal-cmd - 0.3.1 + 0.3.2 jar UTF-8 @@ -120,7 +120,7 @@ edu.cmu tetrad-lib - 6.4.0 + 6.4.1 log4j From 9cbfe9ee2e7e526159c2788e0d2c063502280cef Mon Sep 17 00:00:00 2001 From: JUEST4 Date: Thu, 19 Jul 2018 13:23:56 -0400 Subject: [PATCH 3/8] using development lib. commenting out get algo description since not used. --- pom.xml | 4 ++-- .../pitt/dbmi/causal/cmd/tetrad/TetradAlgorithms.java | 11 ++++++----- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/pom.xml b/pom.xml index 2d9c04d..d2a12fe 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ 4.0.0 edu.pitt.dbmi causal-cmd - 0.3.2 + 0.4.0-SNAPSHOT jar UTF-8 @@ -120,7 +120,7 @@ edu.cmu tetrad-lib - 6.4.1 + 6.5.0-SNAPSHOT log4j diff --git a/src/main/java/edu/pitt/dbmi/causal/cmd/tetrad/TetradAlgorithms.java b/src/main/java/edu/pitt/dbmi/causal/cmd/tetrad/TetradAlgorithms.java index fce1fba..86892b2 100644 --- a/src/main/java/edu/pitt/dbmi/causal/cmd/tetrad/TetradAlgorithms.java +++ b/src/main/java/edu/pitt/dbmi/causal/cmd/tetrad/TetradAlgorithms.java @@ -92,10 +92,11 @@ public String getName(Class clazz) { : ""; } - public String getDescription(Class clazz) { - return (clazz != null && clazz.isAnnotationPresent(Algorithm.class)) - ? ((Algorithm) clazz.getAnnotation(Algorithm.class)).description() - : ""; - } + // not used so commenting out as this is more tetrad gui +// public String getDescription(Class clazz) { +// return (clazz != null && clazz.isAnnotationPresent(Algorithm.class)) +// ? ((Algorithm) clazz.getAnnotation(Algorithm.class)).description() +// : ""; +// } } From c1f7eb779669993093b7eccadf1cecf356683b58 Mon Sep 17 00:00:00 2001 From: Kevin Bui Date: Fri, 27 Jul 2018 13:35:48 -0400 Subject: [PATCH 4/8] FileIO is no longer needed. Use Java 8 Stream API instead. --- .../dbmi/causal/cmd/tetrad/TetradUtils.java | 21 ++-- .../edu/pitt/dbmi/causal/cmd/util/FileIO.java | 97 ------------------- 2 files changed, 14 insertions(+), 104 deletions(-) delete mode 100644 src/main/java/edu/pitt/dbmi/causal/cmd/util/FileIO.java diff --git a/src/main/java/edu/pitt/dbmi/causal/cmd/tetrad/TetradUtils.java b/src/main/java/edu/pitt/dbmi/causal/cmd/tetrad/TetradUtils.java index 2c61e35..3834e06 100644 --- a/src/main/java/edu/pitt/dbmi/causal/cmd/tetrad/TetradUtils.java +++ b/src/main/java/edu/pitt/dbmi/causal/cmd/tetrad/TetradUtils.java @@ -30,7 +30,6 @@ import edu.pitt.dbmi.causal.cmd.CmdArgs; import edu.pitt.dbmi.causal.cmd.ValidationException; import edu.pitt.dbmi.causal.cmd.util.DateTime; -import edu.pitt.dbmi.causal.cmd.util.FileIO; import edu.pitt.dbmi.data.Dataset; import edu.pitt.dbmi.data.reader.covariance.CovarianceDataReader; import edu.pitt.dbmi.data.reader.covariance.LowerCovarianceDataReader; @@ -49,6 +48,7 @@ import java.io.File; import java.io.IOException; import java.io.PrintStream; +import java.nio.file.Files; import java.nio.file.Path; import java.util.Collections; import java.util.HashSet; @@ -57,6 +57,7 @@ import java.util.Map; import java.util.Set; import java.util.stream.Collectors; +import java.util.stream.Stream; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -172,18 +173,24 @@ public static IKnowledge readInKnowledge(CmdArgs cmdArgs, PrintStream out) throw } private static Set getExcludeVariables(CmdArgs cmdArgs, PrintStream out) throws IOException { - Set excludeVars; - Path file = cmdArgs.getExcludeVariableFile(); if (file == null) { - excludeVars = new HashSet<>(); + return Collections.EMPTY_SET; } else { + Set set = new HashSet<>(); + logStartReading(file, out); - excludeVars = FileIO.extractUniqueLine(cmdArgs.getExcludeVariableFile()); + try (Stream stream = Files.lines(file)) { + stream + .map(e -> e.trim()) + .filter(e -> !e.isEmpty()) + .distinct() + .collect(Collectors.toCollection(() -> set)); + } logFinishReading(file, out); - } - return excludeVars; + return set; + } } public static List getDataModels(CmdArgs cmdArgs, PrintStream out) throws IOException { diff --git a/src/main/java/edu/pitt/dbmi/causal/cmd/util/FileIO.java b/src/main/java/edu/pitt/dbmi/causal/cmd/util/FileIO.java deleted file mode 100644 index dae6c5e..0000000 --- a/src/main/java/edu/pitt/dbmi/causal/cmd/util/FileIO.java +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Copyright (C) 2017 University of Pittsburgh. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, - * MA 02110-1301 USA - */ -package edu.pitt.dbmi.causal.cmd.util; - -import java.io.BufferedReader; -import java.io.BufferedWriter; -import java.io.IOException; -import java.nio.charset.Charset; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.StandardOpenOption; -import java.util.HashSet; -import java.util.LinkedList; -import java.util.List; -import java.util.Set; - -/** - * - * Mar 13, 2017 5:26:10 PM - * - * @author Kevin V. Bui (kvb2@pitt.edu) - */ -public class FileIO { - - private FileIO() { - } - - public static void writeLineByLine(Set set, Path fileOut) throws IOException { - if (!(set == null || set.isEmpty())) { - try (BufferedWriter writer = Files.newBufferedWriter(fileOut, StandardOpenOption.CREATE)) { - for (String s : set) { - writer.write(s); - writer.newLine(); - } - } - } - } - - public static void writeLineByLine(List list, Path fileOut) throws IOException { - if (!(list == null || list.isEmpty())) { - try (BufferedWriter writer = Files.newBufferedWriter(fileOut, StandardOpenOption.CREATE)) { - for (String s : list) { - writer.write(s); - writer.newLine(); - } - } - } - } - - public static List extractLineByLine(Path file) throws IOException { - List lines = new LinkedList<>(); - - if (file != null) { - try (BufferedReader reader = Files.newBufferedReader(file, Charset.defaultCharset())) { - for (String line = reader.readLine(); line != null; line = reader.readLine()) { - lines.add(line); - } - } - } - - return lines; - } - - public static Set extractUniqueLine(Path file) throws IOException { - Set lines = new HashSet<>(); - - if (file != null) { - try (BufferedReader reader = Files.newBufferedReader(file, Charset.defaultCharset())) { - for (String line = reader.readLine(); line != null; line = reader.readLine()) { - line = line.trim(); - if (line.length() > 0) { - lines.add(line); - } - } - } - } - - return lines; - } - -} From 3a3246e2d9c59ecea77a8f5ebf909342c7b1619c Mon Sep 17 00:00:00 2001 From: Kevin Bui Date: Fri, 27 Jul 2018 16:06:35 -0400 Subject: [PATCH 5/8] Fixed bug where default boolean value is set to true. --- src/main/java/edu/pitt/dbmi/causal/cmd/CmdParser.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main/java/edu/pitt/dbmi/causal/cmd/CmdParser.java b/src/main/java/edu/pitt/dbmi/causal/cmd/CmdParser.java index ed3d026..d9e03a4 100644 --- a/src/main/java/edu/pitt/dbmi/causal/cmd/CmdParser.java +++ b/src/main/java/edu/pitt/dbmi/causal/cmd/CmdParser.java @@ -31,6 +31,7 @@ import edu.pitt.dbmi.causal.cmd.util.FileUtils; import edu.pitt.dbmi.causal.cmd.util.OptionFactory; import java.io.FileNotFoundException; +import java.io.Serializable; import java.nio.file.Path; import java.nio.file.Paths; import java.util.HashMap; @@ -357,7 +358,11 @@ private static Map getValidParameters(CommandLine cmd, CmdArgs c } parameters.put(param, value); } else { - parameters.put(param, paramDesc.getDefaultValue().toString()); + Serializable defaultValue = paramDesc.getDefaultValue(); + String value = (defaultValue instanceof Boolean) + ? Boolean.FALSE.toString() + : defaultValue.toString(); + parameters.put(param, value); } }; From ba3b12ae7285a1432a0035087e0fd6bb5dbbd346 Mon Sep 17 00:00:00 2001 From: chirayukong Date: Wed, 26 Sep 2018 16:25:45 -0400 Subject: [PATCH 6/8] Updated tetrad-lib's version and the boostrap unit test --- pom.xml | 2 +- .../edu/pitt/dbmi/causal/cmd/CausalCmdApplicationTest.java | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index d2a12fe..24526c3 100644 --- a/pom.xml +++ b/pom.xml @@ -120,7 +120,7 @@ edu.cmu tetrad-lib - 6.5.0-SNAPSHOT + 6.6.0-SNAPSHOT log4j diff --git a/src/test/java/edu/pitt/dbmi/causal/cmd/CausalCmdApplicationTest.java b/src/test/java/edu/pitt/dbmi/causal/cmd/CausalCmdApplicationTest.java index f22820a..378a6b0 100644 --- a/src/test/java/edu/pitt/dbmi/causal/cmd/CausalCmdApplicationTest.java +++ b/src/test/java/edu/pitt/dbmi/causal/cmd/CausalCmdApplicationTest.java @@ -60,8 +60,9 @@ public void testMainWithBootstrap() throws IOException { String contData = TestFiles.getInstance().getContinuousData().toString(); String dirOut = tmpFolder.newFolder("gfci_bootstrap").toString(); String[] args = { - "--bootstrapEnsemble", "1", - "--bootstrapSampleSize", "5", + "--resamplingEnsemble", "1", + "--numberResampling", "5", + "--resampleSize","100", "--dataset", contData, "--delimiter", "tab", "--data-type", "continuous", From d87e6799a0f0b8d63c481d962dddb0f5d17197f0 Mon Sep 17 00:00:00 2001 From: Kevin Bui Date: Mon, 1 Oct 2018 11:48:35 -0400 Subject: [PATCH 7/8] Updated project version. Updated dependency version. --- pom.xml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pom.xml b/pom.xml index d2a12fe..3d40d78 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ 4.0.0 edu.pitt.dbmi causal-cmd - 0.4.0-SNAPSHOT + 0.4.1-SNAPSHOT jar UTF-8 @@ -37,7 +37,7 @@ maven-resources-plugin - 3.0.2 + 3.1.0 copy-dist-resources @@ -60,7 +60,7 @@ org.apache.maven.plugins maven-jar-plugin - 3.0.2 + 3.1.0 @@ -120,7 +120,7 @@ edu.cmu tetrad-lib - 6.5.0-SNAPSHOT + 6.6.0-SNAPSHOT log4j From 83bab7ac872afcb86cce1227a25479d5ff3ebf43 Mon Sep 17 00:00:00 2001 From: Kevin Bui Date: Mon, 1 Oct 2018 15:05:32 -0400 Subject: [PATCH 8/8] Made "targetName" as a required parameter for the Markov blanket algorithms. Added a unit test for fges-mb. --- .../edu/pitt/dbmi/causal/cmd/CmdParams.java | 1 + .../edu/pitt/dbmi/causal/cmd/CmdParser.java | 7 ++++++- .../causal/cmd/CausalCmdApplicationTest.java | 20 ++++++++++++++++++- 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/src/main/java/edu/pitt/dbmi/causal/cmd/CmdParams.java b/src/main/java/edu/pitt/dbmi/causal/cmd/CmdParams.java index 936fbb8..b3eafaa 100644 --- a/src/main/java/edu/pitt/dbmi/causal/cmd/CmdParams.java +++ b/src/main/java/edu/pitt/dbmi/causal/cmd/CmdParams.java @@ -57,6 +57,7 @@ public interface CmdParams { public static final String SCORE = "score"; public static final String NUM_CATEGORIES = "numCategories"; + public static final String TARGET_NAME = "targetName"; public static final String THREAD = "thread"; diff --git a/src/main/java/edu/pitt/dbmi/causal/cmd/CmdParser.java b/src/main/java/edu/pitt/dbmi/causal/cmd/CmdParser.java index d9e03a4..26b5ea0 100644 --- a/src/main/java/edu/pitt/dbmi/causal/cmd/CmdParser.java +++ b/src/main/java/edu/pitt/dbmi/causal/cmd/CmdParser.java @@ -250,7 +250,12 @@ private static ParseOptions getValidOptions(String[] args, Options options) thro // add Tetrad parameters params.forEach(param -> { - opts.addOption(CmdOptions.getInstance().getLongOption(param)); + if (param.equals(CmdParams.TARGET_NAME)) { + // add required Tetrad parameters + opts.addOption(Option.builder().longOpt(CmdParams.TARGET_NAME).desc("Target variable.").hasArg().argName("string").required().build()); + } else { + opts.addOption(CmdOptions.getInstance().getLongOption(param)); + } }); try { diff --git a/src/test/java/edu/pitt/dbmi/causal/cmd/CausalCmdApplicationTest.java b/src/test/java/edu/pitt/dbmi/causal/cmd/CausalCmdApplicationTest.java index 378a6b0..2f245d0 100644 --- a/src/test/java/edu/pitt/dbmi/causal/cmd/CausalCmdApplicationTest.java +++ b/src/test/java/edu/pitt/dbmi/causal/cmd/CausalCmdApplicationTest.java @@ -37,6 +37,24 @@ public class CausalCmdApplicationTest { public CausalCmdApplicationTest() { } + @Test + public void testMainFgesMb() throws IOException { + String contData = TestFiles.getInstance().getContinuousData().toString(); + String dirOut = tmpFolder.newFolder("fges_mb").toString(); + String[] args = { + "--dataset", contData, + "--delimiter", "tab", + "--data-type", "continuous", + "--algorithm", "fges-mb", + "--score", "sem-bic", + "--targetName", "X1", + "--verbose", + "--skip-latest", + "--out", dirOut + }; + CausalCmdApplication.main(args); + } + @Test public void testMainCovariance() throws IOException { String covarData = TestFiles.getInstance().getCovarianceData().toString(); @@ -62,7 +80,7 @@ public void testMainWithBootstrap() throws IOException { String[] args = { "--resamplingEnsemble", "1", "--numberResampling", "5", - "--resampleSize","100", + "--resampleSize", "100", "--dataset", contData, "--delimiter", "tab", "--data-type", "continuous",