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

Hide BiopythonDeprecationWarnings when reading certain sequence files #1729

Closed
wants to merge 1 commit into from

Conversation

victorlin
Copy link
Member

Description of proposed changes

Biopython 1.85 will show a deprecation warning when using format='fasta' with files that start with anything but '>'. This will be triggered in 2 cases:

  1. when attempting to read GenBank files as FASTA
  2. when attempting to read a FASTA file with comments

For (1), this deprecation warning will eventually become a ValueError which works with the existing try/catch block in ancentral.py to continue parsing as GenBank. For (2), it should be decided independently of Biopython if Augur should support FASTA with comments.

In both cases, the warning as-is should not be exposed to Augur users. It is not triggered when reading files format='fasta-pearson', so this is the easiest thing to do to maintain behavior of Biopython <1.85.

An alternative workaround is to suppress BiopythonDeprecationWarnings entirely with

warnings.simplefilter("ignore", BiopythonDeprecationWarning)

but that is less targeted and can lead to suppression of meaningful warnings.

Related issue(s)

Closes #1727

Checklist

  • Automated checks pass
  • Check if you need to add a changelog message
  • Check if you need to add tests
  • Check if you need to update docs
  • Post-merge: create issue for deciding if Augur should support FASTA with comments

Biopython 1.85 will show a deprecation warning when using format='fasta'
with files that start with anything but '>'. This will be triggered in 2
cases:

1. when attempting to read GenBank files as FASTA
2. when attempting to read a FASTA file with comments

For (1), this deprecation warning will eventually become a ValueError
which works with the existing try/catch block in ancentral.py to
continue parsing as GenBank. For (2), it should be decided independently
of Biopython if Augur should support FASTA with comments.

In both cases, the warning as-is should not be exposed to Augur users.
It is not triggered when reading files format='fasta-pearson', so this
is the easiest thing to do to maintain behavior of Biopython <1.85.

An alternative workaround is to suppress BiopythonDeprecationWarnings
entirely with

    warnings.simplefilter("ignore", BiopythonDeprecationWarning)

but that is less targeted and can lead to suppression of meaningful
warnings.
@victorlin victorlin self-assigned this Jan 17, 2025
@victorlin victorlin marked this pull request as draft January 17, 2025 19:54
@victorlin
Copy link
Member Author

This doesn't work on Biopython <1.85 because format='fasta-pearson' was only introduced with Biopython 1.85: biopython/biopython@378c4c1

@tsibley
Copy link
Member

tsibley commented Jan 17, 2025

An alternative workaround is to suppress BiopythonDeprecationWarnings entirely with

warnings.simplefilter("ignore", BiopythonDeprecationWarning)

but that is less targeted and can lead to suppression of meaningful warnings.

You could use a more complex filter to more precisely ignore just the specific warning in question (e.g.)

@victorlin
Copy link
Member Author

I'll open a new PR with warnings.filterwarnings along the lines of #1727 (comment)

@victorlin victorlin closed this Jan 17, 2025
@victorlin victorlin deleted the victorlin/fix-ci branch January 17, 2025 20:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CI failing with new BioPython deprecation warning
2 participants