Skip to content

Commit

Permalink
Squashed 'modules/core/dependency/python-ihm/' changes from 64b600104…
Browse files Browse the repository at this point in the history
…c..6bb50f3acf

6bb50f3acf Include group ID even if the group is empty
1b962e7dd8 Add support for revision information
76dbdd203f Fix release date
c7fcb36cda Update for 1.7 release
1838c05522 Add recent changes
5b7a934f88 Fix typo
65fee4068b Check for missing translation or rotation
739c711ee3 Handle null features in dumper
a218a21e05 Allow for an ensemble without a model group
e6f793bf5d Check for invalid atom seq_ids in starting models
e869dbc7aa Handle null reference
471944efdf Handle non-standard residues in reference sequence
1588e7cc85 Allow output of invalid segment residue ranges
33c55f2609 Allow output of invalid crosslink residues
1a38fb53c6 Allow output of invalid not-modeled residues
4ad4776b8c Note that some checks cannot be disabled, closes ihmwg/python-ihm#153
57f7143bfa Allow disabling atom_site checks
b235f9bec6 Allow skipping reference sequence checks
2b0d37955c Start support for disabling dump-time checks
31aa954f48 Check crosslink residue ranges at dump time
8838c553e1 Allow for empty struct_ref_seq_dif.mon_id
8dbf1697c3 Only check residue seq_id for polymers
ea8cba722e Use latest Actions, Ubuntu, Python
736edd24e2 Clarify IDMapper for adding-to-system
d8e02df21b Note that we don't relabel chains, etc.
4f0b717f44 Check for typos before making a release
3b1a01db07 Clarify that added-to System must have IDs
13cb7895c5 Test adding a file to an existing system
5c70daf02d Add preliminary support for adding a file to a System
a7d52dd6e7 Allow dataset to have multiple locations, closes ihmwg/python-ihm#151
39e23fad80 Allow for extra 3DEM restraint info lines
b2482b69de Add assembly_id to mapping for 3DEM/SAS restraints
b56eb1439a Add missing 3DEM restraint fields
c6122e33ce Remove util/make-mmcif.py (long gone)

git-subtree-dir: modules/core/dependency/python-ihm
git-subtree-split: 6bb50f3acfac6cd665faad9885dacbcc8659c541
  • Loading branch information
