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

ENH: Improved alpha diversity format validation #204

Merged
merged 4 commits into from Jan 28, 2019
Merged

ENH: Improved alpha diversity format validation #204

merged 4 commits into from Jan 28, 2019

Conversation

thermokarst
Copy link
Contributor

Refactors the existing sniffer to use the current validation API. Also, removes the (likely accidental off-by-one) restriction that a minimum of two samples are present (it looks like the original code forgot to account for the header row).

@thermokarst thermokarst added this to In Review in 2019.1 via automation Jan 23, 2019
@ebolyen ebolyen self-assigned this Jan 24, 2019
Copy link
Member

@ebolyen ebolyen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor comments

return i > 1
header = None
records_seen = 0
file_ = enumerate(fh) if level == 'min' else zip(range(10), fh)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
file_ = enumerate(fh) if level == 'min' else zip(range(10), fh)
file_ = enumerate(fh, 1) if level == 'min' else zip(range(1, 10), fh)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line becomes 81 cols long (which was why I didn't do this in the first place). Options: promote from a ternary to a real if/else block; unindent the whole block by removing the filehandle context manager and instead manually closing. Any other options come to mind?

records_seen = 0
file_ = enumerate(fh) if level == 'min' else zip(range(10), fh)
for i, line in file_:
i = i + 1 # For easier reporting
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
i = i + 1 # For easier reporting

continue # Blank line
elif line.startswith('#'):
continue # Comment line
cells = [c.strip() for c in line.rstrip('\n').split('\t')]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's switch this to csv for quote handling

@ebolyen ebolyen moved this from In Review to In Development in 2019.1 Jan 25, 2019
@ebolyen ebolyen assigned thermokarst and unassigned ebolyen Jan 25, 2019
@thermokarst thermokarst assigned ebolyen and unassigned thermokarst Jan 25, 2019
@thermokarst thermokarst moved this from In Development to In Review in 2019.1 Jan 25, 2019
format.validate()

def test_alpha_diversity_format_validate_negative(self):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:)

@ebolyen ebolyen merged commit 3155ac8 into qiime2:master Jan 28, 2019
2019.1 automation moved this from In Review to Completed Jan 28, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
2019.1
  
Completed
Development

Successfully merging this pull request may close these issues.

None yet

2 participants