Skip to content

Commit 1b1d7e0

Browse files
author
Paul K. Korir, PhD
committed
v0.7.3: merge with colour option added
* upgraded github workflow dependencies
1 parent c9aae1c commit 1b1d7e0

File tree

8 files changed

+925
-893
lines changed

8 files changed

+925
-893
lines changed

.github/workflows/python-package.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ jobs:
1818
python-version: [ 3.6, 3.7, 3.8, 3.9, '3.10' ]
1919

2020
steps:
21-
- uses: actions/checkout@v2
21+
- uses: actions/checkout@v3
2222
- name: Set up Python ${{ matrix.python-version }}
23-
uses: actions/setup-python@v2
23+
uses: actions/setup-python@v4
2424
with:
2525
python-version: ${{ matrix.python-version }}
2626
- name: Install dependencies
@@ -41,7 +41,7 @@ jobs:
4141
# pytest --cov=./sfftkrw ./sfftkrw/unittests
4242
coverage run --rcfile=.coveragerc -m pytest
4343
- name: Upload Coverage to Codecov
44-
uses: codecov/codecov-action@v1
44+
uses: codecov/codecov-action@v3
4545
with:
4646
verbose: true
4747

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
#Changes by release
22

3+
## [0.7.3] - 2023-01-27 Option to include source EMDB-SFF colours when merging
4+
5+
* In EMDB-SFF `v0.8.0.dev1` `SFFSegmentation.merge_annotation(other_seg, include_colour=False)` (*do not* merge colour by default)
6+
37
## [0.7.2] - 2022-04-26
48

59
add Python3.10 support

setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
u"Programming Language :: Python :: 3.8",
3737
u"Programming Language :: Python :: 3.9",
3838
u"Programming Language :: Python :: 3.10",
39+
u"Programming Language :: Python :: 3.11",
3940
u"Topic :: Software Development :: Libraries :: Python Modules",
4041
u"Topic :: Terminals",
4142
u"Topic :: Text Processing",

sfftkrw/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
SFFTKRW_VERSION = 'v0.7.2'
1+
SFFTKRW_VERSION = 'v0.7.3'
22
SFFTKRW_ENTRY_POINT = 'sff'

sfftkrw/schema/adapter_v0_8_0_dev1.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2518,10 +2518,11 @@ def to_file(self, *args, **kwargs):
25182518
"""Alias for :py:meth:`.export` method. Passes all args and kwargs onto :py:meth:`.export`"""
25192519
return super(SFFSegmentation, self).export(*args, **kwargs)
25202520

2521-
def merge_annotation(self, other_seg):
2521+
def merge_annotation(self, other_seg, include_colour=False):
25222522
"""Merge the annotation from another sff_seg to this one
25232523
25242524
:param other_seg: segmentation to get annotations from
2525+
:param bool include_colour: copy the colours from the source (useful if you want control over the colours)
25252526
:type other_seg: :py:class:`sfftkrw.SFFSegmentation`
25262527
"""
25272528
_assert_or_raise(other_seg, SFFSegmentation)
@@ -2534,6 +2535,8 @@ def merge_annotation(self, other_seg):
25342535
for segment in self.segments:
25352536
other_segment = other_seg.segments.get_by_id(segment.id)
25362537
segment.biological_annotation = other_segment.biological_annotation
2538+
if include_colour:
2539+
segment.colour = other_segment.colour
25372540

25382541
def copy_annotation(self, from_id, to_id):
25392542
"""Copy annotation across segments

sfftkrw/test_data/sff/v0.8/emd_1014.json

Lines changed: 886 additions & 886 deletions
Large diffs are not rendered by default.

sfftkrw/unittests/test_adapter_v0_8_0_dev1.py

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -574,6 +574,21 @@ def test_hff(self):
574574
with h5py.File(self.test_hdf5_fn, u'r') as h:
575575
ee2 = adapter.SFFExternalReferenceList.from_hff(h[u'container'])
576576

577+
def test_create_from_list(self):
578+
"""Test that we can create an SFFExternalReferenceList from a literal list"""
579+
ee = [adapter.SFFExternalReference(
580+
resource=self.rr[i],
581+
url=self.uu[i],
582+
accession=self.aa[i],
583+
label=self.ll[i],
584+
description=self.dd[i]
585+
) for i in _xrange(self._no_items)]
586+
E = adapter.SFFExternalReferenceList()
587+
print(ee)
588+
print(E)
589+
ES = adapter.SFFExternalReferenceList(new_obj=True, )
590+
print(ES)
591+
577592

578593
class TestSFFGlobalExternalReferenceList(Py23FixTestCase):
579594
"""Test the SFFGlobalExternalReferenceList class"""
@@ -948,7 +963,8 @@ def test_hff(self):
948963
self.assertIn(u'description', group[u'biological_annotation'])
949964
self.assertEqual(_decode(group[u'biological_annotation/description'][()], 'utf-8'), b_full.description)
950965
self.assertIn(u'number_of_instances', group[u'biological_annotation'])
951-
self.assertEqual(_decode(group[u'biological_annotation/number_of_instances'][()], 'utf-8'), b_full.number_of_instances)
966+
self.assertEqual(_decode(group[u'biological_annotation/number_of_instances'][()], 'utf-8'),
967+
b_full.number_of_instances)
952968
self.assertIn(u'external_references', group[u'biological_annotation'])
953969
self.assertEqual(len(group[u'biological_annotation/external_references']),
954970
len(b_full.external_references))
@@ -5301,6 +5317,14 @@ def test_merge_annotation(self):
53015317
other_segment = seg2.segment_list.get_by_id(segment.id)
53025318
self.assertEqual(segment.biological_annotation.external_references,
53035319
other_segment.biological_annotation.external_references)
5320+
self.assertNotEqual(segment.colour, other_segment.colour)
5321+
# test that we can merge colours too!
5322+
seg1.merge_annotation(seg2, include_colour=True)
5323+
for segment in seg1.segment_list:
5324+
other_segment = seg2.segment_list.get_by_id(segment.id)
5325+
self.assertEqual(segment.biological_annotation.external_references,
5326+
other_segment.biological_annotation.external_references)
5327+
self.assertEqual(segment.colour, other_segment.colour)
53045328

53055329
def test_copy_annotation(self):
53065330
"""Test that we can copy annotations: global and local"""

tox.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[tox]
2-
envlist = py36, py37, py38, py39, py310
2+
envlist = py36, py37, py38, py39, py310, py311
33

44
[testenv]
55
deps =

0 commit comments

Comments
 (0)