Change plate reader/writer to use columns as wells
This commit is contained in:
Binary file not shown.
@@ -31,23 +31,55 @@ public class PlateFileReader {
|
|||||||
BufferedReader reader = Files.newBufferedReader(Path.of(filename));
|
BufferedReader reader = Files.newBufferedReader(Path.of(filename));
|
||||||
CSVParser parser = new CSVParser(reader, plateFileFormat);
|
CSVParser parser = new CSVParser(reader, plateFileFormat);
|
||||||
){
|
){
|
||||||
for(CSVRecord record: parser.getRecords()) {
|
//old code for wells as rows
|
||||||
List<Integer[]> well = new ArrayList<>();
|
// for(CSVRecord record: parser.getRecords()) {
|
||||||
|
// List<Integer[]> well = new ArrayList<>();
|
||||||
|
// for(String s: record) {
|
||||||
|
// if(!"".equals(s)) {
|
||||||
|
// String[] intString = 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]);
|
||||||
|
// }
|
||||||
|
// well.add(arr);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// wells.add(well);
|
||||||
|
for(CSVRecord record: parser) {
|
||||||
|
if (record.hasComment()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (wells.size() == 0) {
|
||||||
|
int num = record.size();
|
||||||
|
for (int i = 0; i < num; i++) {
|
||||||
|
wells.add(new ArrayList<>());
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
} else {
|
||||||
|
int i = 0;
|
||||||
for (String s : record) {
|
for (String s : record) {
|
||||||
if(!"".equals(s)) {
|
if (!"".equals(s)) { //if value isn't the empty string
|
||||||
String[] intString = s.replaceAll("\\[", "")
|
//get rid of brackts, split at commas into a string array
|
||||||
|
String[] intsAsStrings = s.replaceAll("\\[", "")
|
||||||
.replaceAll("]", "")
|
.replaceAll("]", "")
|
||||||
.replaceAll(" ", "")
|
.replaceAll(" ", "")
|
||||||
.split(",");
|
.split(",");
|
||||||
//System.out.println(intString);
|
//Make Integer array with the same values
|
||||||
Integer[] arr = new Integer[intString.length];
|
Integer[] arr = new Integer[intsAsStrings.length];
|
||||||
for (int i = 0; i < intString.length; i++) {
|
for (int j = 0; j < intsAsStrings.length; j++) {
|
||||||
arr[i] = Integer.valueOf(intString[i]);
|
arr[j] = Integer.valueOf(intsAsStrings[j]);
|
||||||
}
|
}
|
||||||
well.add(arr);
|
//Add Integer array to the correct well
|
||||||
|
wells.get(i).add(arr);
|
||||||
|
i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
wells.add(well);
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch(IOException ex){
|
} catch(IOException ex){
|
||||||
System.out.println("plate file " + filename + " not found.");
|
System.out.println("plate file " + filename + " not found.");
|
||||||
|
|||||||
Reference in New Issue
Block a user