Skip to content

Commit

Permalink
add missing test; refactor some paths
Browse files Browse the repository at this point in the history
  • Loading branch information
misialq committed Jul 16, 2024
1 parent 4d85339 commit cd55f94
Show file tree
Hide file tree
Showing 12 changed files with 28 additions and 12 deletions.
5 changes: 5 additions & 0 deletions q2_types/genome_data/tests/data/genome-sequences/sequence1.fa
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
>genome1 some_description1
GGCAGATTCCCCCTAGACCCGCCCGCACCATGGTCAGGCATGCCCCTCCTCATCGCTGGGCACAGCCCAGAGGGT
ATAAACAGTGCTGGAGGCCCACTGCACTCACCGCACCCGGCCAATTTTTGTGTTTTTAGTAGAGACTAAATACCA
TATAGTGAACACCTAAGAGCACCCGGCCAATTTTTGTGTTTTTAGTAGAGAAGATTCCCCCTAGACCCGCCCGCT
ATAGTGAACACCTAAGAACTGGAGGCGGGGGGCCTTGG
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
>genome2 some_description2
ATGGTCAGGCATGCCCCTCCTCATCGCTGGGCGGCAGATTCCCCCTAGACCCGCCCGCACCACAGCCCAGAGGGT
ATAAACAGTGCTGGAGGCAATACCATATAGTGAACACCTAACCACTGCACTCACCGCACCCGGCCAATTTTTGTG
TTTTTAGTAGAGACTAGACGGGGGGCCTTGG
14 changes: 10 additions & 4 deletions q2_types/genome_data/tests/test_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from .._format import (
GenesDirectoryFormat, ProteinsDirectoryFormat, GFF3Format,
LociDirectoryFormat, SeedOrthologDirFmt, OrthologFileFmt,
OrthologAnnotationDirFmt,
OrthologAnnotationDirFmt, GenomeSequencesDirectoryFormat,
)


Expand Down Expand Up @@ -78,6 +78,12 @@ def test_loci_dirfmt_with_suffix(self):

fmt.validate()

def test_genome_sequences_dirfmt_with_suffix(self):
dirpath = self.get_data_path('genome-sequences')
fmt = GenomeSequencesDirectoryFormat(dirpath, mode='r')

fmt.validate()

def test_gff_format_wrong_version(self):
filepath = self.get_data_path('loci-invalid/loci-wrong-version.gff')
with self.assertRaisesRegex(
Expand Down Expand Up @@ -141,20 +147,20 @@ def test_gff_format_invalid_phase(self):
GFF3Format(filepath, mode='r').validate()

def test_ortholog_annotation_dir_fmt_passing(self):
dirpath = self.get_data_path('good_ortholog_annotation')
dirpath = self.get_data_path('ortholog-annotation')
fmt_obj = OrthologAnnotationDirFmt(dirpath, mode='r')
fmt_obj.validate()

def test_ortholog_annotation_dir_fmt_fails_extra_file(self):
dirpath = self.get_data_path('ortholog_annotation_extra')
dirpath = self.get_data_path('ortholog-annotation-extra')
fmt_obj = OrthologAnnotationDirFmt(dirpath, mode='r')

with self.assertRaisesRegex(ValidationError, "Unrecognized file"):
fmt_obj.validate()

def test_ortholog_annotations_annot_dict(self):
annotations = OrthologAnnotationDirFmt(
self.get_data_path('ortholog_annotation_samples'), mode='r'
self.get_data_path('ortholog-annotation-samples'), mode='r'
)

obs = annotations.annotation_dict()
Expand Down
8 changes: 4 additions & 4 deletions q2_types/genome_data/tests/test_transformer.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ def test_interval_metadata_iterator_to_gff(self):

def test_annotations_to_dataframe_samples(self):
annotations = OrthologAnnotationDirFmt(
self.get_data_path('ortholog_annotation_samples'),
self.get_data_path('ortholog-annotation-samples'),
mode='r'
)
obs = _annotations_to_dataframe(annotations)
Expand All @@ -136,7 +136,7 @@ def test_annotations_to_dataframe_samples(self):

def test_annotations_to_dataframe_mags(self):
annotations = OrthologAnnotationDirFmt(
self.get_data_path('ortholog_annotation_mags'),
self.get_data_path('ortholog-annotation-mags'),
mode='r'
)
obs = _annotations_to_dataframe(annotations)
Expand All @@ -147,7 +147,7 @@ def test_annotations_to_dataframe_mags(self):

def test_annotations_to_df_transformer(self):
annotations = OrthologAnnotationDirFmt(
self.get_data_path('ortholog_annotation_mags'),
self.get_data_path('ortholog-annotation-mags'),
mode='r'
)
transformer = self.get_transformer(
Expand All @@ -163,7 +163,7 @@ def test_annotations_to_df_transformer(self):

def test_annotations_to_metadata_transformer(self):
annotations = OrthologAnnotationDirFmt(
self.get_data_path('ortholog_annotation_mags'),
self.get_data_path('ortholog-annotation-mags'),
mode='r'
)
transformer = self.get_transformer(
Expand Down
9 changes: 5 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,12 @@
'data/genes/*',
'data/loci-invalid/*',
'data/loci/*',
'data/genome-sequences/*'
'data/ortholog/*',
'data/ortholog_annotation_extra/*',
'data/ortholog_annotation_mags/*',
'data/ortholog_annotation_samples/*',
'data/good_ortholog_annotation/*',
'data/ortholog-annotation-extra/*',
'data/ortholog-annotation-mags/*',
'data/ortholog-annotation-samples/*',
'data/ortholog-annotation/*',
'data/proteins/*',
],
'q2_types.kraken2.tests': [
Expand Down

0 comments on commit cd55f94

Please sign in to comment.