modify the DeepGraphBuildingMapper
diff --git a/genomix/genomix-data/src/main/java/edu/uci/ics/genomix/type/PositionListWritable.java b/genomix/genomix-data/src/main/java/edu/uci/ics/genomix/type/PositionListWritable.java
index 40817e8..11d0998 100644
--- a/genomix/genomix-data/src/main/java/edu/uci/ics/genomix/type/PositionListWritable.java
+++ b/genomix/genomix-data/src/main/java/edu/uci/ics/genomix/type/PositionListWritable.java
@@ -19,7 +19,8 @@
protected int offset;
protected int valueCount;
protected static final byte[] EMPTY = {};
-
+ public static final int INTBYTES = 4;
+
protected PositionWritable posIter = new PositionWritable();
public PositionListWritable() {
@@ -67,6 +68,14 @@
return posIter;
}
+ public void resetPosition(int i, int readID, byte posInRead) {
+ if (i >= valueCount) {
+ throw new ArrayIndexOutOfBoundsException("No such positions");
+ }
+ Marshal.putInt(readID, storage, offset + i * PositionWritable.LENGTH);
+ storage[offset + INTBYTES] = posInRead;
+ }
+
@Override
public Iterator<PositionWritable> iterator() {
Iterator<PositionWritable> it = new Iterator<PositionWritable>() {
@@ -120,7 +129,7 @@
storage[offset + valueCount * PositionWritable.LENGTH + PositionWritable.INTBYTES] = posInRead;
valueCount += 1;
}
-
+
public static int getCountByDataLength(int length) {
if (length % PositionWritable.LENGTH != 0) {
throw new IllegalArgumentException("Length of positionlist is invalid");
diff --git a/genomix/genomix-hadoop/src/main/java/edu/uci/ics/genomix/hadoop/velvetgraphbuilding/DeepGraphBuildingMapper.java b/genomix/genomix-hadoop/src/main/java/edu/uci/ics/genomix/hadoop/velvetgraphbuilding/DeepGraphBuildingMapper.java
index 954abbe..c3c252a 100644
--- a/genomix/genomix-hadoop/src/main/java/edu/uci/ics/genomix/hadoop/velvetgraphbuilding/DeepGraphBuildingMapper.java
+++ b/genomix/genomix-hadoop/src/main/java/edu/uci/ics/genomix/hadoop/velvetgraphbuilding/DeepGraphBuildingMapper.java
@@ -16,14 +16,18 @@
Mapper<KmerBytesWritable, PositionListWritable, PositionWritable, PositionListAndKmerWritable> {
public PositionWritable VertexID;
+ public PositionWritable tempVertex;
public PositionListWritable listPosZeroInRead;
public PositionListWritable listPosNonZeroInRead;
+ public PositionListWritable tempPosList;
public PositionListAndKmerWritable outputListAndKmer;
@Override
public void configure(JobConf job) {
VertexID = new PositionWritable();
+ tempVertex = new PositionWritable();
listPosZeroInRead = new PositionListWritable();
listPosNonZeroInRead = new PositionListWritable();
+ tempPosList = new PositionListWritable();
outputListAndKmer = new PositionListAndKmerWritable();
}
@Override
@@ -43,12 +47,29 @@
}
for(int i = 0; i < listPosZeroInRead.getCountOfPosition(); i++) {
VertexID.set(listPosZeroInRead.getPosition(i));
- outputListAndKmer.set(listPosNonZeroInRead, key);//you suo bianhua1. -1 2. qudiao tongyihangde
+ tempPosList.reset();
+ for (int j = 0; j < listPosNonZeroInRead.getCountOfPosition(); j++) {
+ tempVertex.set(listPosNonZeroInRead.getPosition(i));
+ if(tempVertex.getReadID() != VertexID.getReadID()) {
+ int tempReadID = tempVertex.getReadID();
+ byte tempPosInRead = (byte) (tempVertex.getPosInRead() - 1);
+ tempVertex.set(tempReadID, tempPosInRead);
+ tempPosList.append(tempVertex);
+ }
+ }
+ outputListAndKmer.set(tempPosList, key);
output.collect(VertexID, outputListAndKmer);
}
for(int i = 0; i < listPosNonZeroInRead.getCountOfPosition(); i++) {
VertexID.set(listPosNonZeroInRead.getPosition(i));
- outputListAndKmer.set(listPosZeroInRead, key);
+ tempPosList.reset();
+ for (int j = 0; j < listPosZeroInRead.getCountOfPosition(); j++) {
+ tempVertex.set(listPosNonZeroInRead.getPosition(i));
+ if(tempVertex.getReadID() != VertexID.getReadID()) {
+ tempPosList.append(tempVertex);
+ }
+ }
+ outputListAndKmer.set(tempPosList, key);
output.collect(VertexID, outputListAndKmer);
}
}
diff --git a/genomix/genomix-hadoop/src/main/java/edu/uci/ics/genomix/hadoop/velvetgraphbuilding/DeepGraphBuildingReducer.java b/genomix/genomix-hadoop/src/main/java/edu/uci/ics/genomix/hadoop/velvetgraphbuilding/DeepGraphBuildingReducer.java
index 40889b2..ee12661 100644
--- a/genomix/genomix-hadoop/src/main/java/edu/uci/ics/genomix/hadoop/velvetgraphbuilding/DeepGraphBuildingReducer.java
+++ b/genomix/genomix-hadoop/src/main/java/edu/uci/ics/genomix/hadoop/velvetgraphbuilding/DeepGraphBuildingReducer.java
@@ -9,9 +9,6 @@
import org.apache.hadoop.mapred.Reducer;
import org.apache.hadoop.mapred.Reporter;
import org.apache.hadoop.mapred.lib.MultipleOutputs;
-import edu.uci.ics.genomix.hadoop.oldtype.VKmerBytesWritable;
-import edu.uci.ics.genomix.hadoop.oldtype.VKmerBytesWritableFactory;
-import edu.uci.ics.genomix.hadoop.pmcommon.MergePathValueWritable;
import edu.uci.ics.genomix.type.NodeWritable;
import edu.uci.ics.genomix.type.PositionListWritable;
import edu.uci.ics.genomix.type.PositionWritable;
diff --git a/genomix/genomix-hadoop/src/main/java/edu/uci/ics/genomix/hadoop/velvetgraphbuilding/LineBasedmappingWritable.java b/genomix/genomix-hadoop/src/main/java/edu/uci/ics/genomix/hadoop/velvetgraphbuilding/LineBasedmappingWritable.java
deleted file mode 100644
index 0b6b0a8..0000000
--- a/genomix/genomix-hadoop/src/main/java/edu/uci/ics/genomix/hadoop/velvetgraphbuilding/LineBasedmappingWritable.java
+++ /dev/null
@@ -1,41 +0,0 @@
-package edu.uci.ics.genomix.hadoop.velvetgraphbuilding;
-
-import java.io.DataInput;
-import java.io.DataOutput;
-import java.io.IOException;
-import edu.uci.ics.genomix.type.PositionListWritable;
-
-public class LineBasedmappingWritable extends PositionListWritable{
- byte posInRead;
-
- public LineBasedmappingWritable() {
- super();
- this.posInRead = -1;
- }
-
- public LineBasedmappingWritable(int count, byte [] data, int offset, byte posInRead) {
- super(count, data, offset);
- this.posInRead = posInRead;
- }
-
- public void set(byte posInRead, PositionListWritable right) {
- super.set(right);
- this.posInRead = posInRead;
- }
-
- @Override
- public void readFields(DataInput in) throws IOException {
- super.readFields(in);
- this.posInRead = in.readByte();
- }
-
- @Override
- public void write(DataOutput out) throws IOException {
- super.write(out);
- out.writeByte(this.posInRead);
- }
-
- public int getPosInInvertedIndex() {
- return this.posInRead;
- }
-}