Use BuildAllGraphs
diff --git a/genomix/genomix-hadoop/src/test/java/edu/uci/ics/genomix/hadoop/graphclean/mergepaths/h3/TestPathMergeH3.java b/genomix/genomix-hadoop/src/test/java/edu/uci/ics/genomix/hadoop/graphclean/mergepaths/h3/TestPathMergeH3.java
index 7db3db5..25e7ed0 100644
--- a/genomix/genomix-hadoop/src/test/java/edu/uci/ics/genomix/hadoop/graphclean/mergepaths/h3/TestPathMergeH3.java
+++ b/genomix/genomix-hadoop/src/test/java/edu/uci/ics/genomix/hadoop/graphclean/mergepaths/h3/TestPathMergeH3.java
@@ -1,8 +1,20 @@
package edu.uci.ics.genomix.hadoop.graphclean.mergepaths.h3;
+import java.io.File;
+import java.io.FileFilter;
+import java.io.IOException;
+import java.nio.file.FileSystems;
+import java.nio.file.FileVisitResult;
+import java.nio.file.Files;
+import java.nio.file.PathMatcher;
+import java.nio.file.Paths;
+import java.nio.file.attribute.BasicFileAttributes;
+import java.nio.file.SimpleFileVisitor;
import java.util.ArrayList;
import java.util.Arrays;
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.io.filefilter.WildcardFileFilter;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.mapred.FileInputFormat;
import org.apache.hadoop.mapred.FileOutputFormat;
@@ -35,9 +47,36 @@
conf.setInt(GenomixJobConf.READ_LENGTH, READ_LENGTH);
}
+ /*
+ * Build all graphs in any "input/reads" directory
+ */
@Test
public void BuildAllGraphs() throws Exception {
- for (String path : )
+ final PathMatcher matcher = FileSystems.getDefault().getPathMatcher("glob:**/src/test/resources/input/reads/**/*.txt");
+ Files.walkFileTree(Paths.get("."), new SimpleFileVisitor<java.nio.file.Path>() {
+ @Override
+ public FileVisitResult visitFile(java.nio.file.Path file, BasicFileAttributes attrs) throws IOException {
+ if (matcher.matches(file)) {
+ TestPathMergeH3 tester = new TestPathMergeH3();
+ tester.LOCAL_SEQUENCE_FILE = file.toString();
+ tester.GRAPHBUILD_FILE = file.getFileName().toString();
+ tester.cleanUpOutput();
+ TestPathMergeH3.copyLocalToDFS(tester.LOCAL_SEQUENCE_FILE, tester.HDFS_SEQUENCE);
+ try {
+ tester.buildGraph();
+ } catch (Exception e) {
+ throw new IOException(e);
+ }
+ }
+ return FileVisitResult.CONTINUE;
+ }
+
+ @Override
+ public FileVisitResult visitFileFailed(java.nio.file.Path file, IOException exc) throws IOException {
+ return FileVisitResult.CONTINUE;
+ }
+ });
+
}
// @Test
@@ -132,9 +171,11 @@
FileOutputFormat.setOutputPath(buildConf, new Path(HDFS_GRAPHBUILD));
buildConf.set(GenomixJobConf.OUTPUT_FORMAT, GenomixJobConf.OUTPUT_FORMAT_BINARY);
buildConf.set(GenomixJobConf.GROUPBY_TYPE, GenomixJobConf.GROUPBY_TYPE_PRECLUSTER);
- driver.runJob(new GenomixJobConf(buildConf), Plan.BUILD_DEBRUJIN_GRAPH, true);
+ driver.runJob(new GenomixJobConf(buildConf), Plan.BUILD_UNMERGED_GRAPH, true);
String fileFormat = buildConf.get(GenomixJobConf.OUTPUT_FORMAT);
boolean resultsAreText = GenomixJobConf.OUTPUT_FORMAT_TEXT.equalsIgnoreCase(fileFormat);
- copyResultsToLocal(HDFS_GRAPHBUILD, ACTUAL_ROOT + GRAPHBUILD_FILE, resultsAreText, buildConf);
+ File rootDir = new File(new File(ACTUAL_ROOT + LOCAL_SEQUENCE_FILE).getParent());
+ FileUtils.forceMkdir(rootDir);
+ copyResultsToLocal(HDFS_GRAPHBUILD, ACTUAL_ROOT + LOCAL_SEQUENCE_FILE, resultsAreText, buildConf);
}
}
diff --git a/genomix/genomix-hadoop/src/test/java/edu/uci/ics/genomix/hadoop/pmcommon/GenomixMiniClusterTest.java b/genomix/genomix-hadoop/src/test/java/edu/uci/ics/genomix/hadoop/pmcommon/GenomixMiniClusterTest.java
index e906c7a..4e6a5f9 100644
--- a/genomix/genomix-hadoop/src/test/java/edu/uci/ics/genomix/hadoop/pmcommon/GenomixMiniClusterTest.java
+++ b/genomix/genomix-hadoop/src/test/java/edu/uci/ics/genomix/hadoop/pmcommon/GenomixMiniClusterTest.java
@@ -88,8 +88,11 @@
FileStatus[] files = dfs.globStatus(new Path(hdfsSrcDir + "*"));
SequenceFile.Reader reader = new SequenceFile.Reader(dfs, files[0].getPath(), conf);
- SequenceFile.Writer writer = new SequenceFile.Writer(lfs, new JobConf(), new Path(localDestFile
- + ".binmerge"), reader.getKeyClass(), reader.getValueClass());
+ String destBinDir = localDestFile.substring(0, localDestFile.lastIndexOf("."));
+ FileUtil.copy(FileSystem.get(conf), new Path(hdfsSrcDir), FileSystem.getLocal(new Configuration()),
+ new Path(destBinDir), false, conf);
+// SequenceFile.Writer writer = new SequenceFile.Writer(lfs, new JobConf(), new Path(localDestFile
+// + ".binmerge"), reader.getKeyClass(), reader.getValueClass());
Writable key = (Writable) ReflectionUtils.newInstance(reader.getKeyClass(), conf);
Writable value = (Writable) ReflectionUtils.newInstance(reader.getValueClass(), conf);
@@ -106,12 +109,12 @@
bw.write(key.toString() + "\t" + value.toString());
System.out.println(key.toString() + "\t" + value.toString());
bw.newLine();
- writer.append(key, value);
+// writer.append(key, value);
}
reader.close();
}
- writer.close();
+// writer.close();
bw.close();
}