332 Commits

Author SHA1 Message Date
8d5ef92908 Can drop Optional and Union in typing on Python 3.10 onwards
pyupgrade --py310-plus --keep-percent-format *.py
2025-01-16 00:24:37 +00:00
474ca70b62 Pass IGNORE_EXCEPTION_DETAIL to run_doctest in Seq.py 2024-11-25 22:52:29 +00:00
0f9f60b43d Avoid loading of doctest: use Bio._utils instead 2024-11-25 22:52:29 +00:00
81eb70b107 Remove more unused imports (F401)
Again, found by linting.
2024-06-27 09:55:07 +09:00
87350ad4df Remove now redundany typing imports
Found with ruff check F401 (which we don't currently
enforce but probably ought to later).
2024-06-27 09:55:07 +09:00
519066cfb8 pep 585 typing rewrites etc using pyupgrade 3.16.0
$ pyupgrade --keep-percent-format --py39-plus \
      Bio/*.py Bio/*/*.py BioSQL/*.py

Didn't find any changes in tests, scripts, or docs.
Followed by removing a few now redundant imports
and black in one case.
2024-06-27 09:55:07 +09:00
de0bb21fb3 Apply isort (forcing single lines, not sorting by type) via ruff
$ ruff check --fix --select=I \
  --config=lint.isort.force-single-line=true \
  --config=lint.isort.order-by-type=false \
  BioSQL/ Bio/ Tests/ Scripts/ Doc/ setup.py

Using ruff version 0.4.10
2024-06-26 15:31:39 +09:00
57056bbfc4 ruff format v0.3.1, black v24.2.0
Reverted unwanted changes (mostly arrays in tests, but also
some whitespace in doctests).

Remaining changes are standardising spacing between module
docstring and imports, and lower-case \x<hex> in strings.
2024-03-14 11:05:43 +00:00
6636e9de6e Ran black v24.2.0 2024-03-14 11:05:43 +00:00
c013510512 Remove deprecated code from Bio.Seq for release 1.82 (#4498)
* update

* update

* update

* update

* updating NEWS and DEPRECAED

* updating DEPRECAED

---------

Co-authored-by: Michiel de Hoon <mdehoon@tkx249.genome.gsc.riken.jp>
2023-11-20 15:44:14 +09:00
4db566987c Explain transcription convention in docstring (#4439)
Based partly on a paragraph from our tutorial, then reworded with Michiel's feedback.
2023-09-06 13:30:16 +01:00
42ca9f27b8 Basic type hints: QualityIO, SeqRecords, ...
Co-authored-by: Thomas Holder <thomas@thomas-holder.de>
2023-08-08 10:51:44 +01:00
1081053660 Add a search method to Seq and MutableSeq (#4327)
* update

* update

* update

* fix error message for pypy

---------

Co-authored-by: Michiel de Hoon <mdehoon@tkx249.genome.gsc.riken.jp>
2023-06-21 10:46:06 +09:00
f39ccb47ca Refactor removeprefix and removesuffix for ABC work
Also test removeprefix/suffix in undefined sequences
2023-05-22 12:08:14 +01:00
c990eb6218 Adds removeprefix and removesuffix to Seq
Handles versions of python 3 which are not python3.9

(Written before the introduction of the
SequenceDataAbstractBaseClass, rebased
but not yet updated accordingly)
2023-05-22 12:08:14 +01:00
dcf52bd454 remove deprecated code from Bio.Seq (#4173)
* remove deprecated UnknownSeq

* remove deprecated UnknownSeq
2022-11-20 23:30:23 +09:00
d8e63db4e3 deprecate ungap (#4153) 2022-11-08 22:38:18 +09:00
7414724f58 Seqrecord count (#4035)
* add count method to SeqRecord

* adding tests

* update

* update

* update doctext
2022-08-23 22:25:16 +09:00
4b57e0fb0f Add codon to TranslationError exception (#4038) 2022-08-23 09:55:18 +01:00
fc154ae02f add defined_ranges (#3799)
* add defined_ranges

* yellow

* green

* adding test for lazy-loaded sequences
2021-11-23 07:44:56 +09:00
b5e1bda9eb use bytes if the sequence is fully defined (#3790)
* use bytes if the sequence is fully defined

* black

* flake

* flake

* Add defined attribute to Seq (#3779)

* Add defined attribute to Seq

- Add "defined" attribute to Seq object that returns true if the Seq
  contains a fully defined sequence and false if it is unknown or
  partial
- Fixes #3667

* Update run_tests.py to support Python 3.10

- The run_tests.py script assumes that python has a single digit major
  version and single digit minor version, update to support any size
  version numbers

* Simplify Seq.defined check

* Address review comments

- Check if data is defined in a more OO way
- Update partial data types to be considered defined if they contain a
  complete sequence

* use bytes if the sequence is fully defined

* update defined now that zero-length undefined/partially defined sequences cannot occur

* clean up defined

* remove check for zero length

* update docstrings

Co-authored-by: Neil P <npars@users.noreply.github.com>
2021-11-19 19:46:10 +09:00
8546c9622b Add defined attribute to Seq (#3779)
* Add defined attribute to Seq

- Add "defined" attribute to Seq object that returns true if the Seq
  contains a fully defined sequence and false if it is unknown or
  partial
- Fixes #3667

* Update run_tests.py to support Python 3.10

- The run_tests.py script assumes that python has a single digit major
  version and single digit minor version, update to support any size
  version numbers

* Simplify Seq.defined check

* Address review comments

- Check if data is defined in a more OO way
- Update partial data types to be considered defined if they contain a
  complete sequence
2021-11-15 08:51:06 +09:00
1891b12d00 Add islower/isupper methods to Seq (#3753) (#3776) 2021-11-02 23:56:29 +09:00
f1f49deb80 Add __iter__ method to Seq objects to improve list performance #3772 (#3773)
* Adds __iter__ function to _SeqAbstractBaseClass

This dramatically improves performance when calling `list(Seq(...))`

* Adds Seq test_cast_to_list

* Update CONTRIB.rst

* Updates tests with empty Seqs, MutableSeq, and partial Seqs
2021-11-02 06:56:57 +09:00
3802e60e66 f-strings on Bio.Seq* using flynt 0.69 2021-09-13 16:14:16 +01:00
d7588686c1 pyupgrade: f-strings in sequence code
Using pyupgrade v2.25.0,

$ pyupgrade --py37-plus Bio/Seq*.py Bio/SeqUtils/*.py

Reverted two cases by hand were the old style % formating was
replaced with (what I considered to be) a less readable format
method usage.
2021-09-10 09:27:49 +01:00
89dca6d303 Fixing assorted ambiguous typos 2021-08-31 10:41:38 +01:00
b3fb015ef1 Partially defined sequences (#3691)
* partial

* __getitem__

* added tests

* more tests

* simplify

* negative step

* cleanup

* added tests

* addition

* addition tests

* added docstring

* tutorial update

* upper, lower

* add missing methods

* flake

* black & blue

* use consistent black version

* clean up __add__ method by relying on inheritance

* style

* add test for repr on long sequences

* added a test for UndefinedSqeuenceData replacement with different length substring

* added a test for negative length

* style

* simplify

* adding tests

* style

* cleanup

* workaround for python3.7
2021-08-22 16:53:44 +09:00
2da0b26c29 make complement, reverse_complement consistent (#3648)
* make complement, reverse_complement consistent

* style

* style

* sequtils

* workaround

* no more funny business
2021-07-21 23:33:12 +09:00
5a55811d57 typos and stray code (#3646) 2021-06-29 08:46:19 +09:00
d1d9c70948 replace isinstance(int) by isinstance(numbers.Integral) (#3642)
* replace isinstance(int) by isinstance(numbers.Integral) for obvious cases

* add tests

* style
2021-06-28 22:08:08 +09:00
36ad78155a reorder imports for SeqIO and AlignIO
$ reorder-python-imports --separate-relative --separate-from-import --py36-plus Bio/Seq*.py Bio/SeqIO/*.py Bio/AlignIO/*.py Tests/test_Seq*.py Tests/test_AlignIO*.py

$ black Bio/ Tests/
2021-03-06 13:05:10 +00:00
2865e9727f Add __slots__ to sequence objects (#3482)
* put __slots__ on _SeqAbstractBaseClass, Seq, MutableSeq to reduce their memory usage; store attributes in _data instead

* add __slots__ to SequenceDataAbstractBaseClass, _UndefinedSequenceData, _TwoBitSequenceData, _BioSQLSequenceData

* fix __delattr__

* silly stuff from Travis

* Using a private ._attributes dictionary to store the attributes

* put __slots__ on the base class only, and let python create __dict__ on demand on the subclass

* added some tests

* travis
2021-02-16 21:06:02 +09:00
6f203f4351 deprecate the ungap method of Seq objects (#3480)
* deprecate the ungap method of Seq objects

* Declare ungap obsolete
2021-02-12 23:30:16 +09:00
d76592bf53 Seq baseclass (#3455)
* baseclass

* added replace

* updated docstrings

* travis

* travis

* use _SeqAbstractBaseClass for type checking
2021-02-07 09:29:51 +09:00
7b09da61fa Seq bytes (#3451)
* make Seq, MutableSeq methods consistent

* add tests for MutableSeq

* add tests for methods

* tests on subsequences are pointless here as they will return a bytes object

* added BioSQL tests

* travis

* travis

* travis

* travis

* update docstrings, and avoid subclassing __bytes__ in BioSQL
2020-12-24 23:01:36 +09:00
629e27d304 Seq equality and comparisons consistent (#3449)
* be consistent

* adding tests
2020-12-21 00:59:06 +09:00
0832381eaa deprecate UnknownSeq (#3446)
* deprecate UnknownSeq

* travis

* travis

* restore filter in tearDown
2020-12-19 20:25:44 +09:00
14a77f2b8c use an abstract base class (#3445) 2020-12-17 19:23:41 +09:00
2c889ff008 use UndefinedSequenceData for undefined sequences (#3440)
* use UndefinedSequenceData for undefined sequences

* travis

* typo and some silly stuff

* make UndefinedSequenceData a private class

* Peter's suggestions
2020-12-15 09:40:27 +09:00
fcc6e925a2 minor cleanup in Bio.Seq (#3435) 2020-12-07 16:59:48 +00:00
dec78fee4b add lower and upper to MutableSeq (#3430)
* add lower and upper to MutableSqe

* adding strip, lstrip, rstrip, split, rsplit
2020-12-07 20:19:12 +09:00
d9e4f12bfc Add translate method to MutableSeq (#3427)
* translate

* travis
2020-12-04 21:29:43 +09:00
41b6f22574 Add a parser for 2bit files to Bio.SeqIO (#3388)
* add test script

* add test files

* done

* travis

* travis being obnoxious

* remove unnecessary str support

* avoid using PyUnicode_New as it's not in pypy

* add some documentation

* add some documentation

* move to a comment to travis can't bitch about it

* move to a comment to travis can't bitch about it

* documentation update

* fix warning

* Let's see why 32bit windows is not happy

* Let's see why 32bit windows is not happy

* check the file descriptor in advance; on Windows, lseek with a closed file descriptor will by default close the application

* lseek is fubar on windows

* lseek and read apparently are fubar on Windows. Use Python to seek/read, and numpy to keep the code reasonably fast

* deal with closed files

* travis

* more inane stuff from Travis

* weird

* reverting previous change to the tutorial text

* reverting changes to test_SeqIO.py; these are not needed anymore now that twoBit file reading is done via Python

* improving speed

* using C code for 2bit to sequence conversion

* adding missing C code

* expand exception

* accept formats I and L

* release buffer

* travis

* windows

* private

* NEWS
2020-12-04 00:28:39 +09:00
5fd8d0a499 add startswith, endswith, __contains__ 2020-12-02 15:35:30 +00:00
fcd24d7f3a may as well add find and rfind 2020-12-02 15:35:30 +00:00
fe61f3dfac make index, rindex consistent for Seq and MutableSeq 2020-12-02 15:35:30 +00:00
450e5f7095 Seq bytes (#3333)
* MutableSeq bytearray

* bytes in Seq

* use bytes in Seq

* travis

* travis

* travis

* added some tests

* flake is wasting my time

* black is wasting my time
2020-11-21 09:28:19 +09:00
d47136dc20 fix the URL of PDF Tutorial (#3332) 2020-11-16 21:17:29 +00:00
3fa6c08725 don't apply str blindly in Seq methods (#3328) 2020-10-29 12:06:13 +00:00