Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MAINT: adjust regex for genome data semantic types #322

Merged
merged 5 commits into from
May 2, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions q2_types/genome_data/_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,21 @@ def _validate_(self, level):


class GenesDirectoryFormat(model.DirectoryFormat):
genes = model.FileCollection(r'(.*\_)?genes[0-9]*\.(fa|fna|fasta)$',
genes = model.FileCollection(r'.+\.(fa|fna|fasta)$',
format=DNAFASTAFormat)

@genes.set_path_maker
def genes_path_maker(self, genome_id):
return '%s_genes.fasta' % genome_id
return '%s.fasta' % genome_id


class ProteinsDirectoryFormat(model.DirectoryFormat):
proteins = model.FileCollection(r'(.*\_)?proteins[0-9]*\.(fa|faa|fasta)$',
proteins = model.FileCollection(r'.+\.(fa|faa|fasta)$',
format=ProteinFASTAFormat)

@proteins.set_path_maker
def proteins_path_maker(self, genome_id):
return '%s_proteins.fasta' % genome_id
return '%s.fasta' % genome_id


class GFF3Format(model.TextFileFormat):
Expand Down Expand Up @@ -160,12 +160,12 @@ def _validate_(self, level):


class LociDirectoryFormat(model.DirectoryFormat):
loci = model.FileCollection(r'(.*\_)?loci[0-9]*\.gff$',
loci = model.FileCollection(r'.+\.gff$',
format=GFF3Format)

@loci.set_path_maker
def loci_path_maker(self, genome_id):
return '%s_loci.gff' % genome_id
return '%s.gff' % genome_id


plugin.register_formats(
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

48 changes: 0 additions & 48 deletions q2_types/genome_data/tests/test_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,44 +59,12 @@ def test_genes_dirfmt_fa_with_suffix(self):

fmt.validate()

def test_genes_dirfmt_fa_with_prefix(self):
dirpath = self.get_data_path('genes-with-prefix')
fmt = GenesDirectoryFormat(dirpath, mode='r')

fmt.validate()

def test_genes_dirfmt_fa_with_wrong_prefix(self):
dirpath = self.get_data_path('genes-with-wrong-prefix')
fmt = GenesDirectoryFormat(dirpath, mode='r')

with self.assertRaisesRegex(
ValidationError,
'Missing one or more files for GenesDirectoryFormat'
):
fmt.validate()

def test_proteins_dirfmt_fa_with_suffix(self):
dirpath = self.get_data_path('proteins-with-suffix')
misialq marked this conversation as resolved.
Show resolved Hide resolved
fmt = ProteinsDirectoryFormat(dirpath, mode='r')

fmt.validate()

def test_proteins_dirfmt_fa_with_prefix(self):
dirpath = self.get_data_path('proteins-with-prefix')
fmt = ProteinsDirectoryFormat(dirpath, mode='r')

fmt.validate()

def test_proteins_dirfmt_fa_with_wrong_prefix(self):
dirpath = self.get_data_path('proteins-with-wrong-prefix')
fmt = ProteinsDirectoryFormat(dirpath, mode='r')

with self.assertRaisesRegex(
ValidationError,
'Missing one or more files for ProteinsDirectoryFormat'
):
fmt.validate()

def test_gff_format_positive_with_suffix(self):
filepath = self.get_data_path('loci-with-suffix/loci1.gff')
fmt = GFF3Format(filepath, mode='r')
Expand All @@ -109,22 +77,6 @@ def test_loci_dirfmt_with_suffix(self):

fmt.validate()

def test_loci_dirfmt_with_prefix(self):
dirpath = self.get_data_path('loci-with-prefix')
fmt = LociDirectoryFormat(dirpath, mode='r')

fmt.validate()

def test_loci_dirfmt_with_wrong_prefix(self):
dirpath = self.get_data_path('loci-with-wrong-prefix')
fmt = LociDirectoryFormat(dirpath, mode='r')

with self.assertRaisesRegex(
ValidationError,
'Missing one or more files for LociDirectoryFormat'
):
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
13 changes: 6 additions & 7 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,12 @@
['data/*', 'data/*/*',
'data/mags-fa/*', 'data/mags-fasta/*'],
'q2_types.genome_data.tests':
['data/*/', 'data/genes-with-prefix/*',
'data/genes-with-suffix/*', 'data/genes-with-wrong-prefix/*',
'data/loci-invalid/*', 'data/loci-with-prefix/*',
'data/loci-with-suffix/*', 'data/loci-with-wrong-prefix/*',
'data/ortholog/*', 'data/proteins-with-suffix/*',
'data/proteins-with-prefix/*',
'data/proteins-with-wrong-prefix/*',
['data/*/',
'data/genes-with-suffix/*',
'data/loci-invalid/*',
'data/loci-with-suffix/*',
'data/ortholog/*',
'data/proteins-with-suffix/*',
],
'q2_types.kraken2.tests': [
'data/*',
Expand Down
Loading