diff --git a/src/main/java/BiGpairSEQ.java b/src/main/java/BiGpairSEQ.java index af6577d..935888c 100644 --- a/src/main/java/BiGpairSEQ.java +++ b/src/main/java/BiGpairSEQ.java @@ -1,6 +1,6 @@ import java.util.Random; -//main class. For choosing interface type and caching file data +//main class. For choosing interface type and holding settings public class BiGpairSEQ { private static final Random rand = new Random(); @@ -14,6 +14,8 @@ public class BiGpairSEQ { private static boolean cachePlate = false; private static boolean cacheGraph = false; private static String priorityQueueHeapType = "FIBONACCI"; + private static boolean outputBinary = true; + private static boolean outputGraphML = false; public static void main(String[] args) { if (args.length == 0) { @@ -164,4 +166,11 @@ public class BiGpairSEQ { public static void setFibonacciHeap() { priorityQueueHeapType = "FIBONACCI"; } + + public static boolean outputBinary() {return outputBinary;} + public static void setOutputBinary(boolean b) {outputBinary = b;} + + public static boolean outputGraphML() {return outputGraphML;} + public static void setOutputGraphML(boolean b) {outputGraphML = b;} + } diff --git a/src/main/java/InteractiveInterface.java b/src/main/java/InteractiveInterface.java index 90b388f..044e03b 100644 --- a/src/main/java/InteractiveInterface.java +++ b/src/main/java/InteractiveInterface.java @@ -252,7 +252,6 @@ public class InteractiveInterface { String filename = null; String cellFile = null; String plateFile = null; - try { String str = "\nGenerating bipartite weighted graph encoding occupancy overlap data "; str = str.concat("\nrequires a cell sample file and a sample plate file."); @@ -310,9 +309,16 @@ public class InteractiveInterface { List cells = cellSample.getCells(); GraphWithMapData data = Simulator.makeGraph(cells, plate, true); assert filename != null; - GraphDataObjectWriter dataWriter = new GraphDataObjectWriter(filename, data); - dataWriter.writeDataToFile(); - System.out.println("Graph and Data file written to: " + filename); + if(BiGpairSEQ.outputBinary()) { + GraphDataObjectWriter dataWriter = new GraphDataObjectWriter(filename, data); + dataWriter.writeDataToFile(); + System.out.println("Serialized binary graph/data file written to: " + filename); + } + if(BiGpairSEQ.outputGraphML()) { + GraphMLFileWriter graphMLWriter = new GraphMLFileWriter(filename, data.getGraph()); + graphMLWriter.writeGraphToFile(); + System.out.println("GraphML file written to: " + filename); + } if(BiGpairSEQ.cacheGraph()) { BiGpairSEQ.setGraphInMemory(data, filename); @@ -500,7 +506,9 @@ public class InteractiveInterface { System.out.println("1) Turn " + getOnOff(!BiGpairSEQ.cacheCells()) + " cell sample file caching"); System.out.println("2) Turn " + getOnOff(!BiGpairSEQ.cachePlate()) + " plate file caching"); System.out.println("3) Turn " + getOnOff(!BiGpairSEQ.cacheGraph()) + " graph/data file caching"); - System.out.println("4) Maximum weight matching algorithm options"); + System.out.println("4) Turn " + getOnOff(!BiGpairSEQ.outputBinary()) + " serialized binary graph output"); + System.out.println("5) Turn " + getOnOff(!BiGpairSEQ.outputGraphML()) + " GraphML graph output"); + System.out.println("6) Maximum weight matching algorithm options"); System.out.println("0) Return to main menu"); try { input = sc.nextInt(); @@ -508,7 +516,9 @@ public class InteractiveInterface { case 1 -> BiGpairSEQ.setCacheCells(!BiGpairSEQ.cacheCells()); case 2 -> BiGpairSEQ.setCachePlate(!BiGpairSEQ.cachePlate()); case 3 -> BiGpairSEQ.setCacheGraph(!BiGpairSEQ.cacheGraph()); - case 4 -> algorithmOptions(); + case 4 -> BiGpairSEQ.setOutputBinary(!BiGpairSEQ.outputBinary()); + case 5 -> BiGpairSEQ.setOutputGraphML(!BiGpairSEQ.outputGraphML()); + case 6 -> algorithmOptions(); case 0 -> backToMain = true; default -> System.out.println("Invalid input"); } diff --git a/src/main/java/Simulator.java b/src/main/java/Simulator.java index 02f07fc..6d3f6eb 100644 --- a/src/main/java/Simulator.java +++ b/src/main/java/Simulator.java @@ -668,7 +668,7 @@ public class Simulator implements GraphModificationFunctions { private static Map makeVertexToSequenceMap(Map sequences, Integer startValue) { Map map = new LinkedHashMap<>(); //LinkedHashMap to preserve order of entry - Integer index = startValue; + Integer index = startValue; //is this necessary? I don't think I use this. for (Integer k: sequences.keySet()) { map.put(index, k); index++;