DifferentialExperimentContrastLines implements Iterable<String[]> { @Nonnull @Override public Iterator<String[]> iterator() { return contrastDetails.stream().map(list -> list.toArray(new String[0])).iterator(); } DifferentialExperimentContrastLines(DifferentialExperiment experiment); @Nonnull @Override Iterator<String[]> iterator();  }
@Test public void contrastDetailLines() { AssayGroup referenceAssayGroup = new AssayGroup( "g1", ImmutableSet.of(new BiologicalReplicate(ASSAY1), new BiologicalReplicate(ASSAY2))); AssayGroup testAssayGroup = new AssayGroup( "g2", ImmutableSet.of(new BiologicalReplicate(ASSAY3), new BiologicalReplicate(ASSAY4))); Contrast contrast1 = new Contrast( CONTRAST_ID, "array design accession", referenceAssayGroup, testAssayGroup, "display name"); ExperimentDesign experimentDesign = new ExperimentDesign(); SampleCharacteristic sampleCharacteristic1 = SampleCharacteristic.create(SAMPLE_HEADER, SAMPLE_VALUE1, SAMPLE_ONTOLOGY_TERM1); SampleCharacteristic sampleCharacteristic2 = SampleCharacteristic.create(SAMPLE_HEADER, SAMPLE_VALUE2, SAMPLE_ONTOLOGY_TERM2); experimentDesign.putSampleCharacteristic(ASSAY1, SAMPLE_HEADER, sampleCharacteristic1); experimentDesign.putFactor(ASSAY1, FACTOR_HEADER, FACTOR_VALUE1, FACTOR_ONTOLOGY_TERM1); experimentDesign.putSampleCharacteristic(ASSAY2, SAMPLE_HEADER, sampleCharacteristic2); experimentDesign.putFactor(ASSAY2, FACTOR_HEADER, FACTOR_VALUE1, FACTOR_ONTOLOGY_TERM1); experimentDesign.putSampleCharacteristic(ASSAY3, SAMPLE_HEADER, SAMPLE_VALUE3); experimentDesign.putFactor(ASSAY3, FACTOR_HEADER, FACTOR_VALUE2, FACTOR_ONTOLOGY_TERM2); experimentDesign.putSampleCharacteristic(ASSAY4, SAMPLE_HEADER, SAMPLE_VALUE4); experimentDesign.putFactor(ASSAY4, FACTOR_HEADER, FACTOR_VALUE2, FACTOR_ONTOLOGY_TERM2); DifferentialExperiment experiment = new DifferentialExperiment( EXPERIMENT_ACCESSION, new Date(), ImmutableList.of(Pair.of(contrast1, true)), "description", new Species("species", SpeciesProperties.UNKNOWN), ImmutableSet.of(), ImmutableSet.of(), experimentDesign); this.subject = new DifferentialExperimentContrastLines(experiment); Iterator<String[]> lines = subject.iterator(); assertThat( lines.next(), is(new String[] { EXPERIMENT_ACCESSION, CONTRAST_ID, REFERENCE, CHARACTERISTIC, SAMPLE_HEADER, SAMPLE_VALUE2, SAMPLE_ONTOLOGY_ID2})); assertThat( lines.next(), is(new String[] { EXPERIMENT_ACCESSION, CONTRAST_ID, REFERENCE, FACTOR, FACTOR_HEADER, FACTOR_VALUE1, HTTP_OBO + FACTOR_ONTOLOGY_ID1})); assertThat( lines.next(), is(new String[] { EXPERIMENT_ACCESSION, CONTRAST_ID, REFERENCE, CHARACTERISTIC, SAMPLE_HEADER, SAMPLE_VALUE1, HTTP_OBO + SAMPLE_ONTOLOGY_ID1})); assertThat( lines.next(), is(new String[] { EXPERIMENT_ACCESSION, CONTRAST_ID, TEST, CHARACTERISTIC, SAMPLE_HEADER, SAMPLE_VALUE4, ""})); assertThat( lines.next(), is(new String[] { EXPERIMENT_ACCESSION, CONTRAST_ID, TEST, FACTOR, FACTOR_HEADER, FACTOR_VALUE2, FACTOR_ONTOLOGY_ID2})); assertThat( lines.next(), is(new String[] { EXPERIMENT_ACCESSION, CONTRAST_ID, TEST, CHARACTERISTIC, SAMPLE_HEADER, SAMPLE_VALUE3, ""})); }
@Test public void duplicateContrastDetailLines() { AssayGroup referenceAssayGroup = new AssayGroup( "g1", ImmutableSet.of(new BiologicalReplicate(ASSAY1), new BiologicalReplicate(ASSAY2))); AssayGroup testAssayGroup = new AssayGroup( "g2", ImmutableSet.of(new BiologicalReplicate(ASSAY3), new BiologicalReplicate(ASSAY4))); Contrast contrast1 = new Contrast( CONTRAST_ID, "array design accession", referenceAssayGroup, testAssayGroup, "display name"); ExperimentDesign experimentDesign = new ExperimentDesign(); experimentDesign.putSampleCharacteristic(ASSAY1, SAMPLE_HEADER, SAMPLE_VALUE1); experimentDesign.putFactor(ASSAY1, FACTOR_HEADER, FACTOR_VALUE1); experimentDesign.putSampleCharacteristic(ASSAY2, SAMPLE_HEADER, SAMPLE_VALUE1); experimentDesign.putFactor(ASSAY2, FACTOR_HEADER, FACTOR_VALUE1); experimentDesign.putSampleCharacteristic(ASSAY3, SAMPLE_HEADER, SAMPLE_VALUE3); experimentDesign.putFactor(ASSAY3, FACTOR_HEADER, FACTOR_VALUE2); experimentDesign.putSampleCharacteristic(ASSAY4, SAMPLE_HEADER, SAMPLE_VALUE4); experimentDesign.putFactor(ASSAY4, FACTOR_HEADER, FACTOR_VALUE2); DifferentialExperiment experiment = new DifferentialExperiment( EXPERIMENT_ACCESSION, new Date(), ImmutableList.of(Pair.of(contrast1, true)), "description", new Species("species", SpeciesProperties.UNKNOWN), ImmutableSet.of(), ImmutableSet.of(), experimentDesign); this.subject = new DifferentialExperimentContrastLines(experiment); Iterator<String[]> lines = subject.iterator(); assertThat( lines.next(), is(new String[] { EXPERIMENT_ACCESSION, CONTRAST_ID, REFERENCE, CHARACTERISTIC, SAMPLE_HEADER, SAMPLE_VALUE1, ""})); assertThat( lines.next(), is(new String[] { EXPERIMENT_ACCESSION, CONTRAST_ID, REFERENCE, FACTOR, FACTOR_HEADER, FACTOR_VALUE1, ""})); assertThat( lines.next(), is(new String[] { EXPERIMENT_ACCESSION, CONTRAST_ID, TEST, CHARACTERISTIC, SAMPLE_HEADER, SAMPLE_VALUE4, ""})); assertThat( lines.next(), is(new String[] { EXPERIMENT_ACCESSION, CONTRAST_ID, TEST, FACTOR, FACTOR_HEADER, FACTOR_VALUE2, ""})); assertThat( lines.next(), is(new String[] { EXPERIMENT_ACCESSION, CONTRAST_ID, TEST, CHARACTERISTIC, SAMPLE_HEADER, SAMPLE_VALUE3, ""})); }
@Test public void emptyValuesDetailLines() { AssayGroup referenceAssayGroup = new AssayGroup( "g1", ImmutableSet.of(new BiologicalReplicate(ASSAY1), new BiologicalReplicate(ASSAY2))); AssayGroup testAssayGroup = new AssayGroup( "g2", ImmutableSet.of(new BiologicalReplicate(ASSAY3), new BiologicalReplicate(ASSAY4))); Contrast contrast1 = new Contrast( CONTRAST_ID, "array design accession", referenceAssayGroup, testAssayGroup, "display name"); ExperimentDesign experimentDesign = new ExperimentDesign(); experimentDesign.putSampleCharacteristic(ASSAY1, SAMPLE_HEADER, ""); experimentDesign.putFactor(ASSAY1, FACTOR_HEADER, FACTOR_VALUE1); experimentDesign.putSampleCharacteristic(ASSAY2, SAMPLE_HEADER, SAMPLE_VALUE2); experimentDesign.putFactor(ASSAY2, FACTOR_HEADER, FACTOR_VALUE1); experimentDesign.putSampleCharacteristic(ASSAY3, SAMPLE_HEADER, SAMPLE_VALUE3); experimentDesign.putFactor(ASSAY3, FACTOR_HEADER, FACTOR_VALUE2); experimentDesign.putSampleCharacteristic(ASSAY4, SAMPLE_HEADER, SAMPLE_VALUE4); experimentDesign.putFactor(ASSAY4, FACTOR_HEADER, FACTOR_VALUE2); DifferentialExperiment experiment = new DifferentialExperiment( EXPERIMENT_ACCESSION, new Date(), ImmutableList.of(Pair.of(contrast1, true)), "description", new Species("species", SpeciesProperties.UNKNOWN), ImmutableSet.of(), ImmutableSet.of(), experimentDesign); this.subject = new DifferentialExperimentContrastLines(experiment); Iterator<String[]> lines = subject.iterator(); assertThat( lines.next(), is(new String[] { EXPERIMENT_ACCESSION, CONTRAST_ID, REFERENCE, CHARACTERISTIC, SAMPLE_HEADER, SAMPLE_VALUE2, ""})); assertThat( lines.next(), is(new String[] { EXPERIMENT_ACCESSION, CONTRAST_ID, REFERENCE, FACTOR, FACTOR_HEADER, FACTOR_VALUE1, ""})); assertThat( lines.next(), is(new String[] { EXPERIMENT_ACCESSION, CONTRAST_ID, REFERENCE, CHARACTERISTIC, SAMPLE_HEADER, "", ""})); assertThat( lines.next(), is(new String[] { EXPERIMENT_ACCESSION, CONTRAST_ID, TEST, CHARACTERISTIC, SAMPLE_HEADER, SAMPLE_VALUE4, ""})); assertThat( lines.next(), is(new String[] { EXPERIMENT_ACCESSION, CONTRAST_ID, TEST, FACTOR, FACTOR_HEADER, FACTOR_VALUE2, ""})); assertThat( lines.next(), is(new String[] { EXPERIMENT_ACCESSION, CONTRAST_ID, TEST, CHARACTERISTIC, SAMPLE_HEADER, SAMPLE_VALUE3, ""})); }