BaselineAnalyticsInputStreamFactory { public ObjectInputStream<BaselineAnalytics> create(String experimentAccession, ExperimentType experimentType) throws IOException { checkArgument(experimentType.isBaseline()); if (experimentType.isProteomicsBaseline()) { AtlasResource<?> resource = dataFileHub.getProteomicsBaselineExperimentFiles(experimentAccession).main; return new ProteomicsBaselineAnalyticsInputStream(resource.getReader(), resource.toString()); } else { AtlasResource<?> tpms = dataFileHub.getRnaSeqBaselineExperimentFiles(experimentAccession) .dataFile(ExpressionUnit.Absolute.Rna.TPM); AtlasResource<?> fpkms = dataFileHub.getRnaSeqBaselineExperimentFiles(experimentAccession) .dataFile(ExpressionUnit.Absolute.Rna.FPKM); checkArgument( tpms.exists() || fpkms.exists(), String.format("No FPKMs or TPMs found for %s", experimentAccession)); return new RnaSeqBaselineAnalyticsInputStream( tpms.exists() ? Optional.of(tpms.getReader()) : Optional.empty(), fpkms.exists() ? Optional.of(fpkms.getReader()) : Optional.empty()); } } @Inject  BaselineAnalyticsInputStreamFactory(DataFileHub dataFileHub); ObjectInputStream<BaselineAnalytics> create(String experimentAccession, ExperimentType experimentType);  }
@Test public void createForRnaSeqBaselineWithTpmsOnly() throws Exception { Object objectInputStream = subject.create(EXPERIMENT_ACCESSION_RNASEQ_TPMS, ExperimentType.RNASEQ_MRNA_BASELINE); assertThat(objectInputStream, is(instanceOf(RnaSeqBaselineAnalyticsInputStream.class))); }
@Test public void createRnaSeqBaselineWithFpkmsOnly() throws Exception { subject.create(EXPERIMENT_ACCESSION_RNASQ_FPKMS, ExperimentType.RNASEQ_MRNA_BASELINE); }
@Test public void createForProteomics() throws Exception { ObjectInputStream<BaselineAnalytics> objectInputStream = subject.create(EXPERIMENT_ACCESSION_PROTEOMICS, ExperimentType.PROTEOMICS_BASELINE); assertThat(objectInputStream, is(instanceOf(ProteomicsBaselineAnalyticsInputStream.class))); }
@Test(expected = IllegalArgumentException.class) public void createRnaSeqBaselineWithNoFpkmsOrTpmsThrows() throws Exception { subject.create(EXPERIMENT_ACCESSION_NO_TPMS_FPKMS, ExperimentType.RNASEQ_MRNA_BASELINE); }