Coverage for src/python/ensembl/io/genomio/gff3/features.py: 84%
15 statements
« prev ^ index » next coverage.py v7.6.12, created at 2025-02-21 15:37 +0000
« prev ^ index » next coverage.py v7.6.12, created at 2025-02-21 15:37 +0000
1# See the NOTICE file distributed with this work for additional information
2# regarding copyright ownership.
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15"""GFF3 features."""
17from __future__ import annotations
19__all__ = [
20 "GFFSeqFeature",
21]
23from Bio.SeqFeature import SeqFeature, Location
26class GFFSeqFeature(SeqFeature):
27 """Extends `Bio.SeqFeature.SeqFeature` with sub_features, to be used for typing."""
29 def __init__(
30 self,
31 location: Location | None = None,
32 *,
33 type: str = "", # pylint: disable=W0622
34 id: str = "<unknown id>", # pylint: disable=W0622
35 qualifiers: dict | None = None,
36 sub_features: list[GFFSeqFeature] | None = None,
37 ):
38 super().__init__(location, type=type, id=id, qualifiers=qualifiers)
39 if sub_features is None: 39 ↛ 41line 39 didn't jump to line 41 because the condition on line 39 was always true
40 sub_features = []
41 self.sub_features = sub_features
43 @classmethod
44 def cast(cls, feat: SeqFeature) -> GFFSeqFeature:
45 """Cast a SeqFeature to a GFFSeqFeature."""
46 feat.__class__ = cls
47 if not hasattr(feat, "sub_features"): 47 ↛ 48line 47 didn't jump to line 48 because the condition on line 47 was never true
48 feat.sub_features = [] # type: ignore[attr-defined]
49 return feat # type: ignore[return-value]