PCFFile { @NotNull public static ListMultimap<Chromosome, PCFPosition> readPositions(int windowSize, @NotNull PCFSource source, @NotNull final String filename) throws IOException { ListMultimap<Chromosome, PCFPosition> result = ArrayListMultimap.create(); final Window window = new Window(windowSize); @Nullable ModifiablePCFPosition builder = null; String prevChromosome = Strings.EMPTY; long minPosition = 1; List<ModifiablePCFPosition> chromosomeResult = Lists.newArrayList(); for (String line : Files.readAllLines(new File(filename).toPath())) { if (!line.startsWith(HEADER_PREFIX)) { String[] values = line.split(DELIMITER); final String chromosomeName = values[1]; if (HumanChromosome.contains(chromosomeName)) { if (!chromosomeName.equals(prevChromosome)) { if (builder != null) { chromosomeResult.add(builder); result.putAll(HumanChromosome.fromString(prevChromosome), PCFMerge.merge(chromosomeResult)); } chromosomeResult.clear(); builder = null; minPosition = 1; prevChromosome = chromosomeName; } long start = window.start(Long.parseLong(values[3])); long end = window.start(Long.parseLong(values[4])) + windowSize; if (builder != null) { chromosomeResult.add(builder.setMaxPosition(start)); } chromosomeResult.add(ModifiablePCFPosition.create() .setChromosome(chromosomeName) .setSource(source) .setPosition(start) .setMinPosition(minPosition) .setMaxPosition(start)); minPosition = end; builder = ModifiablePCFPosition.create() .setChromosome(chromosomeName) .setSource(source) .setPosition(end) .setMinPosition(end) .setMaxPosition(end); } } } if (builder != null) { chromosomeResult.add(builder); result.putAll(HumanChromosome.fromString(prevChromosome), PCFMerge.merge(chromosomeResult)); } return result; } private  PCFFile(); @NotNull static String generateRatioFilename(@NotNull final String basePath, @NotNull final String sample); @NotNull static String generateBAFFilename(@NotNull final String basePath, @NotNull final String sample); @NotNull static ListMultimap<Chromosome, PCFPosition> readPositions(int windowSize, @NotNull PCFSource source,
            @NotNull final String filename); @NotNull static Multimap<String, GenomeRegion> read(int windowSize, @NotNull final String filename);  }
@Test public void testBafFile() throws IOException { final ListMultimap<Chromosome, PCFPosition> resultMap = PCFFile.readPositions(WINDOW, PCFSource.TUMOR_BAF, BASE_PATH + File.separator + "baf.pcf"); final List<PCFPosition> chromOneResults = resultMap.get(HumanChromosome._1); assertEquals(4, chromOneResults.size()); assertPosition(93548001, chromOneResults.get(0)); assertPosition(193800001, chromOneResults.get(1)); assertPosition(193803001, chromOneResults.get(2)); assertPosition(193804001, chromOneResults.get(3)); final List<PCFPosition> chromTwoResults = resultMap.get(HumanChromosome._2); assertEquals(4, chromTwoResults.size()); assertPosition(93548001, chromTwoResults.get(0)); assertPosition(193800001, chromTwoResults.get(1)); assertPosition(193803001, chromTwoResults.get(2)); assertPosition(193804001, chromTwoResults.get(3)); }
@Test public void testRatioFile() throws IOException { final ListMultimap<Chromosome, PCFPosition> resultMap = PCFFile.readPositions(WINDOW, PCFSource.TUMOR_BAF, BASE_PATH + File.separator + "ratio.pcf"); final List<PCFPosition> chromosomeOneResults = resultMap.get(HumanChromosome._1); assertEquals(5, chromosomeOneResults.size()); assertPosition(835001, 1, 835001, chromosomeOneResults.get(0)); assertPosition(2583001, 2583001, 2583001, chromosomeOneResults.get(1)); assertPosition(2584001, 2584001, 2695001, chromosomeOneResults.get(2)); assertPosition(2695001, 2584001, 2695001, chromosomeOneResults.get(3)); assertPosition(4363001, 4363001, 4363001, chromosomeOneResults.get(4)); final List<PCFPosition> chromosomeThreeResults = resultMap.get(HumanChromosome._3); assertEquals(5, chromosomeThreeResults.size()); assertPosition(90449001, 1, 90449001, chromosomeThreeResults.get(0)); assertPosition(90452001, 90452001, 90452001, chromosomeThreeResults.get(1)); assertPosition(90455001, 90455001, 90457001, chromosomeThreeResults.get(2)); assertPosition(90457001, 90455001, 90457001, chromosomeThreeResults.get(3)); assertPosition(90458001, 90458001, 90458001, chromosomeThreeResults.get(4)); }