Implemented parameter for CDR1 frequency

This commit is contained in:
2021-11-18 11:55:54 -06:00
parent 4157cfb556
commit 2064d7e9fc
4 changed files with 19 additions and 22 deletions

View File

@@ -13,6 +13,7 @@ public class CellFileWriter {
private String[] headers = {"Alpha CDR3", "Beta CDR3", "Alpha CDR1", "Beta CDR1"};
List<Integer[]> cells;
String filename;
Integer cdr1Freq;
public CellFileWriter(String filename, CellSample cells) {
if(!filename.matches(".*\\.csv")){
@@ -20,15 +21,18 @@ public class CellFileWriter {
}
this.filename = filename;
this.cells = cells.getCells();
this.cdr1Freq = cells.getCdr1Freq();
}
public void writeCellsToFile() {
CSVFormat cellFileFormat = CSVFormat.Builder.create()
.setCommentMarker('#')
.setHeader(headers)
.build();
try(BufferedWriter writer = Files.newBufferedWriter(Path.of(filename), StandardOpenOption.CREATE_NEW);
CSVPrinter printer = new CSVPrinter(writer, cellFileFormat);
){
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);