Skip to content

Commit

Permalink
Squashed 'modules/core/dependency/python-ihm/' changes from 30cfb62e7…
Browse files Browse the repository at this point in the history
…f..dacfddea3a

dacfddea3a Fix syntax error
6a6b3f1a81 Add DHSO and BMSO cross-linkers
941b506723 Test FRETAnalysis constructor type check
9e42a1f303 Allow rejecting old file versions
8145ad5c35 Note compliance with dictionary version 1.04
a8e248d1e8 Merge pull request ihmwg/python-ihm#47 from CAHanke/master
08b1d75231 Adapt to modifications in FLR dictionary
725e06b28a Test with the new Python 3.8
25ba45f17b Update for 0.12 release
9e09ba9335 Note that Location is abstract

git-subtree-dir: modules/core/dependency/python-ihm
git-subtree-split: dacfddea3a12d71ba097c7066d075dd73f0ac09a
  • Loading branch information
benmwebb committed Nov 14, 2019
1 parent 3695af6 commit 2de7fdb
Show file tree
Hide file tree
Showing 16 changed files with 1,267 additions and 169 deletions.
1 change: 1 addition & 0 deletions modules/core/dependency/python-ihm/.travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ python:
- 2.7
- 3.6
- 3.7
- 3.8
matrix:
include:
- dist: trusty
Expand Down
8 changes: 8 additions & 0 deletions modules/core/dependency/python-ihm/ChangeLog.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
HEAD
====
- :func:`ihm.reader.read` has a new optional ``reject_old_file`` argument.
If set, it will raise an exception if asked to read a file that conforms
to too old a version of the IHM extension dictionary.
- Definitions for the DHSO and BMSO cross-linkers are now provided in the
:mod:`ihm.cross_linkers` module.

0.12 - 2019-10-16
=================
- :class:`ihm.restraint.ResidueFeature` objects can now act on one or
more :class:`Residue` objects, which act equivalently to
1-residue ranges (:class:`AsymUnitRange` or :class:`EntityRange`).
Expand Down
2 changes: 1 addition & 1 deletion modules/core/dependency/python-ihm/MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
include src/ihm_format.h
include src/ihm_format.i
include src/ihm_format_wrap_0.11.c
include src/ihm_format_wrap_0.12.c
12 changes: 12 additions & 0 deletions modules/core/dependency/python-ihm/docs/cross_linkers.rst
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,15 @@ The :mod:`ihm.cross_linkers` Python module
.. data:: edc

EDC cross-linker that links a carboxyl group with a primary amine.

.. data:: dhso

DHSO (dihydrazide sulfoxide) MS-cleavable cross-linker that links
carboxyl groups, described in
`Gutierrez et al, 2016 <https://dx.doi.org/10.1021/acs.analchem.6b02240>`_.

.. data:: bmso

BMSO (bismaleimide sulfoxide) MS-cleavable cross-linker that links
cysteines, described in
`Gutierrez et al, 2018 <https://dx.doi.org/10.1021/acs.analchem.8b01287>`_.
17 changes: 16 additions & 1 deletion modules/core/dependency/python-ihm/docs/flr.rst
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,27 @@ The :mod:`ihm.flr` Python module
.. autoclass:: Instrument
:members:

.. autoclass:: ExpSetting
.. autoclass:: InstSetting
:members:

.. autoclass:: ExpCondition
:members:

.. autoclass:: FRETAnalysis
:members:

.. autoclass:: LifetimeFitModel
:members:

.. autoclass:: RefMeasurementGroup
:members:

.. autoclass:: RefMeasurement
:members:

.. autoclass:: RefMeasurementLifetime
:members:

.. autoclass:: FRETDistanceRestraintGroup
:members:

Expand Down
2 changes: 2 additions & 0 deletions modules/core/dependency/python-ihm/docs/reader.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ The :mod:`ihm.reader` Python module

.. autoexception:: UnknownKeywordWarning

.. autoexception:: OldFileError

.. autoclass:: Handler
:members:

Expand Down
2 changes: 1 addition & 1 deletion 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 urllib2
import json

