Clean genomix package and complete mergeing with Master
diff --git a/genomix/genomix-data/src/main/java/edu/uci/ics/genomix/type/KmerBytesWritable.java b/genomix/genomix-data/src/main/java/edu/uci/ics/genomix/type/KmerBytesWritable.java
index bbba2fb..4ba12c0 100644
--- a/genomix/genomix-data/src/main/java/edu/uci/ics/genomix/type/KmerBytesWritable.java
+++ b/genomix/genomix-data/src/main/java/edu/uci/ics/genomix/type/KmerBytesWritable.java
@@ -38,7 +38,7 @@
protected static final byte[] EMPTY_BYTES = {};
protected static int lettersInKmer;
- protected static int bytesUsed;
+ private static int bytesUsed;
protected byte[] bytes;
protected int offset;
@@ -48,7 +48,7 @@
* should be called before any kmers are created
*/
public static void setGlobalKmerLength(int k) {
- bytesUsed = KmerUtil.getByteNumFromK(k);
+ setBytesUsed(KmerUtil.getByteNumFromK(k));
lettersInKmer = k;
}
@@ -56,7 +56,7 @@
* Initialize as empty kmer
*/
public KmerBytesWritable() {
- bytes = new byte[bytesUsed];
+ bytes = new byte[getBytesUsed()];
offset = 0;
}
@@ -102,7 +102,7 @@
*/
public void setAsCopy(KmerBytesWritable other) {
if (lettersInKmer > 0) {
- System.arraycopy(other.bytes, other.offset, bytes, offset, bytesUsed);
+ System.arraycopy(other.bytes, other.offset, bytes, offset, getBytesUsed());
}
}
@@ -116,7 +116,7 @@
throw new IllegalArgumentException("Provided VKmer (" + other + ") is of an incompatible length (was " + other.getKmerLetterLength() + ", should be " + lettersInKmer + ")!");
}
if (lettersInKmer > 0) {
- System.arraycopy(other.bytes, other.kmerStartOffset, bytes, offset, bytesUsed);
+ System.arraycopy(other.bytes, other.kmerStartOffset, bytes, offset, getBytesUsed());
}
}
@@ -128,11 +128,11 @@
* @param newOffset
*/
public void setAsCopy(byte[] newData, int newOffset) {
- if (newData.length - newOffset < bytesUsed) {
- throw new IllegalArgumentException("Requested " + bytesUsed + " bytes (k=" + lettersInKmer
+ if (newData.length - newOffset < getBytesUsed()) {
+ throw new IllegalArgumentException("Requested " + getBytesUsed() + " bytes (k=" + lettersInKmer
+ ") but buffer has only " + (newData.length - newOffset) + " bytes");
}
- System.arraycopy(newData, newOffset, bytes, offset, bytesUsed);
+ System.arraycopy(newData, newOffset, bytes, offset, getBytesUsed());
}
/**
@@ -143,8 +143,8 @@
* @param newOffset
*/
public void setAsReference(byte[] newData, int newOffset) {
- if (newData.length - newOffset < bytesUsed) {
- throw new IllegalArgumentException("Requested " + bytesUsed + " bytes (k=" + lettersInKmer
+ if (newData.length - newOffset < getBytesUsed()) {
+ throw new IllegalArgumentException("Requested " + getBytesUsed() + " bytes (k=" + lettersInKmer
+ ") but buffer has only " + (newData.length - newOffset) + " bytes");
}
bytes = newData;
@@ -187,7 +187,7 @@
private byte geneCodeAtPosition(int pos) {
int posByte = pos / 4;
int shift = (pos % 4) << 1;
- return (byte) ((bytes[offset + bytesUsed - 1 - posByte] >> shift) & 0x3);
+ return (byte) ((bytes[offset + getBytesUsed() - 1 - posByte] >> shift) & 0x3);
}
public static int getKmerLength() {
@@ -195,7 +195,7 @@
}
public static int getBytesPerKmer() {
- return bytesUsed;
+ return getBytesUsed();
}
@Override
@@ -209,7 +209,7 @@
@Override
public int getLength() {
- return bytesUsed;
+ return getBytesUsed();
}
/**
@@ -219,10 +219,11 @@
* @param stringBytes
* @param start
*/
+ @SuppressWarnings("static-access")
public void setByRead(byte[] stringBytes, int start) {
byte l = 0;
int bytecount = 0;
- int bcount = this.bytesUsed - 1;
+ int bcount = this.getBytesUsed() - 1;
for (int i = start; i < start + lettersInKmer && i < stringBytes.length; i++) {
byte code = GeneCode.getCodeFromSymbol(stringBytes[i]);
l |= (byte) (code << bytecount);
@@ -250,7 +251,7 @@
public void setByReadReverse(byte[] array, int start) {
byte l = 0;
int bytecount = 0;
- int bcount = bytesUsed - 1;
+ int bcount = getBytesUsed() - 1;
// for (int i = start + kmerlength - 1; i >= 0 && i < array.length; i--)
// {
for (int i = start + lettersInKmer - 1; i >= start && i < array.length; i--) {
@@ -287,8 +288,8 @@
* @return the shift out gene, in gene code format
*/
public byte shiftKmerWithNextCode(byte c) {
- byte output = (byte) (bytes[offset + bytesUsed - 1] & 0x03);
- for (int i = bytesUsed - 1; i > 0; i--) {
+ byte output = (byte) (bytes[offset + getBytesUsed() - 1] & 0x03);
+ for (int i = getBytesUsed() - 1; i > 0; i--) {
byte in = (byte) (bytes[offset + i - 1] & 0x03);
bytes[offset + i] = (byte) (((bytes[offset + i] >>> 2) & 0x3f) | (in << 6));
}
@@ -320,11 +321,11 @@
public byte shiftKmerWithPreCode(byte c) {
int pos = ((lettersInKmer - 1) % 4) << 1;
byte output = (byte) ((bytes[offset] >> pos) & 0x03);
- for (int i = 0; i < bytesUsed - 1; i++) {
+ for (int i = 0; i < getBytesUsed() - 1; i++) {
byte in = (byte) ((bytes[offset + i + 1] >> 6) & 0x03);
bytes[offset + i] = (byte) ((bytes[offset + i] << 2) | in);
}
- bytes[offset + bytesUsed - 1] = (byte) ((bytes[offset + bytesUsed - 1] << 2) | c);
+ bytes[offset + getBytesUsed() - 1] = (byte) ((bytes[offset + getBytesUsed() - 1] << 2) | c);
clearLeadBit();
return output;
}
@@ -364,17 +365,17 @@
@Override
public void readFields(DataInput in) throws IOException {
- in.readFully(bytes, offset, bytesUsed);
+ in.readFully(bytes, offset, getBytesUsed());
}
@Override
public void write(DataOutput out) throws IOException {
- out.write(bytes, offset, bytesUsed);
+ out.write(bytes, offset, getBytesUsed());
}
@Override
public int hashCode() {
- return Marshal.hashBytes(bytes, offset, bytesUsed);
+ return Marshal.hashBytes(bytes, offset, getBytesUsed());
}
@Override
@@ -382,7 +383,7 @@
if (right_obj instanceof KmerBytesWritable) {
// since these may be backed by storage of different sizes, we have to manually check each byte
KmerBytesWritable right = (KmerBytesWritable) right_obj;
- for (int i=0; i < bytesUsed; i++) {
+ for (int i=0; i < getBytesUsed(); i++) {
if (bytes[offset + i] != right.bytes[right.offset + i]) {
return false;
}
@@ -394,7 +395,15 @@
@Override
public String toString() {
- return KmerUtil.recoverKmerFrom(lettersInKmer, bytes, offset, bytesUsed);
+ return KmerUtil.recoverKmerFrom(lettersInKmer, bytes, offset, getBytesUsed());
+ }
+
+ public static int getBytesUsed() {
+ return bytesUsed;
+ }
+
+ public static void setBytesUsed(int bytesUsed) {
+ KmerBytesWritable.bytesUsed = bytesUsed;
}
public static class Comparator extends WritableComparator {
diff --git a/genomix/genomix-data/src/main/java/edu/uci/ics/genomix/type/VKmerBytesWritable.java b/genomix/genomix-data/src/main/java/edu/uci/ics/genomix/type/VKmerBytesWritable.java
index f9ebd15..79c342c 100644
--- a/genomix/genomix-data/src/main/java/edu/uci/ics/genomix/type/VKmerBytesWritable.java
+++ b/genomix/genomix-data/src/main/java/edu/uci/ics/genomix/type/VKmerBytesWritable.java
@@ -104,6 +104,7 @@
*
* @param other
*/
+ @SuppressWarnings("static-access")
public VKmerBytesWritable(KmerBytesWritable other) {
this(other.lettersInKmer);
setAsCopy(other);
@@ -126,6 +127,7 @@
*
* @param other
*/
+ @SuppressWarnings("static-access")
public void setAsCopy(KmerBytesWritable other) {
reset(other.lettersInKmer);
if (lettersInKmer > 0) {
diff --git a/genomix/genomix-hyracks/src/main/java/edu/uci/ics/genomix/hyracks/newgraph/job/JobGenCheckReader.java b/genomix/genomix-hyracks/src/main/java/edu/uci/ics/genomix/hyracks/newgraph/job/JobGenCheckReader.java
index f512f43..e077306 100644
--- a/genomix/genomix-hyracks/src/main/java/edu/uci/ics/genomix/hyracks/newgraph/job/JobGenCheckReader.java
+++ b/genomix/genomix-hyracks/src/main/java/edu/uci/ics/genomix/hyracks/newgraph/job/JobGenCheckReader.java
@@ -18,7 +18,6 @@
import java.io.IOException;
import java.util.Map;
-import org.apache.hadoop.conf.Configuration;
import edu.uci.ics.genomix.hyracks.newgraph.dataflow.ReadsKeyValueParserFactory;
import edu.uci.ics.genomix.type.NodeWritable;
import edu.uci.ics.genomix.type.KmerBytesWritable;
@@ -33,7 +32,6 @@
import edu.uci.ics.hyracks.dataflow.std.connectors.OneToOneConnectorDescriptor;
import edu.uci.ics.hyracks.hdfs.api.ITupleWriter;
import edu.uci.ics.hyracks.hdfs.api.ITupleWriterFactory;
-import edu.uci.ics.hyracks.hdfs.dataflow.ConfFactory;
import edu.uci.ics.hyracks.hdfs.dataflow.HDFSReadOperatorDescriptor;
import edu.uci.ics.hyracks.hdfs.dataflow.HDFSWriteOperatorDescriptor;
import edu.uci.ics.hyracks.hdfs.scheduler.Scheduler;
diff --git a/genomix/genomix-hyracks/src/test/java/edu/uci/ics/genomix/hyracks/newgraph/test/JobRun.java b/genomix/genomix-hyracks/src/test/java/edu/uci/ics/genomix/hyracks/newgraph/test/JobRun.java
index 3a98573..6e20440 100644
--- a/genomix/genomix-hyracks/src/test/java/edu/uci/ics/genomix/hyracks/newgraph/test/JobRun.java
+++ b/genomix/genomix-hyracks/src/test/java/edu/uci/ics/genomix/hyracks/newgraph/test/JobRun.java
@@ -1,21 +1,16 @@
package edu.uci.ics.genomix.hyracks.newgraph.test;
-import java.io.BufferedWriter;
import java.io.DataOutputStream;
import java.io.File;
import java.io.FileOutputStream;
-import java.io.FileWriter;
import java.io.IOException;
-import junit.framework.Assert;
import org.apache.commons.io.FileUtils;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.FileUtil;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.hdfs.MiniDFSCluster;
-import org.apache.hadoop.io.NullWritable;
-import org.apache.hadoop.io.SequenceFile;
import org.apache.hadoop.mapred.FileInputFormat;
import org.apache.hadoop.mapred.FileOutputFormat;
import org.apache.hadoop.mapred.JobConf;
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 e2e7dfb..6533d5f 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
@@ -2,7 +2,6 @@
import edu.uci.ics.genomix.pregelix.io.AdjacencyListWritable;
import edu.uci.ics.genomix.pregelix.io.VertexValueWritable;
-import edu.uci.ics.genomix.type.KmerBytesWritable;
import edu.uci.ics.genomix.type.VKmerBytesWritable;
public class VertexUtil {