From 02c8e6aacbaa3c845677ae720426fe105503425d Mon Sep 17 00:00:00 2001 From: eugenefischer <66030419+eugenefischer@users.noreply.github.com> Date: Mon, 26 Sep 2022 13:37:48 -0500 Subject: [PATCH] Refactor sequences to be strings instead of integers, to make simulating read errors easier --- src/main/java/CellFileReader.java | 26 +++------ src/main/java/CellFileWriter.java | 4 +- src/main/java/CellSample.java | 20 +++---- src/main/java/GraphWithMapData.java | 6 +-- src/main/java/MatchingResult.java | 6 +-- src/main/java/Plate.java | 38 ++++++------- src/main/java/PlateFileReader.java | 14 ++--- src/main/java/PlateFileWriter.java | 8 +-- src/main/java/Simulator.java | 83 ++++++++++++++--------------- src/main/java/Vertex.java | 11 ++-- 10 files changed, 101 insertions(+), 115 deletions(-) diff --git a/src/main/java/CellFileReader.java b/src/main/java/CellFileReader.java index f9dd61e..41a1b1f 100644 --- a/src/main/java/CellFileReader.java +++ b/src/main/java/CellFileReader.java @@ -12,7 +12,7 @@ import java.util.List; public class CellFileReader { private String filename; - private List distinctCells = new ArrayList<>(); + private List distinctCells = new ArrayList<>(); private Integer cdr1Freq; public CellFileReader(String filename) { @@ -32,11 +32,11 @@ public class CellFileReader { CSVParser parser = new CSVParser(reader, cellFileFormat); ){ for(CSVRecord record: parser.getRecords()) { - Integer[] cell = new Integer[4]; - cell[0] = Integer.valueOf(record.get("Alpha CDR3")); - cell[1] = Integer.valueOf(record.get("Beta CDR3")); - cell[2] = Integer.valueOf(record.get("Alpha CDR1")); - cell[3] = Integer.valueOf(record.get("Beta CDR1")); + String[] cell = new String[4]; + cell[0] = record.get("Alpha CDR3"); + cell[1] = record.get("Beta CDR3"); + cell[2] = record.get("Alpha CDR1"); + cell[3] = record.get("Beta CDR1"); distinctCells.add(cell); } @@ -47,8 +47,8 @@ public class CellFileReader { } //get CDR1 frequency - ArrayList cdr1Alphas = new ArrayList<>(); - for (Integer[] cell : distinctCells) { + ArrayList cdr1Alphas = new ArrayList<>(); + for (String[] cell : distinctCells) { cdr1Alphas.add(cell[3]); } double count = cdr1Alphas.stream().distinct().count(); @@ -62,14 +62,4 @@ public class CellFileReader { } public String getFilename() { return filename;} - - //Refactor everything that uses this to have access to a Cell Sample and get the cells there instead. - public List getListOfDistinctCellsDEPRECATED(){ - return distinctCells; - } - - public Integer getCellCountDEPRECATED() { - //Refactor everything that uses this to have access to a Cell Sample and get the count there instead. - return distinctCells.size(); - } } diff --git a/src/main/java/CellFileWriter.java b/src/main/java/CellFileWriter.java index e4c52cd..c173f7e 100644 --- a/src/main/java/CellFileWriter.java +++ b/src/main/java/CellFileWriter.java @@ -11,7 +11,7 @@ import java.util.List; public class CellFileWriter { private String[] headers = {"Alpha CDR3", "Beta CDR3", "Alpha CDR1", "Beta CDR1"}; - List cells; + List cells; String filename; Integer cdr1Freq; @@ -35,7 +35,7 @@ public class CellFileWriter { printer.printComment("Sample contains 1 unique CDR1 for every " + cdr1Freq + "unique CDR3s."); printer.printRecords(cells); } catch(IOException ex){ - System.out.println("Could not make new file named "+filename); + System.out.println("Could not make new file named " + filename); System.err.println(ex); } } diff --git a/src/main/java/CellSample.java b/src/main/java/CellSample.java index 95b6e39..b32e912 100644 --- a/src/main/java/CellSample.java +++ b/src/main/java/CellSample.java @@ -5,7 +5,7 @@ import java.util.stream.IntStream; public class CellSample { - private List cells; + private List cells; private Integer cdr1Freq; public CellSample(Integer numDistinctCells, Integer cdr1Freq){ @@ -24,28 +24,28 @@ public class CellSample { //Each cell represented by 4 values //two CDR3s, and two CDR1s. First two values are CDR3s (alpha, beta), second two are CDR1s (alpha, beta) - List distinctCells = new ArrayList<>(); + List distinctCells = new ArrayList<>(); for(int i = 0; i < numbersCDR3.size() - 1; i = i + 2){ //Go through entire CDR3 list once, make pairs of alphas and betas - Integer tmpCDR3a = numbersCDR3.get(i); - Integer tmpCDR3b = numbersCDR3.get(i+1); - //Go through (likely shorter) CDR1 list as many times as necessary, make pairs of alphas and betas - Integer tmpCDR1a = numbersCDR1.get(i % numbersCDR1.size()); - Integer tmpCDR1b = numbersCDR1.get((i+1) % numbersCDR1.size()); + String tmpCDR3a = numbersCDR3.get(i).toString(); + String tmpCDR3b = numbersCDR3.get(i+1).toString(); + //Go through the (likely shorter) CDR1 list as many times as necessary, make pairs of alphas and betas + String tmpCDR1a = numbersCDR1.get(i % numbersCDR1.size()).toString(); + String tmpCDR1b = numbersCDR1.get((i+1) % numbersCDR1.size()).toString(); //Make the array representing the cell - Integer[] tmp = {tmpCDR3a, tmpCDR3b, tmpCDR1a, tmpCDR1b}; + String[] tmp = {tmpCDR3a, tmpCDR3b, tmpCDR1a, tmpCDR1b}; //Add the cell to the list of distinct cells distinctCells.add(tmp); } this.cells = distinctCells; } - public CellSample(List cells, Integer cdr1Freq){ + public CellSample(List cells, Integer cdr1Freq){ this.cells = cells; this.cdr1Freq = cdr1Freq; } - public List getCells(){ + public List getCells(){ return cells; } diff --git a/src/main/java/GraphWithMapData.java b/src/main/java/GraphWithMapData.java index aad6c2f..8588088 100644 --- a/src/main/java/GraphWithMapData.java +++ b/src/main/java/GraphWithMapData.java @@ -15,7 +15,7 @@ public class GraphWithMapData implements java.io.Serializable { private Integer[] wellPopulations; private Integer alphaCount; private Integer betaCount; - private final Map distCellsMapAlphaKey; + private final Map distCellsMapAlphaKey; // private final Map plateVtoAMap; // private final Map plateVtoBMap; // private final Map plateAtoVMap; @@ -25,7 +25,7 @@ public class GraphWithMapData implements java.io.Serializable { private final Duration time; public GraphWithMapData(SimpleWeightedGraph graph, Integer numWells, Integer[] wellConcentrations, - Map distCellsMapAlphaKey, Integer alphaCount, Integer betaCount, Duration time){ + Map distCellsMapAlphaKey, Integer alphaCount, Integer betaCount, Duration time){ // Map plateVtoAMap, // Map plateVtoBMap, Map plateAtoVMap, @@ -66,7 +66,7 @@ public class GraphWithMapData implements java.io.Serializable { return betaCount; } - public Map getDistCellsMapAlphaKey() { + public Map getDistCellsMapAlphaKey() { return distCellsMapAlphaKey; } diff --git a/src/main/java/MatchingResult.java b/src/main/java/MatchingResult.java index 4502f51..55b7932 100644 --- a/src/main/java/MatchingResult.java +++ b/src/main/java/MatchingResult.java @@ -9,11 +9,11 @@ public class MatchingResult { private final List comments; private final List headers; private final List> allResults; - private final Map matchMap; + private final Map matchMap; private final Duration time; public MatchingResult(Map metadata, List headers, - List> allResults, MapmatchMap, Duration time){ + List> allResults, MapmatchMap, Duration time){ /* * POSSIBLE KEYS FOR METADATA MAP ARE: * sample plate filename * @@ -57,7 +57,7 @@ public class MatchingResult { return headers; } - public Map getMatchMap() { + public Map getMatchMap() { return matchMap; } diff --git a/src/main/java/Plate.java b/src/main/java/Plate.java index 168ee67..6af544b 100644 --- a/src/main/java/Plate.java +++ b/src/main/java/Plate.java @@ -11,7 +11,7 @@ public class Plate { private CellSample cells; private String sourceFile; private String filename; - private List> wells; + private List> wells; private final Random rand = BiGpairSEQ.getRand(); private int size; private double error; @@ -48,13 +48,13 @@ public class Plate { } //constructor for returning a Plate from a PlateFileReader - public Plate(String filename, List> wells) { + public Plate(String filename, List> wells) { this.filename = filename; this.wells = wells; this.size = wells.size(); List concentrations = new ArrayList<>(); - for (List w: wells) { + for (List w: wells) { if(!concentrations.contains(w.size())){ concentrations.add(w.size()); } @@ -65,7 +65,7 @@ public class Plate { } } - private void fillWellsExponential(List cells, double lambda){ + private void fillWellsExponential(List cells, double lambda){ this.lambda = lambda; exponential = true; int numSections = populations.length; @@ -74,17 +74,17 @@ public class Plate { int n; while (section < numSections){ for (int i = 0; i < (size / numSections); i++) { - List well = new ArrayList<>(); + List well = new ArrayList<>(); for (int j = 0; j < populations[section]; j++) { do { //inverse transform sampling: for random number u in [0,1), x = log(1-u) / (-lambda) m = (Math.log10((1 - rand.nextDouble()))/(-lambda)) * Math.sqrt(cells.size()); } while (m >= cells.size() || m < 0); n = (int) Math.floor(m); - Integer[] cellToAdd = cells.get(n).clone(); + String[] cellToAdd = cells.get(n).clone(); for(int k = 0; k < cellToAdd.length; k++){ if(Math.abs(rand.nextDouble()) < error){//error applied to each seqeunce - cellToAdd[k] = -1; + cellToAdd[k] = "-1"; } } well.add(cellToAdd); @@ -95,7 +95,7 @@ public class Plate { } } - private void fillWells( List cells, double stdDev) { + private void fillWells( List cells, double stdDev) { this.stdDev = stdDev; int numSections = populations.length; int section = 0; @@ -103,16 +103,16 @@ public class Plate { int n; while (section < numSections){ for (int i = 0; i < (size / numSections); i++) { - List well = new ArrayList<>(); + List well = new ArrayList<>(); for (int j = 0; j < populations[section]; j++) { do { m = (rand.nextGaussian() * stdDev) + (cells.size() / 2); } while (m >= cells.size() || m < 0); n = (int) Math.floor(m); - Integer[] cellToAdd = cells.get(n).clone(); + String[] cellToAdd = cells.get(n).clone(); for(int k = 0; k < cellToAdd.length; k++){ if(Math.abs(rand.nextDouble()) < error){//error applied to each sequence - cellToAdd[k] = -1; + cellToAdd[k] = "-1"; } } well.add(cellToAdd); @@ -143,23 +143,23 @@ public class Plate { return error; } - public List> getWells() { + public List> getWells() { return wells; } //returns a map of the counts of the sequence at cell index sIndex, in all wells - public Map assayWellsSequenceS(int... sIndices){ + public Map assayWellsSequenceS(int... sIndices){ return this.assayWellsSequenceS(0, size, sIndices); } //returns a map of the counts of the sequence at cell index sIndex, in a specific well - public Map assayWellsSequenceS(int n, int... sIndices) { + public Map assayWellsSequenceS(int n, int... sIndices) { return this.assayWellsSequenceS(n, n+1, sIndices); } //returns a map of the counts of the sequence at cell index sIndex, in a range of wells - public Map assayWellsSequenceS(int start, int end, int... sIndices) { - Map assay = new HashMap<>(); + public Map assayWellsSequenceS(int start, int end, int... sIndices) { + Map assay = new HashMap<>(); for(int sIndex: sIndices){ for(int i = start; i < end; i++){ countSequences(assay, wells.get(i), sIndex); @@ -168,11 +168,11 @@ public class Plate { return assay; } //For the sequences at cell indices sIndices, counts number of unique sequences in the given well into the given map - private void countSequences(Map wellMap, List well, int... sIndices) { - for(Integer[] cell : well) { + private void countSequences(Map wellMap, List well, int... sIndices) { + for(String[] cell : well) { for(int sIndex: sIndices){ //skip dropout sequences, which have value -1 - if(cell[sIndex] != -1){ + if(!"-1".equals(cell[sIndex])){ wellMap.merge(cell[sIndex], 1, (oldValue, newValue) -> oldValue + newValue); } } diff --git a/src/main/java/PlateFileReader.java b/src/main/java/PlateFileReader.java index 27e98b0..463dab5 100644 --- a/src/main/java/PlateFileReader.java +++ b/src/main/java/PlateFileReader.java @@ -13,7 +13,7 @@ import java.util.regex.Pattern; public class PlateFileReader { - private List> wells = new ArrayList<>(); + private List> wells = new ArrayList<>(); private String filename; public PlateFileReader(String filename){ @@ -32,17 +32,17 @@ public class PlateFileReader { CSVParser parser = new CSVParser(reader, plateFileFormat); ){ for(CSVRecord record: parser.getRecords()) { - List well = new ArrayList<>(); + List well = new ArrayList<>(); for(String s: record) { if(!"".equals(s)) { - String[] intString = s.replaceAll("\\[", "") + String[] sequences = s.replaceAll("\\[", "") .replaceAll("]", "") .replaceAll(" ", "") .split(","); - //System.out.println(intString); - Integer[] arr = new Integer[intString.length]; - for (int i = 0; i < intString.length; i++) { - arr[i] = Integer.valueOf(intString[i]); + //System.out.println(sequences); + String[] arr = new String[sequences.length]; + for (int i = 0; i < sequences.length; i++) { + arr[i] = sequences[i]; } well.add(arr); } diff --git a/src/main/java/PlateFileWriter.java b/src/main/java/PlateFileWriter.java index 3547add..a493412 100644 --- a/src/main/java/PlateFileWriter.java +++ b/src/main/java/PlateFileWriter.java @@ -10,7 +10,7 @@ import java.util.*; public class PlateFileWriter { private int size; - private List> wells; + private List> wells; private double stdDev; private double lambda; private Double error; @@ -40,13 +40,13 @@ public class PlateFileWriter { } public void writePlateFile(){ - Comparator> listLengthDescending = Comparator.comparingInt(List::size); + Comparator> listLengthDescending = Comparator.comparingInt(List::size); wells.sort(listLengthDescending.reversed()); int maxLength = wells.get(0).size(); List> wellsAsStrings = new ArrayList<>(); - for (List w: wells){ + for (List w: wells){ List tmp = new ArrayList<>(); - for(Integer[] c: w) { + for(String[] c: w) { tmp.add(Arrays.toString(c)); } wellsAsStrings.add(tmp); diff --git a/src/main/java/Simulator.java b/src/main/java/Simulator.java index ede14e8..698993c 100644 --- a/src/main/java/Simulator.java +++ b/src/main/java/Simulator.java @@ -12,9 +12,6 @@ import java.text.NumberFormat; import java.time.Instant; import java.time.Duration; import java.util.*; -import java.util.stream.IntStream; - -import static java.lang.Float.*; //NOTE: "sequence" in method and variable names refers to a peptide sequence from a simulated T cell public class Simulator implements GraphModificationFunctions { @@ -26,7 +23,7 @@ public class Simulator implements GraphModificationFunctions { //even if not directed. public static GraphWithMapData makeGraph(CellSample cellSample, Plate samplePlate, boolean verbose) { Instant start = Instant.now(); - List distinctCells = cellSample.getCells(); + List distinctCells = cellSample.getCells(); int[] alphaIndices = {SequenceType.CDR3_ALPHA.ordinal()}; int[] betaIndices = {SequenceType.CDR3_BETA.ordinal()}; @@ -34,13 +31,13 @@ public class Simulator implements GraphModificationFunctions { if(verbose){System.out.println("Making cell maps");} //HashMap keyed to Alphas, values Betas - Map distCellsMapAlphaKey = makeSequenceToSequenceMap(distinctCells, 0, 1); + Map distCellsMapAlphaKey = makeSequenceToSequenceMap(distinctCells, 0, 1); if(verbose){System.out.println("Cell maps made");} if(verbose){System.out.println("Making well maps");} - Map allAlphas = samplePlate.assayWellsSequenceS(alphaIndices); - Map allBetas = samplePlate.assayWellsSequenceS(betaIndices); + Map allAlphas = samplePlate.assayWellsSequenceS(alphaIndices); + Map allBetas = samplePlate.assayWellsSequenceS(betaIndices); int alphaCount = allAlphas.size(); if(verbose){System.out.println("All alphas count: " + alphaCount);} int betaCount = allBetas.size(); @@ -63,17 +60,17 @@ public class Simulator implements GraphModificationFunctions { //distinct indices between the rows and columns. vertexStartValue lets me track where I switch //from numbering rows to columns, so I can assign unique numbers to every vertex, and then //subtract the vertexStartValue from betas to use their vertex labels as array indices - Integer vertexStartValue = 0; + int vertexStartValue = 0; //keys are sequential integer vertices, values are alphas - Map plateVtoAMap = makeVertexToSequenceMap(allAlphas, vertexStartValue); + Map plateVtoAMap = makeVertexToSequenceMap(allAlphas, vertexStartValue); //new start value for vertex to beta map should be one more than final vertex value in alpha map vertexStartValue += plateVtoAMap.size(); //keys are sequential integers vertices, values are betas - Map plateVtoBMap = makeVertexToSequenceMap(allBetas, vertexStartValue); + Map plateVtoBMap = makeVertexToSequenceMap(allBetas, vertexStartValue); //keys are alphas, values are sequential integer vertices from previous map - Map plateAtoVMap = invertVertexMap(plateVtoAMap); + Map plateAtoVMap = invertVertexMap(plateVtoAMap); //keys are betas, values are sequential integer vertices from previous map - Map plateBtoVMap = invertVertexMap(plateVtoBMap); + Map plateBtoVMap = invertVertexMap(plateVtoBMap); if(verbose){System.out.println("Vertex maps made");} //make adjacency matrix for bipartite graph generator @@ -81,9 +78,9 @@ public class Simulator implements GraphModificationFunctions { //for a bipartite graph, and all the SimpleWeightedBipartiteGraphMatrixGenerator class expects.) if(verbose){System.out.println("Creating adjacency matrix");} //Count how many wells each alpha sequence appears in - Map alphaWellCounts = new HashMap<>(); + Map alphaWellCounts = new HashMap<>(); //count how many wells each beta sequence appears in - Map betaWellCounts = new HashMap<>(); + Map betaWellCounts = new HashMap<>(); //the adjacency matrix to be used by the graph generator double[][] weights = new double[plateVtoAMap.size()][plateVtoBMap.size()]; countSequencesAndFillMatrix(samplePlate, allAlphas, allBetas, plateAtoVMap, @@ -101,7 +98,7 @@ public class Simulator implements GraphModificationFunctions { //List alphaVertices = new ArrayList<>(plateVtoAMap.keySet()); //This will work because LinkedHashMap preserves order of entry List alphaVertices = new ArrayList<>(); //start with map of all alphas mapped to vertex values, get occupancy from the alphaWellCounts map - for (Integer seq : plateAtoVMap.keySet()) { + for (String seq : plateAtoVMap.keySet()) { Vertex alphaVertex = new Vertex(SequenceType.CDR3_ALPHA, seq, alphaWellCounts.get(seq), plateAtoVMap.get(seq)); alphaVertices.add(alphaVertex); } @@ -112,7 +109,7 @@ public class Simulator implements GraphModificationFunctions { //the list of beta vertices //List betaVertices = new ArrayList<>(plateVtoBMap.keySet());//This will work because LinkedHashMap preserves order of entry List betaVertices = new ArrayList<>(); - for (Integer seq : plateBtoVMap.keySet()) { + for (String seq : plateBtoVMap.keySet()) { Vertex betaVertex = new Vertex(SequenceType.CDR3_BETA, seq, betaWellCounts.get(seq), plateBtoVMap.get(seq)); betaVertices.add(betaVertex); } @@ -147,7 +144,7 @@ public class Simulator implements GraphModificationFunctions { int numWells = data.getNumWells(); //Integer alphaCount = data.getAlphaCount(); //Integer betaCount = data.getBetaCount(); - Map distCellsMapAlphaKey = data.getDistCellsMapAlphaKey(); + Map distCellsMapAlphaKey = data.getDistCellsMapAlphaKey(); Set alphas = new HashSet<>(); Set betas = new HashSet<>(); for(Vertex v: graph.vertexSet()) { @@ -228,7 +225,7 @@ public class Simulator implements GraphModificationFunctions { int trueCount = 0; int falseCount = 0; boolean check; - Map matchMap = new HashMap<>(); + Map matchMap = new HashMap<>(); while(weightIter.hasNext()) { e = weightIter.next(); Vertex source = graph.getEdgeSource(e); @@ -637,14 +634,14 @@ public class Simulator implements GraphModificationFunctions { // } //Remove sequences based on occupancy - public static void filterByOccupancyThresholds(Map wellMap, int low, int high){ - List noise = new ArrayList<>(); - for(Integer k: wellMap.keySet()){ + public static void filterByOccupancyThresholds(Map wellMap, int low, int high){ + List noise = new ArrayList<>(); + for(String k: wellMap.keySet()){ if((wellMap.get(k) > high) || (wellMap.get(k) < low)){ noise.add(k); } } - for(Integer k: noise) { + for(String k: noise) { wellMap.remove(k); } } @@ -652,35 +649,35 @@ public class Simulator implements GraphModificationFunctions { //Counts the well occupancy of the row peptides and column peptides into given maps, and //fills weights in the given 2D array private static void countSequencesAndFillMatrix(Plate samplePlate, - Map allRowSequences, - Map allColumnSequences, - Map rowSequenceToVertexMap, - Map columnSequenceToVertexMap, + Map allRowSequences, + Map allColumnSequences, + Map rowSequenceToVertexMap, + Map columnSequenceToVertexMap, int[] rowSequenceIndices, int[] colSequenceIndices, - Map rowSequenceCounts, - Map columnSequenceCounts, + Map rowSequenceCounts, + Map columnSequenceCounts, double[][] weights){ - Map wellNRowSequences = null; - Map wellNColumnSequences = null; + Map wellNRowSequences = null; + Map wellNColumnSequences = null; int vertexStartValue = rowSequenceToVertexMap.size(); int numWells = samplePlate.getSize(); for (int n = 0; n < numWells; n++) { wellNRowSequences = samplePlate.assayWellsSequenceS(n, rowSequenceIndices); - for (Integer a : wellNRowSequences.keySet()) { + for (String a : wellNRowSequences.keySet()) { if(allRowSequences.containsKey(a)){ rowSequenceCounts.merge(a, 1, (oldValue, newValue) -> oldValue + newValue); } } wellNColumnSequences = samplePlate.assayWellsSequenceS(n, colSequenceIndices); - for (Integer b : wellNColumnSequences.keySet()) { + for (String b : wellNColumnSequences.keySet()) { if(allColumnSequences.containsKey(b)){ columnSequenceCounts.merge(b, 1, (oldValue, newValue) -> oldValue + newValue); } } - for (Integer i : wellNRowSequences.keySet()) { + for (String i : wellNRowSequences.keySet()) { if(allRowSequences.containsKey(i)){ - for (Integer j : wellNColumnSequences.keySet()) { + for (String j : wellNColumnSequences.keySet()) { if(allColumnSequences.containsKey(j)){ weights[rowSequenceToVertexMap.get(i)][columnSequenceToVertexMap.get(j) - vertexStartValue] += 1.0; } @@ -691,27 +688,27 @@ public class Simulator implements GraphModificationFunctions { } } - private static Map makeSequenceToSequenceMap(List cells, int keySequenceIndex, - int valueSequenceIndex){ - Map keySequenceToValueSequenceMap = new HashMap<>(); - for (Integer[] cell : cells) { + private static Map makeSequenceToSequenceMap(List cells, int keySequenceIndex, + int valueSequenceIndex){ + Map keySequenceToValueSequenceMap = new HashMap<>(); + for (String[] cell : cells) { keySequenceToValueSequenceMap.put(cell[keySequenceIndex], cell[valueSequenceIndex]); } return keySequenceToValueSequenceMap; } - private static Map makeVertexToSequenceMap(Map sequences, Integer startValue) { - Map map = new LinkedHashMap<>(); //LinkedHashMap to preserve order of entry + private static Map makeVertexToSequenceMap(Map sequences, Integer startValue) { + Map map = new LinkedHashMap<>(); //LinkedHashMap to preserve order of entry Integer index = startValue; //is this necessary? I don't think I use this. - for (Integer k: sequences.keySet()) { + for (String k: sequences.keySet()) { map.put(index, k); index++; } return map; } - private static Map invertVertexMap(Map map) { - Map inverse = new HashMap<>(); + private static Map invertVertexMap(Map map) { + Map inverse = new HashMap<>(); for (Integer k : map.keySet()) { inverse.put(map.get(k), k); } diff --git a/src/main/java/Vertex.java b/src/main/java/Vertex.java index a96306d..13a8dfc 100644 --- a/src/main/java/Vertex.java +++ b/src/main/java/Vertex.java @@ -5,7 +5,7 @@ import java.io.Serializable; public class Vertex implements Serializable, Comparable { private SequenceType type; private Integer vertexLabel; - private Integer sequence; + private String sequence; private Integer occupancy; private Integer readCount; private Double potential; @@ -18,14 +18,14 @@ public class Vertex implements Serializable, Comparable { this.vertexLabel = Integer.parseInt((vertexLabel)); } - public Vertex(SequenceType type, Integer sequence, Integer occupancy, Integer vertexLabel) { + public Vertex(SequenceType type, String sequence, Integer occupancy, Integer vertexLabel) { this.type = type; this.vertexLabel = vertexLabel; this.sequence = sequence; this.occupancy = occupancy; } - public Vertex(SequenceType type, Integer sequence, Integer occupancy, Integer vertexLabel, Integer readCount) { + public Vertex(SequenceType type, String sequence, Integer occupancy, Integer vertexLabel, Integer readCount) { this.type = type; this.vertexLabel = vertexLabel; this.sequence = sequence; @@ -50,13 +50,12 @@ public class Vertex implements Serializable, Comparable { this.vertexLabel = Integer.parseInt(label); } - public Integer getSequence() { - + public String getSequence() { return sequence; } public void setSequence(String sequence) { - this.sequence = Integer.parseInt(sequence); + this.sequence = sequence; } public Integer getOccupancy() {