Skip to content

Commit

Permalink
SQUASH: Addressing @thermokarst's review
Browse files Browse the repository at this point in the history
  • Loading branch information
Oddant1 committed Jul 24, 2020
1 parent d3df7d1 commit fee57b1
Showing 1 changed file with 10 additions and 14 deletions.
24 changes: 10 additions & 14 deletions q2_types/feature_data/_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,17 +143,15 @@ def _validate_(self, level):


class DNAFASTAFormat(model.TextFileFormat):
def _validate_lines(self, max_lines):
def _validate_(self, max_lines):
level_map = {'min': 100, 'max': float('inf')}

FASTADNAValidator = re.compile(r'[ACGTURYKMSWBDHVN]+\r?\n?')
ValidationSet = frozenset(('A', 'C', 'G', 'T', 'U', 'R', 'Y', 'K', 'M',
'S', 'W', 'B', 'D', 'H', 'V', 'N'))

_validate_DNAFASTAFormats(self, FASTADNAValidator, ValidationSet,
max_lines)

def _validate_(self, max_lines):
level_map = {'min': 100, 'max': float('inf')}
self._validate_lines(level_map[max_lines])
level_map[max_lines])


DNASequencesDirectoryFormat = model.SingleFileDirectoryFormat(
Expand All @@ -168,26 +166,24 @@ class PairedDNASequencesDirectoryFormat(model.DirectoryFormat):


class AlignedDNAFASTAFormat(model.TextFileFormat):
def _validate_lines(self, max_lines):
def _validate_(self, max_lines):
level_map = {'min': 100, 'max': float('inf')}

FASTADNAValidator = re.compile(r'[ACGTURYKMSWBDHVN.-]+\r?\n?')
ValidationSet = frozenset(('A', 'C', 'G', 'T', 'U', 'R', 'Y', 'K', 'M',
'S', 'W', 'B', 'D', 'H', 'V', 'N', '.',
'-'))

_validate_DNAFASTAFormats(self, FASTADNAValidator, ValidationSet,
max_lines, True)

def _validate_(self, max_lines):
level_map = {'min': 100, 'max': float('inf')}
self._validate_lines(level_map[max_lines])
level_map[max_lines], True)


AlignedDNASequencesDirectoryFormat = model.SingleFileDirectoryFormat(
'AlignedDNASequencesDirectoryFormat', 'aligned-dna-sequences.fasta',
AlignedDNAFASTAFormat)


def _validate_DNAFASTAFormats(file, FASTADNAValidator, ValidationSet,
def _validate_DNAFASTAFormats(fmt, FASTADNAValidator, ValidationSet,
max_lines, aligned=False):
last_line_was_ID = False
ids = {}
Expand All @@ -196,7 +192,7 @@ def _validate_DNAFASTAFormats(file, FASTADNAValidator, ValidationSet,
prev_seq_len = 0
prev_seq_start_line = 0

with open(str(file), 'rb') as fh:
with open(str(fmt), 'rb') as fh:
try:
first = fh.read(6)
if first[:3] == b'\xEF\xBB\xBF':
Expand Down

0 comments on commit fee57b1

Please sign in to comment.