benmwebb committed Oct 29, 2024
1 parent 5ffd1f9 commit f2d8dac
Show file tree
Hide file tree
Showing 21 changed files with 967 additions and 151 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [ubuntu-22.04]
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']
os: [ubuntu-24.04]
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13']
include:
- os: ubuntu-20.04
python-version: '3.6'
Expand All @@ -22,7 +22,7 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies (Mac)
Expand Down
16 changes: 16 additions & 0 deletions modules/core/dependency/python-ihm/ChangeLog.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
1.7 - 2024-10-22
================
- Sanity checks when writing out a file can now be disabled if desired,
using the new ``check`` argument to :func:`ihm.dumper.write` (#153).
- Data that have been split over multiple mmCIF or BinaryCIF files can now
be combined into a single :class:`ihm.System` object using the new
``add_to_system`` argument to :func:`ihm.reader.read`.
- Input files that assign multiple :class:`ihm.location.Location` objects
to a single :class:`ihm.dataset.Dataset` can now be read (#151).
- Bugfix: multiple :class:`ihm.restraint.EM3DRestraint` and
:class:`ihm.restraint.SASRestraint` objects can now be created for a
single dataset, as long as they act on different assemblies, as allowed
by the dictionary.
- Bugfix: allow for non-standard residues in the ``struct_ref`` table (#154).


1.6 - 2024-09-27
================
- The new class :class:`ihm.model.NotModeledResidueRange` allows for
Expand Down
3 changes: 1 addition & 2 deletions modules/core/dependency/python-ihm/MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
include ChangeLog.rst
include LICENSE
include examples/*
include util/make-mmcif.py
include src/ihm_format.h
include src/ihm_format.i
include src/ihm_format_wrap_1.6.c
include src/ihm_format_wrap_1.7.c
6 changes: 6 additions & 0 deletions modules/core/dependency/python-ihm/docs/main.rst
Original file line number Diff line number Diff line change
Expand Up @@ -119,3 +119,9 @@ The :mod:`ihm` Python module

.. autoclass:: BranchLink
:members:

.. autoclass:: Revision
:members:

.. autoclass:: RevisionDetails
:members:
48 changes: 46 additions & 2 deletions modules/core/dependency/python-ihm/ihm/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import json
from . import util

__version__ = '1.6'
__version__ = '1.7'


class __UnknownValue(object):
Expand Down Expand Up @@ -121,6 +121,9 @@ def __init__(self, title=None, id='model', model_details=None,
#: See :class:`Collection`.
self.collections = []

#: Revision/update history. See :class:`Revision`.
self.revisions = []

#: All orphaned chemical descriptors in the system.
#: See :class:`ChemDescriptor`. This can be used to track descriptors
#: that are not otherwise used - normally one is assigned to a
Expand Down Expand Up @@ -1288,7 +1291,8 @@ def __init__(self, seq_id, entity=None, asym=None):
if entity is None and asym:
self.entity = asym.entity
self.seq_id = seq_id
util._check_residue(self)
if self.entity is not None and self.entity.is_polymeric():
util._check_residue(self)

def atom(self, atom_id):
"""Get a :class:`~ihm.Atom` in this residue with the given name."""
Expand Down Expand Up @@ -1794,3 +1798,43 @@ def __init__(self, num1, atom_id1, leaving_atom_id1, num2, atom_id2,
self.leaving_atom_id1 = leaving_atom_id1
self.leaving_atom_id2 = leaving_atom_id2
self.order, self.details = order, details


class Revision(object):
"""Represent part of the history of a :class:`System`.
:param str data_content_type: The type of file that was changed.
:param int major: Major version number.
:param int minor: Minor version number.
:param date: Release date.
:type date: :class:`datetime.date`
Generally these objects are added to :attr:`System.revisions`.
"""
def __init__(self, data_content_type, minor, major, date):
self.data_content_type = data_content_type
self.minor, self.major = minor, major
self.date = date
#: More details of the changes, as :class:`RevisionDetails` objects
self.details = []
#: Collection of categories (as strings) updated with this revision
self.groups = []
#: Categories (as strings) updated with this revision
self.categories = []
#: Items (as strings) updated with this revision
self.items = []


class RevisionDetails(object):
"""More information on the changes in a given :class:`Revision`.
:param str provider: The provider (author, repository) of the revision.
:param str type: Classification of the revision.
:param str description: Additional details describing the revision.
These objects are typically stored in :attr:`Revision.details`.
"""
def __init__(self, provider, type, description):
self.provider = provider
self.type = type
self.description = description
23 changes: 22 additions & 1 deletion modules/core/dependency/python-ihm/ihm/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class Dataset(object):
:param str details: Text giving more information about the dataset.
"""

_eq_keys = ['location']
_eq_keys = ['_locations']
_allow_duplicates = False

# Datasets compare equal iff they are the same class, have the
Expand All @@ -38,13 +38,34 @@ def __hash__(self):
data_type = 'Other'

def __init__(self, location, details=None):
# The dictionary actually allows for multiple locations for a given
# dataset. Support this via a private attribute so we can at least
# handle reading existing files. 'location' just references the
# first location in this list.
self._locations = ()

self.location, self.details = location, details

#: A list of :class:`Dataset` and/or :class:`TransformedDataset`
#: objects from which this one was derived.
#: For example, a 3D EM map may be derived from a set of 2D images.
self.parents = []

def _add_location(self, loc):
if self.location is None:
self.location = loc
else:
self._locations += (loc,)

def __get_location(self):
return self._locations[0]

def __set_location(self, val):
self._locations = (val, )

location = property(__get_location, __set_location,
doc="A pointer to where the dataset is stored")

def add_primary(self, dataset):
"""Add another Dataset from which this one was ultimately derived,
i.e. it is added as a parent, unless a parent already exists,
Expand Down
Loading

0 comments on commit f2d8dac

Please sign in to comment.