Skip to content

Commit

Permalink
Merge branch 'development'
Browse files Browse the repository at this point in the history
# Conflicts:
#	pom.xml
  • Loading branch information
kvb2univpitt committed Oct 29, 2019
2 parents f51519a + 4ab1a70 commit 23c030a
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 4 deletions.
6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>edu.pitt.dbmi</groupId>
<artifactId>causal-cmd</artifactId>
<version>1.1.1</version>
<version>1.1.2</version>
<packaging>jar</packaging>

<properties>
Expand Down Expand Up @@ -144,7 +144,7 @@
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.7.26</version>
<version>1.7.28</version>
</dependency>
<dependency>
<groupId>junit</groupId>
Expand All @@ -153,4 +153,4 @@
</dependency>
</dependencies>

</project>
</project>
36 changes: 35 additions & 1 deletion src/main/java/edu/pitt/dbmi/causal/cmd/CmdParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@
*/
package edu.pitt.dbmi.causal.cmd;

import edu.cmu.tetrad.algcomparison.algorithm.Algorithm;
import edu.cmu.tetrad.algcomparison.algorithm.AlgorithmFactory;
import edu.cmu.tetrad.algcomparison.utils.TakesIndependenceWrapper;
import edu.cmu.tetrad.algcomparison.utils.UsesScoreWrapper;
import edu.cmu.tetrad.data.DataType;
import edu.cmu.tetrad.util.ParamDescription;
import edu.cmu.tetrad.util.ParamDescriptions;
Expand All @@ -30,6 +33,7 @@
import java.io.Serializable;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
Expand Down Expand Up @@ -273,7 +277,7 @@ private static ParseOptions getValidOptions(String[] args, Options options) thro

List<String> params = new LinkedList<>();
try {
params.addAll(AlgorithmFactory.create(algorithmClass, indTestClass, scoreClass).getParameters());
params.addAll(getAllParameters(AlgorithmFactory.create(algorithmClass, indTestClass, scoreClass)));
} catch (IllegalAccessException | InstantiationException exception) {
throw new CmdParserException(parseOptions, exception);
}
Expand Down Expand Up @@ -301,6 +305,36 @@ private static ParseOptions getValidOptions(String[] args, Options options) thro
return parseOptions;
}

/**
* Get the parameters for the algorithm, the algorithm's test and the
* algorithm's score.
*
* @param algorithm to get parameters from
* @return list of parameters for the algorithm, test and score
*/
private static List<String> getAllParameters(Algorithm algorithm) {
if (algorithm == null) {
return Collections.EMPTY_LIST;
}

List<String> params = new LinkedList<>();

// add algorithm parameters
params.addAll(algorithm.getParameters());

// add the algorithm test parameters, if any
if (algorithm instanceof TakesIndependenceWrapper) {
params.addAll(((TakesIndependenceWrapper) algorithm).getIndependenceWrapper().getParameters());
}

// add the algorithm's score parameters, if any
if (algorithm instanceof UsesScoreWrapper) {
params.addAll(((UsesScoreWrapper) algorithm).getScoreWrapper().getParameters());
}

return params;
}

private static void addGraphManipulationOptions(Options opts) {
opts.addOption(CmdOptions.getInstance().getLongOption(CmdParams.CHOOSE_DAG_IN_PATTERN));
opts.addOption(CmdOptions.getInstance().getLongOption(CmdParams.CHOOSE_MAG_IN_PAG));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,8 @@ public void testGFCIWithContinuousData() throws IOException {
"--algorithm", "gfci",
"--test", "fisher-z-test",
"--score", "sem-bic",
"--penaltyDiscount", "1.0",
"--structurePrior", "0.01",
"--verbose",
"--skip-latest",
"--out", dirOut
Expand Down

0 comments on commit 23c030a

Please sign in to comment.