List of usage examples for org.apache.commons.io FileUtils contentEquals
public static boolean contentEquals(File file1, File file2) throws IOException
From source file:org.corehunter.tests.data.simple.SimpleDefaultGenotypeDataTest.java
@Test public void homozygousToCsvFileWithUnselectedIds() throws IOException { expectedHeaders = HEADERS_UNIQUE_NAMES; expectedMarkerNames = MARKER_NAMES_DEFAULT; expectedAlleleNames = ALLELE_NAMES_HOMOZYGOUS; SimpleDefaultGenotypeData genotypicData = new SimpleDefaultGenotypeData(NAME, HEADERS_UNIQUE_NAMES, MARKER_NAMES_DEFAULT, ALLELE_OBS_HOMOZYGOUS); Set<Integer> ids = genotypicData.getIDs(); Path dirPath = Paths.get(TEST_OUTPUT); Files.createDirectories(dirPath); dirPath = Files.createTempDirectory(dirPath, "GenoHomozygous-UnselectedIds"); // create solution SubsetSolution solution = new SubsetSolution(ids); for (int sel : SELECTION) { solution.select(sel);//w w w . j a v a 2 s . com } Path path; // write with integer ids dataName = "with-ids.csv"; path = Paths.get(dirPath.toString(), dataName); System.out.println(" |- Write default genotypes file (homozygous, with solution) " + dataName); genotypicData.writeData(path, FileType.CSV, solution, false, true, true); assertTrue("Output is not correct!", FileUtils.contentEquals( new File(SimpleDistanceMatrixDataTest.class .getResource("/homozygous_genotypes/out/unsel-with-ids.csv").getPath()), path.toFile())); // write without integer ids dataName = "no-ids.csv"; path = Paths.get(dirPath.toString(), dataName); System.out.println(" |- Write default genotypes file (homozygous, with solution) " + dataName); genotypicData.writeData(path, FileType.CSV, solution, false, true, false); assertTrue("Output is not correct!", FileUtils.contentEquals( new File(SimpleDistanceMatrixDataTest.class .getResource("/homozygous_genotypes/out/unsel-no-ids.csv").getPath()), path.toFile())); }
From source file:org.corehunter.tests.data.simple.SimpleDefaultGenotypeDataTest.java
@Test public void diploidToCsvFileWithAllIds() throws IOException { expectedHeaders = HEADERS_UNIQUE_NAMES; expectedMarkerNames = MARKER_NAMES_DEFAULT; expectedAlleleNames = ALLELE_NAMES_DIPLOID; SimpleDefaultGenotypeData genotypicData = new SimpleDefaultGenotypeData(NAME, HEADERS_UNIQUE_NAMES, MARKER_NAMES_DEFAULT, ALLELE_OBS_DIPLOID); Set<Integer> ids = genotypicData.getIDs(); Path dirPath = Paths.get(TEST_OUTPUT); Files.createDirectories(dirPath); dirPath = Files.createTempDirectory(dirPath, "GenoDiploid-AllIds"); // create solution SubsetSolution solution = new SubsetSolution(ids); for (int sel : SELECTION) { solution.select(sel);//from www . ja v a2s . c o m } Path path; // write with integer ids dataName = "with-ids.csv"; path = Paths.get(dirPath.toString(), dataName); System.out.println(" |- Write default genotypes file (diploid, with solution) " + dataName); genotypicData.writeData(path, FileType.CSV, solution, true, true, true); assertTrue("Output is not correct!", FileUtils .contentEquals( new File(SimpleDistanceMatrixDataTest.class .getResource("/diploid_genotypes/out/all-with-ids.csv").getPath()), path.toFile())); // write without integer ids dataName = "no-ids.csv"; path = Paths.get(dirPath.toString(), dataName); System.out.println(" |- Write default genotypes file (diploid, with solution) " + dataName); genotypicData.writeData(path, FileType.CSV, solution, true, true, false); assertTrue("Output is not correct!", FileUtils .contentEquals( new File(SimpleDistanceMatrixDataTest.class .getResource("/diploid_genotypes/out/all-no-ids.csv").getPath()), path.toFile())); }
From source file:org.corehunter.tests.data.simple.SimpleDefaultGenotypeDataTest.java
@Test public void diploidToCsvFileWithSelectedIds() throws IOException { expectedHeaders = HEADERS_UNIQUE_NAMES; expectedMarkerNames = MARKER_NAMES_DEFAULT; expectedAlleleNames = ALLELE_NAMES_DIPLOID; SimpleDefaultGenotypeData genotypicData = new SimpleDefaultGenotypeData(NAME, HEADERS_UNIQUE_NAMES, MARKER_NAMES_DEFAULT, ALLELE_OBS_DIPLOID); Set<Integer> ids = genotypicData.getIDs(); Path dirPath = Paths.get(TEST_OUTPUT); Files.createDirectories(dirPath); dirPath = Files.createTempDirectory(dirPath, "GenoDiploid-SelectedIds"); // create solution SubsetSolution solution = new SubsetSolution(ids); for (int sel : SELECTION) { solution.select(sel);//ww w. j a v a 2 s . com } Path path; // write with integer ids dataName = "with-ids.csv"; path = Paths.get(dirPath.toString(), dataName); System.out.println(" |- Write default genotypes file (diploid, with solution) " + dataName); genotypicData.writeData(path, FileType.CSV, solution, true, false, true); assertTrue("Output is not correct!", FileUtils .contentEquals( new File(SimpleDistanceMatrixDataTest.class .getResource("/diploid_genotypes/out/sel-with-ids.csv").getPath()), path.toFile())); // write without integer ids dataName = "no-ids.csv"; path = Paths.get(dirPath.toString(), dataName); System.out.println(" |- Write default genotypes file (diploid, with solution) " + dataName); genotypicData.writeData(path, FileType.CSV, solution, true, false, false); assertTrue("Output is not correct!", FileUtils .contentEquals( new File(SimpleDistanceMatrixDataTest.class .getResource("/diploid_genotypes/out/sel-no-ids.csv").getPath()), path.toFile())); }
From source file:org.corehunter.tests.data.simple.SimpleDefaultGenotypeDataTest.java
@Test public void diploidToCsvFileWithUnselectedIds() throws IOException { expectedHeaders = HEADERS_UNIQUE_NAMES; expectedMarkerNames = MARKER_NAMES_DEFAULT; expectedAlleleNames = ALLELE_NAMES_DIPLOID; SimpleDefaultGenotypeData genotypicData = new SimpleDefaultGenotypeData(NAME, HEADERS_UNIQUE_NAMES, MARKER_NAMES_DEFAULT, ALLELE_OBS_DIPLOID); Set<Integer> ids = genotypicData.getIDs(); Path dirPath = Paths.get(TEST_OUTPUT); Files.createDirectories(dirPath); dirPath = Files.createTempDirectory(dirPath, "GenoDiploid-UnselectedIds"); // create solution SubsetSolution solution = new SubsetSolution(ids); for (int sel : SELECTION) { solution.select(sel);//w w w . ja v a 2 s. co m } Path path; // write with integer ids dataName = "with-ids.csv"; path = Paths.get(dirPath.toString(), dataName); System.out.println(" |- Write default genotypes file (diploid, with solution) " + dataName); genotypicData.writeData(path, FileType.CSV, solution, false, true, true); assertTrue("Output is not correct!", FileUtils.contentEquals( new File(SimpleDistanceMatrixDataTest.class .getResource("/diploid_genotypes/out/unsel-with-ids.csv").getPath()), path.toFile())); // write without integer ids dataName = "no-ids.csv"; path = Paths.get(dirPath.toString(), dataName); System.out.println(" |- Write default genotypes file (diploid, with solution) " + dataName); genotypicData.writeData(path, FileType.CSV, solution, false, true, false); assertTrue("Output is not correct!", FileUtils .contentEquals( new File(SimpleDistanceMatrixDataTest.class .getResource("/diploid_genotypes/out/unsel-no-ids.csv").getPath()), path.toFile())); }
From source file:org.corehunter.tests.data.simple.SimpleDistanceMatrixDataTest.java
@Test public void toCsvFileWithAllIds() throws IOException { expectedHeaders = HEADERS_UNIQUE_NAMES; SimpleDistanceMatrixData distanceData = new SimpleDistanceMatrixData(expectedHeaders, DISTANCES); Set<Integer> ids = distanceData.getIDs(); Path dirPath = Paths.get(TEST_OUTPUT); Files.createDirectories(dirPath); dirPath = Files.createTempDirectory(dirPath, "DistanceMatrix-AllIds"); // create solution SubsetSolution solution = new SubsetSolution(ids); for (int sel : SELECTION) { solution.select(sel);// w w w.j a va2s . co m } Path path; // write with integer ids dataName = "with-ids.csv"; path = Paths.get(dirPath.toString(), dataName); System.out.println(" |- Write distance matrix file (with solution) " + dataName); distanceData.writeData(path, FileType.CSV, solution, true, true, true); assertTrue("Output is not correct!", FileUtils.contentEquals(new File( SimpleDistanceMatrixDataTest.class.getResource("/distances/out/all-with-ids.csv").getPath()), path.toFile())); // write without integer ids dataName = "no-ids.csv"; path = Paths.get(dirPath.toString(), dataName); System.out.println(" |- Write distance matrix file (with solution) " + dataName); distanceData.writeData(path, FileType.CSV, solution, false, true, true); assertTrue("Output is not correct!", FileUtils.contentEquals(new File( SimpleDistanceMatrixDataTest.class.getResource("/distances/out/all-no-ids.csv").getPath()), path.toFile())); }
From source file:org.corehunter.tests.data.simple.SimpleDistanceMatrixDataTest.java
@Test public void toCsvFileWithSelectedIds() throws IOException { expectedHeaders = HEADERS_UNIQUE_NAMES; SimpleDistanceMatrixData distanceData = new SimpleDistanceMatrixData(expectedHeaders, DISTANCES); Set<Integer> ids = distanceData.getIDs(); Path dirPath = Paths.get(TEST_OUTPUT); Files.createDirectories(dirPath); dirPath = Files.createTempDirectory(dirPath, "DistanceMatrix-SelectedIds"); // create solution SubsetSolution solution = new SubsetSolution(ids); for (int sel : SELECTION) { solution.select(sel);// www . ja v a 2s. com } Path path; // write with integer ids dataName = "with-ids.csv"; path = Paths.get(dirPath.toString(), dataName); System.out.println(" |- Write distance matrix file (with solution) " + dataName); distanceData.writeData(path, FileType.CSV, solution, true, true, false); assertTrue("Output is not correct!", FileUtils.contentEquals(new File( SimpleDistanceMatrixDataTest.class.getResource("/distances/out/sel-with-ids.csv").getPath()), path.toFile())); // write without integer ids dataName = "no-ids.csv"; path = Paths.get(dirPath.toString(), dataName); System.out.println(" |- Write distance matrix file (with solution) " + dataName); distanceData.writeData(path, FileType.CSV, solution, false, true, false); assertTrue("Output is not correct!", FileUtils.contentEquals(new File( SimpleDistanceMatrixDataTest.class.getResource("/distances/out/sel-no-ids.csv").getPath()), path.toFile())); }
From source file:org.corehunter.tests.data.simple.SimpleDistanceMatrixDataTest.java
@Test public void toCsvFileWithUnselectedIds() throws IOException { expectedHeaders = HEADERS_UNIQUE_NAMES; SimpleDistanceMatrixData distanceData = new SimpleDistanceMatrixData(expectedHeaders, DISTANCES); Set<Integer> ids = distanceData.getIDs(); Path dirPath = Paths.get(TEST_OUTPUT); Files.createDirectories(dirPath); dirPath = Files.createTempDirectory(dirPath, "DistanceMatrix-UnselectedIds"); // create solution SubsetSolution solution = new SubsetSolution(ids); for (int sel : SELECTION) { solution.select(sel);//from ww w . ja v a2 s .co m } Path path; // write with integer ids dataName = "with-ids.csv"; path = Paths.get(dirPath.toString(), dataName); System.out.println(" |- Write distance matrix file (with solution) " + dataName); distanceData.writeData(path, FileType.CSV, solution, true, false, true); assertTrue("Output is not correct!", FileUtils .contentEquals( new File(SimpleDistanceMatrixDataTest.class .getResource("/distances/out/unsel-with-ids.csv").getPath()), path.toFile())); // write without integer ids dataName = "no-ids.csv"; path = Paths.get(dirPath.toString(), dataName); System.out.println(" |- Write distance matrix file (with solution) " + dataName); distanceData.writeData(path, FileType.CSV, solution, false, false, true); assertTrue("Output is not correct!", FileUtils.contentEquals(new File( SimpleDistanceMatrixDataTest.class.getResource("/distances/out/unsel-no-ids.csv").getPath()), path.toFile())); }
From source file:org.corehunter.tests.data.simple.SimpleFrequencyGenotypeDataTest.java
@Test public void toCsvFileWithAllIds() throws IOException { expectedHeaders = HEADERS_UNIQUE_NAMES; expectedMarkerNames = MARKER_NAMES;//from w ww .j ava 2s. c om expectedAlleleNames = ALLELE_NAMES; SimpleFrequencyGenotypeData genotypicData = new SimpleFrequencyGenotypeData(expectedHeaders, expectedMarkerNames, expectedAlleleNames, ALLELE_FREQUENCIES); Set<Integer> ids = genotypicData.getIDs(); Path dirPath = Paths.get(TEST_OUTPUT); Files.createDirectories(dirPath); dirPath = Files.createTempDirectory(dirPath, "GenoFreqs-AllIds"); // create solution SubsetSolution solution = new SubsetSolution(ids); for (int sel : SELECTION) { solution.select(sel); } Path path; // write with integer ids dataName = "with-ids.csv"; path = Paths.get(dirPath.toString(), dataName); System.out.println(" |- Write frequency genotypes file (with solution) " + dataName); genotypicData.writeData(path, FileType.CSV, solution, true, true, true); assertTrue("Output is not correct!", FileUtils.contentEquals( new File(SimpleDistanceMatrixDataTest.class .getResource("/frequency_genotypes/out/all-with-ids.csv").getPath()), path.toFile())); // write without integer ids dataName = "no-ids.csv"; path = Paths.get(dirPath.toString(), dataName); System.out.println(" |- Write frequency genotypes file (with solution) " + dataName); genotypicData.writeData(path, FileType.CSV, solution, true, true, false); assertTrue("Output is not correct!", FileUtils .contentEquals( new File(SimpleDistanceMatrixDataTest.class .getResource("/frequency_genotypes/out/all-no-ids.csv").getPath()), path.toFile())); }
From source file:org.corehunter.tests.data.simple.SimpleFrequencyGenotypeDataTest.java
@Test public void toCsvFileWithSelectedIds() throws IOException { expectedHeaders = HEADERS_UNIQUE_NAMES; expectedMarkerNames = MARKER_NAMES;// ww w . j a v a 2s . c o m expectedAlleleNames = ALLELE_NAMES; SimpleFrequencyGenotypeData genotypicData = new SimpleFrequencyGenotypeData(expectedHeaders, expectedMarkerNames, expectedAlleleNames, ALLELE_FREQUENCIES); Set<Integer> ids = genotypicData.getIDs(); Path dirPath = Paths.get(TEST_OUTPUT); Files.createDirectories(dirPath); dirPath = Files.createTempDirectory(dirPath, "GenoFreqs-SelectedIds"); // create solution SubsetSolution solution = new SubsetSolution(ids); for (int sel : SELECTION) { solution.select(sel); } Path path; // write with integer ids dataName = "with-ids.csv"; path = Paths.get(dirPath.toString(), dataName); System.out.println(" |- Write frequency genotypes file (with solution) " + dataName); genotypicData.writeData(path, FileType.CSV, solution, true, false, true); assertTrue("Output is not correct!", FileUtils.contentEquals( new File(SimpleDistanceMatrixDataTest.class .getResource("/frequency_genotypes/out/sel-with-ids.csv").getPath()), path.toFile())); // write without integer ids dataName = "no-ids.csv"; path = Paths.get(dirPath.toString(), dataName); System.out.println(" |- Write frequency genotypes file (with solution) " + dataName); genotypicData.writeData(path, FileType.CSV, solution, true, false, false); assertTrue("Output is not correct!", FileUtils .contentEquals( new File(SimpleDistanceMatrixDataTest.class .getResource("/frequency_genotypes/out/sel-no-ids.csv").getPath()), path.toFile())); }
From source file:org.corehunter.tests.data.simple.SimpleFrequencyGenotypeDataTest.java
@Test public void toCsvFileWithUnselectedIds() throws IOException { expectedHeaders = HEADERS_UNIQUE_NAMES; expectedMarkerNames = MARKER_NAMES;//from w w w .ja v a 2s . c o m expectedAlleleNames = ALLELE_NAMES; SimpleFrequencyGenotypeData genotypicData = new SimpleFrequencyGenotypeData(expectedHeaders, expectedMarkerNames, expectedAlleleNames, ALLELE_FREQUENCIES); Set<Integer> ids = genotypicData.getIDs(); Path dirPath = Paths.get(TEST_OUTPUT); Files.createDirectories(dirPath); dirPath = Files.createTempDirectory(dirPath, "GenoFreqs-UnselectedIds"); // create solution SubsetSolution solution = new SubsetSolution(ids); for (int sel : SELECTION) { solution.select(sel); } Path path; // write with integer ids dataName = "with-ids.csv"; path = Paths.get(dirPath.toString(), dataName); System.out.println(" |- Write frequency genotypes file (with solution) " + dataName); genotypicData.writeData(path, FileType.CSV, solution, false, true, true); assertTrue("Output is not correct!", FileUtils.contentEquals( new File(SimpleDistanceMatrixDataTest.class .getResource("/frequency_genotypes/out/unsel-with-ids.csv").getPath()), path.toFile())); // write without integer ids dataName = "no-ids.csv"; path = Paths.get(dirPath.toString(), dataName); System.out.println(" |- Write frequency genotypes file (with solution) " + dataName); genotypicData.writeData(path, FileType.CSV, solution, false, true, false); assertTrue("Output is not correct!", FileUtils.contentEquals( new File(SimpleDistanceMatrixDataTest.class .getResource("/frequency_genotypes/out/unsel-no-ids.csv").getPath()), path.toFile())); }