mirror of
https://github.com/biopython/biopython.git
synced 2025-10-20 13:43:47 +08:00
Retain letter_annotation as None in upper and lower methods (#4966)
* gitignore .python-version * added name & email * fix so that _per_letter_annotations is not set by calling upper or lower methods * added test for initiation of SeqRecord checking the __dict__ and a test for the __dict__ created by upper
This commit is contained in:
6
.gitignore
vendored
6
.gitignore
vendored
@ -134,3 +134,9 @@ ENV/
|
||||
|
||||
# Testing
|
||||
**/.coverage
|
||||
|
||||
# Ignore the .python-version file used by pyenv
|
||||
# This file specifies the Python version for a project,
|
||||
# but should not be committed to Git, as different developers
|
||||
# may use different Python versions.
|
||||
.python-version
|
||||
|
@ -1127,7 +1127,11 @@ class SeqRecord:
|
||||
dbxrefs=self.dbxrefs[:],
|
||||
features=self.features[:],
|
||||
annotations=self.annotations.copy(),
|
||||
letter_annotations=self.letter_annotations.copy(),
|
||||
letter_annotations=(
|
||||
None
|
||||
if self._per_letter_annotations is None
|
||||
else self.letter_annotations.copy()
|
||||
),
|
||||
)
|
||||
|
||||
def lower(self) -> "SeqRecord":
|
||||
@ -1174,7 +1178,11 @@ class SeqRecord:
|
||||
dbxrefs=self.dbxrefs[:],
|
||||
features=self.features[:],
|
||||
annotations=self.annotations.copy(),
|
||||
letter_annotations=self.letter_annotations.copy(),
|
||||
letter_annotations=(
|
||||
None
|
||||
if self._per_letter_annotations is None
|
||||
else self.letter_annotations.copy()
|
||||
),
|
||||
)
|
||||
|
||||
def isupper(self):
|
||||
|
@ -66,6 +66,7 @@ please open an issue on GitHub or mention it on the mailing list.
|
||||
- Bertrand Frottier <bertrand.frottier at domain free.fr>
|
||||
- Bertrand Néron <https://github.com/bneron>
|
||||
- Bill Barnard <bill at domain barnard-engineering.com>
|
||||
- Björn Johansson <bjorn_johansson@bio.uminho.pt>
|
||||
- Blaise Li <https://github.com/blaiseli>
|
||||
- Bob Bussell <rgb2003 at domain med.cornell.edu>
|
||||
- Bogdan T. <bogdan at pearlgen dot com>
|
||||
|
@ -133,6 +133,21 @@ class SeqRecordCreation(unittest.TestCase):
|
||||
with self.assertRaises(TypeError):
|
||||
SeqRecord(Seq("ACGT"), features={})
|
||||
|
||||
def test_default_properties(self):
|
||||
seqobj = Seq("A")
|
||||
default__dict__ = {
|
||||
"_seq": seqobj,
|
||||
"id": "<unknown id>",
|
||||
"name": "<unknown name>",
|
||||
"description": "<unknown description>",
|
||||
"dbxrefs": [],
|
||||
"annotations": {},
|
||||
"_per_letter_annotations": None,
|
||||
"features": [],
|
||||
}
|
||||
bsr = SeqRecord(seqobj)
|
||||
self.assertEqual(bsr.__dict__, default__dict__)
|
||||
|
||||
|
||||
class SeqRecordMethods(unittest.TestCase):
|
||||
"""Test SeqRecord methods."""
|
||||
@ -226,6 +241,20 @@ Seq('ABCDEFGHIJKLMNOPQRSTUVWZYX')"""
|
||||
|
||||
def test_upper(self):
|
||||
self.assertEqual("ABCDEFGHIJKLMNOPQRSTUVWZYX", self.record.lower().upper().seq)
|
||||
seqobj = Seq("A")
|
||||
default__dict__ = {
|
||||
"_seq": seqobj,
|
||||
"id": "<unknown id>",
|
||||
"name": "<unknown name>",
|
||||
"description": "<unknown description>",
|
||||
"dbxrefs": [],
|
||||
"annotations": {},
|
||||
"_per_letter_annotations": None,
|
||||
"features": [],
|
||||
}
|
||||
bsr = SeqRecord(seqobj)
|
||||
bsru = bsr.upper()
|
||||
self.assertEqual(bsru.__dict__, default__dict__)
|
||||
|
||||
def test_lower(self):
|
||||
self.assertEqual("abcdefghijklmnopqrstuvwzyx", self.record.lower().seq)
|
||||
|
Reference in New Issue
Block a user