BioentityPropertiesSource { Stream<AnnotationFile> getAnnotationFiles() { return getBioentityPropertyFiles(annotationsDirPath, ANNOTATION_FILE_NAME_PATTERN, AnnotationFile::new); } BioentityPropertiesSource(Path annotationsDirPath,
                                     Path arrayDesignsDirPath,
                                     Path reactomeDirPath,
                                     SpeciesFactory speciesFactory);   }
@Test public void oddFilesSkipped() throws Exception { addTemporaryFile( "annotations", "not-a-right-name.tsv", ImmutableList.of()); addTemporaryFile( "annotations", "Homo_sapiens.ensprotein.tsv", ImmutableList.of()); addTemporaryFile( "annotations", "Homo_sapiens.enstranscript.tsv", ImmutableList.of()); assertThat(subject.getAnnotationFiles().count(), is(0L)); addTemporaryFile( "annotations", "Homo_sapiens.ensgene.tsv", ImmutableList.of()); assertThat(subject.getAnnotationFiles().count(), is(1L)); addTemporaryFile( "annotations", "Sleazy_worm.wbpsgene.tsv", ImmutableList.of()); assertThat(subject.getAnnotationFiles().count(), is(2L)); }
@Test public void goodButEmptyAnnotationFile() throws Exception { addTemporaryFile( "annotations", "Homo_sapiens.ensgene.tsv", ImmutableList.of( new String[]{"ensgene", "synonym", "ensfamily_description", "goterm"})); assertHasOneGoodResource(subject.getAnnotationFiles()); assertThat( subject.getAnnotationFiles() .findFirst() .orElseThrow(RuntimeException::new) .species .getEnsemblName(), is(HUMAN.ensemblName())); }
@Test public void goodButEmptyAnnotationFileWithUnknownSpeciesIsGonnaBeABlankFieldInSolrButIsOtherwiseOkayForNow() throws Exception { addTemporaryFile( "annotations", "Unknown_species.ensgene.tsv", ImmutableList.of( new String[]{"ensgene", "synonym", "ensfamily_description", "goterm"})); assertHasOneGoodResource(subject.getAnnotationFiles()); assertThat( subject.getAnnotationFiles() .findFirst() .orElseThrow(RuntimeException::new) .species .getEnsemblName(), is(SpeciesProperties.UNKNOWN.ensemblName())); }
@Test public void goodBasicFile() throws Exception { addTemporaryFile( "annotations", "Homo_sapiens.ensgene.tsv", ImmutableList.of( new String[]{"ensgene", "synonym"}, new String[]{"id", "synonym_value"})); assertHasOneGoodResource(subject.getAnnotationFiles()); assertThat( subject.getAnnotationFiles() .findFirst() .orElseThrow(RuntimeException::new) .get() .collect(toList()), containsInAnyOrder( new BioentityProperty("id", "Homo_sapiens", "ensgene", "id"), new BioentityProperty("id", "Homo_sapiens", "synonym", "synonym_value"))); }
@Test public void goodMirnaFile() throws Exception { addTemporaryFile( "annotations", "Homo_sapiens.mature_mirna.tsv", ImmutableList.of( new String[]{"mirbase_accession", "symbol", "mirbase_name", "mirbase_sequence"}, new String[]{"MIMAT0001535", "cfa-miR-448", "miR-448", "UUGCAUAUGUAGGAUGUCCCAU"})); assertHasOneGoodResource(subject.getAnnotationFiles()); assertThat( subject.getAnnotationFiles() .findFirst() .orElseThrow(RuntimeException::new) .get() .collect(toList()), containsInAnyOrder( new BioentityProperty( "MIMAT0001535", "Homo_sapiens", "mirbase_accession", "MIMAT0001535"), new BioentityProperty( "MIMAT0001535", "Homo_sapiens", "symbol", "cfa-miR-448"), new BioentityProperty( "MIMAT0001535", "Homo_sapiens", "mirbase_name", "miR-448"), new BioentityProperty( "MIMAT0001535", "Homo_sapiens", "mirbase_sequence", "UUGCAUAUGUAGGAUGUCCCAU"))); }
@Test public void goodMultipleFiles() throws Exception { addTemporaryFile( "annotations", "Homo_sapiens.ensgene.tsv", ImmutableList.of( new String[]{"ensgene", "synonym"}, new String[]{"id", "synonym_value"})); addTemporaryFile( "annotations", "Unknown_species.ensgene.tsv", ImmutableList.of( new String[]{"ensgene", "synonym", "other"}, new String[]{"id", "synonym_value", "other_value"})); assertThat( subject.getAnnotationFiles() .flatMap(BioentityPropertiesSource.AnnotationFile::get) .collect(toList()), containsInAnyOrder( new BioentityProperty("id", "Homo_sapiens", "ensgene", "id"), new BioentityProperty("id", "Homo_sapiens", "synonym", "synonym_value"), new BioentityProperty("id", "", "ensgene", "id"), new BioentityProperty("id", "", "synonym", "synonym_value"), new BioentityProperty("id", "", "other", "other_value"))); }
@Test public void annotationFileSkipsEmptyProperties() throws Exception { addTemporaryFile( "annotations", "Homo_sapiens.ensgene.tsv", ImmutableList.of( new String[]{"ensgene", "synonym", "other"}, new String[]{"id", "synonym_value", ""})); assertThat( subject.getAnnotationFiles() .flatMap(BioentityPropertiesSource.AnnotationFile::get) .collect(toList()), containsInAnyOrder( new BioentityProperty("id", "Homo_sapiens", "ensgene", "id"), new BioentityProperty("id", "Homo_sapiens", "synonym", "synonym_value"))); }
@Test public void annotationFileSplitsPropertiesOnSeparator() throws Exception { addTemporaryFile("annotations", "Homo_sapiens.ensgene.tsv", ImmutableList.of( new String[]{"ensgene", "synonym"}, new String[]{"id", "v1@@v2"})); assertThat( subject.getAnnotationFiles() .flatMap(BioentityPropertiesSource.AnnotationFile::get) .collect(toList()), containsInAnyOrder( new BioentityProperty("id", "Homo_sapiens", "ensgene", "id"), new BioentityProperty("id", "Homo_sapiens", "synonym", "v1"), new BioentityProperty("id", "Homo_sapiens", "synonym", "v2"))); }