Refactor Vertex class to use SequenceRecords
This commit is contained in:
@@ -105,8 +105,7 @@ public class Simulator implements GraphModificationFunctions {
|
|||||||
//the list of alpha vertices
|
//the list of alpha vertices
|
||||||
List<Vertex> alphaVertices = new ArrayList<>();
|
List<Vertex> alphaVertices = new ArrayList<>();
|
||||||
for (String seq : plateAtoVMap.keySet()) {
|
for (String seq : plateAtoVMap.keySet()) {
|
||||||
Vertex alphaVertex = new Vertex(SequenceType.CDR3_ALPHA, seq, alphaSequences.get(seq).getOccupancy(),
|
Vertex alphaVertex = new Vertex(alphaSequences.get(seq), plateAtoVMap.get(seq));
|
||||||
plateAtoVMap.get(seq), alphaSequences.get(seq).getReadCount());
|
|
||||||
alphaVertices.add(alphaVertex);
|
alphaVertices.add(alphaVertex);
|
||||||
}
|
}
|
||||||
//Sort to make sure the order of vertices in list matches the order of the adjacency matrix
|
//Sort to make sure the order of vertices in list matches the order of the adjacency matrix
|
||||||
@@ -116,8 +115,7 @@ public class Simulator implements GraphModificationFunctions {
|
|||||||
//the list of beta vertices
|
//the list of beta vertices
|
||||||
List<Vertex> betaVertices = new ArrayList<>();
|
List<Vertex> betaVertices = new ArrayList<>();
|
||||||
for (String seq : plateBtoVMap.keySet()) {
|
for (String seq : plateBtoVMap.keySet()) {
|
||||||
Vertex betaVertex = new Vertex(SequenceType.CDR3_BETA, seq, betaSequences.get(seq).getOccupancy(),
|
Vertex betaVertex = new Vertex(betaSequences.get(seq), plateBtoVMap.get(seq));
|
||||||
plateBtoVMap.get(seq), betaSequences.get(seq).getReadCount());
|
|
||||||
betaVertices.add(betaVertex);
|
betaVertices.add(betaVertex);
|
||||||
}
|
}
|
||||||
//Sort to make sure the order of vertices in list matches the order of the adjacency matrix
|
//Sort to make sure the order of vertices in list matches the order of the adjacency matrix
|
||||||
|
|||||||
@@ -1,76 +1,43 @@
|
|||||||
import org.jheaps.AddressableHeap;
|
import org.jheaps.AddressableHeap;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
public class Vertex implements Serializable, Comparable<Vertex> {
|
public class Vertex implements Serializable, Comparable<Vertex> {
|
||||||
private SequenceType type;
|
private SequenceRecord record;
|
||||||
private Integer vertexLabel;
|
private Integer vertexLabel;
|
||||||
private String sequence;
|
private Double potential;
|
||||||
private Integer occupancy;
|
|
||||||
private Integer readCount;
|
|
||||||
private Double potential;
|
|
||||||
private AddressableHeap queue;
|
private AddressableHeap queue;
|
||||||
|
|
||||||
public Vertex(Integer vertexLabel) {
|
public Vertex(SequenceRecord record, Integer vertexLabel) {
|
||||||
|
this.record = record;
|
||||||
this.vertexLabel = vertexLabel;
|
this.vertexLabel = vertexLabel;
|
||||||
}
|
}
|
||||||
public Vertex(String vertexLabel) {
|
|
||||||
this.vertexLabel = Integer.parseInt((vertexLabel));
|
|
||||||
}
|
|
||||||
|
|
||||||
public Vertex(SequenceType type, String sequence, Integer occupancy, Integer vertexLabel) {
|
public SequenceRecord getRecord() { return record; }
|
||||||
this.type = type;
|
|
||||||
this.vertexLabel = vertexLabel;
|
|
||||||
this.sequence = sequence;
|
|
||||||
this.occupancy = occupancy;
|
|
||||||
this.readCount = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Vertex(SequenceType type, String sequence, Integer occupancy, Integer vertexLabel, Integer readCount) {
|
public SequenceType getType() { return record.getSequenceType(); }
|
||||||
this.type = type;
|
|
||||||
this.vertexLabel = vertexLabel;
|
|
||||||
this.sequence = sequence;
|
|
||||||
this.occupancy = occupancy;
|
|
||||||
this.readCount = readCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public SequenceType getType() {
|
|
||||||
return type;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setType(String type) {
|
|
||||||
this.type = SequenceType.valueOf(type);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getVertexLabel() {
|
public Integer getVertexLabel() {
|
||||||
return vertexLabel;
|
return vertexLabel;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setVertexLabel(String label) {
|
|
||||||
this.vertexLabel = Integer.parseInt(label);
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getSequence() {
|
public String getSequence() {
|
||||||
return sequence;
|
return record.getSequence();
|
||||||
}
|
|
||||||
|
|
||||||
public void setSequence(String sequence) {
|
|
||||||
this.sequence = sequence;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Integer getOccupancy() {
|
public Integer getOccupancy() {
|
||||||
return occupancy;
|
return record.getOccupancy();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setOccupancy(String occupancy) {
|
public Integer getReadCount() { return record.getReadCount(); }
|
||||||
this.occupancy = Integer.parseInt(occupancy);
|
|
||||||
}
|
public Map<Integer, Integer> getWellOccupancies() { return record.getWellOccupancies(); }
|
||||||
|
|
||||||
@Override //adapted from JGraphT example code
|
@Override //adapted from JGraphT example code
|
||||||
public int hashCode()
|
public int hashCode()
|
||||||
{
|
{
|
||||||
return (sequence == null) ? 0 : sequence.hashCode();
|
return (this.getSequence() == null) ? 0 : this.getSequence().hashCode();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override //adapted from JGraphT example code
|
@Override //adapted from JGraphT example code
|
||||||
@@ -83,22 +50,21 @@ public class Vertex implements Serializable, Comparable<Vertex> {
|
|||||||
if (getClass() != obj.getClass())
|
if (getClass() != obj.getClass())
|
||||||
return false;
|
return false;
|
||||||
Vertex other = (Vertex) obj;
|
Vertex other = (Vertex) obj;
|
||||||
if (sequence == null) {
|
if (this.getSequence() == null) {
|
||||||
return other.sequence == null;
|
return other.getSequence() == null;
|
||||||
} else {
|
} else {
|
||||||
return sequence.equals(other.sequence);
|
return this.getSequence().equals(other.getSequence());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override //adapted from JGraphT example code
|
@Override //adapted from JGraphT example code
|
||||||
public String toString()
|
public String toString()
|
||||||
{
|
{
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
sb.append("(").append(vertexLabel)
|
sb.append("(").append(vertexLabel)
|
||||||
.append(", Type: ").append(type.name())
|
.append(", Type: ").append(this.getType().name())
|
||||||
.append(", Sequence: ").append(sequence)
|
.append(", Sequence: ").append(this.getSequence())
|
||||||
.append(", Occupancy: ").append(occupancy).append(")");
|
.append(", Occupancy: ").append(this.getOccupancy()).append(")");
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -106,12 +72,4 @@ public class Vertex implements Serializable, Comparable<Vertex> {
|
|||||||
public int compareTo(Vertex other) {
|
public int compareTo(Vertex other) {
|
||||||
return this.vertexLabel - other.getVertexLabel();
|
return this.vertexLabel - other.getVertexLabel();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Integer getReadCount() {
|
|
||||||
return readCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setReadCount(Integer readCount) {
|
|
||||||
this.readCount = readCount;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user