__version__ = '0.11'
__version__ = '0.12'

class __UnknownValue(object):
# Represent the mmCIF 'unknown' special value
Expand Down
15 changes: 15 additions & 0 deletions modules/core/dependency/python-ihm/ihm/cross_linkers.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,18 @@
smiles='CCN=C=NCCCN(C)C',
inchi='1S/C8H17N3/c1-4-9-8-10-6-5-7-11(2)3/h4-7H2,1-3H3',
inchi_key='LMDZBCPBFSXMTL-UHFFFAOYSA-N')

dhso = ihm.ChemDescriptor('DHSO',
chemical_name='dihydrazide sulfoxide',
smiles='NNC(=O)CC[S](=O)CCC(=O)NN',
inchi='1S/C6H14N4O3S/c7-9-5(11)1-3-14(13)4-2-6(12)10-8'
'/h1-4,7-8H2,(H,9,11)(H,10,12)',
inchi_key='XTCXQISMAWBOOT-UHFFFAOYSA-N')

bmso = ihm.ChemDescriptor('BMSO',
chemical_name='bismaleimide sulfoxide',
smiles='O=C(CC[S](=O)CCC(=O)NCCN1C(=O)C=CC1=O)NCCN2C(=O)C=CC2=O',
inchi='1S/C18H22N4O7S/c23-13(19-7-9-21-15(25)1-2-16(21)26)5-'
'11-30(29)12-6-14(24)20-8-10-22-17(27)3-4-18(22)28/h1-'
'4H,5-12H2,(H,19,23)(H,20,24)',
inchi_key='PUNDHDZIOGBGHG-UHFFFAOYSA-N')
177 changes: 158 additions & 19 deletions modules/core/dependency/python-ihm/ihm/dumper.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ class _AuditConformDumper(Dumper):
def dump(self, system, writer):
with writer.category("_audit_conform") as l:
# Update to match the version of the IHM dictionary we support:
l.write(dict_name="ihm-extension.dic", dict_version="0.137",
dict_location=self.URL % "7ea672a")
l.write(dict_name="ihm-extension.dic", dict_version="1.04",
dict_location=self.URL % "3a8e0b9")


class _StructDumper(Dumper):
Expand Down Expand Up @@ -2083,29 +2083,42 @@ def all_experiments():

def dump(self, system, writer):
with writer.loop('_flr_experiment',
['ordinal_id', 'id', 'instrument_id', 'exp_setting_id',
'sample_id', 'details']) as l:
['ordinal_id', 'id', 'instrument_id', 'inst_setting_id',
'exp_condition_id','sample_id', 'details']) as l:
ordinal = 1
for x in self._experiments_by_id:
for i in range(len(x.sample_list)):
l.write(ordinal_id=ordinal, id=x._id,
instrument_id=x.instrument_list[i]._id,
exp_setting_id=x.exp_setting_list[i]._id,
inst_setting_id=x.inst_setting_list[i]._id,
exp_condition_id=x.exp_condition_list[i]._id,
sample_id=x.sample_list[i]._id,
details=x.details_list[i])
ordinal +=1


class _FLRExpSettingDumper(Dumper):
class _FLRInstSettingDumper(Dumper):
def finalize(self, system):
def all_exp_settings():
return itertools.chain.from_iterable(f._all_exp_settings()
def all_inst_settings():
return itertools.chain.from_iterable(f._all_inst_settings()
for f in system.flr_data)
self._exp_settings_by_id = _assign_all_ids(all_exp_settings)
self._inst_settings_by_id = _assign_all_ids(all_inst_settings)

def dump(self, system, writer):
with writer.loop('_flr_exp_setting', ['id', 'details']) as l:
for x in self._exp_settings_by_id:
with writer.loop('_flr_inst_setting', ['id', 'details']) as l:
for x in self._inst_settings_by_id:
l.write(id=x._id, details=x.details)

class _FLR_ExpConditionDumper(Dumper):
def finalize(self, system):
def all_exp_conditions():
return itertools.chain.from_iterable(f._all_exp_conditions()
for f in system.flr_data)
self._exp_conditions_by_id = _assign_all_ids(all_exp_conditions)

def dump(self, system, writer):
with writer.loop('_flr_exp_condition', ['id', 'details']) as l:
for x in self._exp_conditions_by_id:
l.write(id=x._id, details=x.details)


Expand Down Expand Up @@ -2355,6 +2368,90 @@ def dump(self, system, writer):
gamma=x.gamma, delta=x.delta, a_b=x.a_b)


