add hyrack format
diff --git a/genomix/genomix-data/.classpath b/genomix/genomix-data/.classpath
index 6e26406..7f85d53 100644
--- a/genomix/genomix-data/.classpath
+++ b/genomix/genomix-data/.classpath
@@ -5,6 +5,7 @@
<classpathentry kind="src" output="target/test-classes" path="src/test/java"/>
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
+ <classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER"/>
<classpathentry kind="output" path="target/classes"/>
</classpath>
diff --git a/genomix/genomix-data/.project b/genomix/genomix-data/.project
index f22376e..2749b29 100644
--- a/genomix/genomix-data/.project
+++ b/genomix/genomix-data/.project
@@ -15,8 +15,14 @@
<arguments>
</arguments>
</buildCommand>
+ <buildCommand>
+ <name>org.maven.ide.eclipse.maven2Builder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
</buildSpec>
<natures>
+ <nature>org.maven.ide.eclipse.maven2Nature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
</natures>
diff --git a/genomix/genomix-pregelix/src/main/java/edu/uci/ics/genomix/pregelix/api/io/binary/BinaryVertexInputFormat.java b/genomix/genomix-pregelix/src/main/java/edu/uci/ics/genomix/pregelix/api/io/binary/BinaryVertexInputFormat.java
index e1868b1..a4134af 100644
--- a/genomix/genomix-pregelix/src/main/java/edu/uci/ics/genomix/pregelix/api/io/binary/BinaryVertexInputFormat.java
+++ b/genomix/genomix-pregelix/src/main/java/edu/uci/ics/genomix/pregelix/api/io/binary/BinaryVertexInputFormat.java
@@ -16,13 +16,13 @@
import edu.uci.ics.genomix.type.KmerBytesWritable;
import edu.uci.ics.genomix.type.KmerCountValue;
-public class BinaryVertexInputFormat <I extends WritableComparable<?>, V extends Writable, E extends Writable, M extends Writable>
- extends VertexInputFormat<I, V, E, M>{
-
+public class BinaryVertexInputFormat<I extends WritableComparable<?>, V extends Writable, E extends Writable, M extends Writable>
+ extends VertexInputFormat<I, V, E, M> {
+
/** Uses the SequenceFileInputFormat to do everything */
- @SuppressWarnings("rawtypes")
- protected SequenceFileInputFormat binaryInputFormat = new SequenceFileInputFormat();
-
+ @SuppressWarnings("rawtypes")
+ protected SequenceFileInputFormat binaryInputFormat = new SequenceFileInputFormat();
+
/**
* Abstract class to be implemented by the user based on their specific
* vertex input. Easiest to ignore the key value separator and only use key
@@ -38,7 +38,7 @@
public static abstract class BinaryVertexReader<I extends WritableComparable<?>, V extends Writable, E extends Writable, M extends Writable>
implements VertexReader<I, V, E, M> {
/** Internal line record reader */
- private final RecordReader<KmerBytesWritable,KmerCountValue> lineRecordReader;
+ private final RecordReader<KmerBytesWritable, KmerCountValue> lineRecordReader;
/** Context passed to initialize */
private TaskAttemptContext context;
@@ -74,7 +74,7 @@
*
* @return Record reader to be used for reading.
*/
- protected RecordReader<KmerBytesWritable,KmerCountValue> getRecordReader() {
+ protected RecordReader<KmerBytesWritable, KmerCountValue> getRecordReader() {
return lineRecordReader;
}
@@ -89,21 +89,17 @@
}
@SuppressWarnings("unchecked")
- @Override
+ @Override
public List<InputSplit> getSplits(JobContext context, int numWorkers) throws IOException, InterruptedException {
// Ignore the hint of numWorkers here since we are using SequenceFileInputFormat
// to do this for us
return binaryInputFormat.getSplits(context);
}
- @Override
- public VertexReader<I, V, E, M> createVertexReader(InputSplit split,
- TaskAttemptContext context) throws IOException {
- // TODO Auto-generated method stub
- return null;
- }
-
-
-
+ @Override
+ public VertexReader<I, V, E, M> createVertexReader(InputSplit split, TaskAttemptContext context) throws IOException {
+ // TODO Auto-generated method stub
+ return null;
+ }
}
diff --git a/genomix/genomix-pregelix/src/main/java/edu/uci/ics/genomix/pregelix/api/io/binary/BinaryVertexOutputFormat.java b/genomix/genomix-pregelix/src/main/java/edu/uci/ics/genomix/pregelix/api/io/binary/BinaryVertexOutputFormat.java
index 1435770..d921b5e 100644
--- a/genomix/genomix-pregelix/src/main/java/edu/uci/ics/genomix/pregelix/api/io/binary/BinaryVertexOutputFormat.java
+++ b/genomix/genomix-pregelix/src/main/java/edu/uci/ics/genomix/pregelix/api/io/binary/BinaryVertexOutputFormat.java
@@ -30,7 +30,7 @@
public abstract class BinaryVertexOutputFormat<I extends WritableComparable, V extends Writable, E extends Writable>
extends VertexOutputFormat<I, V, E> {
/** Uses the SequenceFileOutputFormat to do everything */
- protected SequenceFileOutputFormat binaryOutputFormat = new SequenceFileOutputFormat();
+ protected SequenceFileOutputFormat binaryOutputFormat = new SequenceFileOutputFormat();
/**
* Abstract class to be implemented by the user based on their specific
@@ -92,7 +92,7 @@
@Override
public void checkOutputSpecs(JobContext context) throws IOException, InterruptedException {
- binaryOutputFormat.checkOutputSpecs(context);
+ binaryOutputFormat.checkOutputSpecs(context);
}
@Override
diff --git a/genomix/genomix-pregelix/src/main/java/edu/uci/ics/genomix/pregelix/client/Client.java b/genomix/genomix-pregelix/src/main/java/edu/uci/ics/genomix/pregelix/client/Client.java
index e35f10c..f849b21 100644
--- a/genomix/genomix-pregelix/src/main/java/edu/uci/ics/genomix/pregelix/client/Client.java
+++ b/genomix/genomix-pregelix/src/main/java/edu/uci/ics/genomix/pregelix/client/Client.java
@@ -1,4 +1,3 @@
-
package edu.uci.ics.genomix.pregelix.client;
import java.io.IOException;
@@ -33,10 +32,10 @@
@Option(name = "-plan", usage = "query plan choice", required = false)
public Plan planChoice = Plan.OUTER_JOIN;
-
+
@Option(name = "-kmer-size", usage = "the size of kmer", required = false)
public int sizeKmer;
-
+
@Option(name = "-num-iteration", usage = "max number of iterations, for pagerank job only", required = false)
public int numIteration = -1;
@@ -62,7 +61,7 @@
FileOutputFormat.setOutputPath(job, new Path(options.outputPath));
job.getConfiguration().setInt(NaiveAlgorithmForPathMergeVertex.KMER_SIZE, options.sizeKmer);
job.getConfiguration().setInt(LogAlgorithmForPathMergeVertex.KMER_SIZE, options.sizeKmer);
- if (options.numIteration > 0){
+ if (options.numIteration > 0) {
job.getConfiguration().setInt(NaiveAlgorithmForPathMergeVertex.ITERATIONS, options.numIteration);
job.getConfiguration().setInt(LogAlgorithmForPathMergeVertex.ITERATIONS, options.numIteration);
}
diff --git a/genomix/genomix-pregelix/src/main/java/edu/uci/ics/genomix/pregelix/format/LogAlgorithmForPathMergeInputFormat.java b/genomix/genomix-pregelix/src/main/java/edu/uci/ics/genomix/pregelix/format/LogAlgorithmForPathMergeInputFormat.java
index 7a7e43d..4a76ff6 100644
--- a/genomix/genomix-pregelix/src/main/java/edu/uci/ics/genomix/pregelix/format/LogAlgorithmForPathMergeInputFormat.java
+++ b/genomix/genomix-pregelix/src/main/java/edu/uci/ics/genomix/pregelix/format/LogAlgorithmForPathMergeInputFormat.java
@@ -18,17 +18,17 @@
import edu.uci.ics.pregelix.api.util.BspUtils;
public class LogAlgorithmForPathMergeInputFormat extends
- BinaryVertexInputFormat<KmerBytesWritable, ValueStateWritable, NullWritable, LogAlgorithmMessageWritable>{
- /**
- * Format INPUT
- */
+ BinaryVertexInputFormat<KmerBytesWritable, ValueStateWritable, NullWritable, LogAlgorithmMessageWritable> {
+ /**
+ * Format INPUT
+ */
@SuppressWarnings("unchecked")
- @Override
+ @Override
public VertexReader<KmerBytesWritable, ValueStateWritable, NullWritable, LogAlgorithmMessageWritable> createVertexReader(
InputSplit split, TaskAttemptContext context) throws IOException {
return new BinaryLoadGraphReader(binaryInputFormat.createRecordReader(split, context));
}
-
+
@SuppressWarnings("rawtypes")
class BinaryLoadGraphReader extends
BinaryVertexReader<KmerBytesWritable, ValueStateWritable, NullWritable, LogAlgorithmMessageWritable> {
@@ -36,7 +36,7 @@
private KmerBytesWritable vertexId = null;
private ValueStateWritable vertexValue = new ValueStateWritable();
- public BinaryLoadGraphReader(RecordReader<KmerBytesWritable,KmerCountValue> recordReader) {
+ public BinaryLoadGraphReader(RecordReader<KmerBytesWritable, KmerCountValue> recordReader) {
super(recordReader);
}
@@ -47,33 +47,33 @@
@SuppressWarnings("unchecked")
@Override
- public Vertex<KmerBytesWritable, ValueStateWritable, NullWritable, LogAlgorithmMessageWritable> getCurrentVertex() throws IOException,
- InterruptedException {
+ public Vertex<KmerBytesWritable, ValueStateWritable, NullWritable, LogAlgorithmMessageWritable> getCurrentVertex()
+ throws IOException, InterruptedException {
if (vertex == null)
vertex = (Vertex) BspUtils.createVertex(getContext().getConfiguration());
vertex.getMsgList().clear();
vertex.getEdges().clear();
-
- if(getRecordReader() != null){
- /**
- * set the src vertex id
- */
- if(vertexId == null)
- vertexId = new KmerBytesWritable(getRecordReader().getCurrentKey().getKmerLength());
- vertexId.set(getRecordReader().getCurrentKey());
- vertex.setVertexId(vertexId);
- /**
- * set the vertex value
- */
- KmerCountValue kmerCountValue = getRecordReader().getCurrentValue();
- vertexValue.setAdjMap(kmerCountValue.getAdjBitMap());
- vertexValue.setState(State.NON_VERTEX);
- vertex.setVertexValue(vertexValue);
+
+ if (getRecordReader() != null) {
+ /**
+ * set the src vertex id
+ */
+ if (vertexId == null)
+ vertexId = new KmerBytesWritable(getRecordReader().getCurrentKey().getKmerLength());
+ vertexId.set(getRecordReader().getCurrentKey());
+ vertex.setVertexId(vertexId);
+ /**
+ * set the vertex value
+ */
+ KmerCountValue kmerCountValue = getRecordReader().getCurrentValue();
+ vertexValue.setAdjMap(kmerCountValue.getAdjBitMap());
+ vertexValue.setState(State.NON_VERTEX);
+ vertex.setVertexValue(vertexValue);
}
-
+
return vertex;
}
}
-
+
}
diff --git a/genomix/genomix-pregelix/src/main/java/edu/uci/ics/genomix/pregelix/format/LogAlgorithmForPathMergeOutputFormat.java b/genomix/genomix-pregelix/src/main/java/edu/uci/ics/genomix/pregelix/format/LogAlgorithmForPathMergeOutputFormat.java
index f0b2915..68d70ad 100644
--- a/genomix/genomix-pregelix/src/main/java/edu/uci/ics/genomix/pregelix/format/LogAlgorithmForPathMergeOutputFormat.java
+++ b/genomix/genomix-pregelix/src/main/java/edu/uci/ics/genomix/pregelix/format/LogAlgorithmForPathMergeOutputFormat.java
@@ -13,35 +13,35 @@
import edu.uci.ics.genomix.pregelix.type.State;
import edu.uci.ics.genomix.type.KmerBytesWritable;
-public class LogAlgorithmForPathMergeOutputFormat extends
- BinaryVertexOutputFormat<KmerBytesWritable, ValueStateWritable, NullWritable> {
+public class LogAlgorithmForPathMergeOutputFormat extends
+ BinaryVertexOutputFormat<KmerBytesWritable, ValueStateWritable, NullWritable> {
-
+ @Override
+ public VertexWriter<KmerBytesWritable, ValueStateWritable, NullWritable> createVertexWriter(
+ TaskAttemptContext context) throws IOException, InterruptedException {
+ @SuppressWarnings("unchecked")
+ RecordWriter<KmerBytesWritable, ValueStateWritable> recordWriter = binaryOutputFormat.getRecordWriter(context);
+ return new BinaryLoadGraphVertexWriter(recordWriter);
+ }
+
+ /**
+ * Simple VertexWriter that supports {@link BinaryLoadGraphVertex}
+ */
+ public static class BinaryLoadGraphVertexWriter extends
+ BinaryVertexWriter<KmerBytesWritable, ValueStateWritable, NullWritable> {
+
+ public BinaryLoadGraphVertexWriter(RecordWriter<KmerBytesWritable, ValueStateWritable> lineRecordWriter) {
+ super(lineRecordWriter);
+ }
+
@Override
- public VertexWriter<KmerBytesWritable, ValueStateWritable, NullWritable> createVertexWriter(TaskAttemptContext context)
+ public void writeVertex(Vertex<KmerBytesWritable, ValueStateWritable, NullWritable, ?> vertex)
throws IOException, InterruptedException {
- @SuppressWarnings("unchecked")
- RecordWriter<KmerBytesWritable, ValueStateWritable> recordWriter = binaryOutputFormat.getRecordWriter(context);
- return new BinaryLoadGraphVertexWriter(recordWriter);
- }
-
- /**
- * Simple VertexWriter that supports {@link BinaryLoadGraphVertex}
- */
- public static class BinaryLoadGraphVertexWriter extends
- BinaryVertexWriter<KmerBytesWritable, ValueStateWritable, NullWritable> {
-
- public BinaryLoadGraphVertexWriter(RecordWriter<KmerBytesWritable, ValueStateWritable> lineRecordWriter) {
- super(lineRecordWriter);
+ if (vertex.getVertexValue().getState() != State.END_VERTEX
+ && vertex.getVertexValue().getState() != State.MID_VERTEX) {
+ getRecordWriter().write(vertex.getVertexId(), vertex.getVertexValue());
}
- @Override
- public void writeVertex(Vertex<KmerBytesWritable, ValueStateWritable, NullWritable, ?> vertex) throws IOException,
- InterruptedException {
- if(vertex.getVertexValue().getState() != State.END_VERTEX
- && vertex.getVertexValue().getState() != State.MID_VERTEX){
- getRecordWriter().write(vertex.getVertexId(),vertex.getVertexValue());
- }
-
- }
+
}
+ }
}
diff --git a/genomix/genomix-pregelix/src/main/java/edu/uci/ics/genomix/pregelix/format/NaiveAlgorithmForPathMergeInputFormat.java b/genomix/genomix-pregelix/src/main/java/edu/uci/ics/genomix/pregelix/format/NaiveAlgorithmForPathMergeInputFormat.java
index ca134c0..8abfcd0 100644
--- a/genomix/genomix-pregelix/src/main/java/edu/uci/ics/genomix/pregelix/format/NaiveAlgorithmForPathMergeInputFormat.java
+++ b/genomix/genomix-pregelix/src/main/java/edu/uci/ics/genomix/pregelix/format/NaiveAlgorithmForPathMergeInputFormat.java
@@ -18,22 +18,22 @@
import edu.uci.ics.genomix.pregelix.api.io.binary.BinaryVertexInputFormat.BinaryVertexReader;
public class NaiveAlgorithmForPathMergeInputFormat extends
- BinaryVertexInputFormat<KmerBytesWritable, ValueStateWritable, NullWritable, NaiveAlgorithmMessageWritable>{
- /**
- * Format INPUT
- */
+ BinaryVertexInputFormat<KmerBytesWritable, ValueStateWritable, NullWritable, NaiveAlgorithmMessageWritable> {
+ /**
+ * Format INPUT
+ */
@SuppressWarnings("unchecked")
- @Override
+ @Override
public VertexReader<KmerBytesWritable, ValueStateWritable, NullWritable, NaiveAlgorithmMessageWritable> createVertexReader(
InputSplit split, TaskAttemptContext context) throws IOException {
return new BinaryLoadGraphReader(binaryInputFormat.createRecordReader(split, context));
- }
+ }
}
@SuppressWarnings("rawtypes")
class BinaryLoadGraphReader extends
BinaryVertexReader<KmerBytesWritable, ValueStateWritable, NullWritable, NaiveAlgorithmMessageWritable> {
- private Vertex vertex;
+ private Vertex vertex;
private KmerBytesWritable vertexId = null;
private ValueStateWritable vertexValue = new ValueStateWritable();
@@ -48,31 +48,31 @@
@SuppressWarnings("unchecked")
@Override
- public Vertex<KmerBytesWritable, ValueStateWritable, NullWritable, NaiveAlgorithmMessageWritable> getCurrentVertex() throws IOException,
- InterruptedException {
+ public Vertex<KmerBytesWritable, ValueStateWritable, NullWritable, NaiveAlgorithmMessageWritable> getCurrentVertex()
+ throws IOException, InterruptedException {
if (vertex == null)
vertex = (Vertex) BspUtils.createVertex(getContext().getConfiguration());
vertex.getMsgList().clear();
vertex.getEdges().clear();
-
+
vertex.reset();
- if(getRecordReader() != null){
+ if (getRecordReader() != null) {
/**
* set the src vertex id
*/
- if(vertexId == null)
- vertexId = new KmerBytesWritable(getRecordReader().getCurrentKey().getKmerLength());
- vertexId.set(getRecordReader().getCurrentKey());
- vertex.setVertexId(vertexId);
+ if (vertexId == null)
+ vertexId = new KmerBytesWritable(getRecordReader().getCurrentKey().getKmerLength());
+ vertexId.set(getRecordReader().getCurrentKey());
+ vertex.setVertexId(vertexId);
/**
* set the vertex value
*/
KmerCountValue kmerCountValue = getRecordReader().getCurrentValue();
- vertexValue.setAdjMap(kmerCountValue.getAdjBitMap());
+ vertexValue.setAdjMap(kmerCountValue.getAdjBitMap());
vertex.setVertexValue(vertexValue);
}
-
+
return vertex;
}
}
diff --git a/genomix/genomix-pregelix/src/main/java/edu/uci/ics/genomix/pregelix/format/NaiveAlgorithmForPathMergeOutputFormat.java b/genomix/genomix-pregelix/src/main/java/edu/uci/ics/genomix/pregelix/format/NaiveAlgorithmForPathMergeOutputFormat.java
index e3f14a4..311283d 100644
--- a/genomix/genomix-pregelix/src/main/java/edu/uci/ics/genomix/pregelix/format/NaiveAlgorithmForPathMergeOutputFormat.java
+++ b/genomix/genomix-pregelix/src/main/java/edu/uci/ics/genomix/pregelix/format/NaiveAlgorithmForPathMergeOutputFormat.java
@@ -12,33 +12,32 @@
import edu.uci.ics.pregelix.api.graph.Vertex;
import edu.uci.ics.pregelix.api.io.VertexWriter;
-public class NaiveAlgorithmForPathMergeOutputFormat extends
- BinaryVertexOutputFormat<KmerBytesWritable, ValueStateWritable, NullWritable> {
-
-
+public class NaiveAlgorithmForPathMergeOutputFormat extends
+ BinaryVertexOutputFormat<KmerBytesWritable, ValueStateWritable, NullWritable> {
+
+ @Override
+ public VertexWriter<KmerBytesWritable, ValueStateWritable, NullWritable> createVertexWriter(
+ TaskAttemptContext context) throws IOException, InterruptedException {
+ @SuppressWarnings("unchecked")
+ RecordWriter<KmerBytesWritable, ValueStateWritable> recordWriter = binaryOutputFormat.getRecordWriter(context);
+ return new BinaryLoadGraphVertexWriter(recordWriter);
+ }
+
+ /**
+ * Simple VertexWriter that supports {@link BinaryLoadGraphVertex}
+ */
+ public static class BinaryLoadGraphVertexWriter extends
+ BinaryVertexWriter<KmerBytesWritable, ValueStateWritable, NullWritable> {
+ public BinaryLoadGraphVertexWriter(RecordWriter<KmerBytesWritable, ValueStateWritable> lineRecordWriter) {
+ super(lineRecordWriter);
+ }
@Override
- public VertexWriter<KmerBytesWritable, ValueStateWritable, NullWritable> createVertexWriter(TaskAttemptContext context)
+ public void writeVertex(Vertex<KmerBytesWritable, ValueStateWritable, NullWritable, ?> vertex)
throws IOException, InterruptedException {
- @SuppressWarnings("unchecked")
- RecordWriter<KmerBytesWritable, ValueStateWritable> recordWriter = binaryOutputFormat.getRecordWriter(context);
- return new BinaryLoadGraphVertexWriter(recordWriter);
+ //if(vertex.getVertexValue().getState() == State.FILTER
+ // || vertex.getVertexValue().getState() == State.FINAL_VERTEX)
+ getRecordWriter().write(vertex.getVertexId(), vertex.getVertexValue());
}
-
- /**
- * Simple VertexWriter that supports {@link BinaryLoadGraphVertex}
- */
- public static class BinaryLoadGraphVertexWriter extends
- BinaryVertexWriter<KmerBytesWritable, ValueStateWritable, NullWritable> {
- public BinaryLoadGraphVertexWriter(RecordWriter<KmerBytesWritable, ValueStateWritable> lineRecordWriter) {
- super(lineRecordWriter);
- }
- @Override
- public void writeVertex(Vertex<KmerBytesWritable, ValueStateWritable, NullWritable, ?> vertex) throws IOException,
- InterruptedException {
- //if(vertex.getVertexValue().getState() == State.FILTER
- // || vertex.getVertexValue().getState() == State.FINAL_VERTEX)
- getRecordWriter().write(vertex.getVertexId(),vertex.getVertexValue());
- }
- }
+ }
}
diff --git a/genomix/genomix-pregelix/src/main/java/edu/uci/ics/genomix/pregelix/graph/Graph.java b/genomix/genomix-pregelix/src/main/java/edu/uci/ics/genomix/pregelix/graph/Graph.java
index 237cca7..3e66beb 100644
--- a/genomix/genomix-pregelix/src/main/java/edu/uci/ics/genomix/pregelix/graph/Graph.java
+++ b/genomix/genomix-pregelix/src/main/java/edu/uci/ics/genomix/pregelix/graph/Graph.java
@@ -5,55 +5,54 @@
import java.io.FileReader;
public class Graph {
-
- /**
- * Construct a DOT graph in memory, convert it
- * to image and store the image in the file system.
- * @throws Exception
- */
- private void start(String fileName) throws Exception
- {
- File filePathTo = new File("graph/" + fileName);
- BufferedReader br = new BufferedReader(new FileReader(filePathTo));
- String line = "";
- String[] split;
-
- String precursor = "";
- String[] adjMap;
- char[] succeeds;
- String succeed = "";
- String output;
-
- GraphViz gv = new GraphViz();
- gv.addln(gv.start_graph());
- while((line = br.readLine()) != null){
- split = line.split("\t");
- precursor = split[0];
- adjMap = split[1].split("\\|");
- if(adjMap.length > 1){
- succeeds = adjMap[1].toCharArray();
- for(int i = 0; i < succeeds.length; i++){
- succeed = precursor.substring(1) + succeeds[i];
- output = precursor + " -> " + succeed;
- gv.addln(output);
- }
- }
- }
- gv.addln(gv.end_graph());
- System.out.println(gv.getDotSource());
- String type = "ps";
- File out = new File("graph/" + fileName + "_out." + type); // Linux
- gv.writeGraphToFile(gv.getGraph(gv.getDotSource(), type), out);
- }
-
- public static void main(String[] args) throws Exception
- {
- Graph g = new Graph();
- g.start("BridgePath_7");
- g.start("CyclePath_7");
- g.start("SimplePath_7");
- g.start("SinglePath_7");
- g.start("TreePath_7");
- }
+ /**
+ * Construct a DOT graph in memory, convert it
+ * to image and store the image in the file system.
+ *
+ * @throws Exception
+ */
+ private void start(String fileName) throws Exception {
+ File filePathTo = new File("graph/" + fileName);
+ BufferedReader br = new BufferedReader(new FileReader(filePathTo));
+ String line = "";
+ String[] split;
+
+ String precursor = "";
+ String[] adjMap;
+ char[] succeeds;
+ String succeed = "";
+ String output;
+
+ GraphViz gv = new GraphViz();
+ gv.addln(gv.start_graph());
+ while ((line = br.readLine()) != null) {
+ split = line.split("\t");
+ precursor = split[0];
+ adjMap = split[1].split("\\|");
+ if (adjMap.length > 1) {
+ succeeds = adjMap[1].toCharArray();
+ for (int i = 0; i < succeeds.length; i++) {
+ succeed = precursor.substring(1) + succeeds[i];
+ output = precursor + " -> " + succeed;
+ gv.addln(output);
+ }
+ }
+ }
+ gv.addln(gv.end_graph());
+ System.out.println(gv.getDotSource());
+
+ String type = "ps";
+ File out = new File("graph/" + fileName + "_out." + type); // Linux
+ gv.writeGraphToFile(gv.getGraph(gv.getDotSource(), type), out);
+ }
+
+ public static void main(String[] args) throws Exception {
+ Graph g = new Graph();
+ g.start("BridgePath_7");
+ g.start("CyclePath_7");
+ g.start("SimplePath_7");
+ g.start("SinglePath_7");
+ g.start("TreePath_7");
+ }
}
diff --git a/genomix/genomix-pregelix/src/main/java/edu/uci/ics/genomix/pregelix/graph/GraphViz.java b/genomix/genomix-pregelix/src/main/java/edu/uci/ics/genomix/pregelix/graph/GraphViz.java
index c2178bc..4175595 100644
--- a/genomix/genomix-pregelix/src/main/java/edu/uci/ics/genomix/pregelix/graph/GraphViz.java
+++ b/genomix/genomix-pregelix/src/main/java/edu/uci/ics/genomix/pregelix/graph/GraphViz.java
@@ -37,252 +37,261 @@
* <dl>
* <dt>Purpose: GraphViz Java API
* <dd>
- *
* <dt>Description:
- * <dd> With this Java class you can simply call dot
- * from your Java programs
+ * <dd>With this Java class you can simply call dot from your Java programs
* <dt>Example usage:
* <dd>
+ *
* <pre>
- * GraphViz gv = new GraphViz();
- * gv.addln(gv.start_graph());
- * gv.addln("A -> B;");
- * gv.addln("A -> C;");
- * gv.addln(gv.end_graph());
- * System.out.println(gv.getDotSource());
- *
- * String type = "gif";
- * File out = new File("out." + type); // out.gif in this example
- * gv.writeGraphToFile( gv.getGraph( gv.getDotSource(), type ), out );
+ * GraphViz gv = new GraphViz();
+ * gv.addln(gv.start_graph());
+ * gv.addln("A -> B;");
+ * gv.addln("A -> C;");
+ * gv.addln(gv.end_graph());
+ * System.out.println(gv.getDotSource());
+ *
+ * String type = "gif";
+ * File out = new File("out." + type); // out.gif in this example
+ * gv.writeGraphToFile(gv.getGraph(gv.getDotSource(), type), out);
* </pre>
+ *
* </dd>
- *
* </dl>
- *
+ *
* @version v0.4, 2011/02/05 (February) -- Patch of Keheliya Gallaba is added. Now you
- * can specify the type of the output file: gif, dot, fig, pdf, ps, svg, png, etc.
- * @version v0.3, 2010/11/29 (November) -- Windows support + ability
- * to read the graph from a text file
+ * can specify the type of the output file: gif, dot, fig, pdf, ps, svg, png, etc.
+ * @version v0.3, 2010/11/29 (November) -- Windows support + ability
+ * to read the graph from a text file
* @version v0.2, 2010/07/22 (July) -- bug fix
* @version v0.1, 2003/12/04 (December) -- first release
- * @author Laszlo Szathmary (<a href="jabba.laci@gmail.com">jabba.laci@gmail.com</a>)
+ * @author Laszlo Szathmary (<a href="jabba.laci@gmail.com">jabba.laci@gmail.com</a>)
*/
-public class GraphViz
-{
- /**
- * The dir. where temporary files will be created.
- */
- private static String TEMP_DIR = "/tmp"; // Linux
- // private static String TEMP_DIR = "c:/temp"; // Windows
+public class GraphViz {
+ /**
+ * The dir. where temporary files will be created.
+ */
+ private static String TEMP_DIR = "/tmp"; // Linux
+ // private static String TEMP_DIR = "c:/temp"; // Windows
- /**
- * Where is your dot program located? It will be called externally.
- */
- private static String DOT = "/usr/bin/dot"; // Linux
-// private static String DOT = "c:/Program Files/Graphviz2.26.3/bin/dot.exe"; // Windows
+ /**
+ * Where is your dot program located? It will be called externally.
+ */
+ private static String DOT = "/usr/bin/dot"; // Linux
+ // private static String DOT = "c:/Program Files/Graphviz2.26.3/bin/dot.exe"; // Windows
- /**
- * The source of the graph written in dot language.
- */
- private StringBuilder graph = new StringBuilder();
+ /**
+ * The source of the graph written in dot language.
+ */
+ private StringBuilder graph = new StringBuilder();
- /**
- * Constructor: creates a new GraphViz object that will contain
- * a graph.
- */
- public GraphViz() {
- }
+ /**
+ * Constructor: creates a new GraphViz object that will contain
+ * a graph.
+ */
+ public GraphViz() {
+ }
- /**
- * Returns the graph's source description in dot language.
- * @return Source of the graph in dot language.
- */
- public String getDotSource() {
- return graph.toString();
- }
+ /**
+ * Returns the graph's source description in dot language.
+ *
+ * @return Source of the graph in dot language.
+ */
+ public String getDotSource() {
+ return graph.toString();
+ }
- /**
- * Adds a string to the graph's source (without newline).
- */
- public void add(String line) {
- graph.append(line);
- }
+ /**
+ * Adds a string to the graph's source (without newline).
+ */
+ public void add(String line) {
+ graph.append(line);
+ }
- /**
- * Adds a string to the graph's source (with newline).
- */
- public void addln(String line) {
- graph.append(line + "\n");
- }
+ /**
+ * Adds a string to the graph's source (with newline).
+ */
+ public void addln(String line) {
+ graph.append(line + "\n");
+ }
- /**
- * Adds a newline to the graph's source.
- */
- public void addln() {
- graph.append('\n');
- }
+ /**
+ * Adds a newline to the graph's source.
+ */
+ public void addln() {
+ graph.append('\n');
+ }
- /**
- * Returns the graph as an image in binary format.
- * @param dot_source Source of the graph to be drawn.
- * @param type Type of the output image to be produced, e.g.: gif, dot, fig, pdf, ps, svg, png.
- * @return A byte array containing the image of the graph.
- */
- public byte[] getGraph(String dot_source, String type)
- {
- File dot;
- byte[] img_stream = null;
-
- try {
- dot = writeDotSourceToFile(dot_source);
- if (dot != null)
- {
- img_stream = get_img_stream(dot, type);
- if (dot.delete() == false)
- System.err.println("Warning: " + dot.getAbsolutePath() + " could not be deleted!");
- return img_stream;
- }
- return null;
- } catch (java.io.IOException ioe) { return null; }
- }
+ /**
+ * Returns the graph as an image in binary format.
+ *
+ * @param dot_source
+ * Source of the graph to be drawn.
+ * @param type
+ * Type of the output image to be produced, e.g.: gif, dot, fig, pdf, ps, svg, png.
+ * @return A byte array containing the image of the graph.
+ */
+ public byte[] getGraph(String dot_source, String type) {
+ File dot;
+ byte[] img_stream = null;
- /**
- * Writes the graph's image in a file.
- * @param img A byte array containing the image of the graph.
- * @param file Name of the file to where we want to write.
- * @return Success: 1, Failure: -1
- */
- public int writeGraphToFile(byte[] img, String file)
- {
- File to = new File(file);
- return writeGraphToFile(img, to);
- }
+ try {
+ dot = writeDotSourceToFile(dot_source);
+ if (dot != null) {
+ img_stream = get_img_stream(dot, type);
+ if (dot.delete() == false)
+ System.err.println("Warning: " + dot.getAbsolutePath() + " could not be deleted!");
+ return img_stream;
+ }
+ return null;
+ } catch (java.io.IOException ioe) {
+ return null;
+ }
+ }
- /**
- * Writes the graph's image in a file.
- * @param img A byte array containing the image of the graph.
- * @param to A File object to where we want to write.
- * @return Success: 1, Failure: -1
- */
- public int writeGraphToFile(byte[] img, File to)
- {
- try {
- FileOutputStream fos = new FileOutputStream(to);
- fos.write(img);
- fos.close();
- } catch (java.io.IOException ioe) { return -1; }
- return 1;
- }
+ /**
+ * Writes the graph's image in a file.
+ *
+ * @param img
+ * A byte array containing the image of the graph.
+ * @param file
+ * Name of the file to where we want to write.
+ * @return Success: 1, Failure: -1
+ */
+ public int writeGraphToFile(byte[] img, String file) {
+ File to = new File(file);
+ return writeGraphToFile(img, to);
+ }
- /**
- * It will call the external dot program, and return the image in
- * binary format.
- * @param dot Source of the graph (in dot language).
- * @param type Type of the output image to be produced, e.g.: gif, dot, fig, pdf, ps, svg, png.
- * @return The image of the graph in .gif format.
- */
- private byte[] get_img_stream(File dot, String type)
- {
- File img;
- byte[] img_stream = null;
+ /**
+ * Writes the graph's image in a file.
+ *
+ * @param img
+ * A byte array containing the image of the graph.
+ * @param to
+ * A File object to where we want to write.
+ * @return Success: 1, Failure: -1
+ */
+ public int writeGraphToFile(byte[] img, File to) {
+ try {
+ FileOutputStream fos = new FileOutputStream(to);
+ fos.write(img);
+ fos.close();
+ } catch (java.io.IOException ioe) {
+ return -1;
+ }
+ return 1;
+ }
- try {
- img = File.createTempFile("graph_", "."+type, new File(GraphViz.TEMP_DIR));
- Runtime rt = Runtime.getRuntime();
-
- // patch by Mike Chenault
- String[] args = {DOT, "-T"+type, dot.getAbsolutePath(), "-o", img.getAbsolutePath()};
- Process p = rt.exec(args);
-
- p.waitFor();
+ /**
+ * It will call the external dot program, and return the image in
+ * binary format.
+ *
+ * @param dot
+ * Source of the graph (in dot language).
+ * @param type
+ * Type of the output image to be produced, e.g.: gif, dot, fig, pdf, ps, svg, png.
+ * @return The image of the graph in .gif format.
+ */
+ private byte[] get_img_stream(File dot, String type) {
+ File img;
+ byte[] img_stream = null;
- FileInputStream in = new FileInputStream(img.getAbsolutePath());
- img_stream = new byte[in.available()];
- in.read(img_stream);
- // Close it if we need to
- if( in != null ) in.close();
+ try {
+ img = File.createTempFile("graph_", "." + type, new File(GraphViz.TEMP_DIR));
+ Runtime rt = Runtime.getRuntime();
- if (img.delete() == false)
- System.err.println("Warning: " + img.getAbsolutePath() + " could not be deleted!");
- }
- catch (java.io.IOException ioe) {
- System.err.println("Error: in I/O processing of tempfile in dir " + GraphViz.TEMP_DIR+"\n");
- System.err.println(" or in calling external command");
- ioe.printStackTrace();
- }
- catch (java.lang.InterruptedException ie) {
- System.err.println("Error: the execution of the external program was interrupted");
- ie.printStackTrace();
- }
+ // patch by Mike Chenault
+ String[] args = { DOT, "-T" + type, dot.getAbsolutePath(), "-o", img.getAbsolutePath() };
+ Process p = rt.exec(args);
- return img_stream;
- }
+ p.waitFor();
- /**
- * Writes the source of the graph in a file, and returns the written file
- * as a File object.
- * @param str Source of the graph (in dot language).
- * @return The file (as a File object) that contains the source of the graph.
- */
- private File writeDotSourceToFile(String str) throws java.io.IOException
- {
- File temp;
- try {
- temp = File.createTempFile("graph_", ".dot.tmp", new File(GraphViz.TEMP_DIR));
- FileWriter fout = new FileWriter(temp);
- fout.write(str);
- fout.close();
- }
- catch (Exception e) {
- System.err.println("Error: I/O error while writing the dot source to temp file!");
- return null;
- }
- return temp;
- }
+ FileInputStream in = new FileInputStream(img.getAbsolutePath());
+ img_stream = new byte[in.available()];
+ in.read(img_stream);
+ // Close it if we need to
+ if (in != null)
+ in.close();
- /**
- * Returns a string that is used to start a graph.
- * @return A string to open a graph.
- */
- public String start_graph() {
- return "digraph G {";
- }
+ if (img.delete() == false)
+ System.err.println("Warning: " + img.getAbsolutePath() + " could not be deleted!");
+ } catch (java.io.IOException ioe) {
+ System.err.println("Error: in I/O processing of tempfile in dir " + GraphViz.TEMP_DIR + "\n");
+ System.err.println(" or in calling external command");
+ ioe.printStackTrace();
+ } catch (java.lang.InterruptedException ie) {
+ System.err.println("Error: the execution of the external program was interrupted");
+ ie.printStackTrace();
+ }
- /**
- * Returns a string that is used to end a graph.
- * @return A string to close a graph.
- */
- public String end_graph() {
- return "}";
- }
+ return img_stream;
+ }
- /**
- * Read a DOT graph from a text file.
- *
- * @param input Input text file containing the DOT graph
- * source.
- */
- public void readSource(String input)
- {
- StringBuilder sb = new StringBuilder();
-
- try
- {
- FileInputStream fis = new FileInputStream(input);
- DataInputStream dis = new DataInputStream(fis);
- BufferedReader br = new BufferedReader(new InputStreamReader(dis));
- String line;
- while ((line = br.readLine()) != null) {
- sb.append(line);
- }
- dis.close();
- }
- catch (Exception e) {
- System.err.println("Error: " + e.getMessage());
- }
-
- this.graph = sb;
- }
-
+ /**
+ * Writes the source of the graph in a file, and returns the written file
+ * as a File object.
+ *
+ * @param str
+ * Source of the graph (in dot language).
+ * @return The file (as a File object) that contains the source of the graph.
+ */
+ private File writeDotSourceToFile(String str) throws java.io.IOException {
+ File temp;
+ try {
+ temp = File.createTempFile("graph_", ".dot.tmp", new File(GraphViz.TEMP_DIR));
+ FileWriter fout = new FileWriter(temp);
+ fout.write(str);
+ fout.close();
+ } catch (Exception e) {
+ System.err.println("Error: I/O error while writing the dot source to temp file!");
+ return null;
+ }
+ return temp;
+ }
+
+ /**
+ * Returns a string that is used to start a graph.
+ *
+ * @return A string to open a graph.
+ */
+ public String start_graph() {
+ return "digraph G {";
+ }
+
+ /**
+ * Returns a string that is used to end a graph.
+ *
+ * @return A string to close a graph.
+ */
+ public String end_graph() {
+ return "}";
+ }
+
+ /**
+ * Read a DOT graph from a text file.
+ *
+ * @param input
+ * Input text file containing the DOT graph
+ * source.
+ */
+ public void readSource(String input) {
+ StringBuilder sb = new StringBuilder();
+
+ try {
+ FileInputStream fis = new FileInputStream(input);
+ DataInputStream dis = new DataInputStream(fis);
+ BufferedReader br = new BufferedReader(new InputStreamReader(dis));
+ String line;
+ while ((line = br.readLine()) != null) {
+ sb.append(line);
+ }
+ dis.close();
+ } catch (Exception e) {
+ System.err.println("Error: " + e.getMessage());
+ }
+
+ this.graph = sb;
+ }
+
} // end of class GraphViz
diff --git a/genomix/genomix-pregelix/src/main/java/edu/uci/ics/genomix/pregelix/io/LogAlgorithmMessageWritable.java b/genomix/genomix-pregelix/src/main/java/edu/uci/ics/genomix/pregelix/io/LogAlgorithmMessageWritable.java
index 43759a6..fc57b74 100644
--- a/genomix/genomix-pregelix/src/main/java/edu/uci/ics/genomix/pregelix/io/LogAlgorithmMessageWritable.java
+++ b/genomix/genomix-pregelix/src/main/java/edu/uci/ics/genomix/pregelix/io/LogAlgorithmMessageWritable.java
@@ -11,143 +11,143 @@
import edu.uci.ics.genomix.type.KmerBytesWritable;
import edu.uci.ics.genomix.type.VKmerBytesWritable;
-public class LogAlgorithmMessageWritable implements WritableComparable<LogAlgorithmMessageWritable>{
- /**
- * sourceVertexId stores source vertexId when headVertex sends the message
- * stores neighber vertexValue when pathVertex sends the message
- * chainVertexId stores the chains of connected DNA
- * file stores the point to the file that stores the chains of connected DNA
- */
- private KmerBytesWritable sourceVertexId;
- private VKmerBytesWritable chainVertexId;
- private byte adjMap;
- private byte message;
-
- private byte checkMessage;
-
- public LogAlgorithmMessageWritable(){
- sourceVertexId = new VKmerBytesWritable(LogAlgorithmForPathMergeVertex.kmerSize);
- chainVertexId = new VKmerBytesWritable(LogAlgorithmForPathMergeVertex.kmerSize);
- adjMap = 0;
- message = 0;
- checkMessage = 0;
- }
-
- public void set(KmerBytesWritable sourceVertexId, VKmerBytesWritable chainVertexId, byte adjMap, byte message){
- checkMessage = 0;
- if(sourceVertexId != null){
- checkMessage |= CheckMessage.SOURCE;
- this.sourceVertexId.set(sourceVertexId);
- }
- if(chainVertexId != null){
- checkMessage |= CheckMessage.CHAIN;
- this.chainVertexId.set(chainVertexId);
- }
- if(adjMap != 0){
- checkMessage |= CheckMessage.ADJMAP;
- this.adjMap = adjMap;
- }
- this.message = message;
- }
-
- public void reset(){
- checkMessage = 0;
- chainVertexId.reset(LogAlgorithmForPathMergeVertex.kmerSize);
- adjMap = (byte)0;
- message = 0;
- }
+public class LogAlgorithmMessageWritable implements WritableComparable<LogAlgorithmMessageWritable> {
+ /**
+ * sourceVertexId stores source vertexId when headVertex sends the message
+ * stores neighber vertexValue when pathVertex sends the message
+ * chainVertexId stores the chains of connected DNA
+ * file stores the point to the file that stores the chains of connected DNA
+ */
+ private KmerBytesWritable sourceVertexId;
+ private VKmerBytesWritable chainVertexId;
+ private byte adjMap;
+ private byte message;
- public KmerBytesWritable getSourceVertexId() {
- return sourceVertexId;
- }
+ private byte checkMessage;
- public void setSourceVertexId(KmerBytesWritable sourceVertexId) {
- if(sourceVertexId != null){
- checkMessage |= CheckMessage.SOURCE;
- this.sourceVertexId.set(sourceVertexId);
- }
- }
+ public LogAlgorithmMessageWritable() {
+ sourceVertexId = new VKmerBytesWritable(LogAlgorithmForPathMergeVertex.kmerSize);
+ chainVertexId = new VKmerBytesWritable(LogAlgorithmForPathMergeVertex.kmerSize);
+ adjMap = 0;
+ message = 0;
+ checkMessage = 0;
+ }
- public byte getAdjMap() {
- return adjMap;
- }
+ public void set(KmerBytesWritable sourceVertexId, VKmerBytesWritable chainVertexId, byte adjMap, byte message) {
+ checkMessage = 0;
+ if (sourceVertexId != null) {
+ checkMessage |= CheckMessage.SOURCE;
+ this.sourceVertexId.set(sourceVertexId);
+ }
+ if (chainVertexId != null) {
+ checkMessage |= CheckMessage.CHAIN;
+ this.chainVertexId.set(chainVertexId);
+ }
+ if (adjMap != 0) {
+ checkMessage |= CheckMessage.ADJMAP;
+ this.adjMap = adjMap;
+ }
+ this.message = message;
+ }
- public void setAdjMap(byte adjMap) {
- if(adjMap != 0){
- checkMessage |= CheckMessage.ADJMAP;
- this.adjMap = adjMap;
- }
- }
+ public void reset() {
+ checkMessage = 0;
+ chainVertexId.reset(LogAlgorithmForPathMergeVertex.kmerSize);
+ adjMap = (byte) 0;
+ message = 0;
+ }
- public VKmerBytesWritable getChainVertexId() {
- return chainVertexId;
- }
+ public KmerBytesWritable getSourceVertexId() {
+ return sourceVertexId;
+ }
- public void setChainVertexId(VKmerBytesWritable chainVertexId) {
- if(chainVertexId != null){
- checkMessage |= CheckMessage.CHAIN;
- this.chainVertexId.set(chainVertexId);
- }
- }
+ public void setSourceVertexId(KmerBytesWritable sourceVertexId) {
+ if (sourceVertexId != null) {
+ checkMessage |= CheckMessage.SOURCE;
+ this.sourceVertexId.set(sourceVertexId);
+ }
+ }
- public byte getMessage() {
- return message;
- }
+ public byte getAdjMap() {
+ return adjMap;
+ }
- public void setMessage(byte message) {
- this.message = message;
- }
+ public void setAdjMap(byte adjMap) {
+ if (adjMap != 0) {
+ checkMessage |= CheckMessage.ADJMAP;
+ this.adjMap = adjMap;
+ }
+ }
- public int getLengthOfChain() {
- return chainVertexId.getKmerLength();
- }
-
- @Override
- public void write(DataOutput out) throws IOException {
- out.writeByte(checkMessage);
- if((checkMessage & CheckMessage.SOURCE) != 0)
- sourceVertexId.write(out);
- if((checkMessage & CheckMessage.CHAIN) != 0)
- chainVertexId.write(out);
- if((checkMessage & CheckMessage.ADJMAP) != 0)
- out.write(adjMap);
- out.writeByte(message);
- }
+ public VKmerBytesWritable getChainVertexId() {
+ return chainVertexId;
+ }
- @Override
- public void readFields(DataInput in) throws IOException {
- this.reset();
- checkMessage = in.readByte();
- if((checkMessage & CheckMessage.SOURCE) != 0)
- sourceVertexId.readFields(in);
- if((checkMessage & CheckMessage.CHAIN) != 0)
- chainVertexId.readFields(in);
- if((checkMessage & CheckMessage.ADJMAP) != 0)
- adjMap = in.readByte();
- message = in.readByte();
- }
+ public void setChainVertexId(VKmerBytesWritable chainVertexId) {
+ if (chainVertexId != null) {
+ checkMessage |= CheckMessage.CHAIN;
+ this.chainVertexId.set(chainVertexId);
+ }
+ }
- @Override
+ public byte getMessage() {
+ return message;
+ }
+
+ public void setMessage(byte message) {
+ this.message = message;
+ }
+
+ public int getLengthOfChain() {
+ return chainVertexId.getKmerLength();
+ }
+
+ @Override
+ public void write(DataOutput out) throws IOException {
+ out.writeByte(checkMessage);
+ if ((checkMessage & CheckMessage.SOURCE) != 0)
+ sourceVertexId.write(out);
+ if ((checkMessage & CheckMessage.CHAIN) != 0)
+ chainVertexId.write(out);
+ if ((checkMessage & CheckMessage.ADJMAP) != 0)
+ out.write(adjMap);
+ out.writeByte(message);
+ }
+
+ @Override
+ public void readFields(DataInput in) throws IOException {
+ this.reset();
+ checkMessage = in.readByte();
+ if ((checkMessage & CheckMessage.SOURCE) != 0)
+ sourceVertexId.readFields(in);
+ if ((checkMessage & CheckMessage.CHAIN) != 0)
+ chainVertexId.readFields(in);
+ if ((checkMessage & CheckMessage.ADJMAP) != 0)
+ adjMap = in.readByte();
+ message = in.readByte();
+ }
+
+ @Override
public int hashCode() {
return chainVertexId.hashCode();
}
-
+
@Override
public boolean equals(Object o) {
if (o instanceof LogAlgorithmMessageWritable) {
- LogAlgorithmMessageWritable tp = (LogAlgorithmMessageWritable) o;
+ LogAlgorithmMessageWritable tp = (LogAlgorithmMessageWritable) o;
return chainVertexId.equals(tp.chainVertexId);
}
return false;
}
-
+
@Override
public String toString() {
return chainVertexId.toString();
}
-
- @Override
- public int compareTo(LogAlgorithmMessageWritable tp) {
- return chainVertexId.compareTo(tp.chainVertexId);
- }
+
+ @Override
+ public int compareTo(LogAlgorithmMessageWritable tp) {
+ return chainVertexId.compareTo(tp.chainVertexId);
+ }
}
diff --git a/genomix/genomix-pregelix/src/main/java/edu/uci/ics/genomix/pregelix/io/NaiveAlgorithmMessageWritable.java b/genomix/genomix-pregelix/src/main/java/edu/uci/ics/genomix/pregelix/io/NaiveAlgorithmMessageWritable.java
index 6228d0c..f9574a4 100644
--- a/genomix/genomix-pregelix/src/main/java/edu/uci/ics/genomix/pregelix/io/NaiveAlgorithmMessageWritable.java
+++ b/genomix/genomix-pregelix/src/main/java/edu/uci/ics/genomix/pregelix/io/NaiveAlgorithmMessageWritable.java
@@ -12,136 +12,138 @@
import edu.uci.ics.genomix.type.KmerBytesWritable;
import edu.uci.ics.genomix.type.VKmerBytesWritable;
-public class NaiveAlgorithmMessageWritable implements WritableComparable<NaiveAlgorithmMessageWritable>{
- /**
- * sourceVertexId stores source vertexId when headVertex sends the message
- * stores neighber vertexValue when pathVertex sends the message
- * file stores the point to the file that stores the chains of connected DNA
- */
- private KmerBytesWritable sourceVertexId;
- private byte adjMap;
- private byte lastGeneCode;
- private byte message;
-
- private byte checkMessage;
-
- public NaiveAlgorithmMessageWritable(){
- sourceVertexId = new VKmerBytesWritable(NaiveAlgorithmForPathMergeVertex.kmerSize);
- adjMap = (byte)0;
- lastGeneCode = (byte)0;
- message = Message.NON;
- checkMessage = (byte)0;
- }
-
- public void set(KmerBytesWritable sourceVertex, byte adjMap, byte lastGeneCode, byte message){
- checkMessage = 0;
- if(sourceVertexId != null){
- checkMessage |= CheckMessage.SOURCE;
- this.sourceVertexId.set(sourceVertexId);
- }
- if(adjMap != 0){
- checkMessage |= CheckMessage.ADJMAP;
- this.adjMap = adjMap;
- }
- if(lastGeneCode != 0){
- checkMessage |= CheckMessage.LASTGENECODE;
- this.lastGeneCode = lastGeneCode;
- }
- this.message = message;
- }
-
- public void reset(){
- checkMessage = 0;
- adjMap = (byte)0;
- lastGeneCode = (byte)0;
- message = Message.NON;
- }
+public class NaiveAlgorithmMessageWritable implements WritableComparable<NaiveAlgorithmMessageWritable> {
+ /**
+ * sourceVertexId stores source vertexId when headVertex sends the message
+ * stores neighber vertexValue when pathVertex sends the message
+ * file stores the point to the file that stores the chains of connected DNA
+ */
+ private KmerBytesWritable sourceVertexId;
+ private byte adjMap;
+ private byte lastGeneCode;
+ private byte message;
- public KmerBytesWritable getSourceVertexId() {
- return sourceVertexId;
- }
+ private byte checkMessage;
- public void setSourceVertexId(KmerBytesWritable sourceVertexId) {
- if(sourceVertexId != null){
- checkMessage |= CheckMessage.SOURCE;
- this.sourceVertexId.set(sourceVertexId);
- }
- }
+ public NaiveAlgorithmMessageWritable() {
+ sourceVertexId = new VKmerBytesWritable(NaiveAlgorithmForPathMergeVertex.kmerSize);
+ adjMap = (byte) 0;
+ lastGeneCode = (byte) 0;
+ message = Message.NON;
+ checkMessage = (byte) 0;
+ }
- public byte getAdjMap() {
- return adjMap;
- }
+ public void set(KmerBytesWritable sourceVertex, byte adjMap, byte lastGeneCode, byte message) {
+ checkMessage = 0;
+ if (sourceVertexId != null) {
+ checkMessage |= CheckMessage.SOURCE;
+ this.sourceVertexId.set(sourceVertexId);
+ }
+ if (adjMap != 0) {
+ checkMessage |= CheckMessage.ADJMAP;
+ this.adjMap = adjMap;
+ }
+ if (lastGeneCode != 0) {
+ checkMessage |= CheckMessage.LASTGENECODE;
+ this.lastGeneCode = lastGeneCode;
+ }
+ this.message = message;
+ }
- public void setAdjMap(byte adjMap) {
- if(adjMap != 0){
- checkMessage |= CheckMessage.ADJMAP;
- this.adjMap = adjMap;
- }
- }
+ public void reset() {
+ checkMessage = 0;
+ adjMap = (byte) 0;
+ lastGeneCode = (byte) 0;
+ message = Message.NON;
+ }
- public byte getLastGeneCode() {
- return lastGeneCode;
- }
+ public KmerBytesWritable getSourceVertexId() {
+ return sourceVertexId;
+ }
- public void setLastGeneCode(byte lastGeneCode) {
- if(lastGeneCode != 0){
- checkMessage |= CheckMessage.LASTGENECODE;
- this.lastGeneCode = lastGeneCode;
- }
- }
+ public void setSourceVertexId(KmerBytesWritable sourceVertexId) {
+ if (sourceVertexId != null) {
+ checkMessage |= CheckMessage.SOURCE;
+ this.sourceVertexId.set(sourceVertexId);
+ }
+ }
- public byte getMessage() {
- return message;
- }
+ public byte getAdjMap() {
+ return adjMap;
+ }
- public void setMessage(byte message) {
- this.message = message;
- }
+ public void setAdjMap(byte adjMap) {
+ if (adjMap != 0) {
+ checkMessage |= CheckMessage.ADJMAP;
+ this.adjMap = adjMap;
+ }
+ }
- @Override
- public void write(DataOutput out) throws IOException {
- out.writeByte(checkMessage);
- if((checkMessage & CheckMessage.SOURCE) != 0)
- sourceVertexId.write(out);
- if((checkMessage & CheckMessage.ADJMAP) != 0)
- out.write(adjMap);
- if((checkMessage & CheckMessage.LASTGENECODE) != 0)
- out.write(lastGeneCode);
- out.write(message);
- }
+ public byte getLastGeneCode() {
+ return lastGeneCode;
+ }
- @Override
- public void readFields(DataInput in) throws IOException {
- this.reset();
- checkMessage = in.readByte();
- if((checkMessage & CheckMessage.SOURCE) != 0)
- sourceVertexId.readFields(in);
- if((checkMessage & CheckMessage.ADJMAP) != 0)
- adjMap = in.readByte();
- if((checkMessage & CheckMessage.LASTGENECODE) != 0)
- lastGeneCode = in.readByte();
- message = in.readByte();
- }
+ public void setLastGeneCode(byte lastGeneCode) {
+ if (lastGeneCode != 0) {
+ checkMessage |= CheckMessage.LASTGENECODE;
+ this.lastGeneCode = lastGeneCode;
+ }
+ }
+
+ public byte getMessage() {
+ return message;
+ }
+
+ public void setMessage(byte message) {
+ this.message = message;
+ }
+
+ @Override
+ public void write(DataOutput out) throws IOException {
+ out.writeByte(checkMessage);
+ if ((checkMessage & CheckMessage.SOURCE) != 0)
+ sourceVertexId.write(out);
+ if ((checkMessage & CheckMessage.ADJMAP) != 0)
+ out.write(adjMap);
+ if ((checkMessage & CheckMessage.LASTGENECODE) != 0)
+ out.write(lastGeneCode);
+ out.write(message);
+ }
+
+ @Override
+ public void readFields(DataInput in) throws IOException {
+ this.reset();
+ checkMessage = in.readByte();
+ if ((checkMessage & CheckMessage.SOURCE) != 0)
+ sourceVertexId.readFields(in);
+ if ((checkMessage & CheckMessage.ADJMAP) != 0)
+ adjMap = in.readByte();
+ if ((checkMessage & CheckMessage.LASTGENECODE) != 0)
+ lastGeneCode = in.readByte();
+ message = in.readByte();
+ }
@Override
public int hashCode() {
return sourceVertexId.hashCode();
}
+
@Override
public boolean equals(Object o) {
if (o instanceof NaiveAlgorithmMessageWritable) {
- NaiveAlgorithmMessageWritable tp = (NaiveAlgorithmMessageWritable) o;
- return sourceVertexId.equals( tp.sourceVertexId);
+ NaiveAlgorithmMessageWritable tp = (NaiveAlgorithmMessageWritable) o;
+ return sourceVertexId.equals(tp.sourceVertexId);
}
return false;
}
+
@Override
public String toString() {
return sourceVertexId.toString();
}
-
- @Override
- public int compareTo(NaiveAlgorithmMessageWritable tp) {
- return sourceVertexId.compareTo(tp.sourceVertexId);
- }
+
+ @Override
+ public int compareTo(NaiveAlgorithmMessageWritable tp) {
+ return sourceVertexId.compareTo(tp.sourceVertexId);
+ }
}
diff --git a/genomix/genomix-pregelix/src/main/java/edu/uci/ics/genomix/pregelix/io/ValueStateWritable.java b/genomix/genomix-pregelix/src/main/java/edu/uci/ics/genomix/pregelix/io/ValueStateWritable.java
index 0edc762..9a9e30f 100644
--- a/genomix/genomix-pregelix/src/main/java/edu/uci/ics/genomix/pregelix/io/ValueStateWritable.java
+++ b/genomix/genomix-pregelix/src/main/java/edu/uci/ics/genomix/pregelix/io/ValueStateWritable.java
@@ -9,87 +9,84 @@
import edu.uci.ics.genomix.type.KmerBytesWritable;
import edu.uci.ics.genomix.type.VKmerBytesWritable;
-
public class ValueStateWritable implements WritableComparable<ValueStateWritable> {
- private byte adjMap;
- private byte state;
- private VKmerBytesWritable mergeChain;
+ private byte adjMap;
+ private byte state;
+ private VKmerBytesWritable mergeChain;
- public ValueStateWritable() {
- state = State.NON_VERTEX;
- mergeChain = new VKmerBytesWritable(0);
- //isOp = false;
- }
+ public ValueStateWritable() {
+ state = State.NON_VERTEX;
+ mergeChain = new VKmerBytesWritable(0);
+ //isOp = false;
+ }
- public ValueStateWritable(byte adjMap, byte state, VKmerBytesWritable mergeChain) {
- this.adjMap = adjMap;
- this.state = state;
- this.mergeChain.set(mergeChain);
- }
-
- public void set(byte adjMap, byte state, VKmerBytesWritable mergeChain){
- this.adjMap = adjMap;
- this.state = state;
- this.mergeChain.set(mergeChain);
- }
+ public ValueStateWritable(byte adjMap, byte state, VKmerBytesWritable mergeChain) {
+ this.adjMap = adjMap;
+ this.state = state;
+ this.mergeChain.set(mergeChain);
+ }
- public byte getAdjMap() {
- return adjMap;
- }
+ public void set(byte adjMap, byte state, VKmerBytesWritable mergeChain) {
+ this.adjMap = adjMap;
+ this.state = state;
+ this.mergeChain.set(mergeChain);
+ }
- public void setAdjMap(byte adjMap) {
- this.adjMap = adjMap;
- }
+ public byte getAdjMap() {
+ return adjMap;
+ }
- public byte getState() {
- return state;
- }
+ public void setAdjMap(byte adjMap) {
+ this.adjMap = adjMap;
+ }
- public void setState(byte state) {
- this.state = state;
- }
+ public byte getState() {
+ return state;
+ }
- public int getLengthOfMergeChain() {
- return mergeChain.getKmerLength();
- }
-
- public VKmerBytesWritable getMergeChain() {
- return mergeChain;
- }
+ public void setState(byte state) {
+ this.state = state;
+ }
- public void setMergeChain(KmerBytesWritable mergeChain) {
- this.mergeChain.set(mergeChain);
- }
-
- public void setMergeChain(VKmerBytesWritable mergeChain) {
- this.mergeChain.set(mergeChain);
- }
+ public int getLengthOfMergeChain() {
+ return mergeChain.getKmerLength();
+ }
- @Override
- public void readFields(DataInput in) throws IOException {
- adjMap = in.readByte();
- state = in.readByte();
- mergeChain.readFields(in);
- }
+ public VKmerBytesWritable getMergeChain() {
+ return mergeChain;
+ }
- @Override
- public void write(DataOutput out) throws IOException {
- out.writeByte(adjMap);
- out.writeByte(state);
- mergeChain.write(out);
- }
+ public void setMergeChain(KmerBytesWritable mergeChain) {
+ this.mergeChain.set(mergeChain);
+ }
- @Override
- public int compareTo(ValueStateWritable o) {
- return 0;
- }
-
- @Override
- public String toString() {
- return GeneCode.getSymbolFromBitMap(adjMap) + "\t" +
- getLengthOfMergeChain() + "\t" +
- mergeChain.toString();
- }
-
+ public void setMergeChain(VKmerBytesWritable mergeChain) {
+ this.mergeChain.set(mergeChain);
+ }
+
+ @Override
+ public void readFields(DataInput in) throws IOException {
+ adjMap = in.readByte();
+ state = in.readByte();
+ mergeChain.readFields(in);
+ }
+
+ @Override
+ public void write(DataOutput out) throws IOException {
+ out.writeByte(adjMap);
+ out.writeByte(state);
+ mergeChain.write(out);
+ }
+
+ @Override
+ public int compareTo(ValueStateWritable o) {
+ return 0;
+ }
+
+ @Override
+ public String toString() {
+ return GeneCode.getSymbolFromBitMap(adjMap) + "\t" + getLengthOfMergeChain() + "\t" + mergeChain.toString();
+ }
+
}
diff --git a/genomix/genomix-pregelix/src/main/java/edu/uci/ics/genomix/pregelix/log/DataLoadLogFormatter.java b/genomix/genomix-pregelix/src/main/java/edu/uci/ics/genomix/pregelix/log/DataLoadLogFormatter.java
index 6105f18..ae950f4 100644
--- a/genomix/genomix-pregelix/src/main/java/edu/uci/ics/genomix/pregelix/log/DataLoadLogFormatter.java
+++ b/genomix/genomix-pregelix/src/main/java/edu/uci/ics/genomix/pregelix/log/DataLoadLogFormatter.java
@@ -7,23 +7,22 @@
import edu.uci.ics.genomix.type.KmerCountValue;
import edu.uci.ics.genomix.type.VKmerBytesWritable;
-public class DataLoadLogFormatter extends Formatter{
+public class DataLoadLogFormatter extends Formatter {
private VKmerBytesWritable key;
private KmerCountValue value;
- public void set(VKmerBytesWritable key,
- KmerCountValue value){
- this.key.set(key);
- this.value = value;
+ public void set(VKmerBytesWritable key, KmerCountValue value) {
+ this.key.set(key);
+ this.value = value;
}
- public String format(LogRecord record) {
- StringBuilder builder = new StringBuilder(1000);
-
- builder.append(key.toString()
- + "\t" + value.toString() + "\r\n");
- if(!formatMessage(record).equals(""))
- builder.append(formatMessage(record) + "\r\n");
+ public String format(LogRecord record) {
+ StringBuilder builder = new StringBuilder(1000);
+
+ builder.append(key.toString() + "\t" + value.toString() + "\r\n");
+
+ if (!formatMessage(record).equals(""))
+ builder.append(formatMessage(record) + "\r\n");
return builder.toString();
}
diff --git a/genomix/genomix-pregelix/src/main/java/edu/uci/ics/genomix/pregelix/log/LogAlgorithmLogFormatter.java b/genomix/genomix-pregelix/src/main/java/edu/uci/ics/genomix/pregelix/log/LogAlgorithmLogFormatter.java
index a615334..9eba176 100644
--- a/genomix/genomix-pregelix/src/main/java/edu/uci/ics/genomix/pregelix/log/LogAlgorithmLogFormatter.java
+++ b/genomix/genomix-pregelix/src/main/java/edu/uci/ics/genomix/pregelix/log/LogAlgorithmLogFormatter.java
@@ -8,7 +8,7 @@
import edu.uci.ics.genomix.type.VKmerBytesWritable;
public class LogAlgorithmLogFormatter extends Formatter {
- //
+ //
// Create a DateFormat to format the logger timestamp.
//
//private static final DateFormat df = new SimpleDateFormat("dd/MM/yyyy hh:mm:ss.SSS");
@@ -19,78 +19,82 @@
private byte state;
private VKmerBytesWritable mergeChain = new VKmerBytesWritable(1);;
//private boolean testDelete = false;
- /** 0: general operation
- * 1: testDelete
- * 2: testMergeChain
- * 3: testVoteToHalt
- */
- private int operation;
-
- public LogAlgorithmLogFormatter(){
+ /**
+ * 0: general operation
+ * 1: testDelete
+ * 2: testMergeChain
+ * 3: testVoteToHalt
+ */
+ private int operation;
+
+ public LogAlgorithmLogFormatter() {
}
- public void set(long step, VKmerBytesWritable sourceVertexId,
- VKmerBytesWritable destVertexId, LogAlgorithmMessageWritable msg, byte state){
- this.step = step;
- this.sourceVertexId.set(sourceVertexId);
- this.destVertexId.set(destVertexId);
- this.msg = msg;
- this.state = state;
- this.operation = 0;
+ public void set(long step, VKmerBytesWritable sourceVertexId, VKmerBytesWritable destVertexId,
+ LogAlgorithmMessageWritable msg, byte state) {
+ this.step = step;
+ this.sourceVertexId.set(sourceVertexId);
+ this.destVertexId.set(destVertexId);
+ this.msg = msg;
+ this.state = state;
+ this.operation = 0;
}
- public void setMergeChain(long step, VKmerBytesWritable sourceVertexId,
- VKmerBytesWritable mergeChain){
- this.reset();
- this.step = step;
- this.sourceVertexId.set(sourceVertexId);
- this.mergeChain.set(mergeChain);
- this.operation = 2;
+
+ public void setMergeChain(long step, VKmerBytesWritable sourceVertexId, VKmerBytesWritable mergeChain) {
+ this.reset();
+ this.step = step;
+ this.sourceVertexId.set(sourceVertexId);
+ this.mergeChain.set(mergeChain);
+ this.operation = 2;
}
- public void setVotoToHalt(long step, VKmerBytesWritable sourceVertexId){
- this.reset();
- this.step = step;
- this.sourceVertexId.set(sourceVertexId);
- this.operation = 3;
+
+ public void setVotoToHalt(long step, VKmerBytesWritable sourceVertexId) {
+ this.reset();
+ this.step = step;
+ this.sourceVertexId.set(sourceVertexId);
+ this.operation = 3;
}
- public void reset(){
- this.sourceVertexId = new VKmerBytesWritable(1);
- this.destVertexId = new VKmerBytesWritable(1);
- this.msg = new LogAlgorithmMessageWritable();
- this.state = 0;
- this.mergeChain = new VKmerBytesWritable(1);
+
+ public void reset() {
+ this.sourceVertexId = new VKmerBytesWritable(1);
+ this.destVertexId = new VKmerBytesWritable(1);
+ this.msg = new LogAlgorithmMessageWritable();
+ this.state = 0;
+ this.mergeChain = new VKmerBytesWritable(1);
}
+
public String format(LogRecord record) {
StringBuilder builder = new StringBuilder(1000);
String source = sourceVertexId.toString();
String chain = "";
-
+
builder.append("Step: " + step + "\r\n");
builder.append("Source Code: " + source + "\r\n");
- if(operation == 0){
- if(destVertexId.getKmerLength() != -1){
- String dest = destVertexId.toString();
- builder.append("Send message to " + "\r\n");
- builder.append("Destination Code: " + dest + "\r\n");
- }
- builder.append("Message is: " + Message.MESSAGE_CONTENT.getContentFromCode(msg.getMessage()) + "\r\n");
-
- if(msg.getLengthOfChain() != -1){
- chain = msg.getChainVertexId().toString();
- builder.append("Chain Message: " + chain + "\r\n");
- builder.append("Chain Length: " + msg.getLengthOfChain() + "\r\n");
- }
-
- builder.append("State is: " + State.STATE_CONTENT.getContentFromCode(state) + "\r\n");
+ if (operation == 0) {
+ if (destVertexId.getKmerLength() != -1) {
+ String dest = destVertexId.toString();
+ builder.append("Send message to " + "\r\n");
+ builder.append("Destination Code: " + dest + "\r\n");
+ }
+ builder.append("Message is: " + Message.MESSAGE_CONTENT.getContentFromCode(msg.getMessage()) + "\r\n");
+
+ if (msg.getLengthOfChain() != -1) {
+ chain = msg.getChainVertexId().toString();
+ builder.append("Chain Message: " + chain + "\r\n");
+ builder.append("Chain Length: " + msg.getLengthOfChain() + "\r\n");
+ }
+
+ builder.append("State is: " + State.STATE_CONTENT.getContentFromCode(state) + "\r\n");
}
- if(operation == 2){
- chain = mergeChain.toString();
- builder.append("Merge Chain: " + chain + "\r\n");
- builder.append("Merge Chain Length: " + mergeChain.getKmerLength() + "\r\n");
+ if (operation == 2) {
+ chain = mergeChain.toString();
+ builder.append("Merge Chain: " + chain + "\r\n");
+ builder.append("Merge Chain Length: " + mergeChain.getKmerLength() + "\r\n");
}
- if(operation == 3)
- builder.append("Vote to halt!");
- if(!formatMessage(record).equals(""))
- builder.append(formatMessage(record) + "\r\n");
+ if (operation == 3)
+ builder.append("Vote to halt!");
+ if (!formatMessage(record).equals(""))
+ builder.append(formatMessage(record) + "\r\n");
builder.append("\n");
return builder.toString();
}
@@ -102,10 +106,12 @@
public String getTail(Handler h) {
return super.getTail(h);
}
- public int getOperation() {
- return operation;
- }
- public void setOperation(int operation) {
- this.operation = operation;
- }
+
+ public int getOperation() {
+ return operation;
+ }
+
+ public void setOperation(int operation) {
+ this.operation = operation;
+ }
}
\ No newline at end of file
diff --git a/genomix/genomix-pregelix/src/main/java/edu/uci/ics/genomix/pregelix/log/NaiveAlgorithmLogFormatter.java b/genomix/genomix-pregelix/src/main/java/edu/uci/ics/genomix/pregelix/log/NaiveAlgorithmLogFormatter.java
index 5d40431..39b0bc1 100644
--- a/genomix/genomix-pregelix/src/main/java/edu/uci/ics/genomix/pregelix/log/NaiveAlgorithmLogFormatter.java
+++ b/genomix/genomix-pregelix/src/main/java/edu/uci/ics/genomix/pregelix/log/NaiveAlgorithmLogFormatter.java
@@ -5,7 +5,7 @@
import edu.uci.ics.genomix.type.VKmerBytesWritable;
public class NaiveAlgorithmLogFormatter extends Formatter {
- //
+ //
// Create a DateFormat to format the logger timestamp.
//
//private static final DateFormat df = new SimpleDateFormat("dd/MM/yyyy hh:mm:ss.SSS");
@@ -13,26 +13,26 @@
private VKmerBytesWritable sourceVertexId;
private VKmerBytesWritable destVertexId;
- public void set(long step, VKmerBytesWritable sourceVertexId,
- VKmerBytesWritable destVertexId){
- this.step = step;
- this.sourceVertexId.set(sourceVertexId);
- this.destVertexId.set(destVertexId);
+ public void set(long step, VKmerBytesWritable sourceVertexId, VKmerBytesWritable destVertexId) {
+ this.step = step;
+ this.sourceVertexId.set(sourceVertexId);
+ this.destVertexId.set(destVertexId);
}
+
public String format(LogRecord record) {
StringBuilder builder = new StringBuilder(1000);
String source = sourceVertexId.toString();
-
+
builder.append("Step: " + step + "\r\n");
builder.append("Source Code: " + source + "\r\n");
-
- if(destVertexId != null){
- builder.append("Send message to " + "\r\n");
- String dest = destVertexId.toString();
- builder.append("Destination Code: " + dest + "\r\n");
+
+ if (destVertexId != null) {
+ builder.append("Send message to " + "\r\n");
+ String dest = destVertexId.toString();
+ builder.append("Destination Code: " + dest + "\r\n");
}
- if(!formatMessage(record).equals(""))
- builder.append(formatMessage(record) + "\r\n");
+ if (!formatMessage(record).equals(""))
+ builder.append(formatMessage(record) + "\r\n");
builder.append("\n");
return builder.toString();
}
diff --git a/genomix/genomix-pregelix/src/main/java/edu/uci/ics/genomix/pregelix/operator/LogAlgorithmForPathMergeVertex.java b/genomix/genomix-pregelix/src/main/java/edu/uci/ics/genomix/pregelix/operator/LogAlgorithmForPathMergeVertex.java
index 61f70e3..b033c28 100644
--- a/genomix/genomix-pregelix/src/main/java/edu/uci/ics/genomix/pregelix/operator/LogAlgorithmForPathMergeVertex.java
+++ b/genomix/genomix-pregelix/src/main/java/edu/uci/ics/genomix/pregelix/operator/LogAlgorithmForPathMergeVertex.java
@@ -18,6 +18,7 @@
import edu.uci.ics.genomix.type.KmerBytesWritable;
import edu.uci.ics.genomix.type.VKmerBytesWritable;
import edu.uci.ics.genomix.type.VKmerBytesWritableFactory;
+
/*
* vertexId: BytesWritable
* vertexValue: ValueStateWritable
@@ -46,229 +47,230 @@
* The succeed node and precursor node will be stored in vertexValue and we don't use edgeValue.
* The details about message are in edu.uci.ics.pregelix.example.io.MessageWritable.
*/
-public class LogAlgorithmForPathMergeVertex extends Vertex<KmerBytesWritable, ValueStateWritable, NullWritable, LogAlgorithmMessageWritable>{
- public static final String KMER_SIZE = "LogAlgorithmForPathMergeVertex.kmerSize";
- public static final String ITERATIONS = "LogAlgorithmForPathMergeVertex.iteration";
- public static int kmerSize = -1;
- private int maxIteration = -1;
-
- private LogAlgorithmMessageWritable incomingMsg = new LogAlgorithmMessageWritable();
- private LogAlgorithmMessageWritable outgoingMsg = new LogAlgorithmMessageWritable();
-
- private VKmerBytesWritableFactory kmerFactory = new VKmerBytesWritableFactory(1);
- private VKmerBytesWritable chainVertexId = new VKmerBytesWritable(1);
- private VKmerBytesWritable lastKmer = new VKmerBytesWritable(1);
- /**
- * initiate kmerSize, maxIteration
- */
- public void initVertex(){
- if(kmerSize == -1)
- kmerSize = getContext().getConfiguration().getInt(KMER_SIZE, 5);
- if (maxIteration < 0)
+public class LogAlgorithmForPathMergeVertex extends
+ Vertex<KmerBytesWritable, ValueStateWritable, NullWritable, LogAlgorithmMessageWritable> {
+ public static final String KMER_SIZE = "LogAlgorithmForPathMergeVertex.kmerSize";
+ public static final String ITERATIONS = "LogAlgorithmForPathMergeVertex.iteration";
+ public static int kmerSize = -1;
+ private int maxIteration = -1;
+
+ private LogAlgorithmMessageWritable incomingMsg = new LogAlgorithmMessageWritable();
+ private LogAlgorithmMessageWritable outgoingMsg = new LogAlgorithmMessageWritable();
+
+ private VKmerBytesWritableFactory kmerFactory = new VKmerBytesWritableFactory(1);
+ private VKmerBytesWritable chainVertexId = new VKmerBytesWritable(1);
+ private VKmerBytesWritable lastKmer = new VKmerBytesWritable(1);
+
+ /**
+ * initiate kmerSize, maxIteration
+ */
+ public void initVertex() {
+ if (kmerSize == -1)
+ kmerSize = getContext().getConfiguration().getInt(KMER_SIZE, 5);
+ if (maxIteration < 0)
maxIteration = getContext().getConfiguration().getInt(ITERATIONS, 1000000);
outgoingMsg.reset();
- }
- /**
- * get destination vertex
- */
- public VKmerBytesWritable getNextDestVertexId(KmerBytesWritable vertexId, byte geneCode){
- return kmerFactory.shiftKmerWithNextCode(vertexId, geneCode);
- }
-
- public VKmerBytesWritable getPreDestVertexId(KmerBytesWritable vertexId, byte geneCode){
- return kmerFactory.shiftKmerWithPreCode(vertexId, geneCode);
- }
-
- public VKmerBytesWritable getNextDestVertexIdFromBitmap(KmerBytesWritable chainVertexId, byte adjMap){
- return getDestVertexIdFromChain(chainVertexId, adjMap);
- }
-
- public VKmerBytesWritable getDestVertexIdFromChain(KmerBytesWritable chainVertexId, byte adjMap){
- VKmerBytesWritable lastKmer = kmerFactory.getLastKmerFromChain(kmerSize, chainVertexId);
- return getNextDestVertexId(lastKmer, GeneCode.getGeneCodeFromBitMap((byte)(adjMap & 0x0F)));
- }
- /**
- * head send message to all next nodes
- */
- public void sendMsgToAllNextNodes(KmerBytesWritable vertexId, byte adjMap){
- for(byte x = GeneCode.A; x<= GeneCode.T ; x++){
- if((adjMap & (1 << x)) != 0){
- sendMsg(getNextDestVertexId(vertexId, x), outgoingMsg);
- }
- }
- }
- /**
- * head send message to all previous nodes
- */
- public void sendMsgToAllPreviousNodes(KmerBytesWritable vertexId, byte adjMap){
- for(byte x = GeneCode.A; x<= GeneCode.T ; x++){
- if(((adjMap >> 4) & (1 << x)) != 0){
- sendMsg(getPreDestVertexId(vertexId, x), outgoingMsg);
- }
- }
- }
- /**
- * start sending message
- */
- public void startSendMsg(){
- if(VertexUtil.isHeadVertex(getVertexValue().getAdjMap())){
- outgoingMsg.setMessage(Message.START);
- sendMsgToAllNextNodes(getVertexId(), getVertexValue().getAdjMap());
- voteToHalt();
- }
- if(VertexUtil.isRearVertex(getVertexValue().getAdjMap())){
- outgoingMsg.setMessage(Message.END);
- sendMsgToAllPreviousNodes(getVertexId(), getVertexValue().getAdjMap());
- voteToHalt();
- }
- }
- /**
- * initiate head, rear and path node
- */
- public void initState(Iterator<LogAlgorithmMessageWritable> msgIterator){
- while(msgIterator.hasNext()){
- if(!VertexUtil.isPathVertex(getVertexValue().getAdjMap())){
- msgIterator.next();
- voteToHalt();
- }
- else{
- incomingMsg = msgIterator.next();
- setState();
- }
- }
- }
- /**
- * set vertex state
- */
- public void setState(){
- if(incomingMsg.getMessage() == Message.START){
- getVertexValue().setState(State.START_VERTEX);
- getVertexValue().setMergeChain(null);
- }
- else if(incomingMsg.getMessage() == Message.END && getVertexValue().getState() != State.START_VERTEX){
- getVertexValue().setState(State.END_VERTEX);
- getVertexValue().setMergeChain(getVertexId());
- voteToHalt();
- }
- else
- voteToHalt();
- }
- /**
- * head send message to path
- */
- public void sendOutMsg(KmerBytesWritable chainVertexId, byte adjMap){
- if(getVertexValue().getState() == State.START_VERTEX){
- outgoingMsg.setMessage(Message.START);
- outgoingMsg.setSourceVertexId(getVertexId());
- sendMsg(getNextDestVertexIdFromBitmap(chainVertexId, adjMap), outgoingMsg);
- }
- else if(getVertexValue().getState() != State.END_VERTEX){
- outgoingMsg.setMessage(Message.NON);
- outgoingMsg.setSourceVertexId(getVertexId());
- sendMsg(getNextDestVertexIdFromBitmap(chainVertexId, adjMap), outgoingMsg);
- }
- }
- /**
- * head send message to path
- */
- public void sendMsgToPathVertex(Iterator<LogAlgorithmMessageWritable> msgIterator){
- if(getSuperstep() == 3){
- getVertexValue().setMergeChain(getVertexId());
- sendOutMsg(getVertexId(), getVertexValue().getAdjMap());
- }
- else{
- if(msgIterator.hasNext()){
- incomingMsg = msgIterator.next();
- if(mergeChainVertex(msgIterator)){
- if(incomingMsg.getMessage() == Message.END){
- if(getVertexValue().getState() == State.START_VERTEX){
- getVertexValue().setState(State.FINAL_VERTEX);
- //String source = getVertexValue().getMergeChain().toString();
- //System.out.println();
- }
- else
- getVertexValue().setState(State.END_VERTEX);
- }
- else
- sendOutMsg(getVertexValue().getMergeChain(), getVertexValue().getAdjMap());
- }
- }
- }
- }
- /**
- * path response message to head
- */
- public void responseMsgToHeadVertex(Iterator<LogAlgorithmMessageWritable> msgIterator){
- if(msgIterator.hasNext()){
- incomingMsg = msgIterator.next();
- outgoingMsg.setChainVertexId(getVertexValue().getMergeChain());
- outgoingMsg.setAdjMap(getVertexValue().getAdjMap());
- if(getVertexValue().getState() == State.END_VERTEX)
- outgoingMsg.setMessage(Message.END);
- sendMsg(incomingMsg.getSourceVertexId(),outgoingMsg);
-
- if(incomingMsg.getMessage() == Message.START)
- deleteVertex(getVertexId());
- }
- else{
- if(getVertexValue().getState() != State.START_VERTEX
- && getVertexValue().getState() != State.END_VERTEX)
- deleteVertex(getVertexId());//killSelf because it doesn't receive any message
- }
- }
- /**
- * merge chainVertex and store in vertexVal.chainVertexId
- */
- public boolean mergeChainVertex(Iterator<LogAlgorithmMessageWritable> msgIterator){
- //merge chain
- lastKmer.set(kmerFactory.getLastKmerFromChain(incomingMsg.getLengthOfChain() - kmerSize + 1,
- incomingMsg.getChainVertexId()));
- chainVertexId.set(kmerFactory.mergeTwoKmer(getVertexValue().getMergeChain(),
- lastKmer));
- if(VertexUtil.isCycle(getVertexId(), chainVertexId, kmerSize)){
- getVertexValue().setMergeChain(null);
- getVertexValue().setAdjMap(VertexUtil.reverseAdjMap(getVertexValue().getAdjMap(),
- chainVertexId.getGeneCodeAtPosition(kmerSize)));
- getVertexValue().setState(State.CYCLE);
- return false;
- }
- else
- getVertexValue().setMergeChain(chainVertexId);
-
- byte tmpVertexValue = VertexUtil.updateRightNeighber(getVertexValue().getAdjMap(),
- incomingMsg.getAdjMap());
- getVertexValue().setAdjMap(tmpVertexValue);
- return true;
- }
- @Override
- public void compute(Iterator<LogAlgorithmMessageWritable> msgIterator) {
- initVertex();
- if (getSuperstep() == 1)
- startSendMsg();
- else if(getSuperstep() == 2)
- initState(msgIterator);
- else if(getSuperstep()%2 == 1 && getSuperstep() <= maxIteration){
- sendMsgToPathVertex(msgIterator);
- voteToHalt();
- }
- else if(getSuperstep()%2 == 0 && getSuperstep() <= maxIteration){
- responseMsgToHeadVertex(msgIterator);
- voteToHalt();
- }
- else
- voteToHalt();
- }
- public static void main(String[] args) throws Exception {
+ }
+
+ /**
+ * get destination vertex
+ */
+ public VKmerBytesWritable getNextDestVertexId(KmerBytesWritable vertexId, byte geneCode) {
+ return kmerFactory.shiftKmerWithNextCode(vertexId, geneCode);
+ }
+
+ public VKmerBytesWritable getPreDestVertexId(KmerBytesWritable vertexId, byte geneCode) {
+ return kmerFactory.shiftKmerWithPreCode(vertexId, geneCode);
+ }
+
+ public VKmerBytesWritable getNextDestVertexIdFromBitmap(KmerBytesWritable chainVertexId, byte adjMap) {
+ return getDestVertexIdFromChain(chainVertexId, adjMap);
+ }
+
+ public VKmerBytesWritable getDestVertexIdFromChain(KmerBytesWritable chainVertexId, byte adjMap) {
+ VKmerBytesWritable lastKmer = kmerFactory.getLastKmerFromChain(kmerSize, chainVertexId);
+ return getNextDestVertexId(lastKmer, GeneCode.getGeneCodeFromBitMap((byte) (adjMap & 0x0F)));
+ }
+
+ /**
+ * head send message to all next nodes
+ */
+ public void sendMsgToAllNextNodes(KmerBytesWritable vertexId, byte adjMap) {
+ for (byte x = GeneCode.A; x <= GeneCode.T; x++) {
+ if ((adjMap & (1 << x)) != 0) {
+ sendMsg(getNextDestVertexId(vertexId, x), outgoingMsg);
+ }
+ }
+ }
+
+ /**
+ * head send message to all previous nodes
+ */
+ public void sendMsgToAllPreviousNodes(KmerBytesWritable vertexId, byte adjMap) {
+ for (byte x = GeneCode.A; x <= GeneCode.T; x++) {
+ if (((adjMap >> 4) & (1 << x)) != 0) {
+ sendMsg(getPreDestVertexId(vertexId, x), outgoingMsg);
+ }
+ }
+ }
+
+ /**
+ * start sending message
+ */
+ public void startSendMsg() {
+ if (VertexUtil.isHeadVertex(getVertexValue().getAdjMap())) {
+ outgoingMsg.setMessage(Message.START);
+ sendMsgToAllNextNodes(getVertexId(), getVertexValue().getAdjMap());
+ voteToHalt();
+ }
+ if (VertexUtil.isRearVertex(getVertexValue().getAdjMap())) {
+ outgoingMsg.setMessage(Message.END);
+ sendMsgToAllPreviousNodes(getVertexId(), getVertexValue().getAdjMap());
+ voteToHalt();
+ }
+ }
+
+ /**
+ * initiate head, rear and path node
+ */
+ public void initState(Iterator<LogAlgorithmMessageWritable> msgIterator) {
+ while (msgIterator.hasNext()) {
+ if (!VertexUtil.isPathVertex(getVertexValue().getAdjMap())) {
+ msgIterator.next();
+ voteToHalt();
+ } else {
+ incomingMsg = msgIterator.next();
+ setState();
+ }
+ }
+ }
+
+ /**
+ * set vertex state
+ */
+ public void setState() {
+ if (incomingMsg.getMessage() == Message.START) {
+ getVertexValue().setState(State.START_VERTEX);
+ getVertexValue().setMergeChain(null);
+ } else if (incomingMsg.getMessage() == Message.END && getVertexValue().getState() != State.START_VERTEX) {
+ getVertexValue().setState(State.END_VERTEX);
+ getVertexValue().setMergeChain(getVertexId());
+ voteToHalt();
+ } else
+ voteToHalt();
+ }
+
+ /**
+ * head send message to path
+ */
+ public void sendOutMsg(KmerBytesWritable chainVertexId, byte adjMap) {
+ if (getVertexValue().getState() == State.START_VERTEX) {
+ outgoingMsg.setMessage(Message.START);
+ outgoingMsg.setSourceVertexId(getVertexId());
+ sendMsg(getNextDestVertexIdFromBitmap(chainVertexId, adjMap), outgoingMsg);
+ } else if (getVertexValue().getState() != State.END_VERTEX) {
+ outgoingMsg.setMessage(Message.NON);
+ outgoingMsg.setSourceVertexId(getVertexId());
+ sendMsg(getNextDestVertexIdFromBitmap(chainVertexId, adjMap), outgoingMsg);
+ }
+ }
+
+ /**
+ * head send message to path
+ */
+ public void sendMsgToPathVertex(Iterator<LogAlgorithmMessageWritable> msgIterator) {
+ if (getSuperstep() == 3) {
+ getVertexValue().setMergeChain(getVertexId());
+ sendOutMsg(getVertexId(), getVertexValue().getAdjMap());
+ } else {
+ if (msgIterator.hasNext()) {
+ incomingMsg = msgIterator.next();
+ if (mergeChainVertex(msgIterator)) {
+ if (incomingMsg.getMessage() == Message.END) {
+ if (getVertexValue().getState() == State.START_VERTEX) {
+ getVertexValue().setState(State.FINAL_VERTEX);
+ //String source = getVertexValue().getMergeChain().toString();
+ //System.out.println();
+ } else
+ getVertexValue().setState(State.END_VERTEX);
+ } else
+ sendOutMsg(getVertexValue().getMergeChain(), getVertexValue().getAdjMap());
+ }
+ }
+ }
+ }
+
+ /**
+ * path response message to head
+ */
+ public void responseMsgToHeadVertex(Iterator<LogAlgorithmMessageWritable> msgIterator) {
+ if (msgIterator.hasNext()) {
+ incomingMsg = msgIterator.next();
+ outgoingMsg.setChainVertexId(getVertexValue().getMergeChain());
+ outgoingMsg.setAdjMap(getVertexValue().getAdjMap());
+ if (getVertexValue().getState() == State.END_VERTEX)
+ outgoingMsg.setMessage(Message.END);
+ sendMsg(incomingMsg.getSourceVertexId(), outgoingMsg);
+
+ if (incomingMsg.getMessage() == Message.START)
+ deleteVertex(getVertexId());
+ } else {
+ if (getVertexValue().getState() != State.START_VERTEX && getVertexValue().getState() != State.END_VERTEX)
+ deleteVertex(getVertexId());//killSelf because it doesn't receive any message
+ }
+ }
+
+ /**
+ * merge chainVertex and store in vertexVal.chainVertexId
+ */
+ public boolean mergeChainVertex(Iterator<LogAlgorithmMessageWritable> msgIterator) {
+ //merge chain
+ lastKmer.set(kmerFactory.getLastKmerFromChain(incomingMsg.getLengthOfChain() - kmerSize + 1,
+ incomingMsg.getChainVertexId()));
+ chainVertexId.set(kmerFactory.mergeTwoKmer(getVertexValue().getMergeChain(), lastKmer));
+ if (VertexUtil.isCycle(getVertexId(), chainVertexId, kmerSize)) {
+ getVertexValue().setMergeChain(null);
+ getVertexValue().setAdjMap(
+ VertexUtil.reverseAdjMap(getVertexValue().getAdjMap(),
+ chainVertexId.getGeneCodeAtPosition(kmerSize)));
+ getVertexValue().setState(State.CYCLE);
+ return false;
+ } else
+ getVertexValue().setMergeChain(chainVertexId);
+
+ byte tmpVertexValue = VertexUtil.updateRightNeighber(getVertexValue().getAdjMap(), incomingMsg.getAdjMap());
+ getVertexValue().setAdjMap(tmpVertexValue);
+ return true;
+ }
+
+ @Override
+ public void compute(Iterator<LogAlgorithmMessageWritable> msgIterator) {
+ initVertex();
+ if (getSuperstep() == 1)
+ startSendMsg();
+ else if (getSuperstep() == 2)
+ initState(msgIterator);
+ else if (getSuperstep() % 2 == 1 && getSuperstep() <= maxIteration) {
+ sendMsgToPathVertex(msgIterator);
+ voteToHalt();
+ } else if (getSuperstep() % 2 == 0 && getSuperstep() <= maxIteration) {
+ responseMsgToHeadVertex(msgIterator);
+ voteToHalt();
+ } else
+ voteToHalt();
+ }
+
+ public static void main(String[] args) throws Exception {
PregelixJob job = new PregelixJob(LogAlgorithmForPathMergeVertex.class.getSimpleName());
job.setVertexClass(LogAlgorithmForPathMergeVertex.class);
/**
* BinaryInput and BinaryOutput~/
*/
- job.setVertexInputFormatClass(LogAlgorithmForPathMergeInputFormat.class);
- job.setVertexOutputFormatClass(LogAlgorithmForPathMergeOutputFormat.class);
+ job.setVertexInputFormatClass(LogAlgorithmForPathMergeInputFormat.class);
+ job.setVertexOutputFormatClass(LogAlgorithmForPathMergeOutputFormat.class);
job.setOutputKeyClass(KmerBytesWritable.class);
job.setOutputValueClass(ValueStateWritable.class);
job.setDynamicVertexValueSize(true);
Client.run(args, job);
- }
+ }
}
diff --git a/genomix/genomix-pregelix/src/main/java/edu/uci/ics/genomix/pregelix/operator/NaiveAlgorithmForPathMergeVertex.java b/genomix/genomix-pregelix/src/main/java/edu/uci/ics/genomix/pregelix/operator/NaiveAlgorithmForPathMergeVertex.java
index 7d51670..b637f84 100644
--- a/genomix/genomix-pregelix/src/main/java/edu/uci/ics/genomix/pregelix/operator/NaiveAlgorithmForPathMergeVertex.java
+++ b/genomix/genomix-pregelix/src/main/java/edu/uci/ics/genomix/pregelix/operator/NaiveAlgorithmForPathMergeVertex.java
@@ -50,185 +50,190 @@
/**
* Naive Algorithm for path merge graph
*/
-public class NaiveAlgorithmForPathMergeVertex extends Vertex<KmerBytesWritable, ValueStateWritable, NullWritable, NaiveAlgorithmMessageWritable>{
- public static final String KMER_SIZE = "NaiveAlgorithmForPathMergeVertex.kmerSize";
- public static final String ITERATIONS = "NaiveAlgorithmForPathMergeVertex.iteration";
- public static int kmerSize = -1;
- private int maxIteration = -1;
+public class NaiveAlgorithmForPathMergeVertex extends
+ Vertex<KmerBytesWritable, ValueStateWritable, NullWritable, NaiveAlgorithmMessageWritable> {
+ public static final String KMER_SIZE = "NaiveAlgorithmForPathMergeVertex.kmerSize";
+ public static final String ITERATIONS = "NaiveAlgorithmForPathMergeVertex.iteration";
+ public static int kmerSize = -1;
+ private int maxIteration = -1;
- private NaiveAlgorithmMessageWritable incomingMsg = new NaiveAlgorithmMessageWritable();
- private NaiveAlgorithmMessageWritable outgoingMsg = new NaiveAlgorithmMessageWritable();
+ private NaiveAlgorithmMessageWritable incomingMsg = new NaiveAlgorithmMessageWritable();
+ private NaiveAlgorithmMessageWritable outgoingMsg = new NaiveAlgorithmMessageWritable();
- private VKmerBytesWritableFactory kmerFactory = new VKmerBytesWritableFactory(1);
- private VKmerBytesWritable destVertexId = new VKmerBytesWritable(1);
- /**
- * initiate kmerSize, maxIteration
- */
- public void initVertex(){
- if(kmerSize == -1)
- kmerSize = getContext().getConfiguration().getInt(KMER_SIZE, 5);
- if (maxIteration < 0)
+ private VKmerBytesWritableFactory kmerFactory = new VKmerBytesWritableFactory(1);
+ private VKmerBytesWritable destVertexId = new VKmerBytesWritable(1);
+
+ /**
+ * initiate kmerSize, maxIteration
+ */
+ public void initVertex() {
+ if (kmerSize == -1)
+ kmerSize = getContext().getConfiguration().getInt(KMER_SIZE, 5);
+ if (maxIteration < 0)
maxIteration = getContext().getConfiguration().getInt(ITERATIONS, 1000000);
outgoingMsg.reset();
- }
- /**
- * get destination vertex
- */
- public VKmerBytesWritable getDestVertexId(KmerBytesWritable vertexId, byte geneCode){
- return kmerFactory.shiftKmerWithNextCode(vertexId, geneCode);
- }
- public VKmerBytesWritable getPreDestVertexId(KmerBytesWritable vertexId, byte geneCode){
- return kmerFactory.shiftKmerWithPreCode(vertexId, geneCode);
- }
- public VKmerBytesWritable getDestVertexIdFromChain(VKmerBytesWritable chainVertexId, byte adjMap){
- VKmerBytesWritable lastKmer = kmerFactory.getLastKmerFromChain(kmerSize, chainVertexId);
- return getDestVertexId(lastKmer, GeneCode.getGeneCodeFromBitMap((byte)(adjMap & 0x0F)));
- }
- /**
- * head send message to all next nodes
- */
- public void sendMsgToAllNextNodes(KmerBytesWritable vertexId, byte adjMap){
- for(byte x = GeneCode.A; x<= GeneCode.T ; x++){
- if((adjMap & (1 << x)) != 0){
- destVertexId.set(getDestVertexId(vertexId, x));
- sendMsg(destVertexId, outgoingMsg);
- }
- }
- }
- /**
- * head send message to all previous nodes
- */
- public void sendMsgToAllPreviousNodes(KmerBytesWritable vertexId, byte adjMap){
- for(byte x = GeneCode.A; x<= GeneCode.T ; x++){
- if(((adjMap >> 4) & (1 << x)) != 0){
- destVertexId.set(getPreDestVertexId(vertexId, x));
- sendMsg(destVertexId, outgoingMsg);
- }
- }
- }
- /**
- * start sending message
- */
- public void startSendMsg(){
- if(VertexUtil.isHeadVertex(getVertexValue().getAdjMap())){
- outgoingMsg.setMessage(Message.START);
- sendMsgToAllNextNodes(getVertexId(), getVertexValue().getAdjMap());
- }
- if(VertexUtil.isRearVertex(getVertexValue().getAdjMap())){
- outgoingMsg.setMessage(Message.END);
- sendMsgToAllPreviousNodes(getVertexId(), getVertexValue().getAdjMap());
- }
- }
- /**
- * initiate head, rear and path node
- */
- public void initState(Iterator<NaiveAlgorithmMessageWritable> msgIterator){
- while(msgIterator.hasNext()){
- if(!VertexUtil.isPathVertex(getVertexValue().getAdjMap())){
- msgIterator.next();
- voteToHalt();
- }
- else{
- incomingMsg = msgIterator.next();
- setState();
- }
- }
- }
- /**
- * set vertex state
- */
- public void setState(){
- if(incomingMsg.getMessage() == Message.START){
- getVertexValue().setState(State.START_VERTEX);
- }
- else if(incomingMsg.getMessage() == Message.END
- && getVertexValue().getState() != State.START_VERTEX){
- getVertexValue().setState(State.END_VERTEX);
- voteToHalt();
- }
- else
- voteToHalt();
- }
- /**
- * head node sends message to path node
- */
- public void sendMsgToPathVertex(Iterator<NaiveAlgorithmMessageWritable> msgIterator){
- if(getSuperstep() == 3){
- getVertexValue().setMergeChain(getVertexId());
- outgoingMsg.setSourceVertexId(getVertexId());
- destVertexId.set(getDestVertexIdFromChain(getVertexValue().getMergeChain(),
- getVertexValue().getAdjMap()));
- sendMsg(destVertexId,outgoingMsg);
- }else{
- while (msgIterator.hasNext()){
- incomingMsg = msgIterator.next();
- if(incomingMsg.getMessage() != Message.STOP){
- getVertexValue().setMergeChain(kmerFactory.mergeKmerWithNextCode(getVertexValue().getMergeChain(),
- incomingMsg.getLastGeneCode()));
- outgoingMsg.setSourceVertexId(getVertexId());
- destVertexId.set(getDestVertexIdFromChain(getVertexValue().getMergeChain(),
- incomingMsg.getAdjMap()));
- sendMsg(destVertexId,outgoingMsg);
- }
- else{
- getVertexValue().setMergeChain(kmerFactory.mergeKmerWithNextCode(getVertexValue().getMergeChain(),
- incomingMsg.getLastGeneCode()));
- byte adjMap = VertexUtil.updateRightNeighber(getVertexValue().getAdjMap(),
- incomingMsg.getAdjMap());
- getVertexValue().setAdjMap(adjMap);
- getVertexValue().setState(State.FINAL_VERTEX);
- //String source = getVertexValue().getMergeChain().toString();
- //System.out.println();
- }
- }
- }
- }
- /**
- * path node sends message back to head node
- */
- public void responseMsgToHeadVertex(){
- deleteVertex(getVertexId());
- outgoingMsg.setAdjMap(getVertexValue().getAdjMap());
- outgoingMsg.setLastGeneCode(getVertexId().getGeneCodeAtPosition(kmerSize - 1));
- if(getVertexValue().getState() == State.END_VERTEX)
- outgoingMsg.setMessage(Message.STOP);
- sendMsg(incomingMsg.getSourceVertexId(),outgoingMsg);
- }
-
- @Override
- public void compute(Iterator<NaiveAlgorithmMessageWritable> msgIterator) {
- initVertex();
- if (getSuperstep() == 1) {
- startSendMsg();
- voteToHalt();
- }
- else if(getSuperstep() == 2)
- initState(msgIterator);
- else if(getSuperstep()%2 == 1 && getSuperstep() <= maxIteration){
- sendMsgToPathVertex(msgIterator);
- voteToHalt();
- }
- else if(getSuperstep()%2 == 0 && getSuperstep() > 2 && getSuperstep() <= maxIteration){
- while(msgIterator.hasNext()){
- incomingMsg = msgIterator.next();
- responseMsgToHeadVertex();
- }
- voteToHalt();
- }
- else
- voteToHalt();
- }
- public static void main(String[] args) throws Exception {
+ }
+
+ /**
+ * get destination vertex
+ */
+ public VKmerBytesWritable getDestVertexId(KmerBytesWritable vertexId, byte geneCode) {
+ return kmerFactory.shiftKmerWithNextCode(vertexId, geneCode);
+ }
+
+ public VKmerBytesWritable getPreDestVertexId(KmerBytesWritable vertexId, byte geneCode) {
+ return kmerFactory.shiftKmerWithPreCode(vertexId, geneCode);
+ }
+
+ public VKmerBytesWritable getDestVertexIdFromChain(VKmerBytesWritable chainVertexId, byte adjMap) {
+ VKmerBytesWritable lastKmer = kmerFactory.getLastKmerFromChain(kmerSize, chainVertexId);
+ return getDestVertexId(lastKmer, GeneCode.getGeneCodeFromBitMap((byte) (adjMap & 0x0F)));
+ }
+
+ /**
+ * head send message to all next nodes
+ */
+ public void sendMsgToAllNextNodes(KmerBytesWritable vertexId, byte adjMap) {
+ for (byte x = GeneCode.A; x <= GeneCode.T; x++) {
+ if ((adjMap & (1 << x)) != 0) {
+ destVertexId.set(getDestVertexId(vertexId, x));
+ sendMsg(destVertexId, outgoingMsg);
+ }
+ }
+ }
+
+ /**
+ * head send message to all previous nodes
+ */
+ public void sendMsgToAllPreviousNodes(KmerBytesWritable vertexId, byte adjMap) {
+ for (byte x = GeneCode.A; x <= GeneCode.T; x++) {
+ if (((adjMap >> 4) & (1 << x)) != 0) {
+ destVertexId.set(getPreDestVertexId(vertexId, x));
+ sendMsg(destVertexId, outgoingMsg);
+ }
+ }
+ }
+
+ /**
+ * start sending message
+ */
+ public void startSendMsg() {
+ if (VertexUtil.isHeadVertex(getVertexValue().getAdjMap())) {
+ outgoingMsg.setMessage(Message.START);
+ sendMsgToAllNextNodes(getVertexId(), getVertexValue().getAdjMap());
+ }
+ if (VertexUtil.isRearVertex(getVertexValue().getAdjMap())) {
+ outgoingMsg.setMessage(Message.END);
+ sendMsgToAllPreviousNodes(getVertexId(), getVertexValue().getAdjMap());
+ }
+ }
+
+ /**
+ * initiate head, rear and path node
+ */
+ public void initState(Iterator<NaiveAlgorithmMessageWritable> msgIterator) {
+ while (msgIterator.hasNext()) {
+ if (!VertexUtil.isPathVertex(getVertexValue().getAdjMap())) {
+ msgIterator.next();
+ voteToHalt();
+ } else {
+ incomingMsg = msgIterator.next();
+ setState();
+ }
+ }
+ }
+
+ /**
+ * set vertex state
+ */
+ public void setState() {
+ if (incomingMsg.getMessage() == Message.START) {
+ getVertexValue().setState(State.START_VERTEX);
+ } else if (incomingMsg.getMessage() == Message.END && getVertexValue().getState() != State.START_VERTEX) {
+ getVertexValue().setState(State.END_VERTEX);
+ voteToHalt();
+ } else
+ voteToHalt();
+ }
+
+ /**
+ * head node sends message to path node
+ */
+ public void sendMsgToPathVertex(Iterator<NaiveAlgorithmMessageWritable> msgIterator) {
+ if (getSuperstep() == 3) {
+ getVertexValue().setMergeChain(getVertexId());
+ outgoingMsg.setSourceVertexId(getVertexId());
+ destVertexId.set(getDestVertexIdFromChain(getVertexValue().getMergeChain(), getVertexValue().getAdjMap()));
+ sendMsg(destVertexId, outgoingMsg);
+ } else {
+ while (msgIterator.hasNext()) {
+ incomingMsg = msgIterator.next();
+ if (incomingMsg.getMessage() != Message.STOP) {
+ getVertexValue().setMergeChain(
+ kmerFactory.mergeKmerWithNextCode(getVertexValue().getMergeChain(),
+ incomingMsg.getLastGeneCode()));
+ outgoingMsg.setSourceVertexId(getVertexId());
+ destVertexId
+ .set(getDestVertexIdFromChain(getVertexValue().getMergeChain(), incomingMsg.getAdjMap()));
+ sendMsg(destVertexId, outgoingMsg);
+ } else {
+ getVertexValue().setMergeChain(
+ kmerFactory.mergeKmerWithNextCode(getVertexValue().getMergeChain(),
+ incomingMsg.getLastGeneCode()));
+ byte adjMap = VertexUtil.updateRightNeighber(getVertexValue().getAdjMap(), incomingMsg.getAdjMap());
+ getVertexValue().setAdjMap(adjMap);
+ getVertexValue().setState(State.FINAL_VERTEX);
+ //String source = getVertexValue().getMergeChain().toString();
+ //System.out.println();
+ }
+ }
+ }
+ }
+
+ /**
+ * path node sends message back to head node
+ */
+ public void responseMsgToHeadVertex() {
+ deleteVertex(getVertexId());
+ outgoingMsg.setAdjMap(getVertexValue().getAdjMap());
+ outgoingMsg.setLastGeneCode(getVertexId().getGeneCodeAtPosition(kmerSize - 1));
+ if (getVertexValue().getState() == State.END_VERTEX)
+ outgoingMsg.setMessage(Message.STOP);
+ sendMsg(incomingMsg.getSourceVertexId(), outgoingMsg);
+ }
+
+ @Override
+ public void compute(Iterator<NaiveAlgorithmMessageWritable> msgIterator) {
+ initVertex();
+ if (getSuperstep() == 1) {
+ startSendMsg();
+ voteToHalt();
+ } else if (getSuperstep() == 2)
+ initState(msgIterator);
+ else if (getSuperstep() % 2 == 1 && getSuperstep() <= maxIteration) {
+ sendMsgToPathVertex(msgIterator);
+ voteToHalt();
+ } else if (getSuperstep() % 2 == 0 && getSuperstep() > 2 && getSuperstep() <= maxIteration) {
+ while (msgIterator.hasNext()) {
+ incomingMsg = msgIterator.next();
+ responseMsgToHeadVertex();
+ }
+ voteToHalt();
+ } else
+ voteToHalt();
+ }
+
+ public static void main(String[] args) throws Exception {
PregelixJob job = new PregelixJob(NaiveAlgorithmForPathMergeVertex.class.getSimpleName());
job.setVertexClass(NaiveAlgorithmForPathMergeVertex.class);
/**
* BinaryInput and BinaryOutput
*/
- job.setVertexInputFormatClass(NaiveAlgorithmForPathMergeInputFormat.class);
- job.setVertexOutputFormatClass(NaiveAlgorithmForPathMergeOutputFormat.class);
+ job.setVertexInputFormatClass(NaiveAlgorithmForPathMergeInputFormat.class);
+ job.setVertexOutputFormatClass(NaiveAlgorithmForPathMergeOutputFormat.class);
job.setDynamicVertexValueSize(true);
job.setOutputKeyClass(KmerBytesWritable.class);
job.setOutputValueClass(ValueStateWritable.class);
Client.run(args, job);
- }
+ }
}
diff --git a/genomix/genomix-pregelix/src/main/java/edu/uci/ics/genomix/pregelix/sequencefile/CombineSequenceFile.java b/genomix/genomix-pregelix/src/main/java/edu/uci/ics/genomix/pregelix/sequencefile/CombineSequenceFile.java
index 84d846e..7a50537 100644
--- a/genomix/genomix-pregelix/src/main/java/edu/uci/ics/genomix/pregelix/sequencefile/CombineSequenceFile.java
+++ b/genomix/genomix-pregelix/src/main/java/edu/uci/ics/genomix/pregelix/sequencefile/CombineSequenceFile.java
@@ -13,47 +13,44 @@
public class CombineSequenceFile {
- /**
- * @param args
- * @throws Exception
- */
- public static void main(String[] args) throws Exception {
- // TODO Auto-generated method stub
- int kmerSize = 5;
- Configuration conf = new Configuration();
- FileSystem fileSys = FileSystem.get(conf);
-
- Path p = new Path("graphbuildresult/CyclePath2_result");
- //Path p2 = new Path("data/result");
- Path outFile = new Path("here");
- SequenceFile.Reader reader;
- SequenceFile.Writer writer = SequenceFile.createWriter(fileSys, conf,
- outFile, KmerBytesWritable.class, KmerCountValue.class,
- CompressionType.NONE);
- KmerBytesWritable key = new KmerBytesWritable(kmerSize);
- KmerCountValue value = new KmerCountValue();
-
- File dir = new File("graphbuildresult/CyclePath2_result");
- for(File child : dir.listFiles()){
- String name = child.getAbsolutePath();
- Path inFile = new Path(p, name);
- reader = new SequenceFile.Reader(fileSys, inFile, conf);
- while (reader.next(key, value)) {
- System.out.println(key.toString()
- + "\t" + value.toString());
- writer.append(key, value);
- }
- reader.close();
- }
- writer.close();
- System.out.println();
-
- reader = new SequenceFile.Reader(fileSys, outFile, conf);
- while (reader.next(key, value)) {
- System.err.println(key.toString()
- + "\t" + value.toString());
- }
- reader.close();
- }
+ /**
+ * @param args
+ * @throws Exception
+ */
+ public static void main(String[] args) throws Exception {
+ // TODO Auto-generated method stub
+ int kmerSize = 5;
+ Configuration conf = new Configuration();
+ FileSystem fileSys = FileSystem.get(conf);
+
+ Path p = new Path("graphbuildresult/CyclePath2_result");
+ //Path p2 = new Path("data/result");
+ Path outFile = new Path("here");
+ SequenceFile.Reader reader;
+ SequenceFile.Writer writer = SequenceFile.createWriter(fileSys, conf, outFile, KmerBytesWritable.class,
+ KmerCountValue.class, CompressionType.NONE);
+ KmerBytesWritable key = new KmerBytesWritable(kmerSize);
+ KmerCountValue value = new KmerCountValue();
+
+ File dir = new File("graphbuildresult/CyclePath2_result");
+ for (File child : dir.listFiles()) {
+ String name = child.getAbsolutePath();
+ Path inFile = new Path(p, name);
+ reader = new SequenceFile.Reader(fileSys, inFile, conf);
+ while (reader.next(key, value)) {
+ System.out.println(key.toString() + "\t" + value.toString());
+ writer.append(key, value);
+ }
+ reader.close();
+ }
+ writer.close();
+ System.out.println();
+
+ reader = new SequenceFile.Reader(fileSys, outFile, conf);
+ while (reader.next(key, value)) {
+ System.err.println(key.toString() + "\t" + value.toString());
+ }
+ reader.close();
+ }
}
diff --git a/genomix/genomix-pregelix/src/main/java/edu/uci/ics/genomix/pregelix/sequencefile/ConvertToSequenceFile.java b/genomix/genomix-pregelix/src/main/java/edu/uci/ics/genomix/pregelix/sequencefile/ConvertToSequenceFile.java
index d64b279..2a7d668 100644
--- a/genomix/genomix-pregelix/src/main/java/edu/uci/ics/genomix/pregelix/sequencefile/ConvertToSequenceFile.java
+++ b/genomix/genomix-pregelix/src/main/java/edu/uci/ics/genomix/pregelix/sequencefile/ConvertToSequenceFile.java
@@ -13,30 +13,29 @@
import org.apache.hadoop.mapreduce.lib.output.SequenceFileOutputFormat;
public class ConvertToSequenceFile {
- public static void main(String[] args) throws IOException,
- InterruptedException, ClassNotFoundException {
+ public static void main(String[] args) throws IOException, InterruptedException, ClassNotFoundException {
- Configuration conf = new Configuration();
- Job job = new Job(conf);
- job.setJobName("Convert Text");
- job.setJarByClass(Mapper.class);
-
- job.setMapperClass(Mapper.class);
- job.setReducerClass(Reducer.class);
-
- // increase if you need sorting or a special number of files
- job.setNumReduceTasks(0);
-
- job.setOutputKeyClass(LongWritable.class);
- job.setOutputValueClass(Text.class);
-
- job.setOutputFormatClass(SequenceFileOutputFormat.class);
- job.setInputFormatClass(TextInputFormat.class);
-
- TextInputFormat.addInputPath(job, new Path("data/webmap/part-00000"));
- SequenceFileOutputFormat.setOutputPath(job, new Path("folder_seq"));
-
- // submit and wait for completion
- job.waitForCompletion(true);
- }
+ Configuration conf = new Configuration();
+ Job job = new Job(conf);
+ job.setJobName("Convert Text");
+ job.setJarByClass(Mapper.class);
+
+ job.setMapperClass(Mapper.class);
+ job.setReducerClass(Reducer.class);
+
+ // increase if you need sorting or a special number of files
+ job.setNumReduceTasks(0);
+
+ job.setOutputKeyClass(LongWritable.class);
+ job.setOutputValueClass(Text.class);
+
+ job.setOutputFormatClass(SequenceFileOutputFormat.class);
+ job.setInputFormatClass(TextInputFormat.class);
+
+ TextInputFormat.addInputPath(job, new Path("data/webmap/part-00000"));
+ SequenceFileOutputFormat.setOutputPath(job, new Path("folder_seq"));
+
+ // submit and wait for completion
+ job.waitForCompletion(true);
+ }
}
diff --git a/genomix/genomix-pregelix/src/main/java/edu/uci/ics/genomix/pregelix/sequencefile/GenerateSmallFile.java b/genomix/genomix-pregelix/src/main/java/edu/uci/ics/genomix/pregelix/sequencefile/GenerateSmallFile.java
index 6ae2e30..85649b3 100644
--- a/genomix/genomix-pregelix/src/main/java/edu/uci/ics/genomix/pregelix/sequencefile/GenerateSmallFile.java
+++ b/genomix/genomix-pregelix/src/main/java/edu/uci/ics/genomix/pregelix/sequencefile/GenerateSmallFile.java
@@ -18,81 +18,79 @@
public class GenerateSmallFile {
- public static void generateNumOfLinesFromGraphBuildResuiltBigFile(
- Path inFile, Path outFile, int numOfLines) throws IOException {
- Configuration conf = new Configuration();
- FileSystem fileSys = FileSystem.get(conf);
+ public static void generateNumOfLinesFromGraphBuildResuiltBigFile(Path inFile, Path outFile, int numOfLines)
+ throws IOException {
+ Configuration conf = new Configuration();
+ FileSystem fileSys = FileSystem.get(conf);
- SequenceFile.Reader reader = new SequenceFile.Reader(fileSys, inFile,
- conf);
- SequenceFile.Writer writer = SequenceFile.createWriter(fileSys, conf,
- outFile, KmerBytesWritable.class, KmerCountValue.class,
- CompressionType.NONE);
- KmerBytesWritable outKey = new KmerBytesWritable(55);
- KmerCountValue outValue = new KmerCountValue();
- int i = 0;
+ SequenceFile.Reader reader = new SequenceFile.Reader(fileSys, inFile, conf);
+ SequenceFile.Writer writer = SequenceFile.createWriter(fileSys, conf, outFile, KmerBytesWritable.class,
+ KmerCountValue.class, CompressionType.NONE);
+ KmerBytesWritable outKey = new KmerBytesWritable(55);
+ KmerCountValue outValue = new KmerCountValue();
+ int i = 0;
- for (i = 0; i < numOfLines; i++) {
- // System.out.println(i);
- reader.next(outKey, outValue);
- writer.append(outKey, outValue);
- }
- writer.close();
- reader.close();
- }
+ for (i = 0; i < numOfLines; i++) {
+ // System.out.println(i);
+ reader.next(outKey, outValue);
+ writer.append(outKey, outValue);
+ }
+ writer.close();
+ reader.close();
+ }
- public static void generateNumOfLinesFromGraphBuildResuiltBigFile(
- String inFile, String outFile, int numOfLines) throws IOException {
- String lines = readTextFile(inFile, numOfLines);
- writeTextFile(outFile, lines);
- }
+ public static void generateNumOfLinesFromGraphBuildResuiltBigFile(String inFile, String outFile, int numOfLines)
+ throws IOException {
+ String lines = readTextFile(inFile, numOfLines);
+ writeTextFile(outFile, lines);
+ }
- public static void main(String[] args) throws IOException {
- /*Path dir = new Path("data/test8m");
- Path outDir = new Path("data/input/test");
- FileUtils.cleanDirectory(new File("data/input/test"));
- Path inFile = new Path(dir, "part-0");
- Path outFile = new Path(outDir, "part-0-out-100");
- generateNumOfLinesFromGraphBuildResuiltBigFile(inFile, outFile, 100);*/
- String inFile = "data/shortjump_1.head8M.fastq";
- String outFile = "data/testGeneFile";
- generateNumOfLinesFromGraphBuildResuiltBigFile(inFile, outFile, 100000);
- }
+ public static void main(String[] args) throws IOException {
+ /*Path dir = new Path("data/test8m");
+ Path outDir = new Path("data/input/test");
+ FileUtils.cleanDirectory(new File("data/input/test"));
+ Path inFile = new Path(dir, "part-0");
+ Path outFile = new Path(outDir, "part-0-out-100");
+ generateNumOfLinesFromGraphBuildResuiltBigFile(inFile, outFile, 100);*/
+ String inFile = "data/shortjump_1.head8M.fastq";
+ String outFile = "data/testGeneFile";
+ generateNumOfLinesFromGraphBuildResuiltBigFile(inFile, outFile, 100000);
+ }
- public static String readTextFile(String fileName, int numOfLines) {
- String returnValue = "";
- FileReader file;
- String line = "";
- try {
- file = new FileReader(fileName);
- BufferedReader reader = new BufferedReader(file);
- try {
- while ((numOfLines > 0) && (line = reader.readLine()) != null) {
- returnValue += line + "\n";
- numOfLines--;
- }
- } finally {
- reader.close();
- }
- } catch (FileNotFoundException e) {
- throw new RuntimeException("File not found");
- } catch (IOException e) {
- throw new RuntimeException("IO Error occured");
- }
- return returnValue;
+ public static String readTextFile(String fileName, int numOfLines) {
+ String returnValue = "";
+ FileReader file;
+ String line = "";
+ try {
+ file = new FileReader(fileName);
+ BufferedReader reader = new BufferedReader(file);
+ try {
+ while ((numOfLines > 0) && (line = reader.readLine()) != null) {
+ returnValue += line + "\n";
+ numOfLines--;
+ }
+ } finally {
+ reader.close();
+ }
+ } catch (FileNotFoundException e) {
+ throw new RuntimeException("File not found");
+ } catch (IOException e) {
+ throw new RuntimeException("IO Error occured");
+ }
+ return returnValue;
- }
+ }
- public static void writeTextFile(String fileName, String s) {
- FileWriter output;
- try {
- output = new FileWriter(fileName);
- BufferedWriter writer = new BufferedWriter(output);
- writer.write(s);
- writer.close();
- } catch (IOException e) {
- e.printStackTrace();
- }
+ public static void writeTextFile(String fileName, String s) {
+ FileWriter output;
+ try {
+ output = new FileWriter(fileName);
+ BufferedWriter writer = new BufferedWriter(output);
+ writer.write(s);
+ writer.close();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
- }
+ }
}
diff --git a/genomix/genomix-pregelix/src/main/java/edu/uci/ics/genomix/pregelix/sequencefile/GenerateTextFile.java b/genomix/genomix-pregelix/src/main/java/edu/uci/ics/genomix/pregelix/sequencefile/GenerateTextFile.java
index 026bba2..517b9c3 100644
--- a/genomix/genomix-pregelix/src/main/java/edu/uci/ics/genomix/pregelix/sequencefile/GenerateTextFile.java
+++ b/genomix/genomix-pregelix/src/main/java/edu/uci/ics/genomix/pregelix/sequencefile/GenerateTextFile.java
@@ -19,107 +19,108 @@
public class GenerateTextFile {
- public static void generateFromPathmergeResult(int kmerSize, String strSrcDir, String outPutDir) throws IOException{
- Configuration conf = new Configuration();
- FileSystem fileSys = FileSystem.getLocal(conf);
-
- fileSys.create(new Path(outPutDir));
- BufferedWriter bw = new BufferedWriter(new FileWriter(outPutDir));
- File srcPath = new File(strSrcDir);
- for(File f : srcPath.listFiles((FilenameFilter)(new WildcardFileFilter("part*")))){
- SequenceFile.Reader reader = new SequenceFile.Reader(fileSys, new Path(f.getAbsolutePath()), conf);
- KmerBytesWritable key = new KmerBytesWritable(kmerSize);
- ValueStateWritable value = new ValueStateWritable();
-
- while(reader.next(key, value)){
- if (key == null || value == null){
- break;
- }
- bw.write(key.toString()
- + "\t" + value.toString());
- bw.newLine();
- }
- reader.close();
- }
- bw.close();
- }
- public static void generateSpecificLengthChainFromNaivePathmergeResult(int maxLength) throws IOException{
- BufferedWriter bw = new BufferedWriter(new FileWriter("naive_text_" + maxLength));
- Configuration conf = new Configuration();
- FileSystem fileSys = FileSystem.get(conf);
- for(int i = 0; i < 2; i++){
- Path path = new Path("/home/anbangx/genomix_result/final_naive/part-" + i);
- SequenceFile.Reader reader = new SequenceFile.Reader(fileSys, path, conf);
- KmerBytesWritable key = new KmerBytesWritable(55);
- ValueStateWritable value = new ValueStateWritable();
-
- while(reader.next(key, value)){
- if (key == null || value == null){
- break;
- }
- if(value.getLengthOfMergeChain() != -1 && value.getLengthOfMergeChain() <= maxLength){
- bw.write(value.toString());
- bw.newLine();
- }
- }
- reader.close();
- }
- bw.close();
- }
-
- public static void generateSpecificLengthChainFromLogPathmergeResult(int maxLength) throws IOException{
- BufferedWriter bw = new BufferedWriter(new FileWriter("log_text_" + maxLength));
- Configuration conf = new Configuration();
- FileSystem fileSys = FileSystem.get(conf);
- for(int i = 0; i < 2; i++){
- Path path = new Path("/home/anbangx/genomix_result/improvelog2/part-" + i);
- SequenceFile.Reader reader = new SequenceFile.Reader(fileSys, path, conf);
- KmerBytesWritable key = new KmerBytesWritable(55);
- ValueStateWritable value = new ValueStateWritable();
-
- while(reader.next(key, value)){
- if (key == null || value == null){
- break;
- }
- if(value.getLengthOfMergeChain() != -1 && value.getLengthOfMergeChain() <= maxLength
- && value.getState() == State.FINAL_VERTEX){
- bw.write(key.toString()
- + "\t" + value.toString());
- bw.newLine();
- }
- }
- reader.close();
- }
- bw.close();
- }
- public static void generateFromGraphbuildResult() throws IOException{
- BufferedWriter bw = new BufferedWriter(new FileWriter("textfile"));
- Configuration conf = new Configuration();
- FileSystem fileSys = FileSystem.get(conf);
- Path path = new Path("data/input/part-0-out-3000000");
- SequenceFile.Reader reader = new SequenceFile.Reader(fileSys, path, conf);
- KmerBytesWritable key = new KmerBytesWritable(55);
- KmerCountValue value = new KmerCountValue();
-
- while(reader.next(key, value)){
- if (key == null || value == null){
- break;
- }
- bw.write(key.toString());
- bw.newLine();
- }
- reader.close();
- bw.close();
- }
- /**
- * @param args
- * @throws IOException
- */
- public static void main(String[] args) throws IOException {
- //generateFromPathmergeResult();
- //generateFromGraphbuildResult();
- //generateSpecificLengthChainFromPathmergeResult(68);
- //generateSpecificLengthChainFromLogPathmergeResult(68);
- }
+ public static void generateFromPathmergeResult(int kmerSize, String strSrcDir, String outPutDir) throws IOException {
+ Configuration conf = new Configuration();
+ FileSystem fileSys = FileSystem.getLocal(conf);
+
+ fileSys.create(new Path(outPutDir));
+ BufferedWriter bw = new BufferedWriter(new FileWriter(outPutDir));
+ File srcPath = new File(strSrcDir);
+ for (File f : srcPath.listFiles((FilenameFilter) (new WildcardFileFilter("part*")))) {
+ SequenceFile.Reader reader = new SequenceFile.Reader(fileSys, new Path(f.getAbsolutePath()), conf);
+ KmerBytesWritable key = new KmerBytesWritable(kmerSize);
+ ValueStateWritable value = new ValueStateWritable();
+
+ while (reader.next(key, value)) {
+ if (key == null || value == null) {
+ break;
+ }
+ bw.write(key.toString() + "\t" + value.toString());
+ bw.newLine();
+ }
+ reader.close();
+ }
+ bw.close();
+ }
+
+ public static void generateSpecificLengthChainFromNaivePathmergeResult(int maxLength) throws IOException {
+ BufferedWriter bw = new BufferedWriter(new FileWriter("naive_text_" + maxLength));
+ Configuration conf = new Configuration();
+ FileSystem fileSys = FileSystem.get(conf);
+ for (int i = 0; i < 2; i++) {
+ Path path = new Path("/home/anbangx/genomix_result/final_naive/part-" + i);
+ SequenceFile.Reader reader = new SequenceFile.Reader(fileSys, path, conf);
+ KmerBytesWritable key = new KmerBytesWritable(55);
+ ValueStateWritable value = new ValueStateWritable();
+
+ while (reader.next(key, value)) {
+ if (key == null || value == null) {
+ break;
+ }
+ if (value.getLengthOfMergeChain() != -1 && value.getLengthOfMergeChain() <= maxLength) {
+ bw.write(value.toString());
+ bw.newLine();
+ }
+ }
+ reader.close();
+ }
+ bw.close();
+ }
+
+ public static void generateSpecificLengthChainFromLogPathmergeResult(int maxLength) throws IOException {
+ BufferedWriter bw = new BufferedWriter(new FileWriter("log_text_" + maxLength));
+ Configuration conf = new Configuration();
+ FileSystem fileSys = FileSystem.get(conf);
+ for (int i = 0; i < 2; i++) {
+ Path path = new Path("/home/anbangx/genomix_result/improvelog2/part-" + i);
+ SequenceFile.Reader reader = new SequenceFile.Reader(fileSys, path, conf);
+ KmerBytesWritable key = new KmerBytesWritable(55);
+ ValueStateWritable value = new ValueStateWritable();
+
+ while (reader.next(key, value)) {
+ if (key == null || value == null) {
+ break;
+ }
+ if (value.getLengthOfMergeChain() != -1 && value.getLengthOfMergeChain() <= maxLength
+ && value.getState() == State.FINAL_VERTEX) {
+ bw.write(key.toString() + "\t" + value.toString());
+ bw.newLine();
+ }
+ }
+ reader.close();
+ }
+ bw.close();
+ }
+
+ public static void generateFromGraphbuildResult() throws IOException {
+ BufferedWriter bw = new BufferedWriter(new FileWriter("textfile"));
+ Configuration conf = new Configuration();
+ FileSystem fileSys = FileSystem.get(conf);
+ Path path = new Path("data/input/part-0-out-3000000");
+ SequenceFile.Reader reader = new SequenceFile.Reader(fileSys, path, conf);
+ KmerBytesWritable key = new KmerBytesWritable(55);
+ KmerCountValue value = new KmerCountValue();
+
+ while (reader.next(key, value)) {
+ if (key == null || value == null) {
+ break;
+ }
+ bw.write(key.toString());
+ bw.newLine();
+ }
+ reader.close();
+ bw.close();
+ }
+
+ /**
+ * @param args
+ * @throws IOException
+ */
+ public static void main(String[] args) throws IOException {
+ //generateFromPathmergeResult();
+ //generateFromGraphbuildResult();
+ //generateSpecificLengthChainFromPathmergeResult(68);
+ //generateSpecificLengthChainFromLogPathmergeResult(68);
+ }
}
diff --git a/genomix/genomix-pregelix/src/main/java/edu/uci/ics/genomix/pregelix/testcase/GenerateTestInput.java b/genomix/genomix-pregelix/src/main/java/edu/uci/ics/genomix/pregelix/testcase/GenerateTestInput.java
index 0709249..f30512c 100644
--- a/genomix/genomix-pregelix/src/main/java/edu/uci/ics/genomix/pregelix/testcase/GenerateTestInput.java
+++ b/genomix/genomix-pregelix/src/main/java/edu/uci/ics/genomix/pregelix/testcase/GenerateTestInput.java
@@ -6,72 +6,75 @@
public class GenerateTestInput {
- /**
- * Simple Path
- */
- public static String simplePath(int k, int length, int numLines){
- RandomString rs = new RandomString(k, length);
- String output = "";
- for(int i = 0; i < numLines; i++)
- output += rs.nextString(0) + "\r\n";
- return output;
- }
- /**
- * Tree Path
- */
- public static String treePath(int k, int x, int y, int z){
- RandomString rs = new RandomString(k, x + y + k - 1);
- String s1 = rs.nextString(0);
- rs.setLength(x + y + z + k - 1);
- rs.addString(s1.substring(0, x));
- String s2 = rs.nextString(x);
- rs.setLength(x + y + z + k - 1);
- rs.addString(s2.substring(0,x + y));
- String s3 = rs.nextString(x + y);
- return s1 + "\r\n" + s2 + "\r\n" + s3;
- }
- /**
- * Cycle Path
- */
- public static String cyclePath(int k, int length){
- RandomString rs = new RandomString(k, length);
- String s1 = rs.nextString(0);
- String s2 = s1 + s1.substring(1, k + 1);
- return s2;
- }
- /**
- * Bridge Path
- */
- public static String bridgePath(int k, int x){
- RandomString rs = new RandomString(k, x + k + 2 + k - 1);
- String s1 = rs.nextString(0);
- rs.setLength(x + k + 2);
- rs.addString(s1.substring(0, k + 2));
- String s2 = rs.nextString(k + 2) + s1.substring(x + k + 2, x + k + 2 + k - 1);
- return s1 + "\r\n" + s2;
- }
+ /**
+ * Simple Path
+ */
+ public static String simplePath(int k, int length, int numLines) {
+ RandomString rs = new RandomString(k, length);
+ String output = "";
+ for (int i = 0; i < numLines; i++)
+ output += rs.nextString(0) + "\r\n";
+ return output;
+ }
- public static void main(String[] args) {
- // TODO Auto-generated method stub
- OutputStreamWriter writer;
- try {
- writer = new OutputStreamWriter(new FileOutputStream("graph/7/SinglePath"));
- writer.write(simplePath(7,10,1));
- writer.close();
- writer = new OutputStreamWriter(new FileOutputStream("graph/7/SimplePath"));
- writer.write(simplePath(7,10,3));
- writer.close();
- writer = new OutputStreamWriter(new FileOutputStream("graph/7/TreePath"));
- writer.write(treePath(7, 7, 7, 7));
- writer.close();
- writer = new OutputStreamWriter(new FileOutputStream("graph/7/CyclePath"));
- writer.write(cyclePath(7,10));
- writer.close();
- writer = new OutputStreamWriter(new FileOutputStream("graph/7/BridgePath"));
- writer.write(bridgePath(7,2));
- writer.close();
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
+ /**
+ * Tree Path
+ */
+ public static String treePath(int k, int x, int y, int z) {
+ RandomString rs = new RandomString(k, x + y + k - 1);
+ String s1 = rs.nextString(0);
+ rs.setLength(x + y + z + k - 1);
+ rs.addString(s1.substring(0, x));
+ String s2 = rs.nextString(x);
+ rs.setLength(x + y + z + k - 1);
+ rs.addString(s2.substring(0, x + y));
+ String s3 = rs.nextString(x + y);
+ return s1 + "\r\n" + s2 + "\r\n" + s3;
+ }
+
+ /**
+ * Cycle Path
+ */
+ public static String cyclePath(int k, int length) {
+ RandomString rs = new RandomString(k, length);
+ String s1 = rs.nextString(0);
+ String s2 = s1 + s1.substring(1, k + 1);
+ return s2;
+ }
+
+ /**
+ * Bridge Path
+ */
+ public static String bridgePath(int k, int x) {
+ RandomString rs = new RandomString(k, x + k + 2 + k - 1);
+ String s1 = rs.nextString(0);
+ rs.setLength(x + k + 2);
+ rs.addString(s1.substring(0, k + 2));
+ String s2 = rs.nextString(k + 2) + s1.substring(x + k + 2, x + k + 2 + k - 1);
+ return s1 + "\r\n" + s2;
+ }
+
+ public static void main(String[] args) {
+ // TODO Auto-generated method stub
+ OutputStreamWriter writer;
+ try {
+ writer = new OutputStreamWriter(new FileOutputStream("graph/7/SinglePath"));
+ writer.write(simplePath(7, 10, 1));
+ writer.close();
+ writer = new OutputStreamWriter(new FileOutputStream("graph/7/SimplePath"));
+ writer.write(simplePath(7, 10, 3));
+ writer.close();
+ writer = new OutputStreamWriter(new FileOutputStream("graph/7/TreePath"));
+ writer.write(treePath(7, 7, 7, 7));
+ writer.close();
+ writer = new OutputStreamWriter(new FileOutputStream("graph/7/CyclePath"));
+ writer.write(cyclePath(7, 10));
+ writer.close();
+ writer = new OutputStreamWriter(new FileOutputStream("graph/7/BridgePath"));
+ writer.write(bridgePath(7, 2));
+ writer.close();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
}
diff --git a/genomix/genomix-pregelix/src/main/java/edu/uci/ics/genomix/pregelix/testcase/RandomString.java b/genomix/genomix-pregelix/src/main/java/edu/uci/ics/genomix/pregelix/testcase/RandomString.java
index 337c5d8..cd83171 100644
--- a/genomix/genomix-pregelix/src/main/java/edu/uci/ics/genomix/pregelix/testcase/RandomString.java
+++ b/genomix/genomix-pregelix/src/main/java/edu/uci/ics/genomix/pregelix/testcase/RandomString.java
@@ -3,61 +3,57 @@
import java.util.ArrayList;
import java.util.Random;
-public class RandomString
-{
+public class RandomString {
- private static final char[] symbols = new char[4];
+ private static final char[] symbols = new char[4];
- static {
- symbols[0] = 'A';
- symbols[1] = 'C';
- symbols[2] = 'G';
- symbols[3] = 'T';
- }
-
- private final Random random = new Random();
-
- private char[] buf;
-
- private ArrayList<String> existKmer = new ArrayList<String>();;
-
- private int k;
-
- public RandomString(int k, int length)
- {
- if (length < 1)
- throw new IllegalArgumentException("length < 1: " + length);
- buf = new char[length];
- this.k = k;
- }
-
- public String nextString(int startIdx)
- {
- String tmp = "";
- for (int idx = startIdx; idx < buf.length;){
- buf[idx] = symbols[random.nextInt(4)];
- if(idx >= k - 1){
- tmp = new String(buf, idx-k+1, k);
- if(!existKmer.contains(tmp)){
- existKmer.add(tmp);
- idx++;
- }
- }
- else
- idx++;
+ static {
+ symbols[0] = 'A';
+ symbols[1] = 'C';
+ symbols[2] = 'G';
+ symbols[3] = 'T';
}
-
- return new String(buf);
- }
-
- public void setLength(int length){
- buf = new char[length];
- }
-
- public void addString(String s){
- char[] tmp = s.toCharArray();
- for(int i = 0; i < tmp.length; i++)
- buf[i] = tmp[i];
- }
+
+ private final Random random = new Random();
+
+ private char[] buf;
+
+ private ArrayList<String> existKmer = new ArrayList<String>();;
+
+ private int k;
+
+ public RandomString(int k, int length) {
+ if (length < 1)
+ throw new IllegalArgumentException("length < 1: " + length);
+ buf = new char[length];
+ this.k = k;
+ }
+
+ public String nextString(int startIdx) {
+ String tmp = "";
+ for (int idx = startIdx; idx < buf.length;) {
+ buf[idx] = symbols[random.nextInt(4)];
+ if (idx >= k - 1) {
+ tmp = new String(buf, idx - k + 1, k);
+ if (!existKmer.contains(tmp)) {
+ existKmer.add(tmp);
+ idx++;
+ }
+ } else
+ idx++;
+ }
+
+ return new String(buf);
+ }
+
+ public void setLength(int length) {
+ buf = new char[length];
+ }
+
+ public void addString(String s) {
+ char[] tmp = s.toCharArray();
+ for (int i = 0; i < tmp.length; i++)
+ buf[i] = tmp[i];
+ }
}
diff --git a/genomix/genomix-pregelix/src/main/java/edu/uci/ics/genomix/pregelix/type/CheckMessage.java b/genomix/genomix-pregelix/src/main/java/edu/uci/ics/genomix/pregelix/type/CheckMessage.java
index 45741f7..61d2256 100644
--- a/genomix/genomix-pregelix/src/main/java/edu/uci/ics/genomix/pregelix/type/CheckMessage.java
+++ b/genomix/genomix-pregelix/src/main/java/edu/uci/ics/genomix/pregelix/type/CheckMessage.java
@@ -1,39 +1,39 @@
package edu.uci.ics.genomix.pregelix.type;
public class CheckMessage {
-
- public static final byte SOURCE = 1 << 0;
- public static final byte CHAIN = 1 << 1;
- public static final byte ADJMAP = 1 << 2;
- public static final byte MESSAGE = 1 << 3;
- public static final byte STATE = 1 << 4;
- public static final byte LASTGENECODE = 1 << 5;
-
- public final static class CheckMessage_CONTENT{
-
- public static String getContentFromCode(byte code){
- String r = "";
- switch(code){
- case SOURCE:
- r = "SOURCE";
- break;
- case CHAIN:
- r = "CHAIN";
- break;
- case ADJMAP:
- r = "ADJMAP";
- break;
- case MESSAGE:
- r = "MESSAGE";
- break;
- case STATE:
- r = "STATE";
- break;
- case LASTGENECODE:
- r = "LASTGENECODE";
- break;
- }
- return r;
- }
- }
+
+ public static final byte SOURCE = 1 << 0;
+ public static final byte CHAIN = 1 << 1;
+ public static final byte ADJMAP = 1 << 2;
+ public static final byte MESSAGE = 1 << 3;
+ public static final byte STATE = 1 << 4;
+ public static final byte LASTGENECODE = 1 << 5;
+
+ public final static class CheckMessage_CONTENT {
+
+ public static String getContentFromCode(byte code) {
+ String r = "";
+ switch (code) {
+ case SOURCE:
+ r = "SOURCE";
+ break;
+ case CHAIN:
+ r = "CHAIN";
+ break;
+ case ADJMAP:
+ r = "ADJMAP";
+ break;
+ case MESSAGE:
+ r = "MESSAGE";
+ break;
+ case STATE:
+ r = "STATE";
+ break;
+ case LASTGENECODE:
+ r = "LASTGENECODE";
+ break;
+ }
+ return r;
+ }
+ }
}
diff --git a/genomix/genomix-pregelix/src/main/java/edu/uci/ics/genomix/pregelix/type/Message.java b/genomix/genomix-pregelix/src/main/java/edu/uci/ics/genomix/pregelix/type/Message.java
index b1a9517..4332471 100644
--- a/genomix/genomix-pregelix/src/main/java/edu/uci/ics/genomix/pregelix/type/Message.java
+++ b/genomix/genomix-pregelix/src/main/java/edu/uci/ics/genomix/pregelix/type/Message.java
@@ -1,31 +1,35 @@
package edu.uci.ics.genomix.pregelix.type;
public class Message {
-
- public static final byte NON = 0;
- public static final byte START = 1;
- public static final byte END = 2;
- public static final byte STOP = 3;
-
- public final static class MESSAGE_CONTENT{
-
- public static String getContentFromCode(byte code){
- String r = "";
- switch(code){
- case NON:
- r = "NON";
- break;
- case START:
- r = "START";
- break;
- case END:
- r = "END";
- break;
- case STOP:
- r = "STOP";
- break;
- }
- return r;
- }
- }
+
+ public static final byte NON = 0;
+ public static final byte START = 1;
+ public static final byte END = 2;
+ public static final byte STOP = 3;
+ public static final byte PSEUDOREAR = 4;
+
+ public final static class MESSAGE_CONTENT {
+
+ public static String getContentFromCode(byte code) {
+ String r = "";
+ switch (code) {
+ case NON:
+ r = "NON";
+ break;
+ case START:
+ r = "START";
+ break;
+ case END:
+ r = "END";
+ break;
+ case STOP:
+ r = "STOP";
+ break;
+ case PSEUDOREAR:
+ r = "PSEUDOREAR";
+ break;
+ }
+ return r;
+ }
+ }
}
diff --git a/genomix/genomix-pregelix/src/main/java/edu/uci/ics/genomix/pregelix/type/State.java b/genomix/genomix-pregelix/src/main/java/edu/uci/ics/genomix/pregelix/type/State.java
index 4a2af9e..c1f4696 100644
--- a/genomix/genomix-pregelix/src/main/java/edu/uci/ics/genomix/pregelix/type/State.java
+++ b/genomix/genomix-pregelix/src/main/java/edu/uci/ics/genomix/pregelix/type/State.java
@@ -1,47 +1,47 @@
package edu.uci.ics.genomix.pregelix.type;
public class State {
-
- public static final byte NON_VERTEX = 0;
- public static final byte START_VERTEX = 1;
- public static final byte END_VERTEX = 2;
- public static final byte MID_VERTEX = 3;
- public static final byte TODELETE = 4;
- public static final byte FINAL_VERTEX = 5;
- public static final byte FILTER = 6;
- public static final byte CYCLE = 7;
-
- public final static class STATE_CONTENT{
- public static String getContentFromCode(byte code){
- String r = "";
- switch(code){
- case NON_VERTEX:
- r = "NON_VERTEX";
- break;
- case START_VERTEX:
- r = "START_VERTEX";
- break;
- case END_VERTEX:
- r = "END_VERTEX";
- break;
- case MID_VERTEX:
- r = "MID_VERTEX";
- break;
- case TODELETE:
- r = "TODELETE";
- break;
- case FINAL_VERTEX:
- r = "FINAL_VERTEX";
- break;
- case FILTER:
- r = "FINAL_DELETE";
- break;
- case CYCLE:
- r = "CYCLE";
- break;
- }
- return r;
- }
- }
+ public static final byte NON_VERTEX = 0;
+ public static final byte START_VERTEX = 1;
+ public static final byte END_VERTEX = 2;
+ public static final byte MID_VERTEX = 3;
+ public static final byte PSEUDOHEAD = 4;
+ public static final byte PSEUDOREAR = 5;
+ public static final byte FINAL_VERTEX = 6;
+ public static final byte CYCLE = 7;
+
+ public final static class STATE_CONTENT {
+
+ public static String getContentFromCode(byte code) {
+ String r = "";
+ switch (code) {
+ case NON_VERTEX:
+ r = "NON_VERTEX";
+ break;
+ case START_VERTEX:
+ r = "START_VERTEX";
+ break;
+ case END_VERTEX:
+ r = "END_VERTEX";
+ break;
+ case MID_VERTEX:
+ r = "MID_VERTEX";
+ break;
+ case PSEUDOHEAD:
+ r = "PSEUDOHEAD";
+ break;
+ case PSEUDOREAR:
+ r = "PSEUDOREAR";
+ break;
+ case FINAL_VERTEX:
+ r = "FINAL_VERTEX";
+ break;
+ case CYCLE:
+ r = "CYCLE";
+ break;
+ }
+ return r;
+ }
+ }
}
diff --git a/genomix/genomix-pregelix/src/main/java/edu/uci/ics/genomix/pregelix/util/VertexUtil.java b/genomix/genomix-pregelix/src/main/java/edu/uci/ics/genomix/pregelix/util/VertexUtil.java
index 854d176..50ff400 100644
--- a/genomix/genomix-pregelix/src/main/java/edu/uci/ics/genomix/pregelix/util/VertexUtil.java
+++ b/genomix/genomix-pregelix/src/main/java/edu/uci/ics/genomix/pregelix/util/VertexUtil.java
@@ -5,66 +5,81 @@
import edu.uci.ics.genomix.type.VKmerBytesWritable;
public class VertexUtil {
- public static VKmerBytesWritable subKmer = new VKmerBytesWritable(0);
- /**
- * Single Vertex: in-degree = out-degree = 1
- * @param vertexValue
- */
- public static boolean isPathVertex(byte value){
- if(GeneCode.inDegree(value) == 1 && GeneCode.outDegree(value) == 1)
- return true;
- return false;
- }
- /**
- * Head Vertex: out-degree > 0,
- * @param vertexValue
- */
- public static boolean isHeadVertex(byte value){
- if(GeneCode.outDegree(value) > 0 && !isPathVertex(value))
- return true;
- return false;
- }
- /**
- * Rear Vertex: in-degree > 0,
- * @param vertexValue
- */
- public static boolean isRearVertex(byte value){
- if(GeneCode.inDegree(value) > 0 && !isPathVertex(value))
- return true;
- return false;
- }
- /**
- * update right neighber based on next vertexId
- */
- public static byte updateRightNeighberByVertexId(byte oldVertexValue, KmerBytesWritable neighberVertex, int k){
- byte geneCode = neighberVertex.getGeneCodeAtPosition(k-1);
-
- byte newBit = GeneCode.getBitMapFromGeneCode(geneCode); //getAdjBit
- return (byte) ((byte)(oldVertexValue & 0xF0) | (byte) (newBit & 0x0F));
- }
- /**
- * update right neighber
- */
- public static byte updateRightNeighber(byte oldVertexValue, byte newVertexValue){
- return (byte) ((byte)(oldVertexValue & 0xF0) | (byte) (newVertexValue & 0x0F));
- }
- /**
- * check if mergeChain is cycle
- */
- public static boolean isCycle(KmerBytesWritable vertexId, VKmerBytesWritable mergeChain, int kmerSize){
- subKmer.set(vertexId);
+ public static VKmerBytesWritable subKmer = new VKmerBytesWritable(0);
+
+ /**
+ * Single Vertex: in-degree = out-degree = 1
+ *
+ * @param vertexValue
+ */
+ public static boolean isPathVertex(byte value) {
+ if (GeneCode.inDegree(value) == 1 && GeneCode.outDegree(value) == 1)
+ return true;
+ return false;
+ }
+
+ /**
+ * Head Vertex: out-degree > 0,
+ *
+ * @param vertexValue
+ */
+ public static boolean isHeadVertex(byte value) {
+ if (GeneCode.outDegree(value) > 0 && !isPathVertex(value))
+ return true;
+ return false;
+ }
+
+ /**
+ * Rear Vertex: in-degree > 0,
+ *
+ * @param vertexValue
+ */
+ public static boolean isRearVertex(byte value) {
+ if (GeneCode.inDegree(value) > 0 && !isPathVertex(value))
+ return true;
+ return false;
+ }
+
+ /**
+ * update right neighber based on next vertexId
+ */
+ public static byte updateRightNeighberByVertexId(byte oldVertexValue, KmerBytesWritable neighberVertex, int k) {
+ byte geneCode = neighberVertex.getGeneCodeAtPosition(k - 1);
+
+ byte newBit = GeneCode.getBitMapFromGeneCode(geneCode); //getAdjBit
+ return (byte) ((byte) (oldVertexValue & 0xF0) | (byte) (newBit & 0x0F));
+ }
+
+ /**
+ * update right neighber
+ */
+ public static byte updateRightNeighber(byte oldVertexValue, byte newVertexValue) {
+ return (byte) ((byte) (oldVertexValue & 0xF0) | (byte) (newVertexValue & 0x0F));
+ }
+
+ /**
+ * check if mergeChain is cycle
+ */
+ public static boolean isCycle(KmerBytesWritable vertexId, VKmerBytesWritable mergeChain, int kmerSize) {
+ String chain = mergeChain.toString().substring(1);
+ if (chain.contains(vertexId.toString()))
+ return true;
+ return false;
+
+ /*subKmer.set(vertexId);
for(int istart = 1; istart < mergeChain.getKmerLength() - kmerSize + 1; istart++){
byte nextgene = mergeChain.getGeneCodeAtPosition(istart+kmerSize);
subKmer.shiftKmerWithNextCode(nextgene);
if(subKmer.equals(vertexId))
return true;
}
- return false;
- }
- /**
- * reverse neighber
- */
- public static byte reverseAdjMap(byte oldAdjMap, byte geneCode){
- return (byte) ((oldAdjMap & 0xF0) | (GeneCode.getBitMapFromGeneCode(geneCode) & 0x0F));
- }
+ return false;*/
+ }
+
+ /**
+ * reverse neighber
+ */
+ public static byte reverseAdjMap(byte oldAdjMap, byte geneCode) {
+ return (byte) ((oldAdjMap & 0xF0) | (GeneCode.getBitMapFromGeneCode(geneCode) & 0x0F));
+ }
}
diff --git a/genomix/genomix-pregelix/src/test/java/edu/uci/ics/genomix/pregelix/JobGen/JobGenerator.java b/genomix/genomix-pregelix/src/test/java/edu/uci/ics/genomix/pregelix/JobGen/JobGenerator.java
index 5a138c4..8b138f2 100644
--- a/genomix/genomix-pregelix/src/test/java/edu/uci/ics/genomix/pregelix/JobGen/JobGenerator.java
+++ b/genomix/genomix-pregelix/src/test/java/edu/uci/ics/genomix/pregelix/JobGen/JobGenerator.java
@@ -14,15 +14,14 @@
import edu.uci.ics.genomix.type.KmerBytesWritable;
import edu.uci.ics.pregelix.api.job.PregelixJob;
-
public class JobGenerator {
public static String outputBase = "src/test/resources/jobs/";
-
+
private static void generateNaiveAlgorithmForMergeGraphJob(String jobName, String outputPath) throws IOException {
- PregelixJob job = new PregelixJob(jobName);
- job.setVertexClass(NaiveAlgorithmForPathMergeVertex.class);
- job.setVertexInputFormatClass(NaiveAlgorithmForPathMergeInputFormat.class);
+ PregelixJob job = new PregelixJob(jobName);
+ job.setVertexClass(NaiveAlgorithmForPathMergeVertex.class);
+ job.setVertexInputFormatClass(NaiveAlgorithmForPathMergeInputFormat.class);
job.setVertexOutputFormatClass(NaiveAlgorithmForPathMergeOutputFormat.class);
job.setDynamicVertexValueSize(true);
job.setOutputKeyClass(KmerBytesWritable.class);
@@ -30,15 +29,16 @@
job.getConfiguration().setInt(NaiveAlgorithmForPathMergeVertex.KMER_SIZE, 5);
job.getConfiguration().writeXml(new FileOutputStream(new File(outputPath)));
}
-
+
private static void genNaiveAlgorithmForMergeGraph() throws IOException {
- generateNaiveAlgorithmForMergeGraphJob("NaiveAlgorithmForMergeGraph", outputBase + "NaiveAlgorithmForMergeGraph.xml");
+ generateNaiveAlgorithmForMergeGraphJob("NaiveAlgorithmForMergeGraph", outputBase
+ + "NaiveAlgorithmForMergeGraph.xml");
}
-
+
private static void generateLogAlgorithmForMergeGraphJob(String jobName, String outputPath) throws IOException {
- PregelixJob job = new PregelixJob(jobName);
- job.setVertexClass(LogAlgorithmForPathMergeVertex.class);
- job.setVertexInputFormatClass(LogAlgorithmForPathMergeInputFormat.class);
+ PregelixJob job = new PregelixJob(jobName);
+ job.setVertexClass(LogAlgorithmForPathMergeVertex.class);
+ job.setVertexInputFormatClass(LogAlgorithmForPathMergeInputFormat.class);
job.setVertexOutputFormatClass(LogAlgorithmForPathMergeOutputFormat.class);
job.setDynamicVertexValueSize(true);
job.setOutputKeyClass(KmerBytesWritable.class);
@@ -46,14 +46,14 @@
job.getConfiguration().setInt(LogAlgorithmForPathMergeVertex.KMER_SIZE, 5);
job.getConfiguration().writeXml(new FileOutputStream(new File(outputPath)));
}
-
+
private static void genLogAlgorithmForMergeGraph() throws IOException {
- generateLogAlgorithmForMergeGraphJob("LogAlgorithmForMergeGraph", outputBase + "LogAlgorithmForMergeGraph.xml");
+ generateLogAlgorithmForMergeGraphJob("LogAlgorithmForMergeGraph", outputBase + "LogAlgorithmForMergeGraph.xml");
}
-
- public static void main(String[] args) throws IOException {
- genNaiveAlgorithmForMergeGraph();
- genLogAlgorithmForMergeGraph();
- }
+
+ public static void main(String[] args) throws IOException {
+ genNaiveAlgorithmForMergeGraph();
+ genLogAlgorithmForMergeGraph();
+ }
}
diff --git a/genomix/genomix-pregelix/src/test/java/edu/uci/ics/genomix/pregelix/JobRun/PathMergeSmallTestCase.java b/genomix/genomix-pregelix/src/test/java/edu/uci/ics/genomix/pregelix/JobRun/PathMergeSmallTestCase.java
index 818a550..f25ad57 100644
--- a/genomix/genomix-pregelix/src/test/java/edu/uci/ics/genomix/pregelix/JobRun/PathMergeSmallTestCase.java
+++ b/genomix/genomix-pregelix/src/test/java/edu/uci/ics/genomix/pregelix/JobRun/PathMergeSmallTestCase.java
@@ -30,58 +30,55 @@
import edu.uci.ics.pregelix.core.util.PregelixHyracksIntegrationUtil;
public class PathMergeSmallTestCase extends TestCase {
- private final PregelixJob job;
- private final String resultFileDir;
- private final String textFileDir;
- private final String jobFile;
- private final Driver driver = new Driver(this.getClass());
- private final FileSystem dfs;
+ private final PregelixJob job;
+ private final String resultFileDir;
+ private final String textFileDir;
+ private final String jobFile;
+ private final Driver driver = new Driver(this.getClass());
+ private final FileSystem dfs;
- public PathMergeSmallTestCase(String hadoopConfPath, String jobName,
- String jobFile, FileSystem dfs, String hdfsInput, String resultFile, String textFile)
- throws Exception {
- super("test");
- this.jobFile = jobFile;
- this.job = new PregelixJob("test");
- this.job.getConfiguration().addResource(new Path(jobFile));
- this.job.getConfiguration().addResource(new Path(hadoopConfPath));
- FileInputFormat.setInputPaths(job, hdfsInput);
- FileOutputFormat.setOutputPath(job, new Path(hdfsInput + "_result"));
- this.textFileDir = textFile;
- job.setJobName(jobName);
- this.resultFileDir = resultFile;
-
- this.dfs = dfs;
- }
+ public PathMergeSmallTestCase(String hadoopConfPath, String jobName, String jobFile, FileSystem dfs,
+ String hdfsInput, String resultFile, String textFile) throws Exception {
+ super("test");
+ this.jobFile = jobFile;
+ this.job = new PregelixJob("test");
+ this.job.getConfiguration().addResource(new Path(jobFile));
+ this.job.getConfiguration().addResource(new Path(hadoopConfPath));
+ FileInputFormat.setInputPaths(job, hdfsInput);
+ FileOutputFormat.setOutputPath(job, new Path(hdfsInput + "_result"));
+ this.textFileDir = textFile;
+ job.setJobName(jobName);
+ this.resultFileDir = resultFile;
- private void waitawhile() throws InterruptedException {
- synchronized (this) {
- this.wait(20);
- }
- }
+ this.dfs = dfs;
+ }
- @Test
- public void test() throws Exception {
- setUp();
- Plan[] plans = new Plan[] { Plan.OUTER_JOIN };
- for (Plan plan : plans) {
- driver.runJob(job, plan, PregelixHyracksIntegrationUtil.CC_HOST,
- PregelixHyracksIntegrationUtil.TEST_HYRACKS_CC_CLIENT_PORT,
- false);
- }
- compareResults();
- tearDown();
- waitawhile();
- }
+ private void waitawhile() throws InterruptedException {
+ synchronized (this) {
+ this.wait(20);
+ }
+ }
- private void compareResults() throws Exception {
- dfs.copyToLocalFile(FileOutputFormat.getOutputPath(job), new Path(
- resultFileDir));
- GenerateTextFile.generateFromPathmergeResult(5, resultFileDir, textFileDir);
- }
+ @Test
+ public void test() throws Exception {
+ setUp();
+ Plan[] plans = new Plan[] { Plan.OUTER_JOIN };
+ for (Plan plan : plans) {
+ driver.runJob(job, plan, PregelixHyracksIntegrationUtil.CC_HOST,
+ PregelixHyracksIntegrationUtil.TEST_HYRACKS_CC_CLIENT_PORT, false);
+ }
+ compareResults();
+ tearDown();
+ waitawhile();
+ }
- public String toString() {
- return jobFile;
- }
+ private void compareResults() throws Exception {
+ dfs.copyToLocalFile(FileOutputFormat.getOutputPath(job), new Path(resultFileDir));
+ GenerateTextFile.generateFromPathmergeResult(5, resultFileDir, textFileDir);
+ }
+
+ public String toString() {
+ return jobFile;
+ }
}
diff --git a/genomix/genomix-pregelix/src/test/java/edu/uci/ics/genomix/pregelix/JobRun/PathMergeSmallTestSuite.java b/genomix/genomix-pregelix/src/test/java/edu/uci/ics/genomix/pregelix/JobRun/PathMergeSmallTestSuite.java
index 5c6259e..dcbbb79 100644
--- a/genomix/genomix-pregelix/src/test/java/edu/uci/ics/genomix/pregelix/JobRun/PathMergeSmallTestSuite.java
+++ b/genomix/genomix-pregelix/src/test/java/edu/uci/ics/genomix/pregelix/JobRun/PathMergeSmallTestSuite.java
@@ -41,194 +41,171 @@
@SuppressWarnings("deprecation")
public class PathMergeSmallTestSuite extends TestSuite {
- private static final Logger LOGGER = Logger
- .getLogger(PathMergeSmallTestSuite.class.getName());
+ private static final Logger LOGGER = Logger.getLogger(PathMergeSmallTestSuite.class.getName());
- public static final String PreFix = "data/PathTestSet"; //"graphbuildresult";
- public static final String[] TestDir = { PreFix + File.separator
- //+ "split.aa"};
- //+ "split.aa"};/*, PreFix + File.separator
- /*+ "CyclePath"};, PreFix + File.separator
- + "SimplePath", PreFix + File.separator
- + "SinglePath", PreFix + File.separator
- + "TreePath"};*/
- + "2", PreFix + File.separator
- + "3", PreFix + File.separator
- + "4", PreFix + File.separator
- + "5", PreFix + File.separator
- + "6", PreFix + File.separator
- + "7", PreFix + File.separator
- + "8", PreFix + File.separator
- + "9", PreFix + File.separator
- + "TwoKmer", PreFix + File.separator
- + "ThreeKmer", PreFix + File.separator
- + "SinglePath", PreFix + File.separator
- + "SimplePath", PreFix + File.separator
- + "Path", PreFix + File.separator
- + "BridgePath", PreFix + File.separator
- + "CyclePath", PreFix + File.separator
- + "RingPath", PreFix + File.separator
- + "LongPath", PreFix + File.separator
- + "TreePath"};
- private static final String ACTUAL_RESULT_DIR = "actual";
- private static final String PATH_TO_HADOOP_CONF = "src/test/resources/hadoop/conf";
- private static final String PATH_TO_CLUSTER_STORE = "src/test/resources/cluster/stores.properties";
- private static final String PATH_TO_CLUSTER_PROPERTIES = "src/test/resources/cluster/cluster.properties";
- private static final String PATH_TO_JOBS = "src/test/resources/jobs/";
- private static final String PATH_TO_ONLY = "src/test/resources/only.txt";
+ public static final String PreFix = "data/PathTestSet"; //"graphbuildresult";
+ public static final String[] TestDir = { PreFix + File.separator
+ //+ "split.aa"};
+ //+ "split.aa"};/*, PreFix + File.separator
+ /*+ "CyclePath"};, PreFix + File.separator
+ + "SimplePath", PreFix + File.separator
+ + "SinglePath", PreFix + File.separator
+ + "TreePath"};*/
+ + "2", PreFix + File.separator + "3", PreFix + File.separator + "4", PreFix + File.separator + "5",
+ PreFix + File.separator + "6", PreFix + File.separator + "7", PreFix + File.separator + "8",
+ PreFix + File.separator + "9", PreFix + File.separator + "TwoKmer", PreFix + File.separator + "ThreeKmer",
+ PreFix + File.separator + "SinglePath", PreFix + File.separator + "SimplePath",
+ PreFix + File.separator + "Path", PreFix + File.separator + "BridgePath",
+ PreFix + File.separator + "CyclePath", PreFix + File.separator + "RingPath",
+ PreFix + File.separator + "LongPath", PreFix + File.separator + "TreePath" };
+ private static final String ACTUAL_RESULT_DIR = "actual";
+ private static final String PATH_TO_HADOOP_CONF = "src/test/resources/hadoop/conf";
+ private static final String PATH_TO_CLUSTER_STORE = "src/test/resources/cluster/stores.properties";
+ private static final String PATH_TO_CLUSTER_PROPERTIES = "src/test/resources/cluster/cluster.properties";
+ private static final String PATH_TO_JOBS = "src/test/resources/jobs/";
+ private static final String PATH_TO_ONLY = "src/test/resources/only.txt";
- public static final String HDFS_INPUTPATH = "/PathTestSet";
+ public static final String HDFS_INPUTPATH = "/PathTestSet";
- private static final String HADOOP_CONF_PATH = ACTUAL_RESULT_DIR
- + File.separator + "conf.xml";
- private MiniDFSCluster dfsCluster;
+ private static final String HADOOP_CONF_PATH = ACTUAL_RESULT_DIR + File.separator + "conf.xml";
+ private MiniDFSCluster dfsCluster;
- private JobConf conf = new JobConf();
- private int numberOfNC = 2;
+ private JobConf conf = new JobConf();
+ private int numberOfNC = 2;
- public void setUp() throws Exception {
- ClusterConfig.setStorePath(PATH_TO_CLUSTER_STORE);
- ClusterConfig.setClusterPropertiesPath(PATH_TO_CLUSTER_PROPERTIES);
- cleanupStores();
- PregelixHyracksIntegrationUtil.init("src/test/resources/topology.xml");
- LOGGER.info("Hyracks mini-cluster started");
- FileUtils.forceMkdir(new File(ACTUAL_RESULT_DIR));
- FileUtils.cleanDirectory(new File(ACTUAL_RESULT_DIR));
- startHDFS();
- }
+ public void setUp() throws Exception {
+ ClusterConfig.setStorePath(PATH_TO_CLUSTER_STORE);
+ ClusterConfig.setClusterPropertiesPath(PATH_TO_CLUSTER_PROPERTIES);
+ cleanupStores();
+ PregelixHyracksIntegrationUtil.init("src/test/resources/topology.xml");
+ LOGGER.info("Hyracks mini-cluster started");
+ FileUtils.forceMkdir(new File(ACTUAL_RESULT_DIR));
+ FileUtils.cleanDirectory(new File(ACTUAL_RESULT_DIR));
+ startHDFS();
+ }
- private void startHDFS() throws IOException {
- conf.addResource(new Path(PATH_TO_HADOOP_CONF + "/core-site.xml"));
- conf.addResource(new Path(PATH_TO_HADOOP_CONF + "/mapred-site.xml"));
- conf.addResource(new Path(PATH_TO_HADOOP_CONF + "/hdfs-site.xml"));
- FileSystem lfs = FileSystem.getLocal(new Configuration());
- lfs.delete(new Path("build"), true);
- System.setProperty("hadoop.log.dir", "logs");
- dfsCluster = new MiniDFSCluster(conf, numberOfNC, true, null);
- FileSystem dfs = FileSystem.get(conf);
+ private void startHDFS() throws IOException {
+ conf.addResource(new Path(PATH_TO_HADOOP_CONF + "/core-site.xml"));
+ conf.addResource(new Path(PATH_TO_HADOOP_CONF + "/mapred-site.xml"));
+ conf.addResource(new Path(PATH_TO_HADOOP_CONF + "/hdfs-site.xml"));
+ FileSystem lfs = FileSystem.getLocal(new Configuration());
+ lfs.delete(new Path("build"), true);
+ System.setProperty("hadoop.log.dir", "logs");
+ dfsCluster = new MiniDFSCluster(conf, numberOfNC, true, null);
+ FileSystem dfs = FileSystem.get(conf);
- for (String testDir : TestDir) {
- File src = new File(testDir);
- Path dest = new Path(HDFS_INPUTPATH + File.separator + src.getName());
- dfs.mkdirs(dest);
- //src.listFiles()
- //src.listFiles((FilenameFilter)(new WildcardFileFilter("part*")))
- for (File f : src.listFiles()){
- dfs.copyFromLocalFile(new Path(f.getAbsolutePath()), dest);
- }
- }
+ for (String testDir : TestDir) {
+ File src = new File(testDir);
+ Path dest = new Path(HDFS_INPUTPATH + File.separator + src.getName());
+ dfs.mkdirs(dest);
+ //src.listFiles()
+ //src.listFiles((FilenameFilter)(new WildcardFileFilter("part*")))
+ for (File f : src.listFiles()) {
+ dfs.copyFromLocalFile(new Path(f.getAbsolutePath()), dest);
+ }
+ }
- DataOutputStream confOutput = new DataOutputStream(
- new FileOutputStream(new File(HADOOP_CONF_PATH)));
- conf.writeXml(confOutput);
- confOutput.flush();
- confOutput.close();
- }
-
- private void cleanupStores() throws IOException {
- FileUtils.forceMkdir(new File("teststore"));
- FileUtils.forceMkdir(new File("build"));
- FileUtils.cleanDirectory(new File("teststore"));
- FileUtils.cleanDirectory(new File("build"));
- }
+ DataOutputStream confOutput = new DataOutputStream(new FileOutputStream(new File(HADOOP_CONF_PATH)));
+ conf.writeXml(confOutput);
+ confOutput.flush();
+ confOutput.close();
+ }
- /**
- * cleanup hdfs cluster
- */
- private void cleanupHDFS() throws Exception {
- dfsCluster.shutdown();
- }
+ private void cleanupStores() throws IOException {
+ FileUtils.forceMkdir(new File("teststore"));
+ FileUtils.forceMkdir(new File("build"));
+ FileUtils.cleanDirectory(new File("teststore"));
+ FileUtils.cleanDirectory(new File("build"));
+ }
- public void tearDown() throws Exception {
- PregelixHyracksIntegrationUtil.deinit();
- LOGGER.info("Hyracks mini-cluster shut down");
- cleanupHDFS();
- }
+ /**
+ * cleanup hdfs cluster
+ */
+ private void cleanupHDFS() throws Exception {
+ dfsCluster.shutdown();
+ }
- public static Test suite() throws Exception {
- List<String> onlys = getFileList(PATH_TO_ONLY);
- File testData = new File(PATH_TO_JOBS);
- File[] queries = testData.listFiles();
- PathMergeSmallTestSuite testSuite = new PathMergeSmallTestSuite();
- testSuite.setUp();
- boolean onlyEnabled = false;
- FileSystem dfs = FileSystem.get(testSuite.conf);
+ public void tearDown() throws Exception {
+ PregelixHyracksIntegrationUtil.deinit();
+ LOGGER.info("Hyracks mini-cluster shut down");
+ cleanupHDFS();
+ }
- if (onlys.size() > 0) {
- onlyEnabled = true;
- }
+ public static Test suite() throws Exception {
+ List<String> onlys = getFileList(PATH_TO_ONLY);
+ File testData = new File(PATH_TO_JOBS);
+ File[] queries = testData.listFiles();
+ PathMergeSmallTestSuite testSuite = new PathMergeSmallTestSuite();
+ testSuite.setUp();
+ boolean onlyEnabled = false;
+ FileSystem dfs = FileSystem.get(testSuite.conf);
- for (File qFile : queries) {
- if (qFile.isFile()) {
- if (onlyEnabled && !isInList(onlys, qFile.getName())) {
- continue;
- } else {
- for (String testPathStr : TestDir) {
- File testDir = new File(testPathStr);
- String resultFileName = ACTUAL_RESULT_DIR
- + File.separator
- + jobExtToResExt(qFile.getName())
- + File.separator + "bin"
- + File.separator + testDir.getName();
- String textFileName = ACTUAL_RESULT_DIR
- + File.separator
- + jobExtToResExt(qFile.getName())
- + File.separator + "txt"
- + File.separator + testDir.getName();
- testSuite.addTest(new PathMergeSmallTestCase(
- HADOOP_CONF_PATH, qFile.getName(), qFile
- .getAbsolutePath().toString(),
- dfs, HDFS_INPUTPATH + File.separator + testDir.getName(),
- resultFileName, textFileName));
- }
- }
- }
- }
- return testSuite;
- }
+ if (onlys.size() > 0) {
+ onlyEnabled = true;
+ }
- /**
- * Runs the tests and collects their result in a TestResult.
- */
- @Override
- public void run(TestResult result) {
- try {
- int testCount = countTestCases();
- for (int i = 0; i < testCount; i++) {
- // cleanupStores();
- Test each = this.testAt(i);
- if (result.shouldStop())
- break;
- runTest(each, result);
- }
- tearDown();
- } catch (Exception e) {
- throw new IllegalStateException(e);
- }
- }
+ for (File qFile : queries) {
+ if (qFile.isFile()) {
+ if (onlyEnabled && !isInList(onlys, qFile.getName())) {
+ continue;
+ } else {
+ for (String testPathStr : TestDir) {
+ File testDir = new File(testPathStr);
+ String resultFileName = ACTUAL_RESULT_DIR + File.separator + jobExtToResExt(qFile.getName())
+ + File.separator + "bin" + File.separator + testDir.getName();
+ String textFileName = ACTUAL_RESULT_DIR + File.separator + jobExtToResExt(qFile.getName())
+ + File.separator + "txt" + File.separator + testDir.getName();
+ testSuite.addTest(new PathMergeSmallTestCase(HADOOP_CONF_PATH, qFile.getName(), qFile
+ .getAbsolutePath().toString(), dfs,
+ HDFS_INPUTPATH + File.separator + testDir.getName(), resultFileName, textFileName));
+ }
+ }
+ }
+ }
+ return testSuite;
+ }
- protected static List<String> getFileList(String ignorePath)
- throws FileNotFoundException, IOException {
- BufferedReader reader = new BufferedReader(new FileReader(ignorePath));
- String s = null;
- List<String> ignores = new ArrayList<String>();
- while ((s = reader.readLine()) != null) {
- ignores.add(s);
- }
- reader.close();
- return ignores;
- }
+ /**
+ * Runs the tests and collects their result in a TestResult.
+ */
+ @Override
+ public void run(TestResult result) {
+ try {
+ int testCount = countTestCases();
+ for (int i = 0; i < testCount; i++) {
+ // cleanupStores();
+ Test each = this.testAt(i);
+ if (result.shouldStop())
+ break;
+ runTest(each, result);
+ }
+ tearDown();
+ } catch (Exception e) {
+ throw new IllegalStateException(e);
+ }
+ }
- private static String jobExtToResExt(String fname) {
- int dot = fname.lastIndexOf('.');
- return fname.substring(0, dot);
- }
+ protected static List<String> getFileList(String ignorePath) throws FileNotFoundException, IOException {
+ BufferedReader reader = new BufferedReader(new FileReader(ignorePath));
+ String s = null;
+ List<String> ignores = new ArrayList<String>();
+ while ((s = reader.readLine()) != null) {
+ ignores.add(s);
+ }
+ reader.close();
+ return ignores;
+ }
- private static boolean isInList(List<String> onlys, String name) {
- for (String only : onlys)
- if (name.indexOf(only) >= 0)
- return true;
- return false;
- }
+ private static String jobExtToResExt(String fname) {
+ int dot = fname.lastIndexOf('.');
+ return fname.substring(0, dot);
+ }
+
+ private static boolean isInList(List<String> onlys, String name) {
+ for (String only : onlys)
+ if (name.indexOf(only) >= 0)
+ return true;
+ return false;
+ }
}
diff --git a/genomix/genomix-pregelix/src/test/java/edu/uci/ics/genomix/pregelix/ResultGen/ReportGenerator.java b/genomix/genomix-pregelix/src/test/java/edu/uci/ics/genomix/pregelix/ResultGen/ReportGenerator.java
index 00298a3..f5f42fc 100644
--- a/genomix/genomix-pregelix/src/test/java/edu/uci/ics/genomix/pregelix/ResultGen/ReportGenerator.java
+++ b/genomix/genomix-pregelix/src/test/java/edu/uci/ics/genomix/pregelix/ResultGen/ReportGenerator.java
@@ -10,41 +10,44 @@
import org.apache.commons.io.FileUtils;
public class ReportGenerator {
- public static final String PATH_TO_REPORT = "report";
- public static final String PATH_TO_LOGINFO = "log";
+ public static final String PATH_TO_REPORT = "report";
+ public static final String PATH_TO_LOGINFO = "log";
- public static void generateReportFromLoginfo(String fileName) throws Exception {
- DecimalFormat df = new DecimalFormat("0.00");
- BufferedReader br = new BufferedReader(new FileReader(PATH_TO_LOGINFO + "/" + fileName));
- BufferedWriter bw = new BufferedWriter(new FileWriter(new File(PATH_TO_REPORT + "/" + fileName)));
- String line;
- int i = 0;
- double totalTime = 0;
- line = br.readLine();
- do{
- line = br.readLine();
- String[] tokens = line.split(" ");
- for(i = 1; i < tokens.length - 1; i++){
- bw.write(tokens[i] + " ");
- }
- String subString = tokens[i].substring(0, tokens[i].length() - 2);
- double ms = Double.parseDouble(subString)/60000;
- totalTime += ms;
- bw.write(df.format(ms) + "m");
- bw.newLine();
- }while((line = br.readLine()) != null);
- bw.write("The total time is " + df.format(totalTime) + "m");
- bw.close();
- br.close();
- }
-
- public static void main(String[] args) throws Exception {
- FileUtils.forceMkdir(new File(PATH_TO_REPORT));
- FileUtils.cleanDirectory(new File(PATH_TO_REPORT));
- generateReportFromLoginfo("naive_converge");
- generateReportFromLoginfo("log_converge");
- generateReportFromLoginfo("naive_36");
- generateReportFromLoginfo("log_13");
+ public static void generateReportFromLoginfo(String fileName) throws Exception {
+ DecimalFormat df = new DecimalFormat("0.0000");
+ BufferedReader br = new BufferedReader(new FileReader(PATH_TO_LOGINFO + "/" + fileName));
+ BufferedWriter bw = new BufferedWriter(new FileWriter(new File(PATH_TO_REPORT + "/" + fileName)));
+ String line;
+ int i = 0;
+ double totalTime = 0;
+ line = br.readLine();
+ do {
+ line = br.readLine();
+ String[] tokens = line.split(" ");
+ for (i = 1; i < tokens.length - 1; i++) {
+ bw.write(tokens[i] + " ");
+ }
+ String subString = tokens[i].substring(0, tokens[i].length() - 2);
+ double ms = Double.parseDouble(subString) / 60000;
+ totalTime += ms;
+ bw.write(df.format(ms) + "m");
+ bw.newLine();
+ } while ((line = br.readLine()) != null);
+ bw.write("The total time is " + df.format(totalTime) + "m");
+ bw.close();
+ br.close();
+ }
- }
+ public static void main(String[] args) throws Exception {
+ FileUtils.forceMkdir(new File(PATH_TO_REPORT));
+ FileUtils.cleanDirectory(new File(PATH_TO_REPORT));
+ generateReportFromLoginfo("log_nc4");
+ generateReportFromLoginfo("log_nc8");
+ generateReportFromLoginfo("naive_nc4");
+ generateReportFromLoginfo("naive_nc4_vertex16");
+ generateReportFromLoginfo("log_nc4_vertex16");
+ generateReportFromLoginfo("naive_nc8_outerjoin");
+ generateReportFromLoginfo("naive_nc8_outerjoin_2");
+ generateReportFromLoginfo("naive_nc8_innerjoin");
+ }
}
diff --git a/genomix/genomix-pregelix/src/test/java/edu/uci/ics/genomix/pregelix/pathmerge/CompareTest.java b/genomix/genomix-pregelix/src/test/java/edu/uci/ics/genomix/pregelix/pathmerge/CompareTest.java
index b80fb99..0a2ae92 100644
--- a/genomix/genomix-pregelix/src/test/java/edu/uci/ics/genomix/pregelix/pathmerge/CompareTest.java
+++ b/genomix/genomix-pregelix/src/test/java/edu/uci/ics/genomix/pregelix/pathmerge/CompareTest.java
@@ -6,15 +6,14 @@
import edu.uci.ics.genomix.pregelix.example.util.TestUtils;
-
public class CompareTest {
- public static final String PATH_TO_TESTSTORE = "testcase/pathmerge";
- public static final String CHAIN_OUTPUT = PATH_TO_TESTSTORE + "chain";
-
- @Test
- public void test() throws Exception {
- File naive = new File(CHAIN_OUTPUT + "/naive-sort");
- File log = new File(CHAIN_OUTPUT + "/log-sort");
- TestUtils.compareWithResult(naive, log);
- }
+ public static final String PATH_TO_TESTSTORE = "testcase/pathmerge";
+ public static final String CHAIN_OUTPUT = PATH_TO_TESTSTORE + "chain";
+
+ @Test
+ public void test() throws Exception {
+ File naive = new File(CHAIN_OUTPUT + "/naive-sort");
+ File log = new File(CHAIN_OUTPUT + "/log-sort");
+ TestUtils.compareWithResult(naive, log);
+ }
}
diff --git a/genomix/genomix-pregelix/src/test/java/edu/uci/ics/genomix/pregelix/pathmerge/GraphBuildTest.java b/genomix/genomix-pregelix/src/test/java/edu/uci/ics/genomix/pregelix/pathmerge/GraphBuildTest.java
index 6d4e421..66ee26d 100644
--- a/genomix/genomix-pregelix/src/test/java/edu/uci/ics/genomix/pregelix/pathmerge/GraphBuildTest.java
+++ b/genomix/genomix-pregelix/src/test/java/edu/uci/ics/genomix/pregelix/pathmerge/GraphBuildTest.java
@@ -32,159 +32,145 @@
@SuppressWarnings("deprecation")
public class GraphBuildTest {
- private static final String ACTUAL_RESULT_DIR = "graphbuildresult";
- private static final String PATH_TO_HADOOP_CONF = "src/test/resources/hadoop/conf";
+ private static final String ACTUAL_RESULT_DIR = "graphbuildresult";
+ private static final String PATH_TO_HADOOP_CONF = "src/test/resources/hadoop/conf";
- private static final String DATA_PATH = "data/testGeneFile";
- private static final String HDFS_INPUT_PATH = "/test";
- private static final String HDFS_OUTPUT_PATH = "/result";
+ private static final String DATA_PATH = "data/testGeneFile";
+ private static final String HDFS_INPUT_PATH = "/test";
+ private static final String HDFS_OUTPUT_PATH = "/result";
- private static final String DUMPED_RESULT = ACTUAL_RESULT_DIR
- + HDFS_OUTPUT_PATH + "/result.txt";
- private static final String CONVERT_RESULT = ACTUAL_RESULT_DIR
- + "/graph_build_result.txt";
- private static final String EXPECTED_PATH = "src/test/resources/expected/result2";
+ private static final String DUMPED_RESULT = ACTUAL_RESULT_DIR + HDFS_OUTPUT_PATH + "/result.txt";
+ private static final String CONVERT_RESULT = ACTUAL_RESULT_DIR + "/graph_build_result.txt";
+ private static final String EXPECTED_PATH = "src/test/resources/expected/result2";
- private static final String HADOOP_CONF_PATH = ACTUAL_RESULT_DIR
- + File.separator + "conf.xml";
- private MiniDFSCluster dfsCluster;
+ private static final String HADOOP_CONF_PATH = ACTUAL_RESULT_DIR + File.separator + "conf.xml";
+ private MiniDFSCluster dfsCluster;
- private JobConf conf = new JobConf();
- private int numberOfNC = 2;
- private int numPartitionPerMachine = 1;
+ private JobConf conf = new JobConf();
+ private int numberOfNC = 2;
+ private int numPartitionPerMachine = 1;
- private Driver driver;
+ private Driver driver;
- @Before
- public void setUp() throws Exception {
- cleanupStores();
- edu.uci.ics.hyracks.hdfs.utils.HyracksUtils.init();
- FileUtils.forceMkdir(new File(ACTUAL_RESULT_DIR));
- FileUtils.cleanDirectory(new File(ACTUAL_RESULT_DIR));
- startHDFS();
+ @Before
+ public void setUp() throws Exception {
+ cleanupStores();
+ edu.uci.ics.hyracks.hdfs.utils.HyracksUtils.init();
+ FileUtils.forceMkdir(new File(ACTUAL_RESULT_DIR));
+ FileUtils.cleanDirectory(new File(ACTUAL_RESULT_DIR));
+ startHDFS();
- FileInputFormat.setInputPaths(conf, HDFS_INPUT_PATH);
- FileOutputFormat.setOutputPath(conf, new Path(HDFS_OUTPUT_PATH));
+ FileInputFormat.setInputPaths(conf, HDFS_INPUT_PATH);
+ FileOutputFormat.setOutputPath(conf, new Path(HDFS_OUTPUT_PATH));
- conf.setInt(GenomixJob.KMER_LENGTH, 55);
- driver = new Driver(
- edu.uci.ics.hyracks.hdfs.utils.HyracksUtils.CC_HOST,
- edu.uci.ics.hyracks.hdfs.utils.HyracksUtils.TEST_HYRACKS_CC_CLIENT_PORT,
- numPartitionPerMachine);
- }
+ conf.setInt(GenomixJob.KMER_LENGTH, 55);
+ driver = new Driver(edu.uci.ics.hyracks.hdfs.utils.HyracksUtils.CC_HOST,
+ edu.uci.ics.hyracks.hdfs.utils.HyracksUtils.TEST_HYRACKS_CC_CLIENT_PORT, numPartitionPerMachine);
+ }
- private void cleanupStores() throws IOException {
- FileUtils.forceMkdir(new File("teststore"));
- FileUtils.forceMkdir(new File("build"));
- FileUtils.cleanDirectory(new File("teststore"));
- FileUtils.cleanDirectory(new File("build"));
- }
+ private void cleanupStores() throws IOException {
+ FileUtils.forceMkdir(new File("teststore"));
+ FileUtils.forceMkdir(new File("build"));
+ FileUtils.cleanDirectory(new File("teststore"));
+ FileUtils.cleanDirectory(new File("build"));
+ }
- private void startHDFS() throws IOException {
- conf.addResource(new Path(PATH_TO_HADOOP_CONF + "/core-site.xml"));
- conf.addResource(new Path(PATH_TO_HADOOP_CONF + "/mapred-site.xml"));
- conf.addResource(new Path(PATH_TO_HADOOP_CONF + "/hdfs-site.xml"));
+ private void startHDFS() throws IOException {
+ conf.addResource(new Path(PATH_TO_HADOOP_CONF + "/core-site.xml"));
+ conf.addResource(new Path(PATH_TO_HADOOP_CONF + "/mapred-site.xml"));
+ conf.addResource(new Path(PATH_TO_HADOOP_CONF + "/hdfs-site.xml"));
- FileSystem lfs = FileSystem.getLocal(new Configuration());
- lfs.delete(new Path("build"), true);
- System.setProperty("hadoop.log.dir", "logs");
- dfsCluster = new MiniDFSCluster(conf, numberOfNC, true, null);
- FileSystem dfs = FileSystem.get(conf);
- Path src = new Path(DATA_PATH);
- Path dest = new Path(HDFS_INPUT_PATH);
- dfs.mkdirs(dest);
- dfs.copyFromLocalFile(src, dest);
+ FileSystem lfs = FileSystem.getLocal(new Configuration());
+ lfs.delete(new Path("build"), true);
+ System.setProperty("hadoop.log.dir", "logs");
+ dfsCluster = new MiniDFSCluster(conf, numberOfNC, true, null);
+ FileSystem dfs = FileSystem.get(conf);
+ Path src = new Path(DATA_PATH);
+ Path dest = new Path(HDFS_INPUT_PATH);
+ dfs.mkdirs(dest);
+ dfs.copyFromLocalFile(src, dest);
- DataOutputStream confOutput = new DataOutputStream(
- new FileOutputStream(new File(HADOOP_CONF_PATH)));
- conf.writeXml(confOutput);
- confOutput.flush();
- confOutput.close();
- }
+ DataOutputStream confOutput = new DataOutputStream(new FileOutputStream(new File(HADOOP_CONF_PATH)));
+ conf.writeXml(confOutput);
+ confOutput.flush();
+ confOutput.close();
+ }
- private void cleanUpReEntry() throws IOException {
- FileSystem lfs = FileSystem.getLocal(new Configuration());
- if (lfs.exists(new Path(DUMPED_RESULT))) {
- lfs.delete(new Path(DUMPED_RESULT), true);
- }
- FileSystem dfs = FileSystem.get(conf);
- if (dfs.exists(new Path(HDFS_OUTPUT_PATH))) {
- dfs.delete(new Path(HDFS_OUTPUT_PATH), true);
- }
- }
+ private void cleanUpReEntry() throws IOException {
+ FileSystem lfs = FileSystem.getLocal(new Configuration());
+ if (lfs.exists(new Path(DUMPED_RESULT))) {
+ lfs.delete(new Path(DUMPED_RESULT), true);
+ }
+ FileSystem dfs = FileSystem.get(conf);
+ if (dfs.exists(new Path(HDFS_OUTPUT_PATH))) {
+ dfs.delete(new Path(HDFS_OUTPUT_PATH), true);
+ }
+ }
- @Test
- public void TestAll() throws Exception {
- cleanUpReEntry();
- TestPreClusterGroupby();
- }
+ @Test
+ public void TestAll() throws Exception {
+ cleanUpReEntry();
+ TestPreClusterGroupby();
+ }
- public void TestPreClusterGroupby() throws Exception {
- conf.set(GenomixJob.GROUPBY_TYPE, "precluster");
- //conf.set(GenomixJob.OUTPUT_FORMAT, "text");
- System.err.println("Testing PreClusterGroupBy");
- driver.runJob(new GenomixJob(conf), Plan.BUILD_DEBRUJIN_GRAPH, true);
- Assert.assertEquals(true, checkResults(EXPECTED_PATH));
- }
+ public void TestPreClusterGroupby() throws Exception {
+ conf.set(GenomixJob.GROUPBY_TYPE, "precluster");
+ //conf.set(GenomixJob.OUTPUT_FORMAT, "text");
+ System.err.println("Testing PreClusterGroupBy");
+ driver.runJob(new GenomixJob(conf), Plan.BUILD_DEBRUJIN_GRAPH, true);
+ Assert.assertEquals(true, checkResults(EXPECTED_PATH));
+ }
+ private boolean checkResults(String expectedPath) throws Exception {
+ String format = conf.get(GenomixJob.OUTPUT_FORMAT);
+ if ("text".equalsIgnoreCase(format)) {
+ FileUtil.copyMerge(FileSystem.get(conf), new Path(HDFS_OUTPUT_PATH),
+ FileSystem.getLocal(new Configuration()), new Path(DUMPED_RESULT), false, conf, null);
+ } else {
- private boolean checkResults(String expectedPath) throws Exception {
- String format = conf.get(GenomixJob.OUTPUT_FORMAT);
- if ("text".equalsIgnoreCase(format)) {
- FileUtil.copyMerge(FileSystem.get(conf),
- new Path(HDFS_OUTPUT_PATH), FileSystem
- .getLocal(new Configuration()), new Path(
- DUMPED_RESULT), false, conf, null);
- } else {
+ FileSystem.getLocal(new Configuration()).mkdirs(new Path(ACTUAL_RESULT_DIR + HDFS_OUTPUT_PATH));
+ File filePathTo = new File(CONVERT_RESULT);
+ BufferedWriter bw = new BufferedWriter(new FileWriter(filePathTo));
+ for (int i = 0; i < numPartitionPerMachine * numberOfNC; i++) {
+ String partname = "/part-" + i;
+ FileUtil.copy(FileSystem.get(conf), new Path(HDFS_OUTPUT_PATH + partname),
+ FileSystem.getLocal(new Configuration()), new Path(ACTUAL_RESULT_DIR + HDFS_OUTPUT_PATH
+ + partname), false, conf);
- FileSystem.getLocal(new Configuration()).mkdirs(
- new Path(ACTUAL_RESULT_DIR + HDFS_OUTPUT_PATH));
- File filePathTo = new File(CONVERT_RESULT);
- BufferedWriter bw = new BufferedWriter(new FileWriter(filePathTo));
- for (int i = 0; i < numPartitionPerMachine * numberOfNC; i++) {
- String partname = "/part-" + i;
- FileUtil.copy(FileSystem.get(conf), new Path(HDFS_OUTPUT_PATH
- + partname), FileSystem.getLocal(new Configuration()),
- new Path(ACTUAL_RESULT_DIR + HDFS_OUTPUT_PATH
- + partname), false, conf);
+ Path path = new Path(HDFS_OUTPUT_PATH + partname);
+ FileSystem dfs = FileSystem.get(conf);
+ if (dfs.getFileStatus(path).getLen() == 0) {
+ continue;
+ }
+ SequenceFile.Reader reader = new SequenceFile.Reader(dfs, path, conf);
+ KmerBytesWritable key = new KmerBytesWritable(conf.getInt(GenomixJob.KMER_LENGTH,
+ GenomixJob.DEFAULT_KMER));
+ KmerCountValue value = (KmerCountValue) ReflectionUtils.newInstance(reader.getValueClass(), conf);
- Path path = new Path(HDFS_OUTPUT_PATH + partname);
- FileSystem dfs = FileSystem.get(conf);
- if (dfs.getFileStatus(path).getLen() == 0) {
- continue;
- }
- SequenceFile.Reader reader = new SequenceFile.Reader(dfs, path,
- conf);
- KmerBytesWritable key = new KmerBytesWritable(conf.getInt(
- GenomixJob.KMER_LENGTH, GenomixJob.DEFAULT_KMER));
- KmerCountValue value = (KmerCountValue) ReflectionUtils
- .newInstance(reader.getValueClass(), conf);
+ while (reader.next(key, value)) {
+ if (key == null || value == null) {
+ break;
+ }
+ bw.write(key.toString() + "\t" + value.toString());
+ System.out.println(key.toString() + "\t" + value.toString());
+ bw.newLine();
+ }
+ reader.close();
+ }
+ bw.close();
+ }
- while (reader.next(key, value)) {
- if (key == null || value == null) {
- break;
- }
- bw.write(key.toString() + "\t" + value.toString());
- System.out
- .println(key.toString() + "\t" + value.toString());
- bw.newLine();
- }
- reader.close();
- }
- bw.close();
- }
+ // TestUtils.compareWithSortedResult(new File(expectedPath), dumped);
+ return true;
+ }
- // TestUtils.compareWithSortedResult(new File(expectedPath), dumped);
- return true;
- }
+ @After
+ public void tearDown() throws Exception {
+ edu.uci.ics.hyracks.hdfs.utils.HyracksUtils.deinit();
+ cleanupHDFS();
+ }
- @After
- public void tearDown() throws Exception {
- edu.uci.ics.hyracks.hdfs.utils.HyracksUtils.deinit();
- cleanupHDFS();
- }
-
- private void cleanupHDFS() throws Exception {
- dfsCluster.shutdown();
- }
+ private void cleanupHDFS() throws Exception {
+ dfsCluster.shutdown();
+ }
}
diff --git a/genomix/genomix-pregelix/src/test/java/edu/uci/ics/genomix/pregelix/pathmerge/GraphBuildTestCase.java b/genomix/genomix-pregelix/src/test/java/edu/uci/ics/genomix/pregelix/pathmerge/GraphBuildTestCase.java
index ef89b9e..daa7e39 100644
--- a/genomix/genomix-pregelix/src/test/java/edu/uci/ics/genomix/pregelix/pathmerge/GraphBuildTestCase.java
+++ b/genomix/genomix-pregelix/src/test/java/edu/uci/ics/genomix/pregelix/pathmerge/GraphBuildTestCase.java
@@ -24,98 +24,88 @@
import edu.uci.ics.genomix.type.KmerCountValue;
public class GraphBuildTestCase extends TestCase {
- private final JobConf conf;
- private Driver driver;
- private int numberOfNC = 2;
- private int numPartitionPerMachine = 1;
-
- private static final String ACTUAL_RESULT_DIR = "graphbuildresult";
- private static final String HDFS_OUTPUT_PATH = "/result";
- private static final String DUMPED_RESULT = ACTUAL_RESULT_DIR
- + HDFS_OUTPUT_PATH + "/result.txt";
- private static final String CONVERT_RESULT = ACTUAL_RESULT_DIR
- + HDFS_OUTPUT_PATH + "/result.txt.txt";
-
- public GraphBuildTestCase(JobConf conf, Driver driver){
- this.conf = conf;
- this.driver = driver;
- }
-
- private void cleanUpReEntry() throws IOException {
- FileSystem lfs = FileSystem.getLocal(new Configuration());
- if (lfs.exists(new Path(DUMPED_RESULT))) {
- lfs.delete(new Path(DUMPED_RESULT), true);
- }
- FileSystem dfs = FileSystem.get(conf);
- if (dfs.exists(new Path(HDFS_OUTPUT_PATH))) {
- dfs.delete(new Path(HDFS_OUTPUT_PATH), true);
- }
- }
+ private final JobConf conf;
+ private Driver driver;
+ private int numberOfNC = 2;
+ private int numPartitionPerMachine = 1;
- @Test
- public void Test() throws Exception {
- cleanUpReEntry();
- TestPreClusterGroupby();
- }
+ private static final String ACTUAL_RESULT_DIR = "graphbuildresult";
+ private static final String HDFS_OUTPUT_PATH = "/result";
+ private static final String DUMPED_RESULT = ACTUAL_RESULT_DIR + HDFS_OUTPUT_PATH + "/result.txt";
+ private static final String CONVERT_RESULT = ACTUAL_RESULT_DIR + HDFS_OUTPUT_PATH + "/result.txt.txt";
- public void TestPreClusterGroupby() throws Exception {
- conf.set(GenomixJob.GROUPBY_TYPE, "precluster");
- System.err.println("Testing PreClusterGroupBy");
- driver.runJob(new GenomixJob(conf), Plan.BUILD_DEBRUJIN_GRAPH, true);
- Assert.assertEquals(true, checkResults());
- }
+ public GraphBuildTestCase(JobConf conf, Driver driver) {
+ this.conf = conf;
+ this.driver = driver;
+ }
+ private void cleanUpReEntry() throws IOException {
+ FileSystem lfs = FileSystem.getLocal(new Configuration());
+ if (lfs.exists(new Path(DUMPED_RESULT))) {
+ lfs.delete(new Path(DUMPED_RESULT), true);
+ }
+ FileSystem dfs = FileSystem.get(conf);
+ if (dfs.exists(new Path(HDFS_OUTPUT_PATH))) {
+ dfs.delete(new Path(HDFS_OUTPUT_PATH), true);
+ }
+ }
- private boolean checkResults() throws Exception {
- File dumped = null;
- String format = conf.get(GenomixJob.OUTPUT_FORMAT);
- if ("text".equalsIgnoreCase(format)) {
- FileUtil.copyMerge(FileSystem.get(conf),
- new Path(HDFS_OUTPUT_PATH), FileSystem
- .getLocal(new Configuration()), new Path(
- DUMPED_RESULT), false, conf, null);
- dumped = new File(DUMPED_RESULT);
- } else {
+ @Test
+ public void Test() throws Exception {
+ cleanUpReEntry();
+ TestPreClusterGroupby();
+ }
- FileSystem.getLocal(new Configuration()).mkdirs(
- new Path(ACTUAL_RESULT_DIR + HDFS_OUTPUT_PATH));
- File filePathTo = new File(CONVERT_RESULT);
- BufferedWriter bw = new BufferedWriter(new FileWriter(filePathTo));
- for (int i = 0; i < numPartitionPerMachine * numberOfNC; i++) {
- String partname = "/part-" + i;
- FileUtil.copy(FileSystem.get(conf), new Path(HDFS_OUTPUT_PATH
- + partname), FileSystem.getLocal(new Configuration()),
- new Path(ACTUAL_RESULT_DIR + HDFS_OUTPUT_PATH
- + partname), false, conf);
+ public void TestPreClusterGroupby() throws Exception {
+ conf.set(GenomixJob.GROUPBY_TYPE, "precluster");
+ System.err.println("Testing PreClusterGroupBy");
+ driver.runJob(new GenomixJob(conf), Plan.BUILD_DEBRUJIN_GRAPH, true);
+ Assert.assertEquals(true, checkResults());
+ }
- Path path = new Path(HDFS_OUTPUT_PATH + partname);
- FileSystem dfs = FileSystem.get(conf);
- if (dfs.getFileStatus(path).getLen() == 0) {
- continue;
- }
- SequenceFile.Reader reader = new SequenceFile.Reader(dfs, path,
- conf);
- KmerBytesWritable key = new KmerBytesWritable(conf.getInt(
- GenomixJob.KMER_LENGTH, GenomixJob.DEFAULT_KMER));
- KmerCountValue value = (KmerCountValue) ReflectionUtils
- .newInstance(reader.getValueClass(), conf);
+ private boolean checkResults() throws Exception {
+ File dumped = null;
+ String format = conf.get(GenomixJob.OUTPUT_FORMAT);
+ if ("text".equalsIgnoreCase(format)) {
+ FileUtil.copyMerge(FileSystem.get(conf), new Path(HDFS_OUTPUT_PATH),
+ FileSystem.getLocal(new Configuration()), new Path(DUMPED_RESULT), false, conf, null);
+ dumped = new File(DUMPED_RESULT);
+ } else {
- while (reader.next(key, value)) {
- if (key == null || value == null) {
- break;
- }
- bw.write(key.toString() + "\t" + value.toString());
- System.out
- .println(key.toString() + "\t" + value.toString());
- bw.newLine();
- }
- reader.close();
- }
- bw.close();
- dumped = new File(CONVERT_RESULT);
- }
+ FileSystem.getLocal(new Configuration()).mkdirs(new Path(ACTUAL_RESULT_DIR + HDFS_OUTPUT_PATH));
+ File filePathTo = new File(CONVERT_RESULT);
+ BufferedWriter bw = new BufferedWriter(new FileWriter(filePathTo));
+ for (int i = 0; i < numPartitionPerMachine * numberOfNC; i++) {
+ String partname = "/part-" + i;
+ FileUtil.copy(FileSystem.get(conf), new Path(HDFS_OUTPUT_PATH + partname),
+ FileSystem.getLocal(new Configuration()), new Path(ACTUAL_RESULT_DIR + HDFS_OUTPUT_PATH
+ + partname), false, conf);
- // TestUtils.compareWithSortedResult(new File(expectedPath), dumped);
- return true;
- }
+ Path path = new Path(HDFS_OUTPUT_PATH + partname);
+ FileSystem dfs = FileSystem.get(conf);
+ if (dfs.getFileStatus(path).getLen() == 0) {
+ continue;
+ }
+ SequenceFile.Reader reader = new SequenceFile.Reader(dfs, path, conf);
+ KmerBytesWritable key = new KmerBytesWritable(conf.getInt(GenomixJob.KMER_LENGTH,
+ GenomixJob.DEFAULT_KMER));
+ KmerCountValue value = (KmerCountValue) ReflectionUtils.newInstance(reader.getValueClass(), conf);
+
+ while (reader.next(key, value)) {
+ if (key == null || value == null) {
+ break;
+ }
+ bw.write(key.toString() + "\t" + value.toString());
+ System.out.println(key.toString() + "\t" + value.toString());
+ bw.newLine();
+ }
+ reader.close();
+ }
+ bw.close();
+ dumped = new File(CONVERT_RESULT);
+ }
+
+ // TestUtils.compareWithSortedResult(new File(expectedPath), dumped);
+ return true;
+ }
}
diff --git a/genomix/genomix-pregelix/src/test/java/edu/uci/ics/genomix/pregelix/pathmerge/GraphBuildTestSuite.java b/genomix/genomix-pregelix/src/test/java/edu/uci/ics/genomix/pregelix/pathmerge/GraphBuildTestSuite.java
index d361c40..fdc3785 100644
--- a/genomix/genomix-pregelix/src/test/java/edu/uci/ics/genomix/pregelix/pathmerge/GraphBuildTestSuite.java
+++ b/genomix/genomix-pregelix/src/test/java/edu/uci/ics/genomix/pregelix/pathmerge/GraphBuildTestSuite.java
@@ -30,102 +30,98 @@
import junit.framework.TestSuite;
public class GraphBuildTestSuite extends TestSuite {
- private static final String ACTUAL_RESULT_DIR = "graphbuildresult";
- private static final String PATH_TO_HADOOP_CONF = "src/test/resources/hadoop/conf";
+ private static final String ACTUAL_RESULT_DIR = "graphbuildresult";
+ private static final String PATH_TO_HADOOP_CONF = "src/test/resources/hadoop/conf";
- private static final String DATA_PATH = "graph/7/TreePath";
- private static final String HDFS_INPUT_PATH = "/test";
- private static final String HDFS_OUTPUT_PATH = "/result";
+ private static final String DATA_PATH = "graph/7/TreePath";
+ private static final String HDFS_INPUT_PATH = "/test";
+ private static final String HDFS_OUTPUT_PATH = "/result";
- private static final String HADOOP_CONF_PATH = ACTUAL_RESULT_DIR
- + File.separator + "conf.xml";
- private MiniDFSCluster dfsCluster;
+ private static final String HADOOP_CONF_PATH = ACTUAL_RESULT_DIR + File.separator + "conf.xml";
+ private MiniDFSCluster dfsCluster;
- private static JobConf conf = new JobConf();
- private int numberOfNC = 2;
- private int numPartitionPerMachine = 1;
+ private static JobConf conf = new JobConf();
+ private int numberOfNC = 2;
+ private int numPartitionPerMachine = 1;
- private static Driver driver;
+ private static Driver driver;
- public void setUp() throws Exception {
- cleanupStores();
- edu.uci.ics.hyracks.hdfs.utils.HyracksUtils.init();
- FileUtils.forceMkdir(new File(ACTUAL_RESULT_DIR));
- FileUtils.cleanDirectory(new File(ACTUAL_RESULT_DIR));
- startHDFS();
+ public void setUp() throws Exception {
+ cleanupStores();
+ edu.uci.ics.hyracks.hdfs.utils.HyracksUtils.init();
+ FileUtils.forceMkdir(new File(ACTUAL_RESULT_DIR));
+ FileUtils.cleanDirectory(new File(ACTUAL_RESULT_DIR));
+ startHDFS();
- FileInputFormat.setInputPaths(conf, HDFS_INPUT_PATH);
- FileOutputFormat.setOutputPath(conf, new Path(HDFS_OUTPUT_PATH));
+ FileInputFormat.setInputPaths(conf, HDFS_INPUT_PATH);
+ FileOutputFormat.setOutputPath(conf, new Path(HDFS_OUTPUT_PATH));
- conf.setInt(GenomixJob.KMER_LENGTH, 7);
- driver = new Driver(
- edu.uci.ics.hyracks.hdfs.utils.HyracksUtils.CC_HOST,
- edu.uci.ics.hyracks.hdfs.utils.HyracksUtils.TEST_HYRACKS_CC_CLIENT_PORT,
- numPartitionPerMachine);
- }
+ conf.setInt(GenomixJob.KMER_LENGTH, 7);
+ driver = new Driver(edu.uci.ics.hyracks.hdfs.utils.HyracksUtils.CC_HOST,
+ edu.uci.ics.hyracks.hdfs.utils.HyracksUtils.TEST_HYRACKS_CC_CLIENT_PORT, numPartitionPerMachine);
+ }
- private void cleanupStores() throws IOException {
- FileUtils.forceMkdir(new File("teststore"));
- FileUtils.forceMkdir(new File("build"));
- FileUtils.cleanDirectory(new File("teststore"));
- FileUtils.cleanDirectory(new File("build"));
- }
+ private void cleanupStores() throws IOException {
+ FileUtils.forceMkdir(new File("teststore"));
+ FileUtils.forceMkdir(new File("build"));
+ FileUtils.cleanDirectory(new File("teststore"));
+ FileUtils.cleanDirectory(new File("build"));
+ }
- private void startHDFS() throws IOException {
- conf.addResource(new Path(PATH_TO_HADOOP_CONF + "/core-site.xml"));
- conf.addResource(new Path(PATH_TO_HADOOP_CONF + "/mapred-site.xml"));
- conf.addResource(new Path(PATH_TO_HADOOP_CONF + "/hdfs-site.xml"));
+ private void startHDFS() throws IOException {
+ conf.addResource(new Path(PATH_TO_HADOOP_CONF + "/core-site.xml"));
+ conf.addResource(new Path(PATH_TO_HADOOP_CONF + "/mapred-site.xml"));
+ conf.addResource(new Path(PATH_TO_HADOOP_CONF + "/hdfs-site.xml"));
- FileSystem lfs = FileSystem.getLocal(new Configuration());
- lfs.delete(new Path("build"), true);
- System.setProperty("hadoop.log.dir", "logs");
- dfsCluster = new MiniDFSCluster(conf, numberOfNC, true, null);
- FileSystem dfs = FileSystem.get(conf);
- Path src = new Path(DATA_PATH);
- Path dest = new Path(HDFS_INPUT_PATH);
- dfs.mkdirs(dest);
- dfs.copyFromLocalFile(src, dest);
+ FileSystem lfs = FileSystem.getLocal(new Configuration());
+ lfs.delete(new Path("build"), true);
+ System.setProperty("hadoop.log.dir", "logs");
+ dfsCluster = new MiniDFSCluster(conf, numberOfNC, true, null);
+ FileSystem dfs = FileSystem.get(conf);
+ Path src = new Path(DATA_PATH);
+ Path dest = new Path(HDFS_INPUT_PATH);
+ dfs.mkdirs(dest);
+ dfs.copyFromLocalFile(src, dest);
- DataOutputStream confOutput = new DataOutputStream(
- new FileOutputStream(new File(HADOOP_CONF_PATH)));
- conf.writeXml(confOutput);
- confOutput.flush();
- confOutput.close();
- }
-
- public static Test suite() throws Exception {
- GraphBuildTestSuite testSuite = new GraphBuildTestSuite();
- testSuite.setUp();
- testSuite.addTest(new GraphBuildTestCase(conf, driver));
- return testSuite;
- }
-
- /**
- * Runs the tests and collects their result in a TestResult.
- */
- @Override
- public void run(TestResult result) {
- try {
- int testCount = countTestCases();
- for (int i = 0; i < testCount; i++) {
- // cleanupStores();
- Test each = this.testAt(i);
- if (result.shouldStop())
- break;
- runTest(each, result);
- }
- tearDown();
- } catch (Exception e) {
- throw new IllegalStateException(e);
- }
- }
-
- public void tearDown() throws Exception {
- edu.uci.ics.hyracks.hdfs.utils.HyracksUtils.deinit();
- cleanupHDFS();
- }
+ DataOutputStream confOutput = new DataOutputStream(new FileOutputStream(new File(HADOOP_CONF_PATH)));
+ conf.writeXml(confOutput);
+ confOutput.flush();
+ confOutput.close();
+ }
- private void cleanupHDFS() throws Exception {
- dfsCluster.shutdown();
- }
+ public static Test suite() throws Exception {
+ GraphBuildTestSuite testSuite = new GraphBuildTestSuite();
+ testSuite.setUp();
+ testSuite.addTest(new GraphBuildTestCase(conf, driver));
+ return testSuite;
+ }
+
+ /**
+ * Runs the tests and collects their result in a TestResult.
+ */
+ @Override
+ public void run(TestResult result) {
+ try {
+ int testCount = countTestCases();
+ for (int i = 0; i < testCount; i++) {
+ // cleanupStores();
+ Test each = this.testAt(i);
+ if (result.shouldStop())
+ break;
+ runTest(each, result);
+ }
+ tearDown();
+ } catch (Exception e) {
+ throw new IllegalStateException(e);
+ }
+ }
+
+ public void tearDown() throws Exception {
+ edu.uci.ics.hyracks.hdfs.utils.HyracksUtils.deinit();
+ cleanupHDFS();
+ }
+
+ private void cleanupHDFS() throws Exception {
+ dfsCluster.shutdown();
+ }
}
diff --git a/genomix/genomix-pregelix/src/test/java/edu/uci/ics/genomix/pregelix/pathmerge/MergePathTest.java b/genomix/genomix-pregelix/src/test/java/edu/uci/ics/genomix/pregelix/pathmerge/MergePathTest.java
index cb43b72..68c186a 100644
--- a/genomix/genomix-pregelix/src/test/java/edu/uci/ics/genomix/pregelix/pathmerge/MergePathTest.java
+++ b/genomix/genomix-pregelix/src/test/java/edu/uci/ics/genomix/pregelix/pathmerge/MergePathTest.java
@@ -18,119 +18,118 @@
import edu.uci.ics.genomix.type.KmerBytesWritable;
public class MergePathTest {
- public static final String PATH_TO_TESTSTORE = "testcase/pathmerge/";
- public static final String NAIVE_DATA_INPUT = "genomix_result/p1_nc8_4vertex";
- public static final String LOG_DATA_INPUT = "genomix_result/p2_nc8_4vertex";
- public static final String TEXT_OUTPUT = PATH_TO_TESTSTORE + "textfile";
- public static final String CHAIN_OUTPUT = PATH_TO_TESTSTORE + "chain";
-
- private static int nc = 8;
- private static int kmerSize = 55;
- //private static int maxLength = 102;
-
- @Test
- public void test() throws Exception {
- FileUtils.forceMkdir(new File(PATH_TO_TESTSTORE));
- FileUtils.cleanDirectory(new File(PATH_TO_TESTSTORE));
- FileUtils.forceMkdir(new File(TEXT_OUTPUT));
- FileUtils.cleanDirectory(new File(TEXT_OUTPUT));
- FileUtils.forceMkdir(new File(CHAIN_OUTPUT));
- FileUtils.cleanDirectory(new File(CHAIN_OUTPUT));
- generateTextFromPathmergeResult(NAIVE_DATA_INPUT, TEXT_OUTPUT, "/naive");
- generateTextFromPathmergeResult(LOG_DATA_INPUT, TEXT_OUTPUT, "/log");
- //generateSpecificLengthChainFromNaivePathmergeResult(NAIVE_DATA_INPUT, CHAIN_OUTPUT, maxLength);
- //generateSpecificLengthChainFromLogPathmergeResult(LOG_DATA_INPUT, CHAIN_OUTPUT, maxLength);
- }
-
- public static void generateTextFromPathmergeResult(String input, String outputDir, String fileName) throws IOException{
- BufferedWriter bw = new BufferedWriter(new FileWriter(new File(outputDir + fileName)));
- Configuration conf = new Configuration();
- FileSystem fileSys = FileSystem.get(conf);
- for(int i = 0; i < nc; i++){
- Path path = new Path(input + "/part-" + i);
- SequenceFile.Reader reader = new SequenceFile.Reader(fileSys, path, conf);
- KmerBytesWritable key = new KmerBytesWritable(kmerSize);
- ValueStateWritable value = new ValueStateWritable();
-
- while(reader.next(key, value)){
- if (key == null || value == null){
- break;
- }
- if(value.getState() == State.FINAL_VERTEX){
- bw.write(value.getMergeChain().toString()
- + "\t" + GeneCode.getSymbolFromBitMap(value.getAdjMap()));
- bw.newLine();
- /*bw.write(key.toString()
- + "\t" + value.toString());
- bw.newLine();*/
- }
- //if(value.getLengthOfMergeChain() != 0
- // && value.getLengthOfMergeChain() != -1
- // && value.getState() == State.FINAL_VERTEX){
- //bw.write(key.toString() + "\t" +
- // value.toString());
- //bw.write(value.getLengthOfMergeChain() + "\t" +
- // value.getMergeChain().toString() + "\t" +
- // GeneCode.getSymbolFromBitMap(value.getAdjMap()) + "\t" +
- // key.toString());
- //value.getState());
-
- //}
- }
- reader.close();
- }
- bw.close();
- }
-
- public static void generateSpecificLengthChainFromNaivePathmergeResult(String input, String output, int maxLength) throws IOException{
- BufferedWriter bw = new BufferedWriter(new FileWriter(new File(output + "/naive")));
- Configuration conf = new Configuration();
- FileSystem fileSys = FileSystem.get(conf);
- for(int i = 0; i < nc; i++){
- Path path = new Path(input + "/part-" + i);
- SequenceFile.Reader reader = new SequenceFile.Reader(fileSys, path, conf);
- KmerBytesWritable key = new KmerBytesWritable(kmerSize);
- ValueStateWritable value = new ValueStateWritable();
-
- while(reader.next(key, value)){
- if (key == null || value == null){
- break;
- }
- if(value.getLengthOfMergeChain() != -1 && value.getLengthOfMergeChain() <= maxLength
- && value.getLengthOfMergeChain() != kmerSize){
- bw.write(value.getLengthOfMergeChain() + "\t" +
- value.getMergeChain().toString());
- bw.newLine();
- }
- }
- reader.close();
- }
- bw.close();
- }
-
- public static void generateSpecificLengthChainFromLogPathmergeResult(String input, String output, int maxLength) throws IOException{
- BufferedWriter bw = new BufferedWriter(new FileWriter(new File(output + "/log")));
- Configuration conf = new Configuration();
- FileSystem fileSys = FileSystem.get(conf);
- for(int i = 0; i < nc; i++){
- Path path = new Path(input + "/part-" + i);
- SequenceFile.Reader reader = new SequenceFile.Reader(fileSys, path, conf);
- KmerBytesWritable key = new KmerBytesWritable(kmerSize);
- ValueStateWritable value = new ValueStateWritable();
-
- while(reader.next(key, value)){
- if (key == null || value == null){
- break;
- }
- if(value.getLengthOfMergeChain() != -1 && value.getLengthOfMergeChain() <= maxLength
- && value.getState() == State.FINAL_VERTEX){
- bw.write(value.getLengthOfMergeChain() + "\t" +
- value.getMergeChain().toString());
- bw.newLine();
- }
- }
- reader.close();
- }
- bw.close();
- }
+ public static final String PATH_TO_TESTSTORE = "testcase/pathmerge/";
+ public static final String NAIVE_DATA_INPUT = "genomix_result/p1_nc4_16vertex";
+ public static final String LOG_DATA_INPUT = "genomix_result/p2_nc4_16vertex";
+ public static final String TEXT_OUTPUT = PATH_TO_TESTSTORE + "textfile";
+ public static final String CHAIN_OUTPUT = PATH_TO_TESTSTORE + "chain";
+
+ private static int nc = 4;
+ private static int kmerSize = 55;
+
+ //private static int maxLength = 102;
+
+ @Test
+ public void test() throws Exception {
+ FileUtils.forceMkdir(new File(PATH_TO_TESTSTORE));
+ FileUtils.cleanDirectory(new File(PATH_TO_TESTSTORE));
+ FileUtils.forceMkdir(new File(TEXT_OUTPUT));
+ FileUtils.cleanDirectory(new File(TEXT_OUTPUT));
+ FileUtils.forceMkdir(new File(CHAIN_OUTPUT));
+ FileUtils.cleanDirectory(new File(CHAIN_OUTPUT));
+ generateTextFromPathmergeResult(NAIVE_DATA_INPUT, TEXT_OUTPUT, "/naive");
+ generateTextFromPathmergeResult(LOG_DATA_INPUT, TEXT_OUTPUT, "/log");
+ //generateSpecificLengthChainFromNaivePathmergeResult(NAIVE_DATA_INPUT, CHAIN_OUTPUT, maxLength);
+ //generateSpecificLengthChainFromLogPathmergeResult(LOG_DATA_INPUT, CHAIN_OUTPUT, maxLength);
+ }
+
+ public static void generateTextFromPathmergeResult(String input, String outputDir, String fileName)
+ throws IOException {
+ BufferedWriter bw = new BufferedWriter(new FileWriter(new File(outputDir + fileName)));
+ Configuration conf = new Configuration();
+ FileSystem fileSys = FileSystem.get(conf);
+ for (int i = 0; i < nc; i++) {
+ Path path = new Path(input + "/part-" + i);
+ SequenceFile.Reader reader = new SequenceFile.Reader(fileSys, path, conf);
+ KmerBytesWritable key = new KmerBytesWritable(kmerSize);
+ ValueStateWritable value = new ValueStateWritable();
+
+ while (reader.next(key, value)) {
+ if (key == null || value == null) {
+ break;
+ }
+ if (value.getState() == State.FINAL_VERTEX) {
+ /*bw.write(value.getMergeChain().toString()
+ + "\t" + GeneCode.getSymbolFromBitMap(value.getAdjMap()));
+ bw.newLine();*/
+ bw.write(key.toString() + "\t" + value.toString());
+ bw.newLine();
+ }
+ //if(value.getLengthOfMergeChain() != 0
+ // && value.getLengthOfMergeChain() != -1
+ // && value.getState() == State.FINAL_VERTEX){
+ //bw.write(key.toString() + "\t" +
+ // value.toString());
+ //bw.write(value.getLengthOfMergeChain() + "\t" +
+ // value.getMergeChain().toString() + "\t" +
+ // GeneCode.getSymbolFromBitMap(value.getAdjMap()) + "\t" +
+ // key.toString());
+ //value.getState());
+
+ //}
+ }
+ reader.close();
+ }
+ bw.close();
+ }
+
+ public static void generateSpecificLengthChainFromNaivePathmergeResult(String input, String output, int maxLength)
+ throws IOException {
+ BufferedWriter bw = new BufferedWriter(new FileWriter(new File(output + "/naive")));
+ Configuration conf = new Configuration();
+ FileSystem fileSys = FileSystem.get(conf);
+ for (int i = 0; i < nc; i++) {
+ Path path = new Path(input + "/part-" + i);
+ SequenceFile.Reader reader = new SequenceFile.Reader(fileSys, path, conf);
+ KmerBytesWritable key = new KmerBytesWritable(kmerSize);
+ ValueStateWritable value = new ValueStateWritable();
+
+ while (reader.next(key, value)) {
+ if (key == null || value == null) {
+ break;
+ }
+ if (value.getLengthOfMergeChain() <= maxLength && value.getLengthOfMergeChain() != kmerSize) {
+ bw.write(value.getLengthOfMergeChain() + "\t" + value.getMergeChain().toString());
+ bw.newLine();
+ }
+ }
+ reader.close();
+ }
+ bw.close();
+ }
+
+ public static void generateSpecificLengthChainFromLogPathmergeResult(String input, String output, int maxLength)
+ throws IOException {
+ BufferedWriter bw = new BufferedWriter(new FileWriter(new File(output + "/log")));
+ Configuration conf = new Configuration();
+ FileSystem fileSys = FileSystem.get(conf);
+ for (int i = 0; i < nc; i++) {
+ Path path = new Path(input + "/part-" + i);
+ SequenceFile.Reader reader = new SequenceFile.Reader(fileSys, path, conf);
+ KmerBytesWritable key = new KmerBytesWritable(kmerSize);
+ ValueStateWritable value = new ValueStateWritable();
+
+ while (reader.next(key, value)) {
+ if (key == null || value == null) {
+ break;
+ }
+ if (value.getLengthOfMergeChain() <= maxLength && value.getState() == State.FINAL_VERTEX) {
+ bw.write(value.getLengthOfMergeChain() + "\t" + value.getMergeChain().toString());
+ bw.newLine();
+ }
+ }
+ reader.close();
+ }
+ bw.close();
+ }
}