Skip to content

Commit

Permalink
test: add junit tests for variant association analysis, #126
Browse files Browse the repository at this point in the history
  • Loading branch information
jtarraga committed Jun 6, 2017
1 parent ddb8d39 commit 3e176bb
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@ public void execute() throws Exception {
case "rvtests":
rvtests();
break;
case "association":
assoc();
break;
default:
logger.error("Variant subcommand '" + subCommandString + "' not valid");
break;
Expand Down Expand Up @@ -852,4 +855,33 @@ public void rvtests() throws Exception {
// rvtests.run(variantCommandOptions.rvtestsVariantCommandOptions.datasetId);
rvtests.run00(variantCommandOptions.rvtestsVariantCommandOptions.datasetId);
}

public void assoc() throws Exception {
File metaFile = new File(variantCommandOptions.associationVariantCommandOptions.input + ".meta.json");
if (!metaFile.isFile() || !metaFile.exists() || !metaFile.canRead()) {
throw new FileNotFoundException("Check your input metadata file.");
}

SparkConf sparkConf = SparkConfCreator.getConf("variant association", "local", 1, true);
logger.debug("sparkConf = {}", sparkConf.toDebugString());
SparkSession sparkSession = new SparkSession(new SparkContext(sparkConf));

VariantDataset vd = new VariantDataset(sparkSession);
vd.load(variantCommandOptions.associationVariantCommandOptions.input);
vd.createOrReplaceTempView("vcf");
vd.show(2);

VariantMetadataManager variantMetadataManager = new VariantMetadataManager();
variantMetadataManager.load(metaFile.getPath());
Pedigree pedigree = variantMetadataManager.getPedigree("noname");

for (String key: pedigree.getIndividuals().keySet()) {
System.out.println(key + " = " + pedigree.getIndividuals().get(key));
}
//PedigreeManager pedigreeManager = new PedigreeManager();
//pedigreeManager.
//String pheno = variantCommandOptions.associationVariantCommandOptions.pheno;

sparkSession.stop();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package org.opencb.hpg.bigdata.app.cli.local;

import org.junit.Test;

import java.net.URISyntaxException;
import java.nio.file.Path;
import java.nio.file.Paths;

/**
* Created by joaquin on 1/19/17.
*/
public class VariantAssocCLITest {
Path inPath;
Path outPath;
Path confPath;

private void init() throws URISyntaxException {
String root = "/home/jtarraga//data150/test/assoc";
inPath = Paths.get(root + "/test.vcf.avro");
outPath = Paths.get(root + "/assoc.out");
}

@Test
public void assoc() {
try {
init();

StringBuilder commandLine = new StringBuilder();
commandLine.append(" variant association");
commandLine.append(" --log-level ERROR");
commandLine.append(" -i ").append(inPath);
commandLine.append(" -o ").append(outPath);
commandLine.append(" --dataset noname");

VariantQueryCLITest.execute(commandLine.toString());
} catch (Exception e) {
e.printStackTrace();
}
}

}

0 comments on commit 3e176bb

Please sign in to comment.