ChordFileReader { @NotNull public static ChordAnalysis read(@NotNull String filePath) throws IOException { ImmutableChordAnalysis.Builder builder = ImmutableChordAnalysis.builder(); String[] values = findValuesLine(filePath).split(VALUE_SEPARATOR); if (isV1(values)) { builder.BRCA1Value(Double.parseDouble(values[V1_BRCA1_COLUMN])); builder.BRCA2Value(Double.parseDouble(values[V1_BRCA2_COLUMN])); builder.hrdValue(Double.parseDouble(values[V1_HRD_COLUMN])); builder.hrStatus(extractHrStatus(V1_NA)); builder.hrdType(V1_NA); builder.remarksHrStatus(V1_NA); builder.remarksHrdType(V1_NA); } else { String remarksHrStatus = values.length > V2_REMARKS_HR_STATUS_COLUMN ? values[V2_REMARKS_HR_STATUS_COLUMN] : Strings.EMPTY; String remarksHrdType = values.length > V2_REMARKS_HRD_TYPE_COLUMN ? values[V2_REMARKS_HRD_TYPE_COLUMN] : Strings.EMPTY; builder.BRCA1Value(Double.parseDouble(values[V2_BRCA1_COLUMN])); builder.BRCA2Value(Double.parseDouble(values[V2_BRCA2_COLUMN])); builder.hrdValue(Double.parseDouble(values[V2_HRD_COLUMN])); builder.hrStatus(extractHrStatus(values[V2_HR_STATUS_COLUMN])); builder.hrdType(values[V2_HRD_TYPE_COLUMN]); builder.remarksHrStatus(remarksHrStatus); builder.remarksHrdType(remarksHrdType); } return builder.build(); } private  ChordFileReader(); @NotNull static ChordAnalysis read(@NotNull String filePath);  }
@Test public void canLoadV1ChordFile() throws IOException { ChordAnalysis chordAnalysis = ChordFileReader.read(V1_CHORD_FILE); assertEquals(V1_BRCA1, chordAnalysis.BRCA1Value(), EPSILON); assertEquals(V1_BRCA2, chordAnalysis.BRCA2Value(), EPSILON); assertEquals(V1_HRD, chordAnalysis.hrdValue(), EPSILON); assertEquals(ChordStatus.UNKNOWN, chordAnalysis.hrStatus()); assertEquals(ChordFileReader.V1_NA, chordAnalysis.hrdType()); assertEquals(ChordFileReader.V1_NA, chordAnalysis.remarksHrStatus()); assertEquals(ChordFileReader.V1_NA, chordAnalysis.remarksHrdType()); }
@Test public void canLoadV2ChordFile() throws IOException { ChordAnalysis chordAnalysis = ChordFileReader.read(V2_CHORD_FILE); assertEquals(V2_BRCA1, chordAnalysis.BRCA1Value(), EPSILON); assertEquals(V2_BRCA2, chordAnalysis.BRCA2Value(), EPSILON); assertEquals(V2_HRD, chordAnalysis.hrdValue(), EPSILON); assertEquals(V2_HR_STATUS, chordAnalysis.hrStatus()); assertEquals(V2_HRD_TYPE, chordAnalysis.hrdType()); assertEquals(Strings.EMPTY, chordAnalysis.remarksHrStatus()); assertEquals(Strings.EMPTY, chordAnalysis.remarksHrdType()); }