class _FLRLifetimeFitModelDumper(Dumper):
def finalize(self, system):
def all_lifetime_fit_models():
return itertools.chain.from_iterable(f._all_lifetime_fit_models()
for f in system.flr_data)
self._lifetime_fit_models_by_id = _assign_all_ids(all_lifetime_fit_models)

def dump(self, system, writer):
with writer.loop('_flr_lifetime_fit_model',
['id', 'name', 'description',
'external_file_id', 'citation_id']) as l:
for x in self._lifetime_fit_models_by_id:
l.write(id = x._id, name = x.name,
description = x.description,
external_file_id = None if x.external_file is None
else x.external_file._id,
citation_id = None if x.citation is None
else x.citation._id)


class _FLRRefMeasurementDumper(Dumper):
def finalize(self, system):
def all_ref_measurement_groups():
return itertools.chain.from_iterable(f._all_ref_measurement_groups()
for f in system.flr_data)
self._ref_measurement_groups_by_id = _assign_all_ids(all_ref_measurement_groups)

def _all_ref_measurements():
return itertools.chain.from_iterable(f._all_ref_measurements()
for f in system.flr_data)
self._ref_measurements_by_id = _assign_all_ids(_all_ref_measurements)

def _all_ref_measurement_lifetimes():
return itertools.chain.from_iterable(f._all_ref_measurement_lifetimes()
for f in system.flr_data)
self._ref_measurement_lifetimes_by_id = _assign_all_ids(_all_ref_measurement_lifetimes)

def dump(self, system, writer):
self.dump_ref_measurement_group(system, writer)
self.dump_ref_measurement_group_link(system, writer)
self.dump_ref_measurement(system, writer)
self.dump_ref_measurement_lifetimes(system, writer)

def dump_ref_measurement_group(self, system, writer):
with writer.loop('_flr_reference_measurement_group',
['id', 'num_measurements','details']) as l:
for x in self._ref_measurement_groups_by_id:
l.write(id = x._id,
num_measurements = len(x.ref_measurement_list),
details = x.details)

def dump_ref_measurement_group_link(self, system, writer):
with writer.loop('_flr_reference_measurement_group_link',
['group_id', 'reference_measurement_id']) as l:
for x in self._ref_measurement_groups_by_id:
for m in x.ref_measurement_list:
l.write(group_id=x._id,
reference_measurement_id = m._id)

def dump_ref_measurement(self, system, writer):
with writer.loop('_flr_reference_measurement',
['id', 'reference_sample_probe_id',
'num_species', 'details']) as l:
for x in self._ref_measurements_by_id:
l.write(id = x._id,
reference_sample_probe_id = x.ref_sample_probe._id,
num_species = len(x.list_of_lifetimes),
details = x.details)

def dump_ref_measurement_lifetimes(self, system, writer):
with writer.loop('_flr_reference_measurement_lifetime',
['ordinal_id', 'reference_measurement_id',
'species_name', 'species_fraction', 'lifetime']) as l:
ordinal = 1
for x in self._ref_measurements_by_id:
for m in x.list_of_lifetimes:
l.write(ordinal_id = ordinal,
reference_measurement_id = x._id,
species_name = m.species_name,
species_fraction = m.species_fraction,
lifetime = m.lifetime)
ordinal += 1


class _FLRAnalysisDumper(Dumper):
def finalize(self, system):
def all_analyses():
Expand All @@ -2363,27 +2460,67 @@ def all_analyses():
self._analyses_by_id = _assign_all_ids(all_analyses)

def dump(self, system, writer):
self.dump_fret_analysis_general(system, writer)
self.dump_fret_analysis_intensity(system, writer)
self.dump_fret_analysis_lifetime(system, writer)

