Adding GraphML output to options menu

This commit is contained in:
2022-02-24 17:22:07 -06:00
parent f385ebc31f
commit e4d094d796
3 changed files with 27 additions and 8 deletions

View File

@@ -1,6 +1,6 @@
import java.util.Random; 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 { public class BiGpairSEQ {
private static final Random rand = new Random(); private static final Random rand = new Random();
@@ -14,6 +14,8 @@ public class BiGpairSEQ {
private static boolean cachePlate = false; private static boolean cachePlate = false;
private static boolean cacheGraph = false; private static boolean cacheGraph = false;
private static String priorityQueueHeapType = "FIBONACCI"; private static String priorityQueueHeapType = "FIBONACCI";
private static boolean outputBinary = true;
private static boolean outputGraphML = false;
public static void main(String[] args) { public static void main(String[] args) {
if (args.length == 0) { if (args.length == 0) {
@@ -164,4 +166,11 @@ public class BiGpairSEQ {
public static void setFibonacciHeap() { public static void setFibonacciHeap() {
priorityQueueHeapType = "FIBONACCI"; 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;}
} }

View File

@@ -252,7 +252,6 @@ public class InteractiveInterface {
String filename = null; String filename = null;
String cellFile = null; String cellFile = null;
String plateFile = null; String plateFile = null;
try { try {
String str = "\nGenerating bipartite weighted graph encoding occupancy overlap data "; String str = "\nGenerating bipartite weighted graph encoding occupancy overlap data ";
str = str.concat("\nrequires a cell sample file and a sample plate file."); str = str.concat("\nrequires a cell sample file and a sample plate file.");
@@ -310,9 +309,16 @@ public class InteractiveInterface {
List<Integer[]> cells = cellSample.getCells(); List<Integer[]> cells = cellSample.getCells();
GraphWithMapData data = Simulator.makeGraph(cells, plate, true); GraphWithMapData data = Simulator.makeGraph(cells, plate, true);
assert filename != null; assert filename != null;
GraphDataObjectWriter dataWriter = new GraphDataObjectWriter(filename, data); if(BiGpairSEQ.outputBinary()) {
dataWriter.writeDataToFile(); GraphDataObjectWriter dataWriter = new GraphDataObjectWriter(filename, data);
System.out.println("Graph and Data file written to: " + filename); 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()) { if(BiGpairSEQ.cacheGraph()) {
BiGpairSEQ.setGraphInMemory(data, filename); 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("1) Turn " + getOnOff(!BiGpairSEQ.cacheCells()) + " cell sample file caching");
System.out.println("2) Turn " + getOnOff(!BiGpairSEQ.cachePlate()) + " plate 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("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"); System.out.println("0) Return to main menu");
try { try {
input = sc.nextInt(); input = sc.nextInt();
@@ -508,7 +516,9 @@ public class InteractiveInterface {
case 1 -> BiGpairSEQ.setCacheCells(!BiGpairSEQ.cacheCells()); case 1 -> BiGpairSEQ.setCacheCells(!BiGpairSEQ.cacheCells());
case 2 -> BiGpairSEQ.setCachePlate(!BiGpairSEQ.cachePlate()); case 2 -> BiGpairSEQ.setCachePlate(!BiGpairSEQ.cachePlate());
case 3 -> BiGpairSEQ.setCacheGraph(!BiGpairSEQ.cacheGraph()); 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; case 0 -> backToMain = true;
default -> System.out.println("Invalid input"); default -> System.out.println("Invalid input");
} }

View File

@@ -668,7 +668,7 @@ public class Simulator implements GraphModificationFunctions {
private static Map<Integer, Integer> makeVertexToSequenceMap(Map<Integer, Integer> sequences, Integer startValue) { private static Map<Integer, Integer> makeVertexToSequenceMap(Map<Integer, Integer> sequences, Integer startValue) {
Map<Integer, Integer> map = new LinkedHashMap<>(); //LinkedHashMap to preserve order of entry Map<Integer, Integer> 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()) { for (Integer k: sequences.keySet()) {
map.put(index, k); map.put(index, k);
index++; index++;