def dump_fret_analysis_general(self, system, writer):
with writer.loop('_flr_fret_analysis',
['id', 'experiment_id', 'sample_probe_id_1',
'sample_probe_id_2', 'forster_radius_id',
'calibration_parameters_id', 'method_name',
'chi_square_reduced', 'dataset_list_id',
['id', 'experiment_id', 'type',
'sample_probe_id_1', 'sample_probe_id_2',
'forster_radius_id', 'dataset_list_id',
'external_file_id', 'software_id']) as l:
for x in self._analyses_by_id:
l.write(id=x._id,
experiment_id=x.experiment._id,
type = x.type,
sample_probe_id_1=x.sample_probe_1._id,
sample_probe_id_2=x.sample_probe_2._id,
forster_radius_id=x.forster_radius._id,
calibration_parameters_id=x.calibration_parameters._id,
method_name=x.method_name,
chi_square_reduced=x.chi_square_reduced,
dataset_list_id=x.dataset._id,
external_file_id=None if x.external_file is None
else x.external_file._id,
software_id=None if x.software is None
else x.software._id)

def dump_fret_analysis_intensity(self, system, writer):
with writer.loop('_flr_fret_analysis_intensity',
['ordinal_id', 'analysis_id',
'calibration_parameters_id', 'donor_only_fraction',
'chi_square_reduced', 'method_name', 'details']) as l:
ordinal = 1
for x in self._analyses_by_id:
## if it is an intensity-based analysis.
if 'intensity' in x.type:
l.write(ordinal_id = ordinal,
analysis_id = x._id,
calibration_parameters_id = None if x.calibration_parameters is None else x.calibration_parameters._id,
donor_only_fraction = x.donor_only_fraction,
chi_square_reduced = x.chi_square_reduced,
method_name = x.method_name,
details = x.details)
ordinal += 1

def dump_fret_analysis_lifetime(self, system, writer):
with writer.loop('_flr_fret_analysis_lifetime',
['ordinal_id', 'analysis_id',
'reference_measurement_group_id', 'lifetime_fit_model_id',
'donor_only_fraction', 'chi_square_reduced',
'method_name', 'details']) as l:
ordinal = 1
for x in self._analyses_by_id:
## if it is a lifetime-based analysis
if 'lifetime' in x.type:
l.write(ordinal_id = ordinal,
analysis_id = x._id,
reference_measurement_group_id = x.ref_measurement_group._id,
lifetime_fit_model_id = x.lifetime_fit_model._id,
donor_only_fraction = x.donor_only_fraction,
chi_square_reduced = x.chi_square_reduced,
method_name = x.method_name,
details = x.details)
ordinal += 1


class _FLRPeakAssignmentDumper(Dumper):
def finalize(self, system):
Expand Down Expand Up @@ -2700,12 +2837,14 @@ def write(fh, systems, format='mmCIF', dumpers=[]):
_EnsembleDumper(),
_DensityDumper(),
_MultiStateDumper(), _OrderedDumper(),
_FLRExperimentDumper(), _FLRExpSettingDumper(),
_FLRExperimentDumper(), _FLRInstSettingDumper(),
_FLR_ExpConditionDumper(),
_FLRInstrumentDumper(), _FLREntityAssemblyDumper(),
_FLRSampleConditionDumper(), _FLRSampleDumper(),
_FLRProbeDumper(), _FLRSampleProbeDetailsDumper(),
_FLRPolyProbePositionDumper(), _FLRConjugateDumper(),
_FLRForsterRadiusDumper(), _FLRCalibrationParametersDumper(),
_FLRLifetimeFitModelDumper(), _FLRRefMeasurementDumper(),
_FLRAnalysisDumper(), _FLRPeakAssignmentDumper(),
_FLRDistanceRestraintDumper(), _FLRModelQualityDumper(),
_FLRModelDistanceDumper(), _FLRFPSModelingDumper(),
Expand Down
Loading

0 comments on commit 2de7fdb

Please sign in